summaryrefslogtreecommitdiff
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
parent5583ed6cb475a3fbc717f717971f0887ecc0226a (diff)
downloadmanaverse-479e8a53ec90c19890dfb4b3746c4453769d806a.tar.gz
manaverse-479e8a53ec90c19890dfb4b3746c4453769d806a.tar.bz2
manaverse-479e8a53ec90c19890dfb4b3746c4453769d806a.tar.xz
manaverse-479e8a53ec90c19890dfb4b3746c4453769d806a.zip
Add comment field to spells/commands.
-rw-r--r--src/gui/spellpopup.cpp35
-rw-r--r--src/gui/spellpopup.h2
-rw-r--r--src/gui/textcommandeditor.cpp42
-rw-r--r--src/gui/textcommandeditor.h4
-rw-r--r--src/spellmanager.cpp43
-rw-r--r--src/textcommand.cpp15
-rw-r--r--src/textcommand.h19
7 files changed, 109 insertions, 51 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;
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 895ac94f2..4f7d038f2 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -68,31 +68,31 @@ void SpellManager::fillSpells()
{
//id, std::string name, std::string symbol, ST type, int basicLvl, MagicSchool school, int schoolLvl, int mana)
- addSpell(new TextCommand(0, "lum", "#lum", ALLOWTARGET,
+ addSpell(new TextCommand(0, "lum", "#lum", "heal with lifestones", ALLOWTARGET,
"", 1, SKILL_MAGIC_LIFE, 0, 6));
- addSpell(new TextCommand(1, "inm", "#inma", NEEDTARGET,
+ addSpell(new TextCommand(1, "inm", "#inma", "heal", NEEDTARGET,
"", 2, SKILL_MAGIC_LIFE, 2, 10));
- addSpell(new TextCommand(2, "fla", "#flar", NOTARGET,
+ addSpell(new TextCommand(2, "fla", "#flar", "", NOTARGET,
"", 1, SKILL_MAGIC_WAR, 0, 10));
- addSpell(new TextCommand(3, "chi", "#chiza", NOTARGET,
+ addSpell(new TextCommand(3, "chi", "#chiza", "", NOTARGET,
"", 1, SKILL_MAGIC_WAR, 0, 9));
- addSpell(new TextCommand(4, "ing", "#ingrav", NOTARGET,
+ addSpell(new TextCommand(4, "ing", "#ingrav", "", NOTARGET,
"", 2, SKILL_MAGIC_WAR, 2, 20));
- addSpell(new TextCommand(5, "fri", "#frillyar", NOTARGET,
+ addSpell(new TextCommand(5, "fri", "#frillyar", "", NOTARGET,
"", 2, SKILL_MAGIC_WAR, 2, 25));
- addSpell(new TextCommand(6, "upm", "#upmarmu", NOTARGET,
+ addSpell(new TextCommand(6, "upm", "#upmarmu", "", NOTARGET,
"", 2, SKILL_MAGIC_WAR, 2, 20));
- addSpell(new TextCommand(7, "ite", "#itenplz", NOTARGET,
+ addSpell(new TextCommand(7, "ite", "#itenplz", "", NOTARGET,
"", 1, SKILL_MAGIC_NATURE, 0, 3));
- addSpell(new TextCommand(8, "bet", "#betsanc", ALLOWTARGET,
+ addSpell(new TextCommand(8, "bet", "#betsanc", "", ALLOWTARGET,
"", 2, SKILL_MAGIC_NATURE, 2, 14));
- addSpell(new TextCommand(9, "abi", "#abizit", NOTARGET,
+ addSpell(new TextCommand(9, "abi", "#abizit", "", NOTARGET,
"", 1, SKILL_MAGIC, 0, 1));
- addSpell(new TextCommand(10, "inw", "#inwilt", NOTARGET,
+ addSpell(new TextCommand(10, "inw", "#inwilt", "", NOTARGET,
"", 2, SKILL_MAGIC, 2, 7));
- addSpell(new TextCommand(11, "hi", "hi", NOTARGET, ""));
- addSpell(new TextCommand(12, "hea", "heal", NOTARGET, ""));
- addSpell(new TextCommand(13, "@sp", "@spawn maggot 10", NOTARGET, ""));
+ addSpell(new TextCommand(11, "hi", "hi", "", NOTARGET, ""));
+ addSpell(new TextCommand(12, "hea", "heal", "", NOTARGET, ""));
+ addSpell(new TextCommand(13, "@sp", "@spawn maggot 10", "", NOTARGET, ""));
for (int f = 12; f < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; f++)
addSpell(new TextCommand(f));
}
@@ -269,6 +269,8 @@ void SpellManager::load(bool oldConfig)
std::string cmd = cfg->getValue("commandShortcutCmd"
+ toString(i), "");
+ std::string comment = cfg->getValue("commandShortcutComment"
+ + toString(i), "");
std::string symbol = cfg->getValue("commandShortcutSymbol"
+ toString(i), "");
std::string icon = cfg->getValue("commandShortcutIcon"
@@ -276,13 +278,13 @@ void SpellManager::load(bool oldConfig)
if (static_cast<TextCommandType>(commandType) == TEXT_COMMAND_MAGIC)
{
- addSpell(new TextCommand(i, symbol, cmd,
+ addSpell(new TextCommand(i, symbol, cmd, comment,
static_cast<SpellTarget>(targetType), icon, basicLvl,
static_cast<MagicSchool>(school), schoolLvl, mana));
}
else
{
- addSpell(new TextCommand(i, symbol, cmd,
+ addSpell(new TextCommand(i, symbol, cmd, comment,
static_cast<SpellTarget>(targetType), icon));
}
}
@@ -304,6 +306,15 @@ void SpellManager::save()
{
serverConfig.deleteKey("commandShortcutCmd" + toString(i));
}
+ if (spell->getComment() != "")
+ {
+ serverConfig.setValue("commandShortcutComment" + toString(i),
+ spell->getComment());
+ }
+ else
+ {
+ serverConfig.deleteKey("commandShortcutComment" + toString(i));
+ }
if (spell->getSymbol() != "")
{
serverConfig.setValue("commandShortcutSymbol" + toString(i),
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index 1402576d1..30d8c2a4c 100644
--- a/src/textcommand.cpp
+++ b/src/textcommand.cpp
@@ -31,11 +31,12 @@
#include "debug.h"
TextCommand::TextCommand(unsigned int id, std::string symbol,
- std::string command, SpellTarget type,
- std::string icon, unsigned int basicLvl,
- MagicSchool school, unsigned int schoolLvl,
- int mana) :
+ std::string command, std::string comment,
+ SpellTarget type, std::string icon,
+ unsigned int basicLvl, MagicSchool school,
+ unsigned int schoolLvl, int mana) :
mCommand(command),
+ mComment(comment),
mSymbol(symbol),
mTargetType(type),
mIcon(icon),
@@ -52,9 +53,10 @@ TextCommand::TextCommand(unsigned int id, std::string symbol,
TextCommand::TextCommand(unsigned int id, std::string symbol,
- std::string command, SpellTarget type,
- std::string icon) :
+ std::string command, std::string comment,
+ SpellTarget type, std::string icon) :
mCommand(command),
+ mComment(comment),
mSymbol(symbol),
mTargetType(type),
mIcon(icon),
@@ -71,6 +73,7 @@ TextCommand::TextCommand(unsigned int id, std::string symbol,
TextCommand::TextCommand(unsigned int id) :
mCommand(""),
+ mComment(""),
mSymbol(""),
mTargetType(NOTARGET),
mIcon(""),
diff --git a/src/textcommand.h b/src/textcommand.h
index 5ddbe824d..b1af7667d 100644
--- a/src/textcommand.h
+++ b/src/textcommand.h
@@ -62,18 +62,16 @@ class TextCommand
/**
* Constructor.
*/
- TextCommand(unsigned int id, std::string symbol,
- std::string command, SpellTarget type,
- std::string icon, unsigned int basicLvl,
- MagicSchool school = SKILL_MAGIC,
+ TextCommand(unsigned int id, std::string symbol, std::string command,
+ std::string comment, SpellTarget type, std::string icon,
+ unsigned int basicLvl, MagicSchool school = SKILL_MAGIC,
unsigned int schoolLvl = 0, int mana = 0);
/**
* Constructor.
*/
- TextCommand(unsigned int id, std::string symbol,
- std::string command, SpellTarget type,
- std::string icon);
+ TextCommand(unsigned int id, std::string symbol, std::string command,
+ std::string comment, SpellTarget type, std::string icon);
/**
* Constructor.
@@ -91,6 +89,9 @@ class TextCommand
std::string getCommand() const
{ return mCommand; }
+ std::string getComment() const
+ { return mComment; }
+
std::string getSymbol() const
{ return mSymbol; }
@@ -121,6 +122,9 @@ class TextCommand
void setCommand(std::string command)
{ mCommand = command; }
+ void setComment(std::string comment)
+ { mComment = comment; }
+
void setSymbol(std::string symbol)
{ mSymbol = symbol; }
@@ -159,6 +163,7 @@ class TextCommand
protected:
std::string mCommand;
+ std::string mComment;
std::string mSymbol;
SpellTarget mTargetType;
std::string mIcon;