diff options
author | Ira Rice <irarice@gmail.com> | 2009-01-15 19:48:00 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-15 19:48:00 -0700 |
commit | 0a18932056e2a72f41cdd14c831344ad80cfb35b (patch) | |
tree | 9b3592df7749831be8d3e8bd5a8c04f6d1217c90 /src/being.cpp | |
parent | 731dcee8bec7e32d576b0e6a9d98b9a21050362e (diff) | |
download | mana-0a18932056e2a72f41cdd14c831344ad80cfb35b.tar.gz mana-0a18932056e2a72f41cdd14c831344ad80cfb35b.tar.bz2 mana-0a18932056e2a72f41cdd14c831344ad80cfb35b.tar.xz mana-0a18932056e2a72f41cdd14c831344ad80cfb35b.zip |
Added emote database, which is loosely based off of the NPC database.
Also changed all emotes to be animated sprites now, and to load from
emotes.xml. This gives us a bit more flexibility to not only add more
emotes in the future, but allowing them to be animated as well.
NOTE: This commit, unlike the previous emote commits, breaks emotes if
you don't have the xml file. This will be available on Aethyra soon, but
is not rolled into an update at the moment.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/being.cpp b/src/being.cpp index 69da1182..883344d8 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -35,6 +35,7 @@ #include "sound.h" #include "text.h" +#include "resources/emotedb.h" #include "resources/imageset.h" #include "resources/itemdb.h" #include "resources/iteminfo.h" @@ -50,7 +51,7 @@ int Being::instances = 0; int Being::mNumberOfHairstyles = 1; -ImageSet *Being::emotionSet = NULL; +std::vector<AnimatedSprite*> Being::emotionSet; static const int X_SPEECH_OFFSET = 18; static const int Y_SPEECH_OFFSET = 60; @@ -87,10 +88,18 @@ Being::Being(int id, int job, Map *map): if (instances == 0) { - // Load the emotion set - ResourceManager *rm = ResourceManager::getInstance(); - emotionSet = rm->getImageSet("graphics/sprites/emotions.png", 30, 32); - if (!emotionSet) logger->error(_("Unable to load emotions")); + // Setup emote sprites + for (int i = 0; i <= EmoteDB::getLast(); i++) + { + EmoteInfo info = EmoteDB::get(i); + + if (info.sprites != EmoteDB::getUnknown().sprites) + { + std::string file = "graphics/sprites/" + info.sprites.front()->sprite; + int variant = info.sprites.front()->variant; + emotionSet.push_back(AnimatedSprite::load(file, variant)); + } + } // Hairstyles are encoded as negative numbers. Count how far negative we can go. int hairstyles = 1; @@ -117,8 +126,7 @@ Being::~Being() if (instances == 0) { - emotionSet->decRef(); - emotionSet = NULL; + delete_all(emotionSet); } delete mSpeechBubble; @@ -448,8 +456,8 @@ void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY) const int py = mPy + offsetY - 60; const int emotionIndex = mEmotion - 1; - if (emotionIndex >= 0 && emotionIndex < (int) emotionSet->size()) - graphics->drawImage(emotionSet->get(emotionIndex), px, py); + if (emotionIndex >= 0 && emotionIndex < EmoteDB::getLast()) + emotionSet[emotionIndex]->draw(graphics, px, py); } void Being::drawSpeech(Graphics *graphics, int offsetX, int offsetY) |