summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-16 16:18:29 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-16 16:18:29 +0300
commitc94a736ddcf5299b6eacb9cfd5c09c6266dd78aa (patch)
tree356f87aac5b794fa4e0903a15ec83f55f52f7b00 /src
parente811e48760c7f9a22615f40a0b025d34b9f12eb0 (diff)
downloadmanaverse-c94a736ddcf5299b6eacb9cfd5c09c6266dd78aa.tar.gz
manaverse-c94a736ddcf5299b6eacb9cfd5c09c6266dd78aa.tar.bz2
manaverse-c94a736ddcf5299b6eacb9cfd5c09c6266dd78aa.tar.xz
manaverse-c94a736ddcf5299b6eacb9cfd5c09c6266dd78aa.zip
Move itemamountwindowusage enum into separate file.
Also convert it to strong typed enum.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/actions/actions.cpp10
-rw-r--r--src/gui/widgets/itemcontainer.cpp3
-rw-r--r--src/gui/windows/inventorywindow.cpp37
-rw-r--r--src/gui/windows/itemamountwindow.cpp74
-rw-r--r--src/gui/windows/itemamountwindow.h29
-rw-r--r--src/gui/windows/maileditwindow.cpp2
-rw-r--r--src/gui/windows/shopwindow.cpp13
-rw-r--r--src/gui/windows/tradewindow.cpp3
10 files changed, 88 insertions, 85 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 27adf202c..55d64075c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1253,6 +1253,7 @@ SET(SRCS
gui/colorpair.h
enums/gui/dialogtype.h
enums/gui/gradienttype.h
+ enums/gui/itemamountwindowusage.h
enums/gui/progresscolorid.h
enums/gui/serverdialogdonwloadstatus.h
enums/gui/themecolorid.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 0d15388a6..24c8de57b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -107,6 +107,7 @@ SRC += events/actionevent.h \
gui/color.h \
enums/gui/dialogtype.h \
enums/gui/gradienttype.h \
+ enums/gui/itemamountwindowusage.h \
enums/gui/progresscolorid.h \
enums/gui/serverdialogdonwloadstatus.h \
enums/gui/themecolorid.h \
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index a51dab201..1f7df9c9d 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -462,7 +462,7 @@ impHandler(dropItemId)
if (item && !PlayerInfo::isItemProtected(item->getId()))
{
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemDrop,
inventoryWindow, item);
}
return true;
@@ -473,7 +473,7 @@ impHandler(dropItemInv)
Item *const item = getItemByInvIndex(event, InventoryType::Inventory);
if (item && !PlayerInfo::isItemProtected(item->getId()))
{
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemDrop,
inventoryWindow, item);
}
return true;
@@ -1590,7 +1590,7 @@ impHandler(invToStorage)
}
else
{
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreAdd,
inventoryWindow, item);
}
return true;
@@ -1611,7 +1611,7 @@ impHandler(tradeAdd)
}
else
{
- ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::TradeAdd,
tradeWindow, item);
}
return true;
@@ -1633,7 +1633,7 @@ impHandler(storageToInv)
}
else
{
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreRemove,
storageWindow, item);
}
return true;
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index f7f7ceb96..afdf91e79 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -878,7 +878,8 @@ void ItemContainer::mouseReleased(MouseEvent &event)
if (item->getQuantity() > 1
&& !inputManager.isActionActive(InputAction::STOP_ATTACK))
{
- ItemAmountWindow::showWindow(ItemAmountWindow::CraftAdd,
+ ItemAmountWindow::showWindow(
+ ItemAmountWindowUsage::CraftAdd,
npcHandler->getCurrentNpcDialog(),
item,
0,
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index db256b4a1..be38f70ac 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -441,13 +441,13 @@ void InventoryWindow::action(const ActionEvent &event)
if (storageWindow)
{
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreAdd,
this, item);
}
#ifdef EATHENA_SUPPORT
else if (cartWindow && cartWindow->isWindowVisible())
{
- ItemAmountWindow::showWindow(ItemAmountWindow::CartAdd,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::CartAdd,
this, item);
}
#endif
@@ -512,27 +512,28 @@ void InventoryWindow::action(const ActionEvent &event)
}
else
{
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemDrop,
this, item);
}
}
}
else if (eventId == "split")
{
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemSplit,
+ this, item,
(item->getQuantity() - 1));
}
else if (eventId == "retrieve")
{
if (storageWindow)
{
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreRemove,
this, item);
}
#ifdef EATHENA_SUPPORT
else if (cartWindow && cartWindow->isWindowVisible())
{
- ItemAmountWindow::showWindow(ItemAmountWindow::CartRemove,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::CartRemove,
this, item);
}
#endif
@@ -615,7 +616,8 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
{
if (event.getButton() == MouseButton::RIGHT)
{
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
+ ItemAmountWindow::showWindow(
+ ItemAmountWindowUsage::StoreAdd,
inventoryWindow,
item);
}
@@ -631,8 +633,10 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
{
if (event.getButton() == MouseButton::RIGHT)
{
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
- inventoryWindow, item);
+ ItemAmountWindow::showWindow(
+ ItemAmountWindowUsage::StoreRemove,
+ inventoryWindow,
+ item);
}
else
{
@@ -649,7 +653,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
return;
if (event.getButton() == MouseButton::RIGHT)
{
- ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::TradeAdd,
tradeWindow, item);
}
else
@@ -664,14 +668,16 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
{
if (isStorageActive())
{
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
+ ItemAmountWindow::showWindow(
+ ItemAmountWindowUsage::StoreAdd,
inventoryWindow, item);
}
else if (tradeWindow && tradeWindow->isWindowVisible())
{
if (PlayerInfo::isItemProtected(item->getId()))
return;
- ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd,
+ ItemAmountWindow::showWindow(
+ ItemAmountWindowUsage::TradeAdd,
tradeWindow, item);
}
else
@@ -683,7 +689,8 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
{
if (isStorageActive())
{
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
+ ItemAmountWindow::showWindow(
+ ItemAmountWindowUsage::StoreRemove,
inventoryWindow, item);
}
}
@@ -754,7 +761,7 @@ void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED)
if (mSplit && item && inventoryHandler->
canSplit(mItems->getSelectedItem()))
{
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemSplit,
this, item, item->getQuantity() - 1);
}
updateButtons(item);
@@ -1085,7 +1092,7 @@ void InventoryWindow::moveItemToCraft(const int craftSlot)
if (item->getQuantity() > 1
&& !inputManager.isActionActive(InputAction::STOP_ATTACK))
{
- ItemAmountWindow::showWindow(ItemAmountWindow::CraftAdd,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::CraftAdd,
npcHandler->getCurrentNpcDialog(),
item,
0,
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index 70a69d0ed..b36e8ab7b 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -64,52 +64,52 @@
void ItemAmountWindow::finish(Item *const item,
const int amount,
const int price,
- const Usage usage)
+ const ItemAmountWindowUsageT usage)
{
if (!item)
return;
switch (usage)
{
- case TradeAdd:
+ case ItemAmountWindowUsage::TradeAdd:
if (tradeWindow)
tradeWindow->tradeItem(item, amount);
break;
- case ItemDrop:
+ case ItemAmountWindowUsage::ItemDrop:
PlayerInfo::dropItem(item, amount, Sfx_true);
break;
- case ItemSplit:
+ case ItemAmountWindowUsage::ItemSplit:
inventoryHandler->splitItem(item, amount);
break;
- case StoreAdd:
+ case ItemAmountWindowUsage::StoreAdd:
inventoryHandler->moveItem2(InventoryType::Inventory,
item->getInvIndex(), amount, InventoryType::Storage);
break;
- case StoreRemove:
+ case ItemAmountWindowUsage::StoreRemove:
inventoryHandler->moveItem2(InventoryType::Storage,
item->getInvIndex(), amount, InventoryType::Inventory);
break;
- case ShopBuyAdd:
+ case ItemAmountWindowUsage::ShopBuyAdd:
if (shopWindow)
shopWindow->addBuyItem(item, amount, price);
break;
- case ShopSellAdd:
+ case ItemAmountWindowUsage::ShopSellAdd:
if (shopWindow)
shopWindow->addSellItem(item, amount, price);
break;
#ifdef EATHENA_SUPPORT
- case CartAdd:
+ case ItemAmountWindowUsage::CartAdd:
inventoryHandler->moveItem2(InventoryType::Inventory,
item->getInvIndex(), amount, InventoryType::Cart);
break;
- case CartRemove:
+ case ItemAmountWindowUsage::CartRemove:
inventoryHandler->moveItem2(InventoryType::Cart,
item->getInvIndex(), amount, InventoryType::Inventory);
break;
- case MailAdd:
+ case ItemAmountWindowUsage::MailAdd:
if (mailEditWindow)
mailEditWindow->addItem(item, amount);
break;
- case CraftAdd:
+ case ItemAmountWindowUsage::CraftAdd:
{
NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
if (dialog)
@@ -121,7 +121,7 @@ void ItemAmountWindow::finish(Item *const item,
}
}
-ItemAmountWindow::ItemAmountWindow(const Usage usage,
+ItemAmountWindow::ItemAmountWindow(const ItemAmountWindowUsageT usage,
Window *const parent,
Item *const item,
const int maxRange) :
@@ -145,7 +145,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage,
if (!mItem)
return;
- if (usage == ShopBuyAdd)
+ if (usage == ItemAmountWindowUsage::ShopBuyAdd)
mMax = 10000;
else if (!mMax)
mMax = mItem->getQuantity();
@@ -160,7 +160,8 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage,
mItemAmountSlide->setActionEventId("slide");
mItemAmountSlide->addActionListener(this);
- if (mUsage == ShopBuyAdd || mUsage == ShopSellAdd)
+ if (mUsage == ItemAmountWindowUsage::ShopBuyAdd ||
+ mUsage == ItemAmountWindowUsage::ShopSellAdd)
{
mItemPriceTextField = new IntTextField(this, 1);
mItemPriceTextField->setRange(1, 10000000);
@@ -175,7 +176,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage,
mGPLabel = new Label(this, " GP");
}
- if (mUsage == ShopBuyAdd)
+ if (mUsage == ItemAmountWindowUsage::ShopBuyAdd)
{
mItemsModal = new ItemsModal;
mItemDropDown = new DropDown(this, mItemsModal);
@@ -202,7 +203,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage,
ContainerPlacer placer;
placer = getPlacer(0, 0);
int n = 0;
- if (mUsage == ShopBuyAdd)
+ if (mUsage == ItemAmountWindowUsage::ShopBuyAdd)
{
placer(0, n, mItemDropDown, 8);
n++;
@@ -215,7 +216,8 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage,
placer(0, n, mItemIcon, 1, 3);
placer(1, n + 1, mItemAmountSlide, 7);
- if (mUsage == ShopBuyAdd || mUsage == ShopSellAdd)
+ if (mUsage == ItemAmountWindowUsage::ShopBuyAdd ||
+ mUsage == ItemAmountWindowUsage::ShopSellAdd)
{
Button *const minusPriceButton = new Button(
// TRANSLATORS: item amount window button
@@ -247,49 +249,49 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage,
switch (usage)
{
- case TradeAdd:
+ case ItemAmountWindowUsage::TradeAdd:
// TRANSLATORS: amount window message
setCaption(_("Select amount of items to trade."));
break;
- case ItemDrop:
+ case ItemAmountWindowUsage::ItemDrop:
// TRANSLATORS: amount window message
setCaption(_("Select amount of items to drop."));
break;
- case StoreAdd:
+ case ItemAmountWindowUsage::StoreAdd:
// TRANSLATORS: amount window message
setCaption(_("Select amount of items to store."));
break;
#ifdef EATHENA_SUPPORT
- case MailAdd:
+ case ItemAmountWindowUsage::MailAdd:
// TRANSLATORS: amount window message
setCaption(_("Select amount of items to send."));
break;
- case CraftAdd:
+ case ItemAmountWindowUsage::CraftAdd:
// TRANSLATORS: amount window message
setCaption(_("Select amount of items to craft."));
break;
#endif
- case CartAdd:
+ case ItemAmountWindowUsage::CartAdd:
// TRANSLATORS: amount window message
setCaption(_("Select amount of items to store to cart."));
break;
- case StoreRemove:
+ case ItemAmountWindowUsage::StoreRemove:
// TRANSLATORS: amount window message
setCaption(_("Select amount of items to retrieve."));
break;
- case CartRemove:
+ case ItemAmountWindowUsage::CartRemove:
// TRANSLATORS: amount window message
setCaption(_("Select amount of items to retrieve from cart."));
break;
- case ItemSplit:
+ case ItemAmountWindowUsage::ItemSplit:
// TRANSLATORS: amount window message
setCaption(_("Select amount of items to split."));
break;
- case ShopBuyAdd:
+ case ItemAmountWindowUsage::ShopBuyAdd:
// TRANSLATORS: amount window message
setCaption(_("Add to buy shop."));
break;
- case ShopSellAdd:
+ case ItemAmountWindowUsage::ShopSellAdd:
// TRANSLATORS: amount window message
setCaption(_("Add to sell shop."));
break;
@@ -361,7 +363,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
else
{
#ifdef EATHENA_SUPPORT
- if (mUsage == CraftAdd)
+ if (mUsage == ItemAmountWindowUsage::CraftAdd)
{
finish(mItem,
mItemAmountTextField->getValue(),
@@ -399,7 +401,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
Equipm_false,
Equipped_false);
- if (mUsage == ShopBuyAdd)
+ if (mUsage == ItemAmountWindowUsage::ShopBuyAdd)
mMax = 10000;
else if (!mMax)
mMax = mItem->getQuantity();
@@ -467,7 +469,7 @@ void ItemAmountWindow::keyReleased(KeyEvent &event A_UNUSED)
mItemAmountSlide->setValue(mItemAmountTextField->getValue());
}
-void ItemAmountWindow::showWindow(const Usage usage,
+void ItemAmountWindow::showWindow(const ItemAmountWindowUsageT usage,
Window *const parent,
Item *const item,
int maxRange,
@@ -479,10 +481,12 @@ void ItemAmountWindow::showWindow(const Usage usage,
if (!maxRange)
maxRange = item->getQuantity();
- if (usage != ShopBuyAdd && usage != ShopSellAdd && maxRange <= 1)
+ if (usage != ItemAmountWindowUsage::ShopBuyAdd &&
+ usage != ItemAmountWindowUsage::ShopSellAdd &&
+ maxRange <= 1)
{
#ifdef EATHENA_SUPPORT
- if (usage == CraftAdd)
+ if (usage == ItemAmountWindowUsage::CraftAdd)
finish(item, maxRange, tag, usage);
else
#endif
@@ -493,7 +497,7 @@ void ItemAmountWindow::showWindow(const Usage usage,
#ifdef EATHENA_SUPPORT
ItemAmountWindow *const window = CREATEWIDGETR(ItemAmountWindow,
usage, parent, item, maxRange);
- if (usage == CraftAdd)
+ if (usage == ItemAmountWindowUsage::CraftAdd)
window->mPrice = tag;
#else
CREATEWIDGET(ItemAmountWindow,
diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h
index c072b39c7..c9cbd4227 100644
--- a/src/gui/windows/itemamountwindow.h
+++ b/src/gui/windows/itemamountwindow.h
@@ -25,6 +25,8 @@
#include "gui/widgets/window.h"
+#include "enums/gui/itemamountwindowusage.h"
+
#include "listeners/actionlistener.h"
#include "listeners/keylistener.h"
@@ -46,25 +48,6 @@ class ItemAmountWindow final : public Window,
public KeyListener
{
public:
- enum Usage
- {
- TradeAdd = 0,
- ItemDrop,
- StoreAdd,
- StoreRemove,
- CartAdd,
- CartRemove,
- ItemSplit,
- ShopBuyAdd,
-#ifdef EATHENA_SUPPORT
- ShopSellAdd,
- CraftAdd,
- MailAdd
-#else
- ShopSellAdd
-#endif
- };
-
A_DELETE_COPY(ItemAmountWindow)
void postInit() override final;
@@ -94,7 +77,7 @@ class ItemAmountWindow final : public Window,
/**
* Creates the dialog, or bypass it if there aren't enough items.
*/
- static void showWindow(const Usage usage,
+ static void showWindow(const ItemAmountWindowUsageT usage,
Window *const parent,
Item *const item,
int maxRange = 0,
@@ -106,9 +89,9 @@ class ItemAmountWindow final : public Window,
static void finish(Item *const item,
const int amount,
const int price,
- const Usage usage);
+ const ItemAmountWindowUsageT usage);
- ItemAmountWindow(const Usage usage,
+ ItemAmountWindow(const ItemAmountWindowUsageT usage,
Window *const parent,
Item *const item,
const int maxRange = 0);
@@ -131,7 +114,7 @@ class ItemAmountWindow final : public Window,
int mPrice;
int mMax;
- Usage mUsage;
+ ItemAmountWindowUsageT mUsage;
bool mEnabledKeyboard;
};
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index 3416b6960..d0e5e2f31 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -166,7 +166,7 @@ void MailEditWindow::action(const ActionEvent &event)
if (!item)
return;
- ItemAmountWindow::showWindow(ItemAmountWindow::MailAdd,
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::MailAdd,
this, item);
}
}
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index eb07c90dc..6b7994854 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -400,13 +400,18 @@ void ShopWindow::action(const ActionEvent &event)
{
if (isBuySelected)
{
- ItemAmountWindow::showWindow(ItemAmountWindow::ShopBuyAdd,
- this, item, sumAmount(item));
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::ShopBuyAdd,
+ this,
+ item,
+ sumAmount(item));
}
else
{
- ItemAmountWindow::showWindow(ItemAmountWindow::ShopSellAdd,
- this, item, sumAmount(item));
+ ItemAmountWindow::showWindow(
+ ItemAmountWindowUsage::ShopSellAdd,
+ this,
+ item,
+ sumAmount(item));
}
}
}
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index e251b0bd9..6cf601b38 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -395,7 +395,8 @@ void TradeWindow::action(const ActionEvent &event)
return;
// Choose amount of items to trade
- ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd, this, item);
+ ItemAmountWindow::showWindow(ItemAmountWindowUsage::TradeAdd,
+ this, item);
setStatus(PREPARING);
}