diff options
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/enums/gui/npcactionstate.h | 37 | ||||
-rw-r--r-- | src/gui/windows/npcdialog.cpp | 40 | ||||
-rw-r--r-- | src/gui/windows/npcdialog.h | 13 |
5 files changed, 62 insertions, 30 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 10306b550..d02f7d049 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -218,6 +218,7 @@ SET(SRCS gui/widgets/layouthelper.cpp gui/widgets/layouthelper.h enums/gui/layouttype.h + enums/gui/npcactionstate.h enums/gui/npcinputstate.h gui/widgets/linepart.cpp gui/widgets/linepart.h diff --git a/src/Makefile.am b/src/Makefile.am index 1013924cf..ac3eb779f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -243,6 +243,7 @@ SRC += events/actionevent.h \ gui/widgets/layouthelper.cpp \ gui/widgets/layouthelper.h \ enums/gui/layouttype.h \ + enums/gui/npcactionstate.h \ enums/gui/npcinputstate.h \ gui/widgets/linepart.cpp \ gui/widgets/linepart.h \ diff --git a/src/enums/gui/npcactionstate.h b/src/enums/gui/npcactionstate.h new file mode 100644 index 000000000..de6398e99 --- /dev/null +++ b/src/enums/gui/npcactionstate.h @@ -0,0 +1,37 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2016 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef ENUMS_GUI_NPCACTIONSTATE_H +#define ENUMS_GUI_NPCACTIONSTATE_H + +#include "enums/simpletypes/enumdefines.h" + +enumStart(NpcActionState) +{ + WAIT = 0, + NEXT, + INPUT, + CLOSE +} +enumEnd(NpcActionState); + +#endif // ENUMS_GUI_NPCACTIONSTATE_H diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 47bac3b92..38dbb8b92 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -142,7 +142,7 @@ NpcDialog::NpcDialog(const BeingId npcId) : fromBool(getOptionBool("showitemsbackground"), Opaque), "npc_listbackground.xml")), mInputState(NpcInputState::NONE), - mActionState(NPC_ACTION_WAIT), + mActionState(NpcActionState::WAIT), mSkinControls(), mSkinName(), mPlayerBox(new PlayerBox(nullptr)), @@ -296,19 +296,19 @@ void NpcDialog::addText(const std::string &text, const bool save) mTextBox->addRow(text); } mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); - mActionState = NPC_ACTION_WAIT; + mActionState = NpcActionState::WAIT; buildLayout(); } void NpcDialog::showNextButton() { - mActionState = NPC_ACTION_NEXT; + mActionState = NpcActionState::NEXT; buildLayout(); } void NpcDialog::showCloseButton() { - mActionState = NPC_ACTION_CLOSE; + mActionState = NpcActionState::CLOSE; buildLayout(); } @@ -317,7 +317,7 @@ void NpcDialog::action(const ActionEvent &event) const std::string &eventId = event.getId(); if (eventId == "ok") { - if (mActionState == NPC_ACTION_NEXT) + if (mActionState == NpcActionState::NEXT) { if (!PacketLimiter::limitPackets(PacketType::PACKET_NPC_NEXT)) return; @@ -325,14 +325,14 @@ void NpcDialog::action(const ActionEvent &event) nextDialog(); addText(std::string(), false); } - else if (mActionState == NPC_ACTION_CLOSE - || mActionState == NPC_ACTION_WAIT) + else if (mActionState == NpcActionState::CLOSE + || mActionState == NpcActionState::WAIT) { if (cutInWindow) cutInWindow->hide(); closeDialog(); } - else if (mActionState == NPC_ACTION_INPUT) + else if (mActionState == NpcActionState::INPUT) { std::string printText; // Text that will get printed // in the textbox @@ -579,7 +579,7 @@ void NpcDialog::action(const ActionEvent &event) else if (eventId == "close") { restoreVirtuals(); - if (mActionState == NPC_ACTION_INPUT) + if (mActionState == NpcActionState::INPUT) { switch (mInputState) { @@ -688,7 +688,7 @@ void NpcDialog::choiceRequest() (*it)->decRef(); } mImages.clear(); - mActionState = NPC_ACTION_INPUT; + mActionState = NpcActionState::INPUT; mInputState = NpcInputState::LIST; buildLayout(); } @@ -742,7 +742,7 @@ void NpcDialog::refocus() void NpcDialog::textRequest(const std::string &defaultText) { - mActionState = NPC_ACTION_INPUT; + mActionState = NpcActionState::INPUT; mInputState = NpcInputState::STRING; mDefaultString = defaultText; mTextField->setText(defaultText); @@ -775,7 +775,7 @@ bool NpcDialog::isAnyInputFocused() void NpcDialog::integerRequest(const int defaultValue, const int min, const int max) { - mActionState = NPC_ACTION_INPUT; + mActionState = NpcActionState::INPUT; mInputState = NpcInputState::INTEGER; mDefaultInt = defaultValue; mIntField->setRange(min, max); @@ -785,7 +785,7 @@ void NpcDialog::integerRequest(const int defaultValue, const int min, void NpcDialog::itemRequest(const int size) { - mActionState = NPC_ACTION_INPUT; + mActionState = NpcActionState::INPUT; mInputState = NpcInputState::ITEM; mInventory->resize(size); buildLayout(); @@ -793,7 +793,7 @@ void NpcDialog::itemRequest(const int size) void NpcDialog::itemIndexRequest(const int size) { - mActionState = NPC_ACTION_INPUT; + mActionState = NpcActionState::INPUT; mInputState = NpcInputState::ITEM_INDEX; mInventory->resize(size); buildLayout(); @@ -801,7 +801,7 @@ void NpcDialog::itemIndexRequest(const int size) void NpcDialog::itemCraftRequest(const int size) { - mActionState = NPC_ACTION_INPUT; + mActionState = NpcActionState::INPUT; mInputState = NpcInputState::ITEM_CRAFT; mComplexInventory->resize(size); buildLayout(); @@ -809,7 +809,7 @@ void NpcDialog::itemCraftRequest(const int size) void NpcDialog::move(const int amount) { - if (mActionState != NPC_ACTION_INPUT) + if (mActionState != NpcActionState::INPUT) return; switch (mInputState) @@ -1048,13 +1048,13 @@ void NpcDialog::buildLayout() { clearLayout(); - if (mActionState != NPC_ACTION_INPUT) + if (mActionState != NpcActionState::INPUT) { - if (mActionState == NPC_ACTION_WAIT) + if (mActionState == NpcActionState::WAIT) mButton->setCaption(CAPTION_WAITING); - else if (mActionState == NPC_ACTION_NEXT) + else if (mActionState == NpcActionState::NEXT) mButton->setCaption(CAPTION_NEXT); - else if (mActionState == NPC_ACTION_CLOSE) + else if (mActionState == NpcActionState::CLOSE) mButton->setCaption(CAPTION_CLOSE); placeNormalControls(); } diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index 9a905e2f6..429cf95c7 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -26,6 +26,7 @@ #include "enums/simpletypes/beingid.h" #include "enums/simpletypes/beingtypeid.h" +#include "enums/gui/npcactionstate.h" #include "enums/gui/npcinputstate.h" #include "gui/models/extendedlistmodel.h" @@ -79,14 +80,6 @@ class NpcDialog final : public Window, void postInit() override final; - enum NpcActionState - { - NPC_ACTION_WAIT = 0, - NPC_ACTION_NEXT, - NPC_ACTION_INPUT, - NPC_ACTION_CLOSE - }; - /** * Called when receiving actions from the widgets. */ @@ -230,7 +223,7 @@ class NpcDialog final : public Window, void mousePressed(MouseEvent &event) override final; int isCloseState() const - { return mActionState == NPC_ACTION_CLOSE; } + { return mActionState == NpcActionState::CLOSE; } void setSkin(const std::string &skin); @@ -315,7 +308,7 @@ class NpcDialog final : public Window, NpcInputStateT mInputState; - NpcActionState mActionState; + NpcActionStateT mActionState; std::vector<Widget*> mSkinControls; std::string mSkinName; PlayerBox *mPlayerBox A_NONNULLPOINTER; |