diff options
Diffstat (limited to 'src/gui/npcintegerdialog.cpp')
-rw-r--r-- | src/gui/npcintegerdialog.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index ea3398c9..463f46ae 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" @@ -29,17 +29,20 @@ #include "../npc.h" #include "../utils/gettext.h" +#include "../utils/strprintf.h" + +extern NpcTextDialog *npcTextDialog; NpcIntegerDialog::NpcIntegerDialog(): Window(_("NPC Number Request")) { - 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); @@ -60,7 +63,7 @@ NpcIntegerDialog::NpcIntegerDialog(): setLocationRelativeTo(getParent()); } -void NpcIntegerDialog::setRange(const int min, const int max) +void NpcIntegerDialog::setRange(int min, int max) { mValueField->setRange(min, max); } @@ -77,11 +80,13 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event) if (event.getId() == "ok") { finish = 1; + npcTextDialog->addText(strprintf("\n> %d\n", mValueField->getValue())); } else if (event.getId() == "cancel") { finish = 1; mValueField->reset(); + npcTextDialog->addText(_("\n> Cancel\n")); } else if (event.getId() == "decvalue") { @@ -100,11 +105,15 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event) { setVisible(false); current_npc->integerInput(mValueField->getValue()); - current_npc = NULL; mValueField->reset(); } } +void NpcIntegerDialog::setDefaultValue(int value) +{ + mValueField->setDefaultValue(value); +} + bool NpcIntegerDialog::isInputFocused() { return mValueField->isFocused(); |