From 92cbcf85e59b2cfda6581ff22ff999ba2ce370dd Mon Sep 17 00:00:00 2001 From: elexis Date: Tue, 12 Nov 2019 16:53:19 +0000 Subject: [PATCH] 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. --- binaries/data/mods/mod/gui/modio/modio.js | 2 +- .../mods/public/gui/loading/ProgressBar.js | 2 +- source/gui/ObjectTypes/CProgressBar.cpp | 23 ++++++++----------- source/gui/ObjectTypes/CProgressBar.h | 4 ++-- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/binaries/data/mods/mod/gui/modio/modio.js b/binaries/data/mods/mod/gui/modio/modio.js index f5cc5b9837..826715c6a0 100644 --- a/binaries/data/mods/mod/gui/modio/modio.js +++ b/binaries/data/mods/mod/gui/modio/modio.js @@ -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); diff --git a/binaries/data/mods/public/gui/loading/ProgressBar.js b/binaries/data/mods/public/gui/loading/ProgressBar.js index febe46f042..990d989640 100644 --- a/binaries/data/mods/public/gui/loading/ProgressBar.js +++ b/binaries/data/mods/public/gui/loading/ProgressBar.js @@ -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; diff --git a/source/gui/ObjectTypes/CProgressBar.cpp b/source/gui/ObjectTypes/CProgressBar.cpp index b49f855493..98a1b8bd3d 100644 --- a/source/gui/ObjectTypes/CProgressBar.cpp +++ b/source/gui/ObjectTypes/CProgressBar.cpp @@ -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("caption", 100.f, true); - else if (m_Caption < 0.f) - SetSetting("caption", 0.f, true); + if (m_Progress > 100.f) + SetSetting("progress", 100.f, true); + else if (m_Progress < 0.f) + SetSetting("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); } diff --git a/source/gui/ObjectTypes/CProgressBar.h b/source/gui/ObjectTypes/CProgressBar.h index 1423784ee4..6397ad6f18 100644 --- a/source/gui/ObjectTypes/CProgressBar.h +++ b/source/gui/ObjectTypes/CProgressBar.h @@ -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