From 0a18932056e2a72f41cdd14c831344ad80cfb35b Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 15 Jan 2009 19:48:00 -0700 Subject: 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 --- src/gui/emotecontainer.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/gui/emotecontainer.cpp') diff --git a/src/gui/emotecontainer.cpp b/src/gui/emotecontainer.cpp index c3e20c41..691211ca 100644 --- a/src/gui/emotecontainer.cpp +++ b/src/gui/emotecontainer.cpp @@ -25,14 +25,17 @@ #include "emotecontainer.h" #include "emoteshortcut.h" +#include "../animatedsprite.h" #include "../configuration.h" #include "../graphics.h" #include "../log.h" +#include "../resources/emotedb.h" #include "../resources/image.h" #include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" +#include "../utils/dtor.h" #include "../utils/gettext.h" #include "../utils/tostring.h" @@ -46,15 +49,25 @@ EmoteContainer::EmoteContainer(): { ResourceManager *resman = ResourceManager::getInstance(); - mEmoteImg = resman->getImageSet("graphics/sprites/emotions.png", 30, 32); - if (!mEmoteImg) 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; + mEmoteImg.push_back(AnimatedSprite::load(file, variant)); + } + } mSelImg = resman->getImage("graphics/gui/selection.png"); if (!mSelImg) logger->error(_("Unable to load selection.png")); mSelImg->setAlpha(config.getValue("guialpha", 0.8)); - mMaxEmote = mEmoteImg->size(); + mMaxEmote = EmoteDB::getLast() + 1; addMouseListener(this); addWidgetListener(this); @@ -62,11 +75,8 @@ EmoteContainer::EmoteContainer(): EmoteContainer::~EmoteContainer() { - if (mEmoteImg) - { - mEmoteImg->decRef(); - mEmoteImg = NULL; - } + delete_all(mEmoteImg); + if (!mSelImg) { mSelImg->decRef(); @@ -90,8 +100,7 @@ void EmoteContainer::draw(gcn::Graphics *graphics) int emoteY = ((i) / columns) * gridHeight; // Draw emote icon - static_cast(graphics)->drawImage( - mEmoteImg->get(i), emoteX, emoteY); + mEmoteImg[i]->draw(static_cast(graphics), emoteX, emoteY); // Draw selection image below selected item if (mSelectedEmoteIndex == i) -- cgit v1.2.3-70-g09d2