summaryrefslogtreecommitdiff
path: root/src/gui/npcintegerdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/npcintegerdialog.cpp')
-rw-r--r--src/gui/npcintegerdialog.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
index 132a7608..9dc3660b 100644
--- a/src/gui/npcintegerdialog.cpp
+++ b/src/gui/npcintegerdialog.cpp
@@ -1,9 +1,8 @@
/*
- * Aethyra
+ * The Mana World
* Copyright (C) 2004 The Mana World Development Team
*
- * This file is part of Aethyra based on original code
- * from The Mana World.
+ * This file is part of The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,6 +21,7 @@
#include "button.h"
#include "inttextfield.h"
+#include "npc_text.h"
#include "npcintegerdialog.h"
#include "widgets/layout.h"
@@ -32,17 +32,20 @@
#include "../net/protocol.h"
#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
+
+extern NpcTextDialog *npcTextDialog;
NpcIntegerDialog::NpcIntegerDialog(Network *network):
Window(_("NPC Number Request")), mNetwork(network)
{
- mValueField = new IntTextField();
+ mValueField = new IntTextField;
mDecButton = new Button("-", "decvalue", this);
mIncButton = new Button("+", "incvalue", this);
- okButton = new Button(_("OK"), "ok", this);
- cancelButton = new Button(_("Cancel"), "cancel", this);
- resetButton = new Button(_("Reset"), "reset", this);
+ gcn::Button *okButton = new Button(_("OK"), "ok", this);
+ gcn::Button *cancelButton = new Button(_("Cancel"), "cancel", this);
+ gcn::Button *resetButton = new Button(_("Reset"), "reset", this);
mDecButton->setSize(20, 20);
mIncButton->setSize(20, 20);
@@ -63,7 +66,7 @@ NpcIntegerDialog::NpcIntegerDialog(Network *network):
setLocationRelativeTo(getParent());
}
-void NpcIntegerDialog::setRange(const int min, const int max)
+void NpcIntegerDialog::setRange(int min, int max)
{
mValueField->setRange(min, max);
}
@@ -85,11 +88,13 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event)
if (event.getId() == "ok")
{
finish = true;
+ npcTextDialog->addText(strprintf("\n> %d\n", mValueField->getValue()));
}
else if (event.getId() == "cancel")
{
finish = true;
mValueField->reset();
+ npcTextDialog->addText(_("\n> Cancel\n"));
}
else if (event.getId() == "decvalue")
{
@@ -107,7 +112,7 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event)
if (finish)
{
setVisible(false);
- NPC::mTalking = false;
+ NPC::isTalking = false;
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_INT_RESPONSE);
@@ -119,6 +124,11 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event)
}
}
+void NpcIntegerDialog::setDefaultValue(int value)
+{
+ mValueField->setDefaultValue(value);
+}
+
bool NpcIntegerDialog::isInputFocused()
{
return mValueField->isFocused();
@@ -128,3 +138,10 @@ void NpcIntegerDialog::requestFocus()
{
mValueField->requestFocus();
}
+
+void NpcIntegerDialog::setVisible(bool visible)
+{
+ if (visible) npcTextDialog->setVisible(true);
+
+ Window::setVisible(visible);
+}