summaryrefslogtreecommitdiff
path: root/src/item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/item.cpp')
-rw-r--r--src/item.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/item.cpp b/src/item.cpp
index b434387e..a2a1d443 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -21,18 +21,19 @@
#include "item.h"
-#include "gui/theme.h"
+#include "configuration.h"
+#include "event.h"
#include "resources/image.h"
#include "resources/iteminfo.h"
#include "resources/resourcemanager.h"
-#include "configuration.h"
+#include "resources/theme.h"
-Item::Item(int id, int quantity, bool equipment, bool equipped):
+Item::Item(int id, int quantity, bool equipped):
mImage(0),
mDrawImage(0),
mQuantity(quantity),
- mEquipment(equipment), mEquipped(equipped), mInEquipment(false)
+ mEquipped(equipped), mInEquipment(false)
{
setId(id);
}
@@ -47,9 +48,6 @@ void Item::setId(int id)
{
mId = id;
- // Types 0 and 1 are not equippable items.
- mEquipment = id && getInfo().getType() >= 2;
-
// Load the associated image
if (mImage)
mImage->decRef();
@@ -58,8 +56,9 @@ void Item::setId(int id)
mDrawImage->decRef();
ResourceManager *resman = ResourceManager::getInstance();
- std::string imagePath = paths.getValue("itemIcons", "graphics/items/")
- + getInfo().getImageName();
+ SpriteDisplay display = getInfo().getDisplay();
+ std::string imagePath = paths.getStringValue("itemIcons")
+ + display.image;
mImage = resman->getImage(imagePath);
mDrawImage = resman->getImage(imagePath);
@@ -72,3 +71,23 @@ void Item::setId(int id)
paths.getValue("unknownItemFile",
"unknown-item.png"));
}
+
+void Item::doEvent(const std::string &eventName)
+{
+ Mana::Event event(eventName);
+ event.setItem("item", this);
+ event.trigger("Item");
+}
+
+void Item::doEvent(const std::string &eventName, int amount)
+{
+ Mana::Event event(eventName);
+ event.setItem("item", this);
+ event.setInt("amount", amount);
+ event.trigger("Item");
+}
+
+bool Item::isEquippable() const
+{
+ return getInfo().getEquippable();
+}