summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-06-14 20:00:13 +0300
committerAndrei Karas <akaras@inbox.ru>2013-06-14 20:00:13 +0300
commit3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb (patch)
tree514791e1df89602465aa2a29f2b9ca84be5ef618
parent9b0982a39e750974852572d1a965c4a802f5f4cd (diff)
downloadplus-3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb.tar.gz
plus-3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb.tar.bz2
plus-3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb.tar.xz
plus-3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb.zip
Improve shoplistbox.
-rw-r--r--src/gui/widgets/shoplistbox.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index ec3ed12e4..615b93010 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -94,17 +94,21 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
gcn::Font *const font = getFont();
+ const int sz = mListModel->getNumberOfElements();
+ const int fontHeigh = getFont()->getHeight();
+ const int width = mDimension.width - 2 * mPadding;
// Draw the list elements
for (int i = 0, y = 0;
- i < mListModel->getNumberOfElements();
+ i < sz;
++i, y += mRowHeight)
{
bool needDraw(false);
gcn::Color temp;
gcn::Color* backgroundColor = &mBackgroundColor;
- if (mShopItems && mShopItems->at(i) &&
- mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck)
+ ShopItem *const item = mShopItems->at(i);
+ if (mShopItems && item &&
+ mPlayerMoney < item->getPrice() && mPriceCheck)
{
if (i != mSelected)
{
@@ -137,12 +141,12 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
{
graphics->setColor(*backgroundColor);
graphics->fillRectangle(gcn::Rectangle(mPadding, y + mPadding,
- getWidth() - 2 * mPadding, mRowHeight));
+ width, mRowHeight));
}
if (mShopItems)
{
- Image *const icon = mShopItems->at(i)->getImage();
+ Image *const icon = item->getImage();
if (icon)
{
icon->setAlpha(1.0f);
@@ -160,7 +164,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
}
font->drawString(graphics, mListModel->getElementAt(i),
ITEM_ICON_SIZE + mPadding,
- y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2 + mPadding);
+ y + (ITEM_ICON_SIZE - fontHeigh) / 2 + mPadding);
}
BLOCK_END("ShopListBox::draw")
}