summaryrefslogtreecommitdiff
path: root/src/item.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-03 02:50:03 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-03 02:50:03 +0200
commitde51eaa43e05c2126fc1eef2a7e115843f972547 (patch)
tree286a05a069e048247f90c7595f1b8939be784608 /src/item.cpp
parentd4c08d3bf69410a35a50875de50cc6fe74b3bf3e (diff)
parent8627c7745f47492ab349da6a74e98e3d5813418f (diff)
downloadplus-de51eaa43e05c2126fc1eef2a7e115843f972547.tar.gz
plus-de51eaa43e05c2126fc1eef2a7e115843f972547.tar.bz2
plus-de51eaa43e05c2126fc1eef2a7e115843f972547.tar.xz
plus-de51eaa43e05c2126fc1eef2a7e115843f972547.zip
Merge branch 'coloritems'
Diffstat (limited to 'src/item.cpp')
-rw-r--r--src/item.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/item.cpp b/src/item.cpp
index 79540334a..ed0685a9d 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -29,7 +29,8 @@
#include "resources/resourcemanager.h"
#include "configuration.h"
-Item::Item(int id, int quantity, int refine, bool equipment, bool equipped):
+Item::Item(int id, int quantity, int refine, unsigned char color,
+ bool equipment, bool equipped):
mImage(0),
mDrawImage(0),
mQuantity(quantity),
@@ -39,7 +40,7 @@ Item::Item(int id, int quantity, int refine, bool equipment, bool equipped):
mRefine(refine),
mInvIndex(0)
{
- setId(id);
+ setId(id, color);
}
Item::~Item()
@@ -48,9 +49,10 @@ Item::~Item()
mImage->decRef();
}
-void Item::setId(int id)
+void Item::setId(int id, unsigned char color)
{
mId = id;
+ mColor = color;
// Types 0 and 1 are not equippable items.
mEquipment = id && getInfo().getType() >= 2;
@@ -73,8 +75,9 @@ void Item::setId(int id)
SpriteDisplay display = info.getDisplay();
std::string imagePath = paths.getStringValue("itemIcons")
+ display.image;
- mImage = resman->getImage(imagePath);
- mDrawImage = resman->getImage(imagePath);
+ std::string dye = combineDye2(imagePath, info.getDyeColorsString(color));
+ mImage = resman->getImage(dye);
+ mDrawImage = resman->getImage(dye);
if (!mImage)
{
@@ -96,12 +99,14 @@ bool Item::isHaveTag(int tagId)
return mTags[tagId] > 0;
}
-Image *Item::getImage(int id)
+Image *Item::getImage(int id, unsigned char color)
{
ResourceManager *resman = ResourceManager::getInstance();
- SpriteDisplay display = ItemDB::get(id).getDisplay();
+ ItemInfo info = ItemDB::get(id);
+ SpriteDisplay display = info.getDisplay();
std::string imagePath = "graphics/items/" + display.image;
- Image *image = resman->getImage(imagePath);
+ Image *image;
+ image = resman->getImage(combineDye2(imagePath, info.getDyeColorsString(color)));
if (!image)
image = Theme::getImageFromTheme("unknown-item.png");