diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-14 20:00:13 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-14 20:00:13 +0300 |
commit | 3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb (patch) | |
tree | 514791e1df89602465aa2a29f2b9ca84be5ef618 /src | |
parent | 9b0982a39e750974852572d1a965c4a802f5f4cd (diff) | |
download | manaplus-3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb.tar.gz manaplus-3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb.tar.bz2 manaplus-3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb.tar.xz manaplus-3078fd67b62f4dd7de5cb6e944709e5b51c3c8fb.zip |
Improve shoplistbox.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/shoplistbox.cpp | 16 |
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") } |