diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-25 18:45:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-25 18:45:59 +0300 |
commit | 7369332bb0a6d219cb2415a0b5e65bf2825da349 (patch) | |
tree | ef09d6526d0804e7370d41269e2e235d0c34cf6e /src/gui/windows | |
parent | 6b8cc23d56d0f46bb8b53bbfb3468adea6a7dd77 (diff) | |
download | plus-7369332bb0a6d219cb2415a0b5e65bf2825da349.tar.gz plus-7369332bb0a6d219cb2415a0b5e65bf2825da349.tar.bz2 plus-7369332bb0a6d219cb2415a0b5e65bf2825da349.tar.xz plus-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')
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 12 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.h | 2 | ||||
-rw-r--r-- | src/gui/windows/debugwindow.cpp | 18 | ||||
-rw-r--r-- | src/gui/windows/debugwindow.h | 2 | ||||
-rw-r--r-- | src/gui/windows/equipmentwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/minimap.cpp | 13 | ||||
-rw-r--r-- | src/gui/windows/minimap.h | 4 | ||||
-rw-r--r-- | src/gui/windows/outfitwindow.cpp | 56 | ||||
-rw-r--r-- | src/gui/windows/outfitwindow.h | 2 |
9 files changed, 110 insertions, 1 deletions
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index f4641670d..824ba4882 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -2081,6 +2081,18 @@ void ChatWindow::draw(Graphics* graphics) BLOCK_END("ChatWindow::draw") } +void ChatWindow::safeDraw(Graphics* graphics) +{ + BLOCK_START("ChatWindow::draw") + if (!mAutoHide || mHaveMouse) + { + GLDEBUG_START("ChatWindow::draw"); + Window::safeDraw(graphics); + GLDEBUG_END(); + } + BLOCK_END("ChatWindow::draw") +} + void ChatWindow::updateVisibility() { if (!gui) diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 3077b9e8b..e8d920897 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -282,6 +282,8 @@ class ChatWindow final : public Window, void draw(Graphics* graphics) override final; + void safeDraw(Graphics* graphics) override final; + void updateVisibility(); void unHideWindow(); diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index e0d73249b..185e4adab 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -134,6 +134,24 @@ void DebugWindow::draw(Graphics *g) BLOCK_END("DebugWindow::draw") } +void DebugWindow::safeDraw(Graphics *g) +{ + BLOCK_START("DebugWindow::draw") + Window::safeDraw(g); + + if (localPlayer) + { + const Being *const target = localPlayer->getTarget(); + if (target) + { + target->draw(g, -target->getPixelX() + mapTileSize / 2 + + mDimension.width / 2, -target->getPixelY() + mapTileSize + + mDimension.height / 2); + } + } + BLOCK_END("DebugWindow::draw") +} + void DebugWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h index 9a0b2fe5c..5496852f6 100644 --- a/src/gui/windows/debugwindow.h +++ b/src/gui/windows/debugwindow.h @@ -56,6 +56,8 @@ class DebugWindow final : public Window void draw(Graphics *g) override final; + void safeDraw(Graphics *g) override final; + void setPing(int pingTime); void widgetResized(const Event &event) override final; diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index c856433ba..d569c3cc2 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -267,7 +267,7 @@ void EquipmentWindow::safeDraw(Graphics *graphics) { BLOCK_START("EquipmentWindow::draw") // Draw window graphics - Window::draw(graphics); + Window::safeDraw(graphics); int i = 0; Font *const font = getFont(); diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index bdf9c37be..6b2a8547a 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -237,8 +237,21 @@ void Minimap::toggle() void Minimap::draw(Graphics *graphics) { BLOCK_START("Minimap::draw") + Window::draw(graphics); + draw2(graphics); +} + +void Minimap::safeDraw(Graphics *graphics) +{ + BLOCK_START("Minimap::draw") + + Window::safeDraw(graphics); + draw2(graphics); +} +void Minimap::draw2(Graphics *const graphics) +{ if (!userPalette || !localPlayer || !viewport) { BLOCK_END("Minimap::draw") diff --git a/src/gui/windows/minimap.h b/src/gui/windows/minimap.h index 8d7ffc2a8..8c7150080 100644 --- a/src/gui/windows/minimap.h +++ b/src/gui/windows/minimap.h @@ -61,6 +61,10 @@ class Minimap final : public Window, public ConfigListener */ void draw(Graphics *graphics) override final; + void safeDraw(Graphics *graphics) override final; + + void draw2(Graphics *const graphics); + void mouseMoved(MouseEvent &event) override final; void mouseReleased(MouseEvent &event) override final; 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) diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index defaf4c4d..b27bd7d4a 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -54,6 +54,8 @@ class OutfitWindow final : public Window, void draw(Graphics *graphics) override final; + void safeDraw(Graphics *graphics) override final; + void mousePressed(MouseEvent &event) override final; void mouseDragged(MouseEvent &event) override final; |