summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-16 21:16:07 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-16 21:16:07 +0300
commit0c063cf5b45a843485fe3343e5fb79a40141f88c (patch)
treee2419701a312e0ba97404049cd5b82b7420c3fce
parentdb82bf99bbd6d246f3e8da19fe88705f7015f144 (diff)
downloadmanaverse-0c063cf5b45a843485fe3343e5fb79a40141f88c.tar.gz
manaverse-0c063cf5b45a843485fe3343e5fb79a40141f88c.tar.bz2
manaverse-0c063cf5b45a843485fe3343e5fb79a40141f88c.tar.xz
manaverse-0c063cf5b45a843485fe3343e5fb79a40141f88c.zip
Convert DragDropSource enum into strong typed enum.
-rw-r--r--src/dragdrop.h24
-rw-r--r--src/enums/dragdropsource.h39
-rw-r--r--src/gui/widgets/itemcontainer.cpp74
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp8
-rw-r--r--src/gui/widgets/skilllistbox.h2
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp2
-rw-r--r--src/gui/windows/equipmentwindow.cpp16
-rw-r--r--src/gui/windows/outfitwindow.cpp2
-rw-r--r--src/item.cpp2
10 files changed, 89 insertions, 84 deletions
diff --git a/src/dragdrop.h b/src/dragdrop.h
index 278fc7639..387d3b4a9 100644
--- a/src/dragdrop.h
+++ b/src/dragdrop.h
@@ -97,7 +97,7 @@ class DragDrop final
mItem = 0;
mItemColor = ItemColor_one;
mItemImage = nullptr;
- mSource = DRAGDROP_SOURCE_EMPTY;
+ mSource = DragDropSource::Empty;
mTag = -1;
}
}
@@ -146,7 +146,7 @@ class DragDrop final
mItemColor = ItemColor_one;
mText.clear();
mItemImage = nullptr;
- mSource = DRAGDROP_SOURCE_EMPTY;
+ mSource = DragDropSource::Empty;
mTag = -1;
if (info)
{
@@ -173,13 +173,13 @@ class DragDrop final
mItem = 0;
mItemColor = ItemColor_one;
mItemImage = nullptr;
- mSource = DRAGDROP_SOURCE_EMPTY;
+ mSource = DragDropSource::Empty;
mText.clear();
mTag = -1;
}
bool isEmpty() const
- { return mSource == DRAGDROP_SOURCE_EMPTY; }
+ { return mSource == DragDropSource::Empty; }
void select(const Item *const item)
{
@@ -225,16 +225,16 @@ class DragDrop final
bool isSourceItemContainer() const
{
- return mSource == DRAGDROP_SOURCE_INVENTORY
- || mSource == DRAGDROP_SOURCE_STORAGE
+ return mSource == DragDropSource::Inventory
+ || mSource == DragDropSource::Storage
#ifdef EATHENA_SUPPORT
- || mSource == DRAGDROP_SOURCE_CART
+ || mSource == DragDropSource::Cart
#endif
- || mSource == DRAGDROP_SOURCE_TRADE
- || mSource == DRAGDROP_SOURCE_OUTFIT
- || mSource == DRAGDROP_SOURCE_GROUND
- || mSource == DRAGDROP_SOURCE_DROP
- || mSource == DRAGDROP_SOURCE_CRAFT;
+ || mSource == DragDropSource::Trade
+ || mSource == DragDropSource::Outfit
+ || mSource == DragDropSource::Ground
+ || mSource == DragDropSource::Drop
+ || mSource == DragDropSource::Craft;
}
private:
diff --git a/src/enums/dragdropsource.h b/src/enums/dragdropsource.h
index 37ec91d79..f98084a11 100644
--- a/src/enums/dragdropsource.h
+++ b/src/enums/dragdropsource.h
@@ -21,25 +21,30 @@
#ifndef ENUMS_DRAGDROPSOURCE_H
#define ENUMS_DRAGDROPSOURCE_H
-enum DragDropSource
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(DragDropSource)
{
- DRAGDROP_SOURCE_EMPTY = 0,
- DRAGDROP_SOURCE_INVENTORY,
- DRAGDROP_SOURCE_STORAGE,
- DRAGDROP_SOURCE_TRADE,
- DRAGDROP_SOURCE_OUTFIT,
- DRAGDROP_SOURCE_SPELLS,
- DRAGDROP_SOURCE_SKILLS,
- DRAGDROP_SOURCE_GROUND,
- DRAGDROP_SOURCE_DROP,
- DRAGDROP_SOURCE_SHORTCUTS,
- DRAGDROP_SOURCE_CRAFT,
- DRAGDROP_SOURCE_NPC,
- DRAGDROP_SOURCE_EQUIPMENT,
+ Empty = 0,
+ Inventory,
+ Storage,
+ Trade,
+ Outfit,
+ Spells,
+ Skills,
+ Ground,
+ Drop,
+ Shortcuts,
+ Craft,
+ Npc,
#ifdef EATHENA_SUPPORT
- DRAGDROP_SOURCE_CART,
- DRAGDROP_SOURCE_MAIL
+ Equipment,
+ Cart,
+ Mail
+#else
+ Equipment
#endif
-};
+}
+enumEnd(DragDropSource);
#endif // ENUMS_DRAGDROPSOURCE_H
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index c9f5298b7..ac65a024f 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -575,27 +575,27 @@ void ItemContainer::mousePressed(MouseEvent &event)
if (item && mDescItems && chatWindow)
chatWindow->addItemText(item->getInfo().getName());
- DragDropSource src = DRAGDROP_SOURCE_EMPTY;
+ DragDropSource src = DragDropSource::Empty;
switch (mInventory->getType())
{
case InventoryType::INVENTORY:
- src = DRAGDROP_SOURCE_INVENTORY;
+ src = DragDropSource::Inventory;
break;
case InventoryType::STORAGE:
- src = DRAGDROP_SOURCE_STORAGE;
+ src = DragDropSource::Storage;
break;
case InventoryType::TRADE:
- src = DRAGDROP_SOURCE_TRADE;
+ src = DragDropSource::Trade;
break;
case InventoryType::NPC:
- src = DRAGDROP_SOURCE_NPC;
+ src = DragDropSource::Npc;
break;
#ifdef EATHENA_SUPPORT
case InventoryType::CART:
- src = DRAGDROP_SOURCE_CART;
+ src = DragDropSource::Cart;
break;
case InventoryType::MAIL:
- src = DRAGDROP_SOURCE_MAIL;
+ src = DragDropSource::Mail;
break;
#endif
default:
@@ -682,27 +682,27 @@ void ItemContainer::mouseReleased(MouseEvent &event)
else if (mInventory)
{
const DragDropSource src = dragDrop.getSource();
- DragDropSource dst = DRAGDROP_SOURCE_EMPTY;
+ DragDropSource dst = DragDropSource::Empty;
switch (mInventory->getType())
{
case InventoryType::INVENTORY:
- dst = DRAGDROP_SOURCE_INVENTORY;
+ dst = DragDropSource::Inventory;
break;
case InventoryType::STORAGE:
- dst = DRAGDROP_SOURCE_STORAGE;
+ dst = DragDropSource::Storage;
break;
case InventoryType::TRADE:
- dst = DRAGDROP_SOURCE_TRADE;
+ dst = DragDropSource::Trade;
break;
case InventoryType::NPC:
- dst = DRAGDROP_SOURCE_NPC;
+ dst = DragDropSource::Npc;
break;
#ifdef EATHENA_SUPPORT
case InventoryType::MAIL:
- dst = DRAGDROP_SOURCE_MAIL;
+ dst = DragDropSource::Mail;
break;
case InventoryType::CART:
- dst = DRAGDROP_SOURCE_CART;
+ dst = DragDropSource::Cart;
break;
#endif
default:
@@ -716,30 +716,30 @@ void ItemContainer::mouseReleased(MouseEvent &event)
int dstContainer = -1;
bool checkProtection(false);
Inventory *inventory = nullptr;
- if (src == DRAGDROP_SOURCE_INVENTORY
- && dst == DRAGDROP_SOURCE_STORAGE)
+ if (src == DragDropSource::Inventory
+ && dst == DragDropSource::Storage)
{
srcContainer = InventoryType::INVENTORY;
dstContainer = InventoryType::STORAGE;
inventory = PlayerInfo::getInventory();
}
- else if (src == DRAGDROP_SOURCE_STORAGE
- && dst == DRAGDROP_SOURCE_INVENTORY)
+ else if (src == DragDropSource::Storage
+ && dst == DragDropSource::Inventory)
{
srcContainer = InventoryType::STORAGE;
dstContainer = InventoryType::INVENTORY;
inventory = PlayerInfo::getStorageInventory();
}
#ifdef EATHENA_SUPPORT
- if (src == DRAGDROP_SOURCE_INVENTORY
- && dst == DRAGDROP_SOURCE_CART)
+ if (src == DragDropSource::Inventory
+ && dst == DragDropSource::Cart)
{
srcContainer = InventoryType::INVENTORY;
dstContainer = InventoryType::CART;
inventory = PlayerInfo::getInventory();
}
- if (src == DRAGDROP_SOURCE_INVENTORY
- && dst == DRAGDROP_SOURCE_INVENTORY)
+ if (src == DragDropSource::Inventory
+ && dst == DragDropSource::Inventory)
{
const int index = getSlotIndex(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
@@ -750,40 +750,40 @@ void ItemContainer::mouseReleased(MouseEvent &event)
inventoryWindow->combineItems(index, mSelectedIndex);
return;
}
- else if (src == DRAGDROP_SOURCE_CART
- && dst == DRAGDROP_SOURCE_INVENTORY)
+ else if (src == DragDropSource::Cart
+ && dst == DragDropSource::Inventory)
{
srcContainer = InventoryType::CART;
dstContainer = InventoryType::INVENTORY;
inventory = PlayerInfo::getCartInventory();
}
- else if (src == DRAGDROP_SOURCE_CART
- && dst == DRAGDROP_SOURCE_STORAGE)
+ else if (src == DragDropSource::Cart
+ && dst == DragDropSource::Storage)
{
srcContainer = InventoryType::CART;
dstContainer = InventoryType::STORAGE;
inventory = PlayerInfo::getCartInventory();
}
- else if (src == DRAGDROP_SOURCE_STORAGE
- && dst == DRAGDROP_SOURCE_CART)
+ else if (src == DragDropSource::Storage
+ && dst == DragDropSource::Cart)
{
srcContainer = InventoryType::STORAGE;
dstContainer = InventoryType::CART;
inventory = PlayerInfo::getStorageInventory();
}
#endif
- if (src == DRAGDROP_SOURCE_INVENTORY
- && dst == DRAGDROP_SOURCE_TRADE)
+ if (src == DragDropSource::Inventory
+ && dst == DragDropSource::Trade)
{
checkProtection = true;
inventory = PlayerInfo::getInventory();
}
- else if (src == DRAGDROP_SOURCE_INVENTORY
+ else if (src == DragDropSource::Inventory
#ifdef EATHENA_SUPPORT
- && (dst == DRAGDROP_SOURCE_NPC
- || dst == DRAGDROP_SOURCE_MAIL))
+ && (dst == DragDropSource::Npc
+ || dst == DragDropSource::Mail))
#else
- && dst == DRAGDROP_SOURCE_NPC)
+ && dst == DragDropSource::Npc)
#endif
{
inventory = PlayerInfo::getInventory();
@@ -799,10 +799,10 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
return;
}
- else if (src == DRAGDROP_SOURCE_NPC)
+ else if (src == DragDropSource::Npc)
{
inventory = PlayerInfo::getInventory();
- if (dst == DRAGDROP_SOURCE_NPC)
+ if (dst == DragDropSource::Npc)
{
const Item *const item = mInventory->getItem(
dragDrop.getTag());
@@ -847,7 +847,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
}
#ifdef EATHENA_SUPPORT
- else if (src == DRAGDROP_SOURCE_MAIL)
+ else if (src == DragDropSource::Mail)
{
inventory = PlayerInfo::getInventory();
if (inventory)
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 170a4f504..dc7c214dd 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -390,7 +390,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
if (item)
{
selShortcut->removeItem(index);
- dragDrop.dragItem(item, DRAGDROP_SOURCE_SHORTCUTS, index);
+ dragDrop.dragItem(item, DragDropSource::Shortcuts, index);
}
else
{
@@ -411,7 +411,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
{
selShortcut->removeItem(index);
dragDrop.dragCommand(spell,
- DRAGDROP_SOURCE_SHORTCUTS, index);
+ DragDropSource::Shortcuts, index);
dragDrop.setItem(itemId);
}
else
@@ -432,7 +432,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
{
selShortcut->removeItem(index);
dragDrop.dragSkill(skill,
- DRAGDROP_SOURCE_SHORTCUTS, index);
+ DragDropSource::Shortcuts, index);
dragDrop.setItem(itemId);
}
else
@@ -509,7 +509,7 @@ void ItemShortcutContainer::mouseReleased(MouseEvent &event)
}
else
{
- if (dragDrop.getSource() == DRAGDROP_SOURCE_SHORTCUTS)
+ if (dragDrop.getSource() == DragDropSource::Shortcuts)
{
const int oldIndex = dragDrop.getTag();
selShortcut->setItem(oldIndex, dragDrop.getItem(),
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 74057ff32..35d2998a9 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -212,7 +212,7 @@ class SkillListBox final : public ListBox
const SkillInfo *const skill = getSkillByEvent(event);
if (!skill)
return;
- dragDrop.dragSkill(skill, DRAGDROP_SOURCE_SKILLS);
+ dragDrop.dragSkill(skill, DragDropSource::Skills);
dragDrop.setItem(skill->id + SKILL_MIN_ID);
}
ListBox::mouseDragged(event);
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 4c4b444d8..5a3a568f8 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -200,7 +200,7 @@ void SpellShortcutContainer::mouseDragged(MouseEvent &event)
TextCommand *const spell = spellManager->getSpell(itemId);
if (spell)
{
- dragDrop.dragCommand(spell, DRAGDROP_SOURCE_SPELLS, index);
+ dragDrop.dragCommand(spell, DragDropSource::Spells, index);
dragDrop.setItem(spell->getId() + SPELL_MIN_ID);
}
else
@@ -269,7 +269,7 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
if (!dragDrop.isEmpty())
{
- if (dragDrop.getSource() == DRAGDROP_SOURCE_SPELLS)
+ if (dragDrop.getSource() == DragDropSource::Spells)
{
const int oldIndex = dragDrop.getTag();
const int idx = mNumber * SPELL_SHORTCUT_ITEMS;
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index 4066a915c..5a8a0432d 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -246,7 +246,7 @@ void VirtShortcutContainer::mouseDragged(MouseEvent &event)
if (item)
{
- dragDrop.dragItem(item, DRAGDROP_SOURCE_DROP);
+ dragDrop.dragItem(item, DragDropSource::Drop);
mShortcut->removeItem(index);
}
else
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 53097802a..4bd285b8f 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -359,8 +359,8 @@ void EquipmentWindow::action(const ActionEvent &event)
else if (eventId == "playerbox")
{
const DragDropSource src = dragDrop.getSource();
- if (dragDrop.isEmpty() || (src != DRAGDROP_SOURCE_INVENTORY
- && src != DRAGDROP_SOURCE_EQUIPMENT))
+ if (dragDrop.isEmpty() || (src != DragDropSource::Inventory
+ && src != DragDropSource::Equipment))
{
return;
}
@@ -373,7 +373,7 @@ void EquipmentWindow::action(const ActionEvent &event)
if (!item)
return;
- if (dragDrop.getSource() == DRAGDROP_SOURCE_INVENTORY)
+ if (dragDrop.getSource() == DragDropSource::Inventory)
{
if (item->isEquipment() == Equipm_true)
{
@@ -459,7 +459,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
{
event.consume();
setSelected(i);
- dragDrop.dragItem(item, DRAGDROP_SOURCE_EQUIPMENT);
+ dragDrop.dragItem(item, DragDropSource::Equipment);
return;
}
}
@@ -502,8 +502,8 @@ void EquipmentWindow::mouseReleased(MouseEvent &event)
{
Window::mouseReleased(event);
const DragDropSource src = dragDrop.getSource();
- if (dragDrop.isEmpty() || (src != DRAGDROP_SOURCE_INVENTORY
- && src != DRAGDROP_SOURCE_EQUIPMENT))
+ if (dragDrop.isEmpty() || (src != DragDropSource::Inventory
+ && src != DragDropSource::Equipment))
{
return;
}
@@ -517,7 +517,7 @@ void EquipmentWindow::mouseReleased(MouseEvent &event)
if (!item)
return;
- if (dragDrop.getSource() == DRAGDROP_SOURCE_INVENTORY)
+ if (dragDrop.getSource() == DragDropSource::Inventory)
{
if (item->isEquipment() == Equipm_true)
{
@@ -525,7 +525,7 @@ void EquipmentWindow::mouseReleased(MouseEvent &event)
PlayerInfo::equipItem(item, Sfx_true);
}
}
- else if (dragDrop.getSource() == DRAGDROP_SOURCE_EQUIPMENT)
+ else if (dragDrop.getSource() == DragDropSource::Equipment)
{
if (item->isEquipment() == Equipm_true)
{
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index 7ce43333b..1cf89cb42 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -467,7 +467,7 @@ void OutfitWindow::mouseDragged(MouseEvent &event)
{
Item *const item = inv->findItem(itemId, itemColor);
if (item)
- dragDrop.dragItem(item, DRAGDROP_SOURCE_OUTFIT);
+ dragDrop.dragItem(item, DragDropSource::Outfit);
else
dragDrop.clear();
mItems[mCurrentOutfit][index] = -1;
diff --git a/src/item.cpp b/src/item.cpp
index 2f574130c..721c8115b 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -35,7 +35,7 @@
#include "debug.h"
-DragDrop dragDrop(nullptr, DRAGDROP_SOURCE_EMPTY);
+DragDrop dragDrop(nullptr, DragDropSource::Empty);
Item::Item(const int id,
const int type,