summaryrefslogtreecommitdiff
path: root/src/gui/widgets/spellshortcutcontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-25 18:07:58 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-25 18:07:58 +0300
commit9569e469a481076bdbc330377bf8445eb32fbaa6 (patch)
tree5afe0076206954d5f1649aedc5bcd9529757be14 /src/gui/widgets/spellshortcutcontainer.cpp
parent0bcc82648c49db05980e879a13baba2c76264bd4 (diff)
downloadmv-9569e469a481076bdbc330377bf8445eb32fbaa6.tar.gz
mv-9569e469a481076bdbc330377bf8445eb32fbaa6.tar.bz2
mv-9569e469a481076bdbc330377bf8445eb32fbaa6.tar.xz
mv-9569e469a481076bdbc330377bf8445eb32fbaa6.zip
Add safeDraw method into shortcutcontainer childs.
Diffstat (limited to 'src/gui/widgets/spellshortcutcontainer.cpp')
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp60
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)