diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-02-16 18:52:54 +0000 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-02-16 18:52:54 +0000 |
commit | 26a52e8f74306b6e13e7a2029c19d8c7e1efd23a (patch) | |
tree | e239a4842ba2dd02cbd9a50e5a040783b40e9ca7 /src | |
parent | e1b66a9d88b43cee01ad15226c14fa6880fcbd04 (diff) | |
download | mana-26a52e8f74306b6e13e7a2029c19d8c7e1efd23a.tar.gz mana-26a52e8f74306b6e13e7a2029c19d8c7e1efd23a.tar.bz2 mana-26a52e8f74306b6e13e7a2029c19d8c7e1efd23a.tar.xz mana-26a52e8f74306b6e13e7a2029c19d8c7e1efd23a.zip |
Allow setting default values for NPC dialogs
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/npcintegerdialog.cpp | 5 | ||||
-rw-r--r-- | src/gui/npcintegerdialog.h | 7 | ||||
-rw-r--r-- | src/gui/npcstringdialog.cpp | 3 | ||||
-rw-r--r-- | src/gui/npcstringdialog.h | 1 | ||||
-rw-r--r-- | src/net/npchandler.cpp | 1 |
5 files changed, 16 insertions, 1 deletions
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index b05e77ba..6b26349a 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -109,6 +109,11 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event) } } +void NpcIntegerDialog::setDefaultValue(const int value) +{ + mValueField->setDefaultValue(value); +} + bool NpcIntegerDialog::isInputFocused() { return mValueField->isFocused(); diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h index a8ffcf0f..7c064ca6 100644 --- a/src/gui/npcintegerdialog.h +++ b/src/gui/npcintegerdialog.h @@ -62,6 +62,13 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener void setRange(const int min, const int max); /** + * Sets the default value. + * + * @param value The new default value + */ + void setDefaultValue(const int value); + + /** * Checks whether NpcStringDialog is Focused or not. */ bool isInputFocused(); diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index dc5893f8..f2ccc3cf 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -57,13 +57,14 @@ std::string NpcStringDialog::getValue() void NpcStringDialog::setValue(const std::string &value) { mValueField->setText(value); + mDefault = value; } void NpcStringDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "cancel") { - mValueField->setText(""); + mValueField->setText(mDefault); npcTextDialog->addText(_("\n> Cancel\n")); } else diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h index 960f8cec..0faaf203 100644 --- a/src/gui/npcstringdialog.h +++ b/src/gui/npcstringdialog.h @@ -70,6 +70,7 @@ class NpcStringDialog : public Window, public gcn::ActionListener private: gcn::TextField *mValueField; + std::string mDefault; }; #endif // GUI_NPCSTRINGDIALOG_H diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp index 3080bcf8..a6dc216b 100644 --- a/src/net/npchandler.cpp +++ b/src/net/npchandler.cpp @@ -94,6 +94,7 @@ void NPCHandler::handleMessage(MessageIn *msg) id = msg->readInt32(); current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id)); npcIntegerDialog->setRange(0, 2147483647); + npcIntegerDialog->setDefaultValue(0); npcIntegerDialog->setVisible(true); npcIntegerDialog->requestFocus(); break; |