summaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2007-12-10 02:22:59 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2007-12-10 02:22:59 +0000
commite961be5bfd29ad3f44f948828981cb3ab07f25a7 (patch)
tree5464d14635191407eb24c7ad76b1b218b33016d2 /src/player.cpp
parent43b986ceffdb436d8850a876bd485c9a3eea8cdd (diff)
downloadmana-e961be5bfd29ad3f44f948828981cb3ab07f25a7.tar.gz
mana-e961be5bfd29ad3f44f948828981cb3ab07f25a7.tar.bz2
mana-e961be5bfd29ad3f44f948828981cb3ab07f25a7.tar.xz
mana-e961be5bfd29ad3f44f948828981cb3ab07f25a7.zip
Simplified player subsprite handling by treating equipment, hairstyle and base sprites alike. Implementing female hairstyles is now a purely content-sided task.
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp49
1 files changed, 14 insertions, 35 deletions
diff --git a/src/player.cpp b/src/player.cpp
index d1999c89..a1a86587 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -94,39 +94,26 @@ void Player::setGender(int gender)
gender = 0;
}
+
if (gender != mGender)
{
- // Reload base sprite
- AnimatedSprite *newBaseSprite;
- if (gender == 0)
- {
- newBaseSprite = AnimatedSprite::load(
- "graphics/sprites/player_male_base.xml");
- }
- else
- {
- newBaseSprite = AnimatedSprite::load(
- "graphics/sprites/player_female_base.xml");
- }
+ Being::setGender(gender);
- delete mSprites[BASE_SPRITE];
- mSprites[BASE_SPRITE] = newBaseSprite;
+ setSprite(Being::BASE_SPRITE, -100); /* Human base sprite. When implementing
+ * different races remove this line
+ * and set the base sprite when setting
+ * the race of the player character.
+ */
- // Reload equipment
+ // Reload all subsprites
for (int i = 1; i < VECTOREND_SPRITE; i++)
{
- if (i != HAIR_SPRITE && mEquipmentSpriteIDs.at(i) != 0)
+ if (mSpriteIDs.at(i) != 0)
{
- AnimatedSprite *newEqSprite = AnimatedSprite::load(
- "graphics/sprites/" + ItemDB::get(
- mEquipmentSpriteIDs.at(i)).getSprite(gender));
- delete mSprites[i];
- mSprites[i] = newEqSprite;
+ setSprite(i, mSpriteIDs.at(i), mSpriteColors.at(i));
}
}
}
-
- Being::setGender(gender);
}
void Player::setHairStyle(int style, int color)
@@ -151,20 +138,12 @@ void Player::setHairStyle(int style, int color)
"#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;
+ setSprite(HAIR_SPRITE, style * -1, colors[color]);
setAction(mAction);
}
-void Player::setVisibleEquipment(int slot, int id)
+void Player::setSprite(int slot, int id, std::string color)
{
// id = 0 means unequip
if (id == 0)
@@ -175,7 +154,7 @@ void Player::setVisibleEquipment(int slot, int id)
else
{
AnimatedSprite *equipmentSprite = AnimatedSprite::load(
- "graphics/sprites/" + ItemDB::get(id).getSprite(mGender));
+ "graphics/sprites/" + ItemDB::get(id).getSprite(mGender) + "|" + color);
if (equipmentSprite)
equipmentSprite->setDirection(getSpriteDirection());
@@ -191,5 +170,5 @@ void Player::setVisibleEquipment(int slot, int id)
setAction(mAction);
}
- Being::setVisibleEquipment(slot, id);
+ Being::setSprite(slot, id, color);
}