diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-25 18:07:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-25 18:07:58 +0300 |
commit | 9569e469a481076bdbc330377bf8445eb32fbaa6 (patch) | |
tree | 5afe0076206954d5f1649aedc5bcd9529757be14 /src/gui/widgets/emoteshortcutcontainer.cpp | |
parent | 0bcc82648c49db05980e879a13baba2c76264bd4 (diff) | |
download | manaplus-9569e469a481076bdbc330377bf8445eb32fbaa6.tar.gz manaplus-9569e469a481076bdbc330377bf8445eb32fbaa6.tar.bz2 manaplus-9569e469a481076bdbc330377bf8445eb32fbaa6.tar.xz manaplus-9569e469a481076bdbc330377bf8445eb32fbaa6.zip |
Add safeDraw method into shortcutcontainer childs.
Diffstat (limited to 'src/gui/widgets/emoteshortcutcontainer.cpp')
-rw-r--r-- | src/gui/widgets/emoteshortcutcontainer.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 0896188d9..97f012e89 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -127,6 +127,58 @@ void EmoteShortcutContainer::draw(Graphics *graphics) BLOCK_END("EmoteShortcutContainer::draw") } +void EmoteShortcutContainer::safeDraw(Graphics *graphics) +{ + if (!emoteShortcut) + return; + + BLOCK_START("EmoteShortcutContainer::draw") + if (settings.guiAlpha != mAlpha) + { + if (mBackgroundImg) + mBackgroundImg->setAlpha(mAlpha); + mAlpha = settings.guiAlpha; + } + + Font *const font = getFont(); + safeDrawBackground(graphics); + + unsigned sz = static_cast<unsigned>(mEmoteImg.size()); + if (sz > mMaxItems) + sz = mMaxItems; + for (unsigned i = 0; i < sz; i++) + { + const EmoteSprite *const emoteImg = mEmoteImg[i]; + if (emoteImg) + { + const AnimatedSprite *const sprite = emoteImg->sprite; + if (sprite) + { + sprite->draw(graphics, + (i % mGridWidth) * mBoxWidth + 2, + (i / mGridWidth) * mBoxHeight + 10); + } + } + } + for (unsigned i = 0; i < mMaxItems; i++) + { + const int emoteX = (i % mGridWidth) * mBoxWidth; + const int emoteY = (i / mGridWidth) * mBoxHeight; + + // Draw emote keyboard shortcut. + const std::string key = inputManager.getKeyValueString( + InputAction::EMOTE_1 + i); + + font->drawString(graphics, + mForegroundColor, + mForegroundColor2, + key, + emoteX + 2, emoteY + 2); + } + + BLOCK_END("EmoteShortcutContainer::draw") +} + void EmoteShortcutContainer::mouseDragged(MouseEvent &event A_UNUSED) { } |