diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-02-18 19:17:57 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-02-18 19:17:57 +0000 |
commit | 8f28636093d75b33cc5071e659291ac2ff54db8b (patch) | |
tree | 3a14a0f1f3993f12bf54990c417d5858acdf6de0 /src/player.cpp | |
parent | 9a4006a58aa332855fa6e3c143de915cae2e952b (diff) | |
download | mana-8f28636093d75b33cc5071e659291ac2ff54db8b.tar.gz mana-8f28636093d75b33cc5071e659291ac2ff54db8b.tar.bz2 mana-8f28636093d75b33cc5071e659291ac2ff54db8b.tar.xz mana-8f28636093d75b33cc5071e659291ac2ff54db8b.zip |
Merged revisions 3762-3772,3776-3782 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/branches/0.0
........
r3762 | crush_tmw | 2007-12-04 00:25:25 +0100 (Tue, 04 Dec 2007) | 1 line
Added/renamed some headgears for the christmas event.
........
r3763 | crush_tmw | 2007-12-04 14:51:20 +0100 (Tue, 04 Dec 2007) | 1 line
tophead -> tophat
........
r3764 | b_lindeijer | 2007-12-05 21:20:25 +0100 (Wed, 05 Dec 2007) | 3 lines
Fix drawing of very high fringe tiles by keeping track of the maximum tile
height.
........
r3765 | crush_tmw | 2007-12-07 01:50:15 +0100 (Fri, 07 Dec 2007) | 1 line
Added a new drop item for the christmas event.
........
r3768 | crush_tmw | 2007-12-09 20:45:53 +0100 (Sun, 09 Dec 2007) | 1 line
New versions of funky hat and elf hat by QOAL.
........
r3769 | crush_tmw | 2007-12-10 03:22:59 +0100 (Mon, 10 Dec 2007) | 1 line
Simplified player subsprite handling by treating equipment, hairstyle and base sprites alike. Implementing female hairstyles is now a purely content-sided task.
........
r3770 | crush_tmw | 2007-12-10 03:50:15 +0100 (Mon, 10 Dec 2007) | 1 line
Added an option to show log messages in the chat console.
........
r3771 | crush_tmw | 2007-12-10 17:12:56 +0100 (Mon, 10 Dec 2007) | 1 line
Implemented female hairstyles.
........
r3772 | b_lindeijer | 2007-12-10 21:42:11 +0100 (Mon, 10 Dec 2007) | 2 lines
Include cassert header.
........
r3777 | crush_tmw | 2007-12-14 18:33:45 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed some errors with the filenames of the new items (unrelated to my eAthena problems).
........
r3778 | crush_tmw | 2007-12-14 19:21:39 +0100 (Fri, 14 Dec 2007) | 1 line
fixed some more screwups with the new items.
........
r3780 | crush_tmw | 2007-12-14 19:40:12 +0100 (Fri, 14 Dec 2007) | 1 line
Put new items in equipment.xml for backward compatibility with the last client release.
........
r3782 | b_lindeijer | 2007-12-17 16:59:04 +0100 (Mon, 17 Dec 2007) | 2 lines
Fixed the item tags.
........
Diffstat (limited to 'src/player.cpp')
-rw-r--r-- | src/player.cpp | 63 |
1 files changed, 22 insertions, 41 deletions
diff --git a/src/player.cpp b/src/player.cpp index f928aeb1..050790e8 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -37,8 +37,9 @@ Player::Player(int id, int job, Map *map): Being(id, job, map), - mEquipmentSpriteIDs(VECTOREND_SPRITE, 0), - mGender(2), mHairStyle(0), mHairColor(0) + mGender(2), + mHairStyle(0), + mHairColor(0) { } @@ -59,45 +60,31 @@ Player::drawName(Graphics *graphics, int offsetX, int offsetY) graphics->drawText(mName, px + 15, py + 30, gcn::Graphics::CENTER); } -void Player::setGender(int sex) +void Player::setGender(int gender) { // Players can only be male or female - if (sex > 1) + if (gender > 1) { - logger->log("Warning: unsupported gender %i, assuming male.", sex); - sex = 0; + logger->log("Warning: unsupported gender %i, assuming male.", gender); + gender = 0; } - if (sex != mGender) + if (gender != mGender) { - mGender = sex; + mGender = gender; - // Reload base sprite - AnimatedSprite *newBaseSprite; - if (sex == 0) - { - newBaseSprite = AnimatedSprite::load( - "graphics/sprites/player_male_base.xml"); - } - else - { - newBaseSprite = AnimatedSprite::load( - "graphics/sprites/player_female_base.xml"); - } + /* Human base sprite. When implementing different races remove this + * line and set the base sprite when setting the race of the player + * character. + */ + setSprite(Being::BASE_SPRITE, -100); - delete mSprites[BASE_SPRITE]; - mSprites[BASE_SPRITE] = newBaseSprite; - - // 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(sex)); - delete mSprites[i]; - mSprites[i] = newEqSprite; + setSprite(i, mSpriteIDs.at(i), mSpriteColors.at(i)); } } } @@ -126,19 +113,12 @@ void Player::setHairStyle(int style, int color) "#460850,611967,e7b4ae", // dark purple }; - AnimatedSprite *newHairSprite = AnimatedSprite::load - (strprintf("graphics/sprites/hairstyle%d.xml|%s", style, 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, const std::string &color) { // id = 0 means unequip if (id == 0) @@ -149,7 +129,8 @@ 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()); @@ -165,5 +146,5 @@ void Player::setVisibleEquipment(int slot, int id) setAction(mAction); } - mEquipmentSpriteIDs[slot] = id; + Being::setSprite(slot, id, color); } |