summaryrefslogtreecommitdiff
path: root/src/resources/iteminfo.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-04 16:29:14 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-04 20:20:52 +0100
commit5c7f9d1d216fd1edca231ed274ac3077cb34909f (patch)
tree234405f8f9d0b422a02d8cc44854aaa6992cf2d9 /src/resources/iteminfo.cpp
parentd5ebad4e74da011777f9ba1a13fbb37d18c827b9 (diff)
downloadmana-5c7f9d1d216fd1edca231ed274ac3077cb34909f.tar.gz
mana-5c7f9d1d216fd1edca231ed274ac3077cb34909f.tar.bz2
mana-5c7f9d1d216fd1edca231ed274ac3077cb34909f.tar.xz
mana-5c7f9d1d216fd1edca231ed274ac3077cb34909f.zip
Fixed character display
This change fixes hair style to take into account "race", which makes the faces visible again. Hair colors should also be fixed now, with partial support for itemcolors.xml added. The Mana client now also supports per-character gender, and it now hides the hair style and color buttons on character creation, when there are none to choose from. Closes #43
Diffstat (limited to 'src/resources/iteminfo.cpp')
-rw-r--r--src/resources/iteminfo.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 9e7fd6b7..b3208777 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -24,21 +24,22 @@
#include "resources/itemdb.h"
#include "configuration.h"
-const std::string &ItemInfo::getSprite(Gender gender) const
+const std::string &ItemInfo::getSprite(Gender gender, int race) const
{
if (mView)
{
// Forward the request to the item defining how to view this item
- return itemDb->get(mView).getSprite(gender);
+ return itemDb->get(mView).getSprite(gender, race);
}
- else
- {
- static const std::string empty;
- auto i =
- mAnimationFiles.find(gender);
- return (i != mAnimationFiles.end()) ? i->second : empty;
- }
+ auto i = mAnimationFiles.find(static_cast<int>(gender) + race * 4);
+
+ // Fall back to ignoring race
+ if (race != 0 && i == mAnimationFiles.end())
+ i = mAnimationFiles.find(static_cast<int>(gender));
+
+ static const std::string empty;
+ return i != mAnimationFiles.end() ? i->second : empty;
}
void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename)
@@ -49,8 +50,11 @@ void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename)
const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
{
static const std::string empty;
- std::map< EquipmentSoundEvent, std::vector<std::string> >::const_iterator i;
- i = mSounds.find(event);
-
+ auto i = mSounds.find(event);
return i == mSounds.end() ? empty : i->second[rand() % i->second.size()];
}
+
+void ItemInfo::setSprite(const std::string &animationFile, Gender gender, int race)
+{
+ mAnimationFiles[static_cast<int>(gender) + race * 4] = animationFile;
+}