diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-11-03 09:58:25 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-11-03 09:58:25 +0000 |
commit | 8a60e11684e84807f3526b37afa8cbf6f103b8fd (patch) | |
tree | 202058890ef2f8f2c5e9873acbb6f59327b28762 /src/player.cpp | |
parent | 8a0e94b31be13ef9c52b281c32095279d7fa1ca7 (diff) | |
download | mana-8a60e11684e84807f3526b37afa8cbf6f103b8fd.tar.gz mana-8a60e11684e84807f3526b37afa8cbf6f103b8fd.tar.bz2 mana-8a60e11684e84807f3526b37afa8cbf6f103b8fd.tar.xz mana-8a60e11684e84807f3526b37afa8cbf6f103b8fd.zip |
Fixed double load of hair graphics.
Diffstat (limited to 'src/player.cpp')
-rw-r--r-- | src/player.cpp | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/src/player.cpp b/src/player.cpp index 0fe6460c..062c1135 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -31,7 +31,7 @@ #include "resources/itemdb.h" #include "resources/iteminfo.h" -#include "utils/tostring.h" +#include "utils/strprintf.h" #include "gui/gui.h" @@ -103,42 +103,25 @@ void Player::setGender(int sex) } } -void Player::setHairColor(int color) +void Player::setHairStyle(int style, int color) { - if (color != mHairColor) - { - mHairColor = color < NR_HAIR_COLORS ? color : 0; - - AnimatedSprite *newHairSprite = AnimatedSprite::load( - "graphics/sprites/hairstyle" + toString(getHairStyle()) + ".xml", - mHairColor); - if (newHairSprite) - newHairSprite->setDirection(getSpriteDirection()); - - delete mSprites[HAIR_SPRITE]; - mSprites[HAIR_SPRITE] = newHairSprite; + style = style < 0 ? mHairStyle : style % NR_HAIR_STYLES; + color = color < 0 ? mHairColor : color % NR_HAIR_COLORS; + if (style == mHairStyle && color == mHairColor) return; - setAction(mAction); - } -} + mHairStyle = style; + mHairColor = color; -void Player::setHairStyle(int style) -{ - if (style != mHairStyle) - { - mHairStyle = style < NR_HAIR_STYLES ? style : 0; + AnimatedSprite *newHairSprite = AnimatedSprite::load + (strprintf("graphics/sprites/hairstyle%d.xml", style), color); - AnimatedSprite *newHairSprite = AnimatedSprite::load( - "graphics/sprites/hairstyle" + toString(getHairStyle()) + ".xml", - mHairColor); - if (newHairSprite) - newHairSprite->setDirection(getSpriteDirection()); + if (newHairSprite) + newHairSprite->setDirection(getSpriteDirection()); - delete mSprites[HAIR_SPRITE]; - mSprites[HAIR_SPRITE] = newHairSprite; + delete mSprites[HAIR_SPRITE]; + mSprites[HAIR_SPRITE] = newHairSprite; - setAction(mAction); - } + setAction(mAction); } void Player::setVisibleEquipment(int slot, int id) |