summaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-21 19:43:11 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-21 19:43:11 +0000
commit7c7909350565c3506f8b24645cac10f3197e1fc5 (patch)
tree748ce81596f924d81cb7b6fdba84fe22a054e305 /src/player.cpp
parent434d0bd000576b534c51f611c09eb99b3863e1c5 (diff)
downloadmana-7c7909350565c3506f8b24645cac10f3197e1fc5.tar.gz
mana-7c7909350565c3506f8b24645cac10f3197e1fc5.tar.bz2
mana-7c7909350565c3506f8b24645cac10f3197e1fc5.tar.xz
mana-7c7909350565c3506f8b24645cac10f3197e1fc5.zip
Merged revisions 3705-3711,3714,3718,3721-3722,3729-3731,3735,3742 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/trunk (dynamic recoloring of sprites and related changes) ........ r3705 | gmelquio | 2007-11-03 10:58:25 +0100 (Sat, 03 Nov 2007) | 1 line Fixed double load of hair graphics. ........ r3706 | gmelquio | 2007-11-03 22:04:51 +0100 (Sat, 03 Nov 2007) | 1 line Added automatic recoloring of images. Inspired by fungos' ideas (PR #41). ........ r3707 | gmelquio | 2007-11-03 22:08:21 +0100 (Sat, 03 Nov 2007) | 1 line Experimented recoloring on scorpions. ........ r3708 | gmelquio | 2007-11-04 12:52:44 +0100 (Sun, 04 Nov 2007) | 1 line Tightened palette handling. ........ r3709 | gmelquio | 2007-11-04 12:54:31 +0100 (Sun, 04 Nov 2007) | 1 line Experimented with scorpions again. ........ r3710 | gmelquio | 2007-11-04 16:40:37 +0100 (Sun, 04 Nov 2007) | 1 line Applied recoloring to hair styles. ........ r3711 | gmelquio | 2007-11-04 17:50:37 +0100 (Sun, 04 Nov 2007) | 1 line Converted slimes to recoloring. ........ r3742 | gmelquio | 2007-11-16 14:16:00 +0100 (Fri, 16 Nov 2007) | 1 line Sped up recoloring of transparent pixels. ........
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp69
1 files changed, 30 insertions, 39 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 483bb726..d1999c89 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"
@@ -129,48 +129,39 @@ void Player::setGender(int gender)
Being::setGender(gender);
}
-void Player::setHairColor(int color)
+void Player::setHairStyle(int style, int color)
{
- if (color != mHairColor && mHairStyle > 0)
- {
- const std::string hairStyle = toString(getHairStyle());
- const std::string gender = (mGender == 0) ? "-male" : "-female";
-
- AnimatedSprite *newHairSprite = AnimatedSprite::load(
- "graphics/sprites/hairstyle" + hairStyle + gender + ".xml",
- color - 1);
- if (newHairSprite)
- newHairSprite->setDirection(getSpriteDirection());
+ style = style < 0 ? mHairStyle : style % NR_HAIR_STYLES;
+ color = color < 0 ? mHairColor : color % NR_HAIR_COLORS;
+ if (style == mHairStyle && color == mHairColor) return;
- delete mSprites[HAIR_SPRITE];
- mSprites[HAIR_SPRITE] = newHairSprite;
-
- setAction(mAction);
- }
-
- Being::setHairColor(color);
-}
+ Being::setHairStyle(style, color);
-void Player::setHairStyle(int style)
-{
- if (style != mHairStyle && mHairColor > 0)
+ static char const *const colors[NR_HAIR_COLORS] =
{
- const std::string hairStyle = toString(style);
- const std::string gender = (mGender == 0) ? "-male" : "-female";
-
- AnimatedSprite *newHairSprite = AnimatedSprite::load(
- "graphics/sprites/hairstyle" + hairStyle + gender + ".xml",
- mHairColor - 1);
- if (newHairSprite)
- newHairSprite->setDirection(getSpriteDirection());
-
- delete mSprites[HAIR_SPRITE];
- mSprites[HAIR_SPRITE] = newHairSprite;
-
- setAction(mAction);
- }
-
- Being::setHairStyle(style);
+ "#8c4b41,da9041,ffffff", // light brown
+ "#06372b,489e25,fdedcc", // green
+ "#5f0b33,91191c,f9ad81", // red
+ "#602486,934cc3,fdc689", // purple
+ "#805e74,c6b09b,ffffff", // gray
+ "#8c6625,dab425,ffffff", // yellow
+ "#1d2d6d,1594a3,fdedcc", // blue
+ "#831f2d,be4f2d,f8cc8b", // brown
+ "#432482,584bbc,dae8e5", // light blue
+ "#460850,611967,e7b4ae", // dark purple
+ };
+
+ AnimatedSprite *newHairSprite = AnimatedSprite::load
+ (strprintf("graphics/sprites/hairstyle%d%s.xml|%s",
+ style,
+ "", //(mGender == 0) ? "-male" : "-female",
+ colors[color]));
+ if (newHairSprite)
+ newHairSprite->setDirection(getSpriteDirection());
+ delete mSprites[HAIR_SPRITE];
+ mSprites[HAIR_SPRITE] = newHairSprite;
+
+ setAction(mAction);
}
void Player::setVisibleEquipment(int slot, int id)