summaryrefslogtreecommitdiff
path: root/src/gui/spellpopup.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-19 19:33:14 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-19 19:45:23 +0300
commit479e8a53ec90c19890dfb4b3746c4453769d806a (patch)
tree1d6499dd44145107e0d28dc4e3fbd96a214d4d7c /src/gui/spellpopup.cpp
parent5583ed6cb475a3fbc717f717971f0887ecc0226a (diff)
downloadmv-479e8a53ec90c19890dfb4b3746c4453769d806a.tar.gz
mv-479e8a53ec90c19890dfb4b3746c4453769d806a.tar.bz2
mv-479e8a53ec90c19890dfb4b3746c4453769d806a.tar.xz
mv-479e8a53ec90c19890dfb4b3746c4453769d806a.zip
Add comment field to spells/commands.
Diffstat (limited to 'src/gui/spellpopup.cpp')
-rw-r--r--src/gui/spellpopup.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp
index c7d25e257..66d69b197 100644
--- a/src/gui/spellpopup.cpp
+++ b/src/gui/spellpopup.cpp
@@ -42,14 +42,15 @@
#include "debug.h"
SpellPopup::SpellPopup():
- Popup("SpellPopup", "spellpopup.xml")
+ Popup("SpellPopup", "spellpopup.xml"),
+ mItemName(new Label),
+ mItemComment(new Label)
{
- // Item Name
- mItemName = new Label;
mItemName->setFont(boldFont);
- mItemName->setPosition(getPadding(), getPadding());
add(mItemName);
+ add(mItemComment);
+
addMouseListener(this);
}
@@ -60,17 +61,39 @@ SpellPopup::~SpellPopup()
void SpellPopup::setItem(TextCommand *spell)
{
if (spell)
+ {
mItemName->setCaption(spell->getName());
+ mItemComment->setCaption(spell->getComment());
+ }
else
+ {
mItemName->setCaption("?");
+ mItemComment->setCaption("");
+ }
mItemName->adjustSize();
+ mItemComment->adjustSize();
int minWidth = mItemName->getWidth();
+ if (mItemComment->getWidth() > minWidth)
+ minWidth = mItemComment->getWidth();
minWidth += 8;
- setWidth(minWidth);
+ setWidth(minWidth + 2 * getPadding());
- setContentSize(minWidth, getPadding() + getFont()->getHeight());
+ mItemName->setPosition(getPadding(), getPadding());
+ mItemComment->setPosition(getPadding(),
+ getPadding() + mItemName->getHeight());
+
+ if (mItemComment->getCaption() != "")
+ {
+ setContentSize(minWidth, getPadding()
+ + 2 * getFont()->getHeight());
+ }
+ else
+ {
+ setContentSize(minWidth, getPadding()
+ + getFont()->getHeight());
+ }
}
void SpellPopup::view(int x, int y)