summaryrefslogtreecommitdiff
path: root/src/gui/windows/outfitwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 18:45:59 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 18:45:59 +0300
commit7369332bb0a6d219cb2415a0b5e65bf2825da349 (patch)
treeef09d6526d0804e7370d41269e2e235d0c34cf6e /src/gui/windows/outfitwindow.cpp
parent6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77 (diff)
downloadmv-7369332bb0a6d219cb2415a0b5e65bf2825da349.tar.gz
mv-7369332bb0a6d219cb2415a0b5e65bf2825da349.tar.bz2
mv-7369332bb0a6d219cb2415a0b5e65bf2825da349.tar.xz
mv-7369332bb0a6d219cb2415a0b5e65bf2825da349.zip
Add missing safeDraw to some windows.
Without it drawing code can mix safe and not safe drawing.
Diffstat (limited to 'src/gui/windows/outfitwindow.cpp')
-rw-r--r--src/gui/windows/outfitwindow.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index 896136bb3..e1f2c3b42 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -374,6 +374,62 @@ void OutfitWindow::draw(Graphics *graphics)
BLOCK_END("OutfitWindow::draw")
}
+void OutfitWindow::safeDraw(Graphics *graphics)
+{
+ BLOCK_START("OutfitWindow::draw")
+ Window::safeDraw(graphics);
+
+ if (mCurrentOutfit < 0 || mCurrentOutfit
+ >= static_cast<signed int>(OUTFITS_COUNT))
+ {
+ return;
+ }
+
+ for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
+ {
+ const int itemX = mPadding + ((i % mGridWidth) * mBoxWidth);
+ const int itemY = mPadding + mTitleBarHeight
+ + ((i / static_cast<unsigned int>(mGridWidth)) * mBoxHeight);
+
+ graphics->setColor(mBorderColor);
+ graphics->drawRectangle(Rect(itemX, itemY, 32, 32));
+ graphics->setColor(mBackgroundColor);
+ graphics->fillRectangle(Rect(itemX, itemY, 32, 32));
+
+ if (mItems[mCurrentOutfit][i] < 0)
+ continue;
+
+ bool foundItem = false;
+ const Inventory *const inv = PlayerInfo::getInventory();
+ if (inv)
+ {
+ const Item *const item = inv->findItem(mItems[mCurrentOutfit][i],
+ mItemColors[mCurrentOutfit][i]);
+ if (item)
+ {
+ // Draw item icon.
+ const Image *const image = item->getImage();
+ if (image)
+ {
+ graphics->drawImage(image, itemX, itemY);
+ foundItem = true;
+ }
+ }
+ }
+ if (!foundItem)
+ {
+ Image *const image = Item::getImage(mItems[mCurrentOutfit][i],
+ mItemColors[mCurrentOutfit][i]);
+ if (image)
+ {
+ graphics->drawImage(image, itemX, itemY);
+ image->decRef();
+ }
+ }
+ }
+ BLOCK_END("OutfitWindow::draw")
+}
+
void OutfitWindow::mouseDragged(MouseEvent &event)
{
if (event.getButton() == MouseButton::LEFT)