diff options
author | sniper <sniper@livecd.janhome.net> | 2009-03-11 15:35:54 +0100 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-03-12 18:53:16 -0600 |
commit | 4260cb92571842c6336537bf0d0c47c4f011ac0f (patch) | |
tree | 6c9ce9d69dc6914bb9948b152171d216a801f7c9 /src/gui/shoplistbox.cpp | |
parent | f3796c231d5bcac6850fb9afc8db652361e3fceb (diff) | |
download | mana-4260cb92571842c6336537bf0d0c47c4f011ac0f.tar.gz mana-4260cb92571842c6336537bf0d0c47c4f011ac0f.tar.bz2 mana-4260cb92571842c6336537bf0d0c47c4f011ac0f.tar.xz mana-4260cb92571842c6336537bf0d0c47c4f011ac0f.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.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 64c97246..19c8a7b4 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -22,7 +22,7 @@ #include <guichan/font.hpp> #include <guichan/listmodel.hpp> -#include "color.h" +#include "palette.h" #include "shop.h" #include "shoplistbox.h" @@ -63,11 +63,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); @@ -78,18 +76,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 (mShopItems && mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck) - if (i == mSelected) - backgroundColor = gcn::Color(145, 0, 0, alpha); + if (i != mSelected) + backgroundColor = &guiPalette->getColor(Palette::SHOP_WARNING, + alpha); else - backgroundColor = gcn::Color(145, 145, 145, alpha); + { + 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 = gcn::Color(red, green, blue, alpha); + backgroundColor = highlightColor; - graphics->setColor(backgroundColor); + graphics->setColor(*backgroundColor); graphics->fillRectangle(gcn::Rectangle(0, y, getWidth(), mRowHeight)); if (mShopItems) @@ -100,7 +107,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); } |