summaryrefslogtreecommitdiff
path: root/src/gui/shoplistbox.cpp
diff options
context:
space:
mode:
authorsniper <sniper@livecd.janhome.net>2009-03-11 15:35:54 +0100
committerIra Rice <irarice@gmail.com>2009-03-12 21:25:27 -0600
commit7d20381b7b9abdf0934ee0fbbb196c788ea93a0d (patch)
tree72e0eef30733d2928d9c0cf41090d3ea10a82e4f /src/gui/shoplistbox.cpp
parent393c1085ed1cb24092778594d2945a39428e41ad (diff)
downloadmana-client-7d20381b7b9abdf0934ee0fbbb196c788ea93a0d.tar.gz
mana-client-7d20381b7b9abdf0934ee0fbbb196c788ea93a0d.tar.bz2
mana-client-7d20381b7b9abdf0934ee0fbbb196c788ea93a0d.tar.xz
mana-client-7d20381b7b9abdf0934ee0fbbb196c788ea93a0d.zip
Extending the internal handling of colors
The internal storage for colors was in the file color.h/color.cpp. It mainly managed the colors in the chat. The Color class was extended to be more generic now and it stores gcn::Color objects instead of integers now. A lot of new colortypes are now available, though not many of them are used for now, that will come in the next patches. The Color class was renamed to Palette and color.{h,cpp} to palette.{h,cpp} to better describe its purpose. The color config gui now lists the new colors, even changes them, but the result is not displayed properly for now.
Diffstat (limited to 'src/gui/shoplistbox.cpp')
-rw-r--r--src/gui/shoplistbox.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp
index 776f26bc..74209122 100644
--- a/src/gui/shoplistbox.cpp
+++ b/src/gui/shoplistbox.cpp
@@ -23,7 +23,7 @@
#include <guichan/font.hpp>
#include <guichan/listmodel.hpp>
-#include "color.h"
+#include "palette.h"
#include "shop.h"
#include "shoplistbox.h"
@@ -64,11 +64,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
if (config.getValue("guialpha", 0.8) != mAlpha)
mAlpha = config.getValue("guialpha", 0.8);
- bool valid;
- const int red = (textColor->getColor('H', valid) >> 16) & 0xFF;
- const int green = (textColor->getColor('H', valid) >> 8) & 0xFF;
- const int blue = textColor->getColor('H', valid) & 0xFF;
- const int alpha = (int)(mAlpha * 255.0f);
+ int alpha = (int)(mAlpha * 255.0f);
+ const gcn::Color* highlightColor =
+ &guiPalette->getColor(Palette::HIGHLIGHT, alpha);
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
@@ -79,19 +77,27 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
i < mListModel->getNumberOfElements();
++i, y += mRowHeight)
{
- gcn::Color backgroundColor = gcn::Color(255, 255, 255, alpha);
+ gcn::Color temp;
+ const gcn::Color* backgroundColor =
+ &guiPalette->getColor(Palette::BACKGROUND, alpha);
- if (i == mSelected)
- {
- backgroundColor = gcn::Color(red, green, blue, alpha);
- }
- else if (mShopItems &&
+ if (mShopItems &&
mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck)
- {
- backgroundColor = gcn::Color(145, 145, 145, alpha);
- }
+ if (i != mSelected)
+ backgroundColor = &guiPalette->getColor(Palette::SHOP_WARNING,
+ alpha);
+ else
+ {
+ temp = guiPalette->getColor(Palette::SHOP_WARNING, alpha);
+ temp.r = (temp.r + highlightColor->r) / 2;
+ temp.g = (temp.g + highlightColor->g) / 2;
+ temp.b = (temp.g + highlightColor->b) / 2;
+ backgroundColor = &temp;
+ }
+ else if (i == mSelected)
+ backgroundColor = highlightColor;
- graphics->setColor(backgroundColor);
+ graphics->setColor(*backgroundColor);
graphics->fillRectangle(gcn::Rectangle(0, y, getWidth(), mRowHeight));
if (mShopItems)
@@ -102,7 +108,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
graphics->drawImage(icon, 1, y);
}
}
- graphics->setColor(gcn::Color(0, 0, 0));
+ graphics->setColor(guiPalette->getColor(Palette::TEXT));
graphics->drawText(mListModel->getElementAt(i), ITEM_ICON_SIZE + 5,
y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2);
}