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/spellshortcutcontainer.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/spellshortcutcontainer.cpp')
-rw-r--r-- | src/gui/widgets/spellshortcutcontainer.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 672858412..5a0de0995 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -121,6 +121,66 @@ void SpellShortcutContainer::draw(Graphics *graphics) BLOCK_END("SpellShortcutContainer::draw") } +void SpellShortcutContainer::safeDraw(Graphics *graphics) +{ + if (!spellShortcut) + return; + + BLOCK_START("SpellShortcutContainer::draw") + if (settings.guiAlpha != mAlpha) + { + mAlpha = settings.guiAlpha; + if (mBackgroundImg) + mBackgroundImg->setAlpha(mAlpha); + } + + Font *const font = getFont(); + + const int selectedId = spellShortcut->getSelectedItem(); + graphics->setColor(mForegroundColor); + safeDrawBackground(graphics); + + // +++ in future need reorder images and string drawing. + for (unsigned i = 0; i < mMaxItems; i++) + { + const int itemX = (i % mGridWidth) * mBoxWidth; + const int itemY = (i / mGridWidth) * mBoxHeight; + + const int itemId = getItemByIndex(i); + if (selectedId >= 0 && itemId == selectedId) + { + graphics->drawRectangle(Rect(itemX + 1, itemY + 1, + mBoxWidth - 1, mBoxHeight - 1)); + } + + if (!spellManager) + continue; + + const TextCommand *const spell = spellManager->getSpell(itemId); + if (spell) + { + if (!spell->isEmpty()) + { + Image *const image = spell->getImage(); + + if (image) + { + image->setAlpha(1.0F); + graphics->drawImage(image, itemX, itemY); + } + } + + font->drawString(graphics, + mForegroundColor, + mForegroundColor2, + spell->getSymbol(), + itemX + 2, itemY + mBoxHeight / 2); + } + } + + BLOCK_END("SpellShortcutContainer::draw") +} + void SpellShortcutContainer::mouseDragged(MouseEvent &event) { if (event.getButton() == MouseButton::LEFT) |