summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-14 14:28:26 -0600
committerIra Rice <irarice@gmail.com>2009-03-14 14:28:26 -0600
commit20ad38045482254b9875ee80de44a9b6f9367d2d (patch)
treed49324d952c6c4197464d98bda1043919594cd13 /src/gui
parent3575c7a606c2d24c0d444e9999892c0390fa5ae8 (diff)
downloadmana-20ad38045482254b9875ee80de44a9b6f9367d2d.tar.gz
mana-20ad38045482254b9875ee80de44a9b6f9367d2d.tar.bz2
mana-20ad38045482254b9875ee80de44a9b6f9367d2d.tar.xz
mana-20ad38045482254b9875ee80de44a9b6f9367d2d.zip
Exposed the progress bar colors to the color management tab.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/palette.cpp1
-rw-r--r--src/gui/palette.h1
-rw-r--r--src/gui/progressbar.cpp13
-rw-r--r--src/gui/setup_colors.cpp27
-rw-r--r--src/gui/textrenderer.h7
-rw-r--r--src/gui/widgets/textpreview.cpp10
-rw-r--r--src/gui/widgets/textpreview.h11
-rw-r--r--src/gui/window.cpp6
-rw-r--r--src/gui/window.h5
9 files changed, 64 insertions, 17 deletions
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index c155cfe2..a3d654be 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -84,6 +84,7 @@ Palette::Palette() :
addColor(TEXT, 0x000000, STATIC, _("Text"));
addColor(SHADOW, 0x000000, STATIC, indent + _("Text Shadow"));
addColor(OUTLINE, 0x000000, STATIC, indent + _("Text Outline"));
+ addColor(PROGRESS_BAR, 0xffffff, STATIC, indent + _("Progress Bar Labels"));
addColor(BACKGROUND, 0xffffff, STATIC, _("Background"));
diff --git a/src/gui/palette.h b/src/gui/palette.h
index 4d8f7f11..f0a3d541 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -51,6 +51,7 @@ class Palette : public gcn::ListModel
ENTRY(TEXT)\
ENTRY(SHADOW)\
ENTRY(OUTLINE)\
+ ENTRY(PROGRESS_BAR)\
ENTRY(BACKGROUND)\
ENTRY(HIGHLIGHT)\
ENTRY(TAB_HIGHLIGHT)\
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index bec86bb1..025e0ec5 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -23,6 +23,7 @@
#include <guichan/font.hpp>
#include "gui.h"
+#include "palette.h"
#include "progressbar.h"
#include "../configuration.h"
@@ -133,18 +134,24 @@ void ProgressBar::draw(gcn::Graphics *graphics)
const int textX = getWidth() / 2;
const int textY = (getHeight() - f->getHeight()) / 2;
+ gcn::Color tempColor = guiPalette->getColor(Palette::OUTLINE);
+
graphics->setFont(f);
- graphics->setColor(gcn::Color(0, 0, 0, alpha));
+ graphics->setColor(gcn::Color((int) tempColor.r, (int) tempColor.g,
+ (int) tempColor.b, 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));
+ tempColor = guiPalette->getColor(Palette::PROGRESS_BAR);
+
+ graphics->setColor(gcn::Color((int) tempColor.r, (int) tempColor.g,
+ (int) tempColor.b, alpha));
graphics->drawText(mText, textX, textY, gcn::Graphics::CENTER);
- graphics->setColor(gcn::Color(0, 0, 0));
+ graphics->setColor(guiPalette->getColor(Palette::TEXT));
}
}
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 09c6a3a9..b7c408d1 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -177,12 +177,12 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
mPreview->clearRows();
mPreviewBox->setContent(mTextPreview);
mTextPreview->setFont(gui->getFont());
- mTextPreview->setTextColor(
- &guiPalette->getColor(Palette::TEXT));
+ mTextPreview->setTextColor(&guiPalette->getColor(Palette::TEXT));
mTextPreview->setTextBGColor(NULL);
- mTextPreview->setOpaque(false);
+ mTextPreview->setOpaque(false);
mTextPreview->setShadow(true);
mTextPreview->setOutline(true);
+ mTextPreview->useTextAlpha(false);
switch (type)
{
@@ -190,10 +190,16 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
case Palette::SHADOW:
case Palette::OUTLINE:
mTextPreview->setFont(gui->getFont());
- mTextPreview->setOutline(true);
mTextPreview->setShadow(type == Palette::SHADOW);
mTextPreview->setOutline(type == Palette::OUTLINE);
break;
+ case Palette::PROGRESS_BAR:
+ mTextPreview->useTextAlpha(true);
+ mTextPreview->setFont(boldFont);
+ mTextPreview->setTextColor(col);
+ mTextPreview->setOutline(true);
+ mTextPreview->setShadow(false);
+ break;
case Palette::TAB_HIGHLIGHT:
mTextPreview->setFont(gui->getFont());
mTextPreview->setTextColor(col);
@@ -201,8 +207,13 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
mTextPreview->setShadow(false);
break;
case Palette::BACKGROUND:
- case Palette::HIGHLIGHT:
case Palette::SHOP_WARNING:
+ mTextPreview->setBGColor(col);
+ mTextPreview->setOpaque(true);
+ mTextPreview->setOutline(false);
+ mTextPreview->setShadow(false);
+ break;
+ case Palette::HIGHLIGHT:
mTextPreview->setTextBGColor(col);
mTextPreview->setOutline(false);
mTextPreview->setShadow(false);
@@ -221,13 +232,10 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
mPreview->clearRows();
if (ch == '<')
- {
msg = toString("@@|") + rawmsg + "@@";
- }
else
- {
msg = "##" + toString(ch) + rawmsg;
- }
+
mPreview->addRow(msg);
break;
case Palette::UNKNOWN_ITEM:
@@ -246,6 +254,7 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
mTextPreview->setFont(boldFont);
mTextPreview->setOutline(false);
mTextPreview->setShadow(false);
+ break;
case Palette::PARTICLE:
case Palette::EXP_INFO:
case Palette::PICKUP_INFO:
diff --git a/src/gui/textrenderer.h b/src/gui/textrenderer.h
index 599e85a3..c0f5a0e9 100644
--- a/src/gui/textrenderer.h
+++ b/src/gui/textrenderer.h
@@ -37,7 +37,7 @@ class TextRenderer
*/
static inline void renderText(gcn::Graphics *graphics, const std::string&
text, int x, int y, gcn::Graphics::Alignment align,
- const gcn::Color* color, gcn::Font *font, bool outline = false,
+ const gcn::Color color, gcn::Font *font, bool outline = false,
bool shadow = false, int alpha = 255)
{
graphics->setFont(font);
@@ -45,8 +45,7 @@ class TextRenderer
// Text shadow
if (shadow)
{
- graphics->setColor(guiPalette->getColor(Palette::SHADOW,
- alpha / 2));
+ graphics->setColor(guiPalette->getColor(Palette::SHADOW, alpha / 2));
if (outline)
{
graphics->drawText(text, x + 2, y + 2, align);
@@ -73,7 +72,7 @@ class TextRenderer
graphics->drawText(text, x, y - 1, align);
}
- graphics->setColor(*color);
+ graphics->setColor(color);
graphics->drawText(text, x, y, align);
}
};
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index e34bb5cb..5408eebe 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -35,6 +35,7 @@ float TextPreview::mAlpha = config.getValue("guialpha", 0.8);
TextPreview::TextPreview(const std::string* text)
{
mText = text;
+ mTextAlpha = false;
mFont = gui->getFont();
mTextColor = &guiPalette->getColor(Palette::TEXT);
mTextBGColor = NULL;
@@ -47,6 +48,11 @@ void TextPreview::draw(gcn::Graphics* graphics)
if (config.getValue("guialpha", 0.8) != mAlpha)
mAlpha = config.getValue("guialpha", 0.8);
+ int alpha = (int) (mAlpha * 255.0f);
+
+ if (!mTextAlpha)
+ alpha = 255;
+
if (mOpaque)
{
graphics->setColor(gcn::Color((int) mBGColor->r,
@@ -69,5 +75,7 @@ void TextPreview::draw(gcn::Graphics* graphics)
}
TextRenderer::renderText(graphics, *mText, 2, 2, gcn::Graphics::LEFT,
- mTextColor, mFont, mOutline, mShadow);
+ gcn::Color(mTextColor->r, mTextColor->g,
+ mTextColor->b, alpha),
+ mFont, mOutline, mShadow, alpha);
}
diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h
index a73eb638..8e116262 100644
--- a/src/gui/widgets/textpreview.h
+++ b/src/gui/widgets/textpreview.h
@@ -45,6 +45,16 @@ class TextPreview : public gcn::Widget
}
/**
+ * Sets the text to use the set alpha value.
+ *
+ * @param alpha whether to use alpha values for the text or not
+ */
+ inline void useTextAlpha(bool alpha)
+ {
+ mTextAlpha = alpha;
+ }
+
+ /**
* Sets the color the text background is drawn in. This is only the
* rectangle directly behind the text, not to full widget.
*
@@ -123,6 +133,7 @@ class TextPreview : public gcn::Widget
const gcn::Color* mBGColor;
const gcn::Color* mTextBGColor;
static float mAlpha;
+ bool mTextAlpha;
bool mOpaque;
bool mShadow;
bool mOutline;
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 144357ca..e6e79b45 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -675,6 +675,12 @@ void Window::setGuiAlpha()
mAlphaChanged = false;
}
+int Window::getGuiAlpha()
+{
+ float alpha = config.getValue("guialpha", 0.8);
+ return (int) (alpha * 255.0f);
+}
+
Layout &Window::getLayout()
{
if (!mLayout) mLayout = new Layout;
diff --git a/src/gui/window.h b/src/gui/window.h
index d573d85f..e04fcfc3 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -300,6 +300,11 @@ class Window : public gcn::Window, gcn::WidgetListener
*/
virtual void close();
+ /**
+ * Gets the alpha value used by the window, in a GUIChan usable format.
+ */
+ int getGuiAlpha();
+
private:
enum ResizeHandles
{