summaryrefslogtreecommitdiff
path: root/src/gui/progressbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/progressbar.cpp')
-rw-r--r--src/gui/progressbar.cpp65
1 files changed, 53 insertions, 12 deletions
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index 9a47eefc..85f21604 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -1,26 +1,30 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <guichan/font.hpp>
+
+#include "gui.h"
#include "progressbar.h"
+#include "../configuration.h"
#include "../graphics.h"
#include "../resources/image.h"
@@ -28,6 +32,7 @@
ImageRect ProgressBar::mBorder;
int ProgressBar::mInstances = 0;
+float ProgressBar::mAlpha = config.getValue("guialpha", 0.8);
ProgressBar::ProgressBar(float progress,
unsigned int width, unsigned int height,
@@ -56,6 +61,12 @@ ProgressBar::ProgressBar(float progress,
mBorder.grid[6] = dBorders->getSubImage(0, 15, 4, 4);
mBorder.grid[7] = dBorders->getSubImage(4, 15, 3, 4);
mBorder.grid[8] = dBorders->getSubImage(7, 15, 4, 4);
+
+ for (int i = 0; i < 9; i++)
+ {
+ mBorder.grid[i]->setAlpha(mAlpha);
+ }
+
dBorders->decRef();
}
@@ -109,32 +120,62 @@ void ProgressBar::logic()
mProgress = mProgressToGo;
}
-void
-ProgressBar::draw(gcn::Graphics *graphics)
+void ProgressBar::draw(gcn::Graphics *graphics)
{
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ {
+ mAlpha = config.getValue("guialpha", 0.8);
+ for (int i = 0; i < 9; i++)
+ {
+ mBorder.grid[i]->setAlpha(mAlpha);
+ }
+ }
+
static_cast<Graphics*>(graphics)->
drawImageRect(0, 0, getWidth(), getHeight(), mBorder);
+ const int alpha = (int)(mAlpha * 255.0f);
+
// The bar
if (mProgress > 0)
{
- graphics->setColor(gcn::Color(mRed, mGreen, mBlue, 200));
+
+ graphics->setColor(gcn::Color(mRed, mGreen, mBlue, alpha));
graphics->fillRectangle(gcn::Rectangle(4, 4,
- (int)(mProgress * (getWidth() - 8)),
+ (int) (mProgress * (getWidth() - 8)),
getHeight() - 8));
}
+
+ // The label
+ 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, alpha));
+ 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, alpha));
+ graphics->drawText(mText, textX, textY, gcn::Graphics::CENTER);
+
+ graphics->setColor(gcn::Color(0, 0, 0));
+ }
}
-void
-ProgressBar::setProgress(float progress)
+void ProgressBar::setProgress(float progress)
{
if (progress < 0.0f) mProgressToGo = 0.0;
else if (progress > 1.0f) mProgressToGo = 1.0;
else mProgressToGo = progress;
}
-void
-ProgressBar::setColor(Uint8 red, Uint8 green, Uint8 blue)
+void ProgressBar::setColor(Uint8 red, Uint8 green, Uint8 blue)
{
mRedToGo = red;
mGreenToGo = green;