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.cpp43
1 files changed, 31 insertions, 12 deletions
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
index 27721f0c..896f3380 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,20 +32,21 @@
#include "../net/protocol.h"
#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
NpcIntegerDialog::NpcIntegerDialog(Network *network):
Window(_("NPC Number Request")), mNetwork(network)
{
- mValueField = new IntTextField();
- setWindowName("NPCInput");
+ setWindowName("NPCInteger");
+ mValueField = new IntTextField;
setDefaultSize(175, 75, ImageRect::CENTER);
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->adjustSize();
mDecButton->setWidth(mIncButton->getWidth());
@@ -61,12 +62,14 @@ NpcIntegerDialog::NpcIntegerDialog(Network *network):
place(0, 0, resetButton);
place(2, 0, cancelButton);
place(3, 0, okButton);
- //reflowLayout(175, 0);
+ reflowLayout(175, 0);
+ center();
+ setDefaultSize();
loadWindowState();
}
-void NpcIntegerDialog::setRange(const int min, const int max)
+void NpcIntegerDialog::setRange(int min, int max)
{
mValueField->setRange(min, max);
}
@@ -88,11 +91,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")
{
@@ -110,18 +115,22 @@ 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);
outMsg.writeInt32(current_npc);
outMsg.writeInt32(mValueField->getValue());
- current_npc = 0;
mValueField->reset();
}
}
+void NpcIntegerDialog::setDefaultValue(int value)
+{
+ mValueField->setDefaultValue(value);
+}
+
bool NpcIntegerDialog::isInputFocused()
{
return mValueField->isFocused();
@@ -131,3 +140,13 @@ void NpcIntegerDialog::requestFocus()
{
mValueField->requestFocus();
}
+
+void NpcIntegerDialog::setVisible(bool visible)
+{
+ if (visible) {
+ npcTextDialog->setVisible(true);
+ requestFocus();
+ }
+
+ Window::setVisible(visible);
+}