summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-16 22:17:15 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-16 22:17:15 +0300
commit5e8e53f6e795a84ab5ca6cfe0d08672878044707 (patch)
tree23f5a196c6a288ef52cea2742b02ddbc52b2db61 /src/gui
parent0c063cf5b45a843485fe3343e5fb79a40141f88c (diff)
downloadplus-5e8e53f6e795a84ab5ca6cfe0d08672878044707.tar.gz
plus-5e8e53f6e795a84ab5ca6cfe0d08672878044707.tar.bz2
plus-5e8e53f6e795a84ab5ca6cfe0d08672878044707.tar.xz
plus-5e8e53f6e795a84ab5ca6cfe0d08672878044707.zip
Convert InventoryType enum into strong typed.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/popups/popupmenu.cpp18
-rw-r--r--src/gui/popups/popupmenu.h2
-rw-r--r--src/gui/widgets/itemcontainer.cpp65
-rw-r--r--src/gui/windows/equipmentwindow.cpp2
-rw-r--r--src/gui/windows/inventorywindow.cpp117
-rw-r--r--src/gui/windows/itemamountwindow.cpp16
-rw-r--r--src/gui/windows/maileditwindow.cpp2
-rw-r--r--src/gui/windows/ministatuswindow.cpp2
-rw-r--r--src/gui/windows/npcdialog.cpp2
-rw-r--r--src/gui/windows/tradewindow.cpp4
10 files changed, 119 insertions, 111 deletions
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index e18906052..f55d8cb22 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1625,7 +1625,7 @@ void PopupMenu::handleLink(const std::string &link,
void PopupMenu::showPopup(Window *const parent,
const int x, const int y,
Item *const item,
- const InventoryType::Type type)
+ const InventoryTypeT type)
{
if (!item)
return;
@@ -1644,7 +1644,7 @@ void PopupMenu::showPopup(Window *const parent,
switch (type)
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
if (tradeWindow && tradeWindow->isWindowVisible() && !isProtected)
{
// TRANSLATORS: popup menu item
@@ -1706,7 +1706,7 @@ void PopupMenu::showPopup(Window *const parent,
addUseDrop(item, isProtected);
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
// TRANSLATORS: popup menu item
// TRANSLATORS: get item from storage
mBrowserBox->addRow("/storagetoinv 'INVINDEX'", _("Retrieve"));
@@ -1734,14 +1734,14 @@ void PopupMenu::showPopup(Window *const parent,
}
break;
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Cart:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
default:
break;
}
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index e8e0ddeb4..d37a29f56 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -96,7 +96,7 @@ class PopupMenu final : public Popup, public LinkHandler
void showPopup(Window *const parent,
const int x, const int y,
Item *const item,
- const InventoryType::Type type);
+ const InventoryTypeT type);
void showPopup(const int x, const int y, Button *const button);
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index ac65a024f..108dc8638 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -578,31 +578,31 @@ void ItemContainer::mousePressed(MouseEvent &event)
DragDropSource src = DragDropSource::Empty;
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
src = DragDropSource::Inventory;
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
src = DragDropSource::Storage;
break;
- case InventoryType::TRADE:
+ case InventoryType::Trade:
src = DragDropSource::Trade;
break;
- case InventoryType::NPC:
+ case InventoryType::Npc:
src = DragDropSource::Npc;
break;
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
src = DragDropSource::Cart;
break;
- case InventoryType::MAIL:
+ case InventoryType::Mail:
src = DragDropSource::Mail;
break;
#endif
default:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
+ case InventoryType::Vending:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
break;
}
if (mSelectedIndex == index && mClicks != 2)
@@ -685,57 +685,57 @@ void ItemContainer::mouseReleased(MouseEvent &event)
DragDropSource dst = DragDropSource::Empty;
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
dst = DragDropSource::Inventory;
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
dst = DragDropSource::Storage;
break;
- case InventoryType::TRADE:
+ case InventoryType::Trade:
dst = DragDropSource::Trade;
break;
- case InventoryType::NPC:
+ case InventoryType::Npc:
dst = DragDropSource::Npc;
break;
#ifdef EATHENA_SUPPORT
- case InventoryType::MAIL:
+ case InventoryType::Mail:
dst = DragDropSource::Mail;
break;
- case InventoryType::CART:
+ case InventoryType::Cart:
dst = DragDropSource::Cart;
break;
#endif
default:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
+ case InventoryType::Vending:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
break;
}
- int srcContainer = -1;
- int dstContainer = -1;
+ InventoryTypeT srcContainer = InventoryType::TypeEnd;
+ InventoryTypeT dstContainer = InventoryType::TypeEnd;
bool checkProtection(false);
Inventory *inventory = nullptr;
if (src == DragDropSource::Inventory
&& dst == DragDropSource::Storage)
{
- srcContainer = InventoryType::INVENTORY;
- dstContainer = InventoryType::STORAGE;
+ srcContainer = InventoryType::Inventory;
+ dstContainer = InventoryType::Storage;
inventory = PlayerInfo::getInventory();
}
else if (src == DragDropSource::Storage
&& dst == DragDropSource::Inventory)
{
- srcContainer = InventoryType::STORAGE;
- dstContainer = InventoryType::INVENTORY;
+ srcContainer = InventoryType::Storage;
+ dstContainer = InventoryType::Inventory;
inventory = PlayerInfo::getStorageInventory();
}
#ifdef EATHENA_SUPPORT
if (src == DragDropSource::Inventory
&& dst == DragDropSource::Cart)
{
- srcContainer = InventoryType::INVENTORY;
- dstContainer = InventoryType::CART;
+ srcContainer = InventoryType::Inventory;
+ dstContainer = InventoryType::Cart;
inventory = PlayerInfo::getInventory();
}
if (src == DragDropSource::Inventory
@@ -753,22 +753,22 @@ void ItemContainer::mouseReleased(MouseEvent &event)
else if (src == DragDropSource::Cart
&& dst == DragDropSource::Inventory)
{
- srcContainer = InventoryType::CART;
- dstContainer = InventoryType::INVENTORY;
+ srcContainer = InventoryType::Cart;
+ dstContainer = InventoryType::Inventory;
inventory = PlayerInfo::getCartInventory();
}
else if (src == DragDropSource::Cart
&& dst == DragDropSource::Storage)
{
- srcContainer = InventoryType::CART;
- dstContainer = InventoryType::STORAGE;
+ srcContainer = InventoryType::Cart;
+ dstContainer = InventoryType::Storage;
inventory = PlayerInfo::getCartInventory();
}
else if (src == DragDropSource::Storage
&& dst == DragDropSource::Cart)
{
- srcContainer = InventoryType::STORAGE;
- dstContainer = InventoryType::CART;
+ srcContainer = InventoryType::Storage;
+ dstContainer = InventoryType::Cart;
inventory = PlayerInfo::getStorageInventory();
}
#endif
@@ -865,10 +865,11 @@ void ItemContainer::mouseReleased(MouseEvent &event)
const Item *const item = inventory->getItem(dragDrop.getTag());
if (item)
{
- if (srcContainer != -1)
+ if (srcContainer != InventoryType::TypeEnd)
{ // inventory <--> storage, cart
inventoryHandler->moveItem2(srcContainer,
- item->getInvIndex(), item->getQuantity(),
+ item->getInvIndex(),
+ item->getQuantity(),
dstContainer);
}
else
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 4bd285b8f..b3accf9ed 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -489,7 +489,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
else
{
popupMenu->showPopup(this, mx, my, item,
- InventoryType::INVENTORY);
+ InventoryType::Inventory);
}
return;
}
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 6f1cac84d..4770ef69a 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -117,24 +117,24 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
setWindowName(inventory->getName());
switch (inventory->getType())
{
- case InventoryType::INVENTORY:
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Inventory:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
default:
mSortDropDown->setSelected(config.getIntValue(
"inventorySortOrder"));
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
mSortDropDown->setSelected(config.getIntValue(
"storageSortOrder"));
break;
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
mSortDropDown->setSelected(config.getIntValue(
"cartSortOrder"));
break;
@@ -151,7 +151,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
if (setupWindow &&
inventory &&
- inventory->getType() != InventoryType::STORAGE)
+ inventory->getType() != InventoryType::Storage)
{
setupWindow->registerWindowForReset(this);
}
@@ -193,7 +193,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
{
// TRANSLATORS: inventory button
const std::string equip = _("Equip");
@@ -257,7 +257,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
break;
}
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
{
// TRANSLATORS: storage button
mStoreButton = new Button(this, _("Store"), "store", this);
@@ -281,7 +281,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
}
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
{
// TRANSLATORS: storage button
mStoreButton = new Button(this, _("Store"), "store", this);
@@ -313,13 +313,13 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
#endif
default:
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
break;
};
@@ -351,7 +351,7 @@ void InventoryWindow::postInit()
mItems->setSortType(mSortDropDown->getSelected());
widgetResized(Event(nullptr));
- if (mInventory && mInventory->getType() == InventoryType::STORAGE)
+ if (mInventory && mInventory->getType() == InventoryType::Storage)
setVisible(Visible_true);
}
@@ -373,24 +373,24 @@ void InventoryWindow::storeSortOrder() const
{
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Inventory:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
default:
config.setValue("inventorySortOrder",
mSortDropDown->getSelected());
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
config.setValue("storageSortOrder",
mSortDropDown->getSelected());
break;
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
config.setValue("cartSortOrder",
mSortDropDown->getSelected());
break;
@@ -480,16 +480,18 @@ void InventoryWindow::action(const ActionEvent &event)
{
if (isStorageActive())
{
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), item->getQuantity(),
- InventoryType::STORAGE);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(),
+ item->getQuantity(),
+ InventoryType::Storage);
}
#ifdef EATHENA_SUPPORT
else if (cartWindow && cartWindow->isWindowVisible())
{
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), item->getQuantity(),
- InventoryType::CART);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(),
+ item->getQuantity(),
+ InventoryType::Cart);
}
else
#endif
@@ -598,13 +600,15 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
if (event.getButton() == MouseButton::RIGHT)
{
ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
- inventoryWindow, item);
+ inventoryWindow,
+ item);
}
else
{
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), item->getQuantity(),
- InventoryType::STORAGE);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(),
+ item->getQuantity(),
+ InventoryType::Storage);
}
}
else
@@ -616,9 +620,10 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
}
else
{
- inventoryHandler->moveItem2(InventoryType::STORAGE,
- item->getInvIndex(), item->getQuantity(),
- InventoryType::INVENTORY);
+ inventoryHandler->moveItem2(InventoryType::Storage,
+ item->getInvIndex(),
+ item->getQuantity(),
+ InventoryType::Inventory);
}
}
}
@@ -793,30 +798,30 @@ void InventoryWindow::close()
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
#endif
setVisible(Visible_false);
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
if (inventoryHandler)
{
- inventoryHandler->closeStorage(InventoryType::STORAGE);
+ inventoryHandler->closeStorage();
inventoryHandler->forgotStorage();
}
scheduleDelete();
break;
default:
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
break;
}
}
@@ -825,17 +830,18 @@ void InventoryWindow::updateWeight()
{
if (!mInventory || !mWeightBar)
return;
- const InventoryType::Type type = mInventory->getType();
+ const InventoryTypeT type = mInventory->getType();
#ifdef EATHENA_SUPPORT
- if (type != InventoryType::INVENTORY && type != InventoryType::CART)
+ if (type != InventoryType::Inventory &&
+ type != InventoryType::Cart)
#else
- if (type != InventoryType::INVENTORY)
+ if (type != InventoryType::Inventory)
#endif
{
return;
}
- const bool isInv = type == InventoryType::INVENTORY;
+ const bool isInv = type == InventoryType::Inventory;
const int total = PlayerInfo::getAttribute(isInv
? Attributes::TOTAL_WEIGHT : Attributes::CART_TOTAL_WEIGHT);
const int max = PlayerInfo::getAttribute(isInv
@@ -948,11 +954,12 @@ void InventoryWindow::widgetResized(const Event &event)
if (!mInventory)
return;
- const InventoryType::Type type = mInventory->getType();
+ const InventoryTypeT type = mInventory->getType();
#ifdef EATHENA_SUPPORT
- if (type != InventoryType::INVENTORY && type != InventoryType::CART)
+ if (type != InventoryType::Inventory &&
+ type != InventoryType::Cart)
#else
- if (type != InventoryType::INVENTORY)
+ if (type != InventoryType::Inventory)
#endif
{
return;
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index a48a6dab2..fba671675 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -74,12 +74,12 @@ void ItemAmountWindow::finish(const Item *const item,
inventoryHandler->splitItem(item, amount);
break;
case StoreAdd:
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), amount, InventoryType::STORAGE);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(), amount, InventoryType::Storage);
break;
case StoreRemove:
- inventoryHandler->moveItem2(InventoryType::STORAGE,
- item->getInvIndex(), amount, InventoryType::INVENTORY);
+ inventoryHandler->moveItem2(InventoryType::Storage,
+ item->getInvIndex(), amount, InventoryType::Inventory);
break;
case ShopBuyAdd:
if (shopWindow)
@@ -91,12 +91,12 @@ void ItemAmountWindow::finish(const Item *const item,
break;
#ifdef EATHENA_SUPPORT
case CartAdd:
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), amount, InventoryType::CART);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(), amount, InventoryType::Cart);
break;
case CartRemove:
- inventoryHandler->moveItem2(InventoryType::CART,
- item->getInvIndex(), amount, InventoryType::INVENTORY);
+ inventoryHandler->moveItem2(InventoryType::Cart,
+ item->getInvIndex(), amount, InventoryType::Inventory);
break;
case MailAdd:
if (mailEditWindow)
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index de403839b..da7210a43 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -66,7 +66,7 @@ MailEditWindow::MailEditWindow() :
mSubjectField(new TextField(this)),
mMoneyField(new IntTextField(this, 0, 0, 10000000)),
mMessageField(new TextField(this)),
- mInventory(new Inventory(InventoryType::MAIL, 1)),
+ mInventory(new Inventory(InventoryType::Mail, 1)),
mItemContainer(new ItemContainer(this, mInventory)),
mItemScrollArea(new ScrollArea(this, mItemContainer,
getOptionBool("showitemsbackground"), "mailedit_listbackground.xml"))
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index 37e6bccc9..aa544e128 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -538,7 +538,7 @@ void MiniStatusWindow::slotsChanged(Inventory *const inventory)
if (!inventory)
return;
- if (inventory->getType() == InventoryType::INVENTORY)
+ if (inventory->getType() == InventoryType::Inventory)
StatusWindow::updateInvSlotsBar(mInvSlotsBar);
}
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index f2157585d..4f716f32d 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -124,7 +124,7 @@ NpcDialog::NpcDialog(const BeingId npcId) :
mButton3(new Button(this, _("Add"), "add", this)),
// TRANSLATORS: npc dialog button
mResetButton(new Button(this, _("Reset"), "reset", this)),
- mInventory(new Inventory(InventoryType::NPC, 1)),
+ mInventory(new Inventory(InventoryType::Npc, 1)),
mItemContainer(new ItemContainer(this, mInventory,
10000, ShowEmptyRows_true)),
mItemScrollArea(new ScrollArea(this, mItemContainer,
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index edd685f30..69cf87848 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -73,8 +73,8 @@ TradeWindow::TradeWindow() :
Window(_("Trade: You"), Modal_false, nullptr, "trade.xml"),
ActionListener(),
SelectionListener(),
- mMyInventory(new Inventory(InventoryType::TRADE)),
- mPartnerInventory(new Inventory(InventoryType::TRADE)),
+ mMyInventory(new Inventory(InventoryType::Trade)),
+ mPartnerInventory(new Inventory(InventoryType::Trade)),
mMyItemContainer(new ItemContainer(this, mMyInventory)),
mPartnerItemContainer(new ItemContainer(this, mPartnerInventory)),
// TRANSLATORS: trade window money label