summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-10-04 23:42:07 +0300
committerAndrei Karas <akaras@inbox.ru>2016-10-04 23:42:07 +0300
commit16be27ddb973b5c2dedb6b5b63083086984c2139 (patch)
tree720747e6cb6e9f61b7e8297252582982a834ad02
parentb3145fb5f1ea419d9b3ee60450866fd199ee1103 (diff)
downloadplus-16be27ddb973b5c2dedb6b5b63083086984c2139.tar.gz
plus-16be27ddb973b5c2dedb6b5b63083086984c2139.tar.bz2
plus-16be27ddb973b5c2dedb6b5b63083086984c2139.tar.xz
plus-16be27ddb973b5c2dedb6b5b63083086984c2139.zip
Move npcinputstate into enums directory.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/enums/gui/npcinputstate.h40
-rw-r--r--src/gui/popups/popupmenu.cpp2
-rw-r--r--src/gui/windows/inventorywindow.cpp2
-rw-r--r--src/gui/windows/npcdialog.cpp118
-rw-r--r--src/gui/windows/npcdialog.h15
7 files changed, 106 insertions, 73 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 048f2c5c2..10306b550 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/npcinputstate.h
gui/widgets/linepart.cpp
gui/widgets/linepart.h
gui/widgets/linkhandler.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 6c36f4f98..1013924cf 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/npcinputstate.h \
gui/widgets/linepart.cpp \
gui/widgets/linepart.h \
gui/widgets/linkhandler.h \
diff --git a/src/enums/gui/npcinputstate.h b/src/enums/gui/npcinputstate.h
new file mode 100644
index 000000000..c75a43bb8
--- /dev/null
+++ b/src/enums/gui/npcinputstate.h
@@ -0,0 +1,40 @@
+/*
+ * 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_NPCINPUTSTATE_H
+#define ENUMS_GUI_NPCINPUTSTATE_H
+
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(NpcInputState)
+{
+ NONE = 0,
+ LIST,
+ STRING,
+ INTEGER,
+ ITEM,
+ ITEM_INDEX,
+ ITEM_CRAFT
+}
+enumEnd(NpcInputState);
+
+#endif // ENUMS_GUI_NPCINPUTSTATE_H
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index fae3c7251..4ae0966da 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1814,7 +1814,7 @@ void PopupMenu::showPopup(Window *const parent,
{
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
if (dialog &&
- dialog->getInputState() == NpcDialog::NPC_INPUT_ITEM_CRAFT)
+ dialog->getInputState() == NpcInputState::ITEM_CRAFT)
{
mBrowserBox->addRow("craftmenu",
// TRANSLATORS: popup menu item
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 40f276c89..05bcda0ae 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -1054,7 +1054,7 @@ void InventoryWindow::moveItemToCraft(const int craftSlot)
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
if (dialog &&
- dialog->getInputState() == NpcDialog::NPC_INPUT_ITEM_CRAFT)
+ dialog->getInputState() == NpcInputState::ITEM_CRAFT)
{
if (item->getQuantity() > 1
&& !inputManager.isActionActive(InputAction::STOP_ATTACK))
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 3ba705152..47bac3b92 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -141,7 +141,7 @@ NpcDialog::NpcDialog(const BeingId npcId) :
mItemScrollArea(new ScrollArea(this, mItemContainer,
fromBool(getOptionBool("showitemsbackground"), Opaque),
"npc_listbackground.xml")),
- mInputState(NPC_INPUT_NONE),
+ mInputState(NpcInputState::NONE),
mActionState(NPC_ACTION_WAIT),
mSkinControls(),
mSkinName(),
@@ -338,7 +338,7 @@ void NpcDialog::action(const ActionEvent &event)
// in the textbox
switch (mInputState)
{
- case NPC_INPUT_LIST:
+ case NpcInputState::LIST:
{
if (mDialogInfo)
return;
@@ -360,7 +360,7 @@ void NpcDialog::action(const ActionEvent &event)
npcHandler->listInput(mNpcId, choice);
break;
}
- case NPC_INPUT_STRING:
+ case NpcInputState::STRING:
{
if (!PacketLimiter::limitPackets(
PacketType::PACKET_NPC_INPUT))
@@ -371,7 +371,7 @@ void NpcDialog::action(const ActionEvent &event)
npcHandler->stringInput(mNpcId, printText);
break;
}
- case NPC_INPUT_INTEGER:
+ case NpcInputState::INTEGER:
{
if (!PacketLimiter::limitPackets(
PacketType::PACKET_NPC_INPUT))
@@ -383,7 +383,7 @@ void NpcDialog::action(const ActionEvent &event)
mNpcId, mIntField->getValue());
break;
}
- case NPC_INPUT_ITEM:
+ case NpcInputState::ITEM:
{
restoreVirtuals();
if (!PacketLimiter::limitPackets(
@@ -431,7 +431,7 @@ void NpcDialog::action(const ActionEvent &event)
mInventory->clear();
break;
}
- case NPC_INPUT_ITEM_INDEX:
+ case NpcInputState::ITEM_INDEX:
{
restoreVirtuals();
if (!PacketLimiter::limitPackets(
@@ -473,7 +473,7 @@ void NpcDialog::action(const ActionEvent &event)
mInventory->clear();
break;
}
- case NPC_INPUT_ITEM_CRAFT:
+ case NpcInputState::ITEM_CRAFT:
{
restoreVirtuals();
if (!PacketLimiter::limitPackets(
@@ -508,13 +508,13 @@ void NpcDialog::action(const ActionEvent &event)
break;
}
- case NPC_INPUT_NONE:
+ case NpcInputState::NONE:
default:
break;
}
- if (mInputState != NPC_INPUT_ITEM &&
- mInputState != NPC_INPUT_ITEM_INDEX &&
- mInputState != NPC_INPUT_ITEM_CRAFT)
+ if (mInputState != NpcInputState::ITEM &&
+ mInputState != NpcInputState::ITEM_INDEX &&
+ mInputState != NpcInputState::ITEM_CRAFT)
{
// addText will auto remove the input layout
addText(strprintf("> \"%s\"", printText.c_str()), false);
@@ -529,21 +529,21 @@ void NpcDialog::action(const ActionEvent &event)
{
switch (mInputState)
{
- case NPC_INPUT_STRING:
+ case NpcInputState::STRING:
mTextField->setText(mDefaultString);
break;
- case NPC_INPUT_INTEGER:
+ case NpcInputState::INTEGER:
mIntField->setValue(mDefaultInt);
break;
- case NPC_INPUT_ITEM:
- case NPC_INPUT_ITEM_INDEX:
+ case NpcInputState::ITEM:
+ case NpcInputState::ITEM_INDEX:
mInventory->clear();
break;
- case NPC_INPUT_ITEM_CRAFT:
+ case NpcInputState::ITEM_CRAFT:
mComplexInventory->clear();
break;
- case NPC_INPUT_NONE:
- case NPC_INPUT_LIST:
+ case NpcInputState::NONE:
+ case NpcInputState::LIST:
default:
break;
}
@@ -560,17 +560,17 @@ void NpcDialog::action(const ActionEvent &event)
{
switch (mInputState)
{
- case NPC_INPUT_ITEM:
- case NPC_INPUT_ITEM_INDEX:
+ case NpcInputState::ITEM:
+ case NpcInputState::ITEM_INDEX:
mInventory->clear();
break;
- case NPC_INPUT_ITEM_CRAFT:
+ case NpcInputState::ITEM_CRAFT:
mComplexInventory->clear();
break;
- case NPC_INPUT_STRING:
- case NPC_INPUT_INTEGER:
- case NPC_INPUT_LIST:
- case NPC_INPUT_NONE:
+ case NpcInputState::STRING:
+ case NpcInputState::INTEGER:
+ case NpcInputState::LIST:
+ case NpcInputState::NONE:
default:
clearRows();
break;
@@ -583,19 +583,19 @@ void NpcDialog::action(const ActionEvent &event)
{
switch (mInputState)
{
- case NPC_INPUT_ITEM:
+ case NpcInputState::ITEM:
npcHandler->stringInput(mNpcId, "0,0");
break;
- case NPC_INPUT_ITEM_INDEX:
+ case NpcInputState::ITEM_INDEX:
npcHandler->stringInput(mNpcId, "-1");
break;
- case NPC_INPUT_ITEM_CRAFT:
+ case NpcInputState::ITEM_CRAFT:
npcHandler->stringInput(mNpcId, "");
break;
- case NPC_INPUT_STRING:
- case NPC_INPUT_INTEGER:
- case NPC_INPUT_NONE:
- case NPC_INPUT_LIST:
+ case NpcInputState::STRING:
+ case NpcInputState::INTEGER:
+ case NpcInputState::NONE:
+ case NpcInputState::LIST:
default:
npcHandler->listInput(mNpcId, 255);
break;
@@ -613,7 +613,7 @@ void NpcDialog::action(const ActionEvent &event)
Inventory *const inventory = PlayerInfo::getInventory();
if (inventory)
{
- if (mInputState == NPC_INPUT_ITEM_CRAFT)
+ if (mInputState == NpcInputState::ITEM_CRAFT)
{
if (mComplexInventory->addVirtualItem(item, -1, 1))
inventory->virtualRemove(item, 1);
@@ -638,9 +638,9 @@ void NpcDialog::action(const ActionEvent &event)
npcHandler->listInput(mNpcId, CAST_U8(cnt + 1));
printText = mItems[cnt];
- if (mInputState != NPC_INPUT_ITEM &&
- mInputState != NPC_INPUT_ITEM_INDEX &&
- mInputState != NPC_INPUT_ITEM_CRAFT)
+ if (mInputState != NpcInputState::ITEM &&
+ mInputState != NpcInputState::ITEM_INDEX &&
+ mInputState != NpcInputState::ITEM_CRAFT)
{
// addText will auto remove the input layout
addText(strprintf("> \"%s\"", printText.c_str()), false);
@@ -689,7 +689,7 @@ void NpcDialog::choiceRequest()
}
mImages.clear();
mActionState = NPC_ACTION_INPUT;
- mInputState = NPC_INPUT_LIST;
+ mInputState = NpcInputState::LIST;
buildLayout();
}
@@ -743,7 +743,7 @@ void NpcDialog::refocus()
void NpcDialog::textRequest(const std::string &defaultText)
{
mActionState = NPC_ACTION_INPUT;
- mInputState = NPC_INPUT_STRING;
+ mInputState = NpcInputState::STRING;
mDefaultString = defaultText;
mTextField->setText(defaultText);
@@ -776,7 +776,7 @@ void NpcDialog::integerRequest(const int defaultValue, const int min,
const int max)
{
mActionState = NPC_ACTION_INPUT;
- mInputState = NPC_INPUT_INTEGER;
+ mInputState = NpcInputState::INTEGER;
mDefaultInt = defaultValue;
mIntField->setRange(min, max);
mIntField->setValue(defaultValue);
@@ -786,7 +786,7 @@ void NpcDialog::integerRequest(const int defaultValue, const int min,
void NpcDialog::itemRequest(const int size)
{
mActionState = NPC_ACTION_INPUT;
- mInputState = NPC_INPUT_ITEM;
+ mInputState = NpcInputState::ITEM;
mInventory->resize(size);
buildLayout();
}
@@ -794,7 +794,7 @@ void NpcDialog::itemRequest(const int size)
void NpcDialog::itemIndexRequest(const int size)
{
mActionState = NPC_ACTION_INPUT;
- mInputState = NPC_INPUT_ITEM_INDEX;
+ mInputState = NpcInputState::ITEM_INDEX;
mInventory->resize(size);
buildLayout();
}
@@ -802,7 +802,7 @@ void NpcDialog::itemIndexRequest(const int size)
void NpcDialog::itemCraftRequest(const int size)
{
mActionState = NPC_ACTION_INPUT;
- mInputState = NPC_INPUT_ITEM_CRAFT;
+ mInputState = NpcInputState::ITEM_CRAFT;
mComplexInventory->resize(size);
buildLayout();
}
@@ -814,17 +814,17 @@ void NpcDialog::move(const int amount)
switch (mInputState)
{
- case NPC_INPUT_INTEGER:
+ case NpcInputState::INTEGER:
mIntField->setValue(mIntField->getValue() + amount);
break;
- case NPC_INPUT_LIST:
+ case NpcInputState::LIST:
mItemList->setSelected(mItemList->getSelected() - amount);
break;
- case NPC_INPUT_NONE:
- case NPC_INPUT_STRING:
- case NPC_INPUT_ITEM:
- case NPC_INPUT_ITEM_INDEX:
- case NPC_INPUT_ITEM_CRAFT:
+ case NpcInputState::NONE:
+ case NpcInputState::STRING:
+ case NpcInputState::ITEM:
+ case NpcInputState::ITEM_INDEX:
+ case NpcInputState::ITEM_CRAFT:
default:
break;
}
@@ -999,7 +999,7 @@ void NpcDialog::placeItemInputControls()
mItemContainer->setMaxColumns(10000);
}
- if (mInputState == NPC_INPUT_ITEM_CRAFT)
+ if (mInputState == NpcInputState::ITEM_CRAFT)
mItemContainer->setInventory(mComplexInventory);
else
mItemContainer->setInventory(mInventory);
@@ -1058,12 +1058,12 @@ void NpcDialog::buildLayout()
mButton->setCaption(CAPTION_CLOSE);
placeNormalControls();
}
- else if (mInputState != NPC_INPUT_NONE)
+ else if (mInputState != NpcInputState::NONE)
{
mButton->setCaption(CAPTION_SUBMIT);
switch (mInputState)
{
- case NPC_INPUT_LIST:
+ case NpcInputState::LIST:
if (!mDialogInfo)
placeMenuControls();
else
@@ -1071,21 +1071,21 @@ void NpcDialog::buildLayout()
mItemList->setSelected(-1);
break;
- case NPC_INPUT_STRING:
+ case NpcInputState::STRING:
placeTextInputControls();
break;
- case NPC_INPUT_INTEGER:
+ case NpcInputState::INTEGER:
placeIntInputControls();
break;
- case NPC_INPUT_ITEM:
- case NPC_INPUT_ITEM_INDEX:
- case NPC_INPUT_ITEM_CRAFT:
+ case NpcInputState::ITEM:
+ case NpcInputState::ITEM_INDEX:
+ case NpcInputState::ITEM_CRAFT:
placeItemInputControls();
break;
- case NPC_INPUT_NONE:
+ case NpcInputState::NONE:
default:
break;
}
@@ -1377,7 +1377,7 @@ void NpcDialog::addCraftItem(Item *const item,
const int amount,
const int slot)
{
- if (mInputState != NPC_INPUT_ITEM_CRAFT)
+ if (mInputState != NpcInputState::ITEM_CRAFT)
return;
Inventory *const inventory = PlayerInfo::getInventory();
diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h
index 1b34eebf4..9a905e2f6 100644
--- a/src/gui/windows/npcdialog.h
+++ b/src/gui/windows/npcdialog.h
@@ -26,6 +26,8 @@
#include "enums/simpletypes/beingid.h"
#include "enums/simpletypes/beingtypeid.h"
+#include "enums/gui/npcinputstate.h"
+
#include "gui/models/extendedlistmodel.h"
#include "gui/widgets/window.h"
@@ -77,17 +79,6 @@ class NpcDialog final : public Window,
void postInit() override final;
- enum NpcInputState
- {
- NPC_INPUT_NONE = 0,
- NPC_INPUT_LIST,
- NPC_INPUT_STRING,
- NPC_INPUT_INTEGER,
- NPC_INPUT_ITEM,
- NPC_INPUT_ITEM_INDEX,
- NPC_INPUT_ITEM_CRAFT
- };
-
enum NpcActionState
{
NPC_ACTION_WAIT = 0,
@@ -323,7 +314,7 @@ class NpcDialog final : public Window,
ScrollArea *mItemScrollArea A_NONNULLPOINTER;
- NpcInputState mInputState;
+ NpcInputStateT mInputState;
NpcActionState mActionState;
std::vector<Widget*> mSkinControls;
std::string mSkinName;