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 | |
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')
-rw-r--r-- | src/gui/spellpopup.cpp | 35 | ||||
-rw-r--r-- | src/gui/spellpopup.h | 2 | ||||
-rw-r--r-- | src/gui/textcommandeditor.cpp | 42 | ||||
-rw-r--r-- | src/gui/textcommandeditor.h | 4 |
4 files changed, 61 insertions, 22 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) diff --git a/src/gui/spellpopup.h b/src/gui/spellpopup.h index 69c47bf45..883b2bfe0 100644 --- a/src/gui/spellpopup.h +++ b/src/gui/spellpopup.h @@ -63,6 +63,8 @@ class SpellPopup : public Popup private: gcn::Label *mItemName; + + gcn::Label *mItemComment; }; #endif // SPELLPOPUP_H diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 282f23ee1..0bd25fcb5 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -168,7 +168,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): Window(_("Command Editor"), false, 0, "commandeditor.xml") { int w = 350; - int h = 350; + int h = 370; mEnabledKeyboard = keyboard.isEnabled(); keyboard.setEnabled(false); @@ -197,6 +197,9 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): mCommandLabel = new Label(_("Command:")); mCommandTextField = new TextField(); + mCommentLabel = new Label(_("Comment:")); + mCommentTextField = new TextField(); + mManaLabel = new Label(_("Mana:")); mManaField = new IntTextField(0); mManaField->setRange(0, 500); @@ -248,6 +251,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): mSymbolTextField->setText(command->getSymbol()); mCommandTextField->setText(command->getCommand()); + mCommentTextField->setText(command->getComment()); mManaField->setValue(command->getMana()); mTypeDropDown->setSelected(command->getTargetType()); mMagicLvlField->setValue(command->getBaseLvl()); @@ -263,25 +267,29 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): placer(2, 1, mSymbolTextField, 3).setPadding(3); placer(0, 2, mCommandLabel, 2).setPadding(3); placer(2, 2, mCommandTextField, 4).setPadding(3); - placer(0, 3, mTypeLabel, 2).setPadding(3); - placer(2, 3, mTypeDropDown, 3).setPadding(3); - placer(0, 4, mIconLabel, 2).setPadding(3); - placer(2, 4, mIconDropDown, 3).setPadding(3); + placer(0, 3, mCommentLabel, 2).setPadding(3); + placer(2, 3, mCommentTextField, 4).setPadding(3); + + placer(0, 4, mTypeLabel, 2).setPadding(3); + placer(2, 4, mTypeDropDown, 3).setPadding(3); + + placer(0, 5, mIconLabel, 2).setPadding(3); + placer(2, 5, mIconDropDown, 3).setPadding(3); - placer(0, 5, mManaLabel, 2).setPadding(3); - placer(2, 5, mManaField, 3).setPadding(3); - placer(0, 6, mMagicLvlLabel, 2).setPadding(3); - placer(2, 6, mMagicLvlField, 3).setPadding(3); + placer(0, 6, mManaLabel, 2).setPadding(3); + placer(2, 6, mManaField, 3).setPadding(3); + placer(0, 7, mMagicLvlLabel, 2).setPadding(3); + placer(2, 7, mMagicLvlField, 3).setPadding(3); - placer(0, 7, mSchoolLabel, 2).setPadding(3); - placer(2, 7, mSchoolDropDown, 3).setPadding(3); - placer(0, 8, mSchoolLvlLabel, 2).setPadding(3); - placer(2, 8, mSchoolLvlField, 3).setPadding(3); + placer(0, 8, mSchoolLabel, 2).setPadding(3); + placer(2, 8, mSchoolDropDown, 3).setPadding(3); + placer(0, 9, mSchoolLvlLabel, 2).setPadding(3); + placer(2, 9, mSchoolLvlField, 3).setPadding(3); - placer(0, 9, mSaveButton, 2).setPadding(3); - placer(2, 9, mCancelButton, 2).setPadding(3); - placer(4, 9, mDeleteButton, 2).setPadding(3); + placer(0, 10, mSaveButton, 2).setPadding(3); + placer(2, 10, mCancelButton, 2).setPadding(3); + placer(4, 10, mDeleteButton, 2).setPadding(3); setWidth(w); setHeight(h); @@ -375,6 +383,7 @@ void TextCommandEditor::save() mCommand->setSymbol(mSymbolTextField->getText()); mCommand->setCommand(mCommandTextField->getText()); + mCommand->setComment(mCommentTextField->getText()); mCommand->setMana(mManaField->getValue()); mCommand->setTargetType( static_cast<SpellTarget>(mTypeDropDown->getSelected())); @@ -392,6 +401,7 @@ void TextCommandEditor::deleteCommand() mCommand->setCommandType(TEXT_COMMAND_TEXT); mCommand->setSymbol(""); mCommand->setCommand(""); + mCommand->setComment(""); mCommand->setMana(0); mCommand->setTargetType(NOTARGET); mCommand->setIcon(""); diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h index 236c42320..9239481b7 100644 --- a/src/gui/textcommandeditor.h +++ b/src/gui/textcommandeditor.h @@ -84,6 +84,10 @@ class TextCommandEditor : public Window, public gcn::ActionListener TextField *mSymbolTextField; Label *mCommandLabel; TextField *mCommandTextField; + + Label *mCommentLabel; + TextField *mCommentTextField; + Label *mTypeLabel; DropDown *mTypeDropDown; Label *mIconLabel; |