// ---------------------------------------------------------------
class RotatingProgressBar : GuiCustom
{
RotatingProgressBar()
{
m_Background = NULL;
m_Progress = NULL;
Reset();
}
void Reset()
{
m_fProgress = 0.0f;
m_fSpeed = PI/4;
}
void Init(ImagePtr background, ImagePtr progress, Flt fSpeed)
{
m_Background = background;
m_Progress = progress;
m_fSpeed = fSpeed;
}
RotatingProgressBar& create(C Rect& rect)
{
super.create(rect);
m_Background = UID(3583697899, 1191445427, 3995744696, 973341463);
m_Progress = UID(222968740, 1123011788, 925899699, 1361919290);
return T;
}
virtual void draw(C GuiPC& gpc);
ImagePtr m_Background;
ImagePtr m_Progress;
Flt m_fSpeed; // degrees per second
Flt m_fProgress;
}
// ----------------------------------------------------------
void RotatingProgressBar::draw(C GuiPC& gpc)
{
if (!gpc.visible || !visible() || !m_Background || !m_Progress)
return;
D.clip(gpc.clip);
m_fProgress += 0.2 * Time.d();
if (m_fProgress >= 1.0f)
m_fProgress -= 1.0f;
Flt fAngle = PI - (m_fProgress * PI2);
Flt width = rect().w();
Flt height = rect().h();
Vec2 size(width, height);
Vec2 center = rect().center() + gpc.offset;
// draw background right
m_Background->drawRotate(center, size, 0.0f);
// draw progress right
if (m_fProgress < 0.5f)
m_Progress->drawRotate(center, size, fAngle);
else
m_Progress->drawRotate(center, size, 0.0f);
// draw background left
m_Background->drawRotate(center, size, PI);
// draw progress left
if (m_fProgress >= 0.5f)
m_Progress->drawRotate(center, size, fAngle);
}