From aa4229cbb9f2b264ca96c3beedc66b1c79ccc1f5 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 5 Mar 2009 23:13:55 -0700 Subject: Made some optimizations based on some profiling done by Octalot, as well as some other optimizations that I could see that cut down on some unneeded redraws, which in turn improved frame rates slightly. Signed-off-by: Ira Rice --- src/gui/progressbar.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui/progressbar.h') diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h index ff146745..3c88f3a3 100644 --- a/src/gui/progressbar.h +++ b/src/gui/progressbar.h @@ -108,6 +108,7 @@ class ProgressBar : public gcn::Widget Uint8 mRed, mGreen, mBlue; Uint8 mRedToGo, mGreenToGo, mBlueToGo; std::string mText; + bool mUpdated; static ImageRect mBorder; static int mInstances; -- cgit v1.2.3-70-g09d2 From dbf402a235d142b44c1936c305f6b3f4c02890bc Mon Sep 17 00:00:00 2001 From: Majin Sniper Date: Thu, 19 Mar 2009 18:58:11 +0100 Subject: Port Progressbar to TextRenderer --- src/gui/progressbar.cpp | 22 ++++++++-------------- src/gui/progressbar.h | 2 ++ 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'src/gui/progressbar.h') diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index 019bf371..f0acfecf 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -23,6 +23,7 @@ #include "gui.h" #include "progressbar.h" +#include "textrenderer.h" #include "../configuration.h" #include "../graphics.h" @@ -34,6 +35,8 @@ ImageRect ProgressBar::mBorder; int ProgressBar::mInstances = 0; float ProgressBar::mAlpha = config.getValue("guialpha", 0.8); +const gcn::Color ProgressBar::TEXT_COLOR = gcn::Color(255, 255, 255); + ProgressBar::ProgressBar(float progress, unsigned int width, unsigned int height, Uint8 red, Uint8 green, Uint8 blue): @@ -129,21 +132,12 @@ void ProgressBar::draw(gcn::Graphics *graphics) if (!mText.empty()) { gcn::Font *f = boldFont; - const int textX = getWidth() / 2; - const int textY = (getHeight() - f->getHeight()) / 2; - - graphics->setFont(f); - - graphics->setColor(gcn::Color(0, 0, 0)); - graphics->drawText(mText, textX + 1, textY, gcn::Graphics::CENTER); - graphics->drawText(mText, textX, textY - 1, gcn::Graphics::CENTER); - graphics->drawText(mText, textX, textY + 1, gcn::Graphics::CENTER); - graphics->drawText(mText, textX - 1, textY, gcn::Graphics::CENTER); - - graphics->setColor(gcn::Color(255, 255, 255)); - graphics->drawText(mText, textX, textY, gcn::Graphics::CENTER); + int textX = getWidth() / 2; + int textY = (getHeight() - f->getHeight()) / 2; - graphics->setColor(gcn::Color(0, 0, 0)); + TextRenderer::renderText(graphics, mText, textX, textY, + gcn::Graphics::CENTER, &TEXT_COLOR, f, true, + false); } } diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h index 5526589c..aa36e02b 100644 --- a/src/gui/progressbar.h +++ b/src/gui/progressbar.h @@ -112,6 +112,8 @@ class ProgressBar : public gcn::Widget static ImageRect mBorder; static int mInstances; static float mAlpha; + + static const gcn::Color TEXT_COLOR; }; #endif -- cgit v1.2.3-70-g09d2