diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-06-21 16:15:33 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-06-21 16:15:33 +0300 |
commit | f6e348a03e14d2e7d91774802f3a4153333d20cb (patch) | |
tree | 37dab64a05444203436e8307b4252a16b93cb795 /src | |
parent | 58a6cd09e9dad44565b939599fa24c5d82011820 (diff) | |
download | ManaVerse-f6e348a03e14d2e7d91774802f3a4153333d20cb.tar.gz ManaVerse-f6e348a03e14d2e7d91774802f3a4153333d20cb.tar.bz2 ManaVerse-f6e348a03e14d2e7d91774802f3a4153333d20cb.tar.xz ManaVerse-f6e348a03e14d2e7d91774802f3a4153333d20cb.zip |
Improve Being::setSpriteColor.
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 64 |
1 files changed, 59 insertions, 5 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index fae5224b6..dea303af5 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2995,12 +2995,66 @@ void Being::setHairColorSpriteID(const unsigned int slot, void Being::setSpriteColor(const unsigned int slot, const std::string &restrict color) restrict2 { + if (!charServerHandler || slot >= charServerHandler->maxSprite()) + return; + + if (slot >= CAST_U32(mSprites.size())) + ensureSize(slot + 1); + + if (slot >= CAST_U32(mSlots.size())) + mSlots.resize(slot + 1, BeingSlot()); + + // disabled for now, because it may broke replace/reorder sprites logic +// if (slot && mSlots[slot].spriteId == id) +// return; + BeingSlot &beingSlot = mSlots[slot]; - setSpriteCards(slot, - beingSlot.spriteId, - color, - ItemColor_one, - beingSlot.cardsId); + const int id = beingSlot.spriteId; + + // id = 0 means unequip + if (id == 0) + { + } + else + { + const ItemInfo &info = ItemDB::get(id); + const std::string &restrict filename = info.getSprite( + mGender, mSubType); + int lastTime = 0; + int startTime = 0; + AnimatedSprite *restrict equipmentSprite = nullptr; + + if (!filename.empty()) + { + equipmentSprite = AnimatedSprite::delayedLoad( + paths.getStringValue("sprites").append( + combineDye(filename, color))); + } + + if (equipmentSprite) + { + equipmentSprite->setSpriteDirection(getSpriteDirection()); + startTime = getStartTime(); + lastTime = getLastTime(); + } + + CompoundSprite::setSprite(slot, equipmentSprite); + + setAction(mAction, 0); + if (equipmentSprite) + { + if (lastTime > 0) + { + equipmentSprite->setLastTime(startTime); + equipmentSprite->update(lastTime); + } + } + } + + beingSlot.color = color; + beingSlot.colorId = ItemColor_one; + if (beingEquipmentWindow) + beingEquipmentWindow->updateBeing(this); } void Being::setHairStyle(const unsigned int slot, |