summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-19 02:41:30 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-19 02:41:30 +0200
commit011135415f7f9c5cfeb220540621dfd1c46e6db9 (patch)
tree55dd2943dca362045e7ed96ef72924728343351e /src/net/tmwa
parentc392eab58774154177a0e790a414c2c52c8ce83b (diff)
parent27114fa2694318f2a1c56cb828a3b79731efcb74 (diff)
downloadmana-011135415f7f9c5cfeb220540621dfd1c46e6db9.tar.gz
mana-011135415f7f9c5cfeb220540621dfd1c46e6db9.tar.bz2
mana-011135415f7f9c5cfeb220540621dfd1c46e6db9.tar.xz
mana-011135415f7f9c5cfeb220540621dfd1c46e6db9.zip
Merge git://gitorious.org/~bertram/mana/mana-equipment-fix into equipment-fix
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/inventoryhandler.cpp5
-rw-r--r--src/net/tmwa/inventoryhandler.h67
2 files changed, 70 insertions, 2 deletions
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index ff875e69..76eb85f5 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -31,6 +31,7 @@
#include "localplayer.h"
#include "log.h"
+#include "gui/equipmentwindow.h"
#include "gui/widgets/chattab.h"
#include "net/messagein.h"
@@ -388,6 +389,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
{
mEquips.setEquipment(getSlot(equipType), index);
}
+
+ // Load the equipment boxes
+ if (equipmentWindow)
+ equipmentWindow->loadEquipBoxes();
}
break;
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 218723e6..4c29e95b 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -34,6 +34,10 @@
#include "net/tmwa/messagehandler.h"
+#include "resources/iteminfo.h"
+
+#include "utils/gettext.h"
+
#include <list>
namespace TmwAthena {
@@ -52,9 +56,40 @@ class EquipBackend : public Equipment::Backend
return PlayerInfo::getInventory()->getItem(invyIndex);
}
+ std::string getSlotName(int slotIndex) const
+ {
+ switch (slotIndex)
+ {
+ case EQUIP_TORSO_SLOT:
+ return std::string(_("Torso"));
+ case EQUIP_ARMS_SLOT:
+ return std::string(_("Arms"));
+ case EQUIP_HEAD_SLOT:
+ return std::string(_("Head"));
+ case EQUIP_LEGS_SLOT:
+ return std::string(_("Legs"));
+ case EQUIP_FEET_SLOT:
+ return std::string(_("Feet"));
+ case EQUIP_RING1_SLOT:
+ return std::string(_("Ring 1/2"));
+ case EQUIP_RING2_SLOT:
+ return std::string(_("Ring 2/2"));
+ case EQUIP_NECKLACE_SLOT:
+ return std::string(_("Necklace"));
+ case EQUIP_FIGHT1_SLOT:
+ return std::string(_("Hand 1/2"));
+ case EQUIP_FIGHT2_SLOT:
+ return std::string(_("Hand 2/2"));
+ case EQUIP_PROJECTILE_SLOT:
+ return std::string(_("Ammo"));
+ default:
+ return std::string();
+ }
+ }
+
void clear()
{
- for (int i = 0; i < EQUIPMENT_SIZE; i++)
+ for (int i = 0; i < EQUIP_VECTOR_END; i++)
{
if (mEquipment[i] != -1)
{
@@ -82,8 +117,30 @@ class EquipBackend : public Equipment::Backend
inventoryWindow->updateButtons();
}
+ void triggerUnequip(int slotIndex) const
+ {
+ Item *item = getEquipment(slotIndex);
+ if (item)
+ item->doEvent(Event::DoUnequip);
+ }
+
+ int getSlotNumber() const
+ { return EQUIP_VECTOR_END; }
+
+ // Note the slot type id is equal to the slot Index for tA.
+ bool isWeaponSlot(unsigned int slotTypeId) const
+ {
+ return (slotTypeId == EQUIP_FIGHT1_SLOT
+ || slotTypeId == EQUIP_FIGHT1_SLOT);
+ }
+
+ bool isAmmoSlot(unsigned int slotTypeId) const
+ {
+ return (slotTypeId == EQUIP_PROJECTILE_SLOT);
+ }
+
private:
- int mEquipment[EQUIPMENT_SIZE];
+ int mEquipment[EQUIP_VECTOR_END];
};
/**
@@ -129,6 +186,12 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler,
size_t getSize(int type) const;
+ bool isWeaponSlot(unsigned int slotTypeId) const
+ { return mEquips.isWeaponSlot(slotTypeId); }
+
+ bool isAmmoSlot(unsigned int slotTypeId) const
+ { return mEquips.isAmmoSlot(slotTypeId); }
+
private:
EquipBackend mEquips;
InventoryItems mInventoryItems;