From c32bbeb3674cef43df33bd1f7a249e95868b7ded Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 18 Jul 2012 13:05:27 +0300 Subject: Add close button to npc dialog in menu selection. --- src/gui/npcdialog.cpp | 13 +++++++++++++ src/gui/npcdialog.h | 2 ++ 2 files changed, 15 insertions(+) (limited to 'src/gui') diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index ebcd02e7e..71a884d88 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -129,6 +129,7 @@ NpcDialog::NpcDialog(int npcId) : // Setup button mButton = new Button("", "ok", this); + mButton2 = new Button(_("Close"), "close", this); //Setup more and less buttons (int input) mPlusButton = new Button(_("+"), "inc", this); @@ -175,6 +176,8 @@ NpcDialog::~NpcDialog() mClearButton = nullptr; delete mButton; mButton = nullptr; + delete mButton2; + mButton2 = nullptr; // These might not actually be in the layout, so lets be safe delete mScrollArea; @@ -321,6 +324,14 @@ void NpcDialog::action(const gcn::ActionEvent &event) // mTextBox->addRow(mNewText); // setText(mNewText); } + else if (event.getId() == "close") + { + if (mActionState == NPC_ACTION_INPUT) + { + Net::getNpcHandler()->listInput(mNpcId, 255); + closeDialog(); + } + } } void NpcDialog::nextDialog() @@ -507,6 +518,7 @@ void NpcDialog::placeMenuControls() place(0, 0, mPlayerBox); place(1, 0, mScrollArea, 6, 3); place(0, 3, mListScrollArea, 7, 3); + place(1, 6, mButton2, 2); place(3, 6, mClearButton, 2); place(5, 6, mButton, 2); } @@ -514,6 +526,7 @@ void NpcDialog::placeMenuControls() { place(0, 0, mScrollArea, 6, 3); place(0, 3, mListScrollArea, 6, 3); + place(0, 6, mButton2, 2); place(2, 6, mClearButton, 2); place(4, 6, mButton, 2); } diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 68ee17e33..75c55ae96 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -238,6 +238,8 @@ class NpcDialog : public Window, public gcn::ActionListener, // Used for the button Button *mButton; + Button *mButton2; + // Will reset the text and integer input to the provided default Button *mResetButton; -- cgit v1.2.3-70-g09d2