From 0c063cf5b45a843485fe3343e5fb79a40141f88c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 16 Nov 2015 21:16:07 +0300 Subject: Convert DragDropSource enum into strong typed enum. --- src/gui/widgets/itemcontainer.cpp | 74 +++++++++++++++--------------- src/gui/widgets/itemshortcutcontainer.cpp | 8 ++-- src/gui/widgets/skilllistbox.h | 2 +- src/gui/widgets/spellshortcutcontainer.cpp | 4 +- src/gui/widgets/virtshortcutcontainer.cpp | 2 +- 5 files changed, 45 insertions(+), 45 deletions(-) (limited to 'src/gui/widgets') 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 -- cgit v1.2.3-60-g2f50