diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-09-19 19:33:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-09-19 19:45:23 +0300 |
commit | 479e8a53ec90c19890dfb4b3746c4453769d806a (patch) | |
tree | 1d6499dd44145107e0d28dc4e3fbd96a214d4d7c /src/gui/spellpopup.cpp | |
parent | 5583ed6cb475a3fbc717f717971f0887ecc0226a (diff) | |
download | manaplus-479e8a53ec90c19890dfb4b3746c4453769d806a.tar.gz manaplus-479e8a53ec90c19890dfb4b3746c4453769d806a.tar.bz2 manaplus-479e8a53ec90c19890dfb4b3746c4453769d806a.tar.xz manaplus-479e8a53ec90c19890dfb4b3746c4453769d806a.zip |
Add comment field to spells/commands.
Diffstat (limited to 'src/gui/spellpopup.cpp')
-rw-r--r-- | src/gui/spellpopup.cpp | 35 |
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) |