Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/CProgressBar.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | void CProgressBar::HandleMessage(SGUIMessage& Message) | ||||
switch (Message.type) | switch (Message.type) | ||||
{ | { | ||||
case GUIM_SETTINGS_UPDATED: | case GUIM_SETTINGS_UPDATED: | ||||
// Update scroll-bar | // Update scroll-bar | ||||
// TODO Gee: (2004-09-01) Is this really updated each time it should? | // TODO Gee: (2004-09-01) Is this really updated each time it should? | ||||
if (Message.value == CStr("caption")) | if (Message.value == CStr("caption")) | ||||
{ | { | ||||
const float value = GUI<float>::GetSetting(this, "caption"); | const float value = GetSetting<float>("caption"); | ||||
if (value > 100.f) | if (value > 100.f) | ||||
GUI<float>::SetSetting(this, "caption", 100.f); | GUI<float>::SetSetting(this, "caption", 100.f); | ||||
else if (value < 0.f) | else if (value < 0.f) | ||||
GUI<float>::SetSetting(this, "caption", 0.f); | GUI<float>::SetSetting(this, "caption", 0.f); | ||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
void CProgressBar::Draw() | void CProgressBar::Draw() | ||||
{ | { | ||||
CGUISpriteInstance& sprite_bar = GUI<CGUISpriteInstance>::GetSetting(this, "sprite_bar"); | CGUISpriteInstance& sprite_bar = GetSetting<CGUISpriteInstance>("sprite_bar"); | ||||
CGUISpriteInstance& sprite_background = GUI<CGUISpriteInstance>::GetSetting(this, "sprite_background"); | CGUISpriteInstance& sprite_background = GetSetting<CGUISpriteInstance>("sprite_background"); | ||||
float bz = GetBufferedZ(); | float bz = GetBufferedZ(); | ||||
int cell_id = 0; | int cell_id = 0; | ||||
const float value = GUI<float>::GetSetting(this, "caption"); | const float value = GetSetting<float>("caption"); | ||||
m_pGUI.DrawSprite(sprite_background, cell_id, bz, m_CachedActualSize); | m_pGUI.DrawSprite(sprite_background, cell_id, bz, m_CachedActualSize); | ||||
// Get size of bar (notice it is drawn slightly closer, to appear above the background) | // Get size of bar (notice it is drawn slightly closer, to appear above the background) | ||||
CRect bar_size(m_CachedActualSize.left, m_CachedActualSize.top, | CRect bar_size(m_CachedActualSize.left, m_CachedActualSize.top, | ||||
m_CachedActualSize.left+m_CachedActualSize.GetWidth()*(value/100.f), m_CachedActualSize.bottom); | m_CachedActualSize.left+m_CachedActualSize.GetWidth()*(value/100.f), m_CachedActualSize.bottom); | ||||
m_pGUI.DrawSprite(sprite_bar, cell_id, bz+0.01f, bar_size); | m_pGUI.DrawSprite(sprite_bar, cell_id, bz+0.01f, bar_size); | ||||
} | } |
Wildfire Games · Phabricator