Rename CProgressBar numeric "caption" setting to "progress" to distinguish it from the Button, Input, Text and Tooltip "caption" setting values that are tag-formatted texts.

Remove TODO question from c4684effb6 since the class updates correctly.

Differential Revision: https://code.wildfiregames.com/D2419
Tested on: clang 9.0.0, Jenkins/gcc6, Jenkins/vs2015

This was SVN commit r23151.
This commit is contained in:
elexis
2019-11-12 16:53:19 +00:00
parent c16eddaedc
commit 92cbcf85e5
4 changed files with 14 additions and 17 deletions
+1 -1
View File
@@ -312,7 +312,7 @@ function progressDialog(dialogCaption, dialogTitle, showProgressBar, buttonCapti
function updateProgressBar(progress, totalSize)
{
let progressPercent = Math.ceil(progress * 100);
Engine.GetGUIObjectByName("downloadDialog_progressBar").caption = progressPercent;
Engine.GetGUIObjectByName("downloadDialog_progressBar").progress = progressPercent;
let transferredSize = progress * totalSize;
let transferredSizeObj = filesizeToObj(transferredSize);
@@ -26,7 +26,7 @@ class ProgressBar
// Show 100 when it is really 99
let progress = progression + 1;
this.progressbar.caption = progress;
this.progressbar.progress = progress;
if (this.showDescription)
this.progressText.caption = description;
+10 -13
View File
@@ -25,11 +25,11 @@ CProgressBar::CProgressBar(CGUI& pGUI)
: IGUIObject(pGUI),
m_SpriteBackground(),
m_SpriteBar(),
m_Caption()
m_Progress()
{
RegisterSetting("sprite_background", m_SpriteBackground);
RegisterSetting("sprite_bar", m_SpriteBar);
RegisterSetting("caption", m_Caption); // aka value from 0 to 100
RegisterSetting("progress", m_Progress); // between 0 and 100
}
CProgressBar::~CProgressBar()
@@ -43,14 +43,12 @@ void CProgressBar::HandleMessage(SGUIMessage& Message)
switch (Message.type)
{
case GUIM_SETTINGS_UPDATED:
// Update scroll-bar
// TODO Gee: (2004-09-01) Is this really updated each time it should?
if (Message.value == "caption")
if (Message.value == "progress")
{
if (m_Caption > 100.f)
SetSetting<float>("caption", 100.f, true);
else if (m_Caption < 0.f)
SetSetting<float>("caption", 0.f, true);
if (m_Progress > 100.f)
SetSetting<float>("progress", 100.f, true);
else if (m_Progress < 0.f)
SetSetting<float>("progress", 0.f, true);
}
break;
default:
@@ -61,13 +59,12 @@ void CProgressBar::HandleMessage(SGUIMessage& Message)
void CProgressBar::Draw()
{
float bz = GetBufferedZ();
int cell_id = 0;
m_pGUI.DrawSprite(m_SpriteBackground, cell_id, bz, m_CachedActualSize);
// Get size of bar (notice it is drawn slightly closer, to appear above the background)
CRect bar_size(m_CachedActualSize.left, m_CachedActualSize.top,
m_CachedActualSize.left+m_CachedActualSize.GetWidth()*(m_Caption/100.f), m_CachedActualSize.bottom);
m_pGUI.DrawSprite(m_SpriteBar, cell_id, bz+0.01f, bar_size);
CRect size = m_CachedActualSize;
size.right = size.left + m_CachedActualSize.GetWidth() * (m_Progress / 100.f),
m_pGUI.DrawSprite(m_SpriteBar, cell_id, bz + 0.01f, size);
}
+2 -2
View File
@@ -38,16 +38,16 @@ protected:
*/
virtual void Draw();
// If caption is set, make sure it's within the interval 0-100
/**
* @see IGUIObject#HandleMessage()
* If the progress is changed, ensure the interval is between 0 and 100.
*/
void HandleMessage(SGUIMessage& Message);
// Settings
CGUISpriteInstance m_SpriteBackground;
CGUISpriteInstance m_SpriteBar;
float m_Caption;
float m_Progress;
};
#endif // INCLUDED_CPROGRESSBAR