summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlue <bluesansdouze@gmail.com>2009-05-03 23:30:41 +0200
committerJared Adams <jaxad0127@gmail.com>2009-05-03 15:36:17 -0600
commit3a274b8e8c1183e2ef37a5ac0d75849db5560fb3 (patch)
treebebf3c320307ef92f9f765b6a983e92d5838922f /src
parent05cd6e178814ccbab62e593a79332ab7aa95a963 (diff)
downloadmana-3a274b8e8c1183e2ef37a5ac0d75849db5560fb3.tar.gz
mana-3a274b8e8c1183e2ef37a5ac0d75849db5560fb3.tar.bz2
mana-3a274b8e8c1183e2ef37a5ac0d75849db5560fb3.tar.xz
mana-3a274b8e8c1183e2ef37a5ac0d75849db5560fb3.zip
NPC Integer input plus and minus
Added plus and minus buttons on NPC Integer input. No server side modifications.
Diffstat (limited to 'src')
-rw-r--r--src/gui/npcdialog.cpp30
-rw-r--r--src/gui/npcdialog.h6
2 files changed, 26 insertions, 10 deletions
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 6c42695e..5b1d1a07 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -45,7 +45,7 @@
#define CAPTION_SUBMIT _("Submit")
NpcDialog::NpcDialog()
- : Window(_("NPC")),
+ : Window(_("NPC")),
mActionState(NPC_ACTION_WAIT),
mInputState(NPC_INPUT_NONE),
mNpcId(0),
@@ -92,6 +92,10 @@ NpcDialog::NpcDialog()
// Setup button
mButton = new Button("", "ok", this);
+ //Setup more and less buttons (int input)
+ mPlusButton = new Button(_("+"), "plus", this);
+ mMinusButton = new Button(_("-"), "minus", this);
+
int width = std::max(mButton->getFont()->getWidth(CAPTION_WAITING),
mButton->getFont()->getWidth(CAPTION_NEXT));
width = std::max(width, mButton->getFont()->getWidth(CAPTION_CLOSE));
@@ -139,19 +143,19 @@ void NpcDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok")
{
- if (mActionState == NPC_ACTION_NEXT)
+ if (mActionState == NPC_ACTION_NEXT)
{
nextDialog();
addText("\n> Next\n");
- }
+ }
else if (mActionState == NPC_ACTION_CLOSE)
{
- if (current_npc)
+ if (current_npc)
closeDialog();
setVisible(false);
current_npc = 0;
NPC::isTalking = false;
- }
+ }
else if (mActionState == NPC_ACTION_INPUT)
{
std::string printText = ""; // Text that will get printed in the textbox
@@ -180,7 +184,7 @@ void NpcDialog::action(const gcn::ActionEvent &event)
}
// addText will auto remove the input layout
addText( strprintf("\n> \"%s\"\n", printText.c_str()) );
- }
+ }
}
else if (event.getId() == "reset")
{
@@ -193,6 +197,14 @@ void NpcDialog::action(const gcn::ActionEvent &event)
mIntField->setValue(mDefaultInt);
}
}
+ else if(event.getId() == "plus")
+ {
+ mIntField->setValue(mIntField->getValue() + 1);
+ }
+ else if(event.getId() == "minus")
+ {
+ mIntField->setValue(mIntField->getValue() - 1);
+ }
}
void NpcDialog::nextDialog()
@@ -308,12 +320,14 @@ void NpcDialog::buildLayout()
else if(mInputState == NPC_INPUT_INTEGER)
{
place(0, 0, mScrollArea, 5, 3);
- place(0, 3, mIntField, 3);
+ place(0, 3, mMinusButton, 1);
+ place(1, 3, mIntField, 3);
+ place(4, 3, mPlusButton, 1);
place(0, 4, mResetButton, 2);
place(3, 4, mButton, 2);
}
}
-
+
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index 7741f35c..2adcc9c1 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -163,17 +163,19 @@ class NpcDialog : public Window, public gcn::ActionListener,
ListBox *mItemList;
gcn::ScrollArea *mListScrollArea;
std::vector<std::string> mItems;
-
+
// Used for string and integer input
TextField *mTextField;
IntTextField *mIntField;
+ Button *mPlusButton;
+ Button *mMinusButton;
// Used for the button
Button *mButton;
// Will reset the text and integer input to the provided default
Button *mResetButton;
-
+
enum NPCInputState {
NPC_INPUT_NONE,
NPC_INPUT_LIST,