summaryrefslogtreecommitdiff
path: root/src/gui/widgets/shoplistbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-04 20:05:48 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-04 20:05:48 +0300
commit62ec17f6e489ec50f17219444468aeb8969dc961 (patch)
tree350d7edb5c26c282a4e1906544536d68831228ac /src/gui/widgets/shoplistbox.cpp
parent71d924d7dcdac067f02a317e9353ee067dbd0bde (diff)
parentfd484fc70fca32ff9065b91c175089b65aa3fd26 (diff)
downloadmanaverse-stripped1.1.9.4.tar.gz
manaverse-stripped1.1.9.4.tar.bz2
manaverse-stripped1.1.9.4.tar.xz
manaverse-stripped1.1.9.4.zip
Merge branch 'master' into strippedstripped1.1.9.4
Conflicts: data/fonts/mplus-1p-bold.ttf data/fonts/mplus-1p-regular.ttf src/guichan/basiccontainer.cpp src/guichan/include/guichan/basiccontainer.hpp src/guichan/widgets/window.cpp
Diffstat (limited to 'src/gui/widgets/shoplistbox.cpp')
-rw-r--r--src/gui/widgets/shoplistbox.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 2fe28181b..793491808 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -50,9 +50,7 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel):
mShopItems(0)
{
mRowHeight = getFont()->getHeight();
- mPriceCheck = true;
-
- mItemPopup = new ItemPopup;
+ init();
}
ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel):
@@ -61,9 +59,17 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel):
mShopItems(shopListModel)
{
mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE);
- mPriceCheck = true;
+ init();
+}
+void ShopListBox::init()
+{
+ mPriceCheck = true;
mItemPopup = new ItemPopup;
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
+ mWarningColor = Theme::getThemeColor(Theme::SHOP_WARNING);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
void ShopListBox::setPlayersMoney(int money)
@@ -80,8 +86,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
mAlpha = Client::getGuiAlpha();
int alpha = static_cast<int>(mAlpha * 255.0f);
- const gcn::Color* highlightColor =
- &Theme::getThemeColor(Theme::HIGHLIGHT, alpha);
+ mHighlightColor.a = alpha;
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
@@ -93,29 +98,30 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
++i, y += mRowHeight)
{
gcn::Color temp;
- const gcn::Color* backgroundColor =
- &Theme::getThemeColor(Theme::BACKGROUND, alpha);
+ gcn::Color* backgroundColor = &mBackgroundColor;
+ mBackgroundColor.a = alpha;
if (mShopItems && mShopItems->at(i) &&
mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck)
{
if (i != mSelected)
{
- backgroundColor = &Theme::getThemeColor(Theme::SHOP_WARNING,
- alpha);
+ backgroundColor = &mWarningColor;
+ backgroundColor->a = alpha;
}
else
{
- temp = Theme::getThemeColor(Theme::SHOP_WARNING, alpha);
- temp.r = (temp.r + highlightColor->r) / 2;
- temp.g = (temp.g + highlightColor->g) / 2;
- temp.b = (temp.g + highlightColor->b) / 2;
+ temp = mWarningColor;
+ temp.r = (temp.r + mHighlightColor.r) / 2;
+ temp.g = (temp.g + mHighlightColor.g) / 2;
+ temp.b = (temp.g + mHighlightColor.b) / 2;
+ temp.a = alpha;
backgroundColor = &temp;
}
}
else if (i == mSelected)
{
- backgroundColor = highlightColor;
+ backgroundColor = &mHighlightColor;
}
graphics->setColor(*backgroundColor);
@@ -130,9 +136,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
graphics->drawImage(icon, 1, y);
}
}
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
graphics->drawText(mListModel->getElementAt(i), ITEM_ICON_SIZE + 5,
- y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2);
+ y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2);
}
}