summaryrefslogtreecommitdiff
path: root/src/gui/widgets/itemcontainer.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-08-15 21:28:10 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-16 13:19:09 -0600
commitd8d9232a67a03548b827bdb0515fe7a620a488f8 (patch)
treed6e0644f99e0ff89f9b320c0b479ba5a4e398125 /src/gui/widgets/itemcontainer.cpp
parenta6c2b90c2dabac18ad8052d948bc540406b3a613 (diff)
downloadmana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.gz
mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.bz2
mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.xz
mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.zip
Move more to the event system
Most of Net::InventoryHandler is now done through events. The ActorSpriteManager was also replaced by events. A few odds and ends were taken care of too. Reviewed-by: Bertram
Diffstat (limited to 'src/gui/widgets/itemcontainer.cpp')
-rw-r--r--src/gui/widgets/itemcontainer.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index b98cac66..a9df95a6 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -260,12 +260,12 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
if (item->isEquipment())
{
if (item->isEquipped())
- Net::getInventoryHandler()->unequipItem(item);
+ item->doEvent("doUnequip");
else
- Net::getInventoryHandler()->equipItem(item);
+ item->doEvent("doEquip");
}
else
- Net::getInventoryHandler()->useItem(item);
+ item->doEvent("doUse");
}
else
@@ -275,18 +275,17 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
}
else if (item && item->getId())
{
- if(event.getClickCount() == 2)
+ if(event.getClickCount() == 2)
{
if (item->isEquipment())
{
if (item->isEquipped())
- Net::getInventoryHandler()->unequipItem(item);
+ item->doEvent("doUnequip");
else
- Net::getInventoryHandler()->equipItem(item);
+ item->doEvent("doEquip");
}
else
- Net::getInventoryHandler()->useItem(item);
-
+ item->doEvent("doUse");
}
else
{
@@ -337,7 +336,14 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event)
return;
if (index == mSelectedIndex || mSelectedIndex == -1)
return;
- Net::getInventoryHandler()->moveItem(mSelectedIndex, index);
+
+ Item *item = getSelectedItem();
+ {
+ Mana::Event event("doMove");
+ event.setItem("item", item);
+ event.setInt("newIndex", index);
+ event.trigger("Item");
+ }
selectNone();
}
@@ -404,8 +410,11 @@ void ItemContainer::keyAction()
mSelectedIndex != -1 &&
mHighlightedIndex != -1)
{
- Net::getInventoryHandler()->moveItem(
- mSelectedIndex, mHighlightedIndex);
+ Item *item = getSelectedItem();
+ Mana::Event event("doMove");
+ event.setItem("item", item);
+ event.setInt("newIndex", mHighlightedIndex);
+ event.trigger("Item");
setSelectedIndex(mHighlightedIndex);
}
// If the highlight is on an item then select it.
@@ -417,8 +426,11 @@ void ItemContainer::keyAction()
// If the highlight is on a blank space then move it.
else if (mSelectedIndex != -1)
{
- Net::getInventoryHandler()->moveItem(
- mSelectedIndex, mHighlightedIndex);
+ Item *item = getSelectedItem();
+ Mana::Event event("doMove");
+ event.setItem("item", item);
+ event.setInt("newIndex", mHighlightedIndex);
+ event.trigger("Item");
selectNone();
}
}