summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/npcintegerdialog.cpp5
-rw-r--r--src/gui/npcintegerdialog.h7
-rw-r--r--src/gui/npcstringdialog.cpp3
-rw-r--r--src/gui/npcstringdialog.h1
-rw-r--r--src/net/npchandler.cpp1
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;