From 479e8a53ec90c19890dfb4b3746c4453769d806a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 19 Sep 2011 19:33:14 +0300 Subject: Add comment field to spells/commands. --- src/gui/spellpopup.cpp | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/gui/spellpopup.cpp') 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) -- cgit v1.2.3-60-g2f50