summaryrefslogtreecommitdiff
path: root/src/gui/emoteshortcutcontainer.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-15 19:48:00 -0700
committerIra Rice <irarice@gmail.com>2009-01-15 19:48:00 -0700
commit0a18932056e2a72f41cdd14c831344ad80cfb35b (patch)
tree9b3592df7749831be8d3e8bd5a8c04f6d1217c90 /src/gui/emoteshortcutcontainer.cpp
parent731dcee8bec7e32d576b0e6a9d98b9a21050362e (diff)
downloadmana-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/gui/emoteshortcutcontainer.cpp')
-rw-r--r--src/gui/emoteshortcutcontainer.cpp42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/gui/emoteshortcutcontainer.cpp b/src/gui/emoteshortcutcontainer.cpp
index de9f8bab..edaa8602 100644
--- a/src/gui/emoteshortcutcontainer.cpp
+++ b/src/gui/emoteshortcutcontainer.cpp
@@ -21,6 +21,7 @@
#include "emoteshortcutcontainer.h"
+#include "../animatedsprite.h"
#include "../emoteshortcut.h"
#include "../graphics.h"
#include "../inventory.h"
@@ -30,12 +31,16 @@
#include "../localplayer.h"
#include "../log.h"
+#include "../resources/emotedb.h"
#include "../resources/image.h"
#include "../resources/resourcemanager.h"
+#include "../utils/dtor.h"
#include "../utils/gettext.h"
#include "../utils/tostring.h"
+static const int MAX_ITEMS = 12;
+
EmoteShortcutContainer::EmoteShortcutContainer():
mEmoteClicked(false),
mEmoteMoved(0)
@@ -48,10 +53,21 @@ EmoteShortcutContainer::EmoteShortcutContainer():
ResourceManager *resman = ResourceManager::getInstance();
mBackgroundImg = resman->getImage("graphics/gui/item_shortcut_bgr.png");
- mEmoteImg = resman->getImageSet("graphics/sprites/emotions.png", 30, 32);
- if (!mEmoteImg) logger->error(_("Unable to load emotions"));
- mMaxItems = emoteShortcut->getEmoteCount();
+ // 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));
+ }
+ }
+
+ mMaxItems = MAX_ITEMS;
mBoxHeight = mBackgroundImg->getHeight();
mBoxWidth = mBackgroundImg->getWidth();
@@ -60,11 +76,8 @@ EmoteShortcutContainer::EmoteShortcutContainer():
EmoteShortcutContainer::~EmoteShortcutContainer()
{
mBackgroundImg->decRef();
- if (mEmoteImg)
- {
- mEmoteImg->decRef();
- mEmoteImg=NULL;
- }
+
+ delete_all(mEmoteImg);
}
void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
@@ -88,21 +101,20 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
if (emoteShortcut->getEmote(i))
{
- static_cast<Graphics*>(graphics)->drawImage(
- mEmoteImg->get(emoteShortcut->getEmote(i) - 1), emoteX + 2, emoteY + 10);
+ mEmoteImg[emoteShortcut->getEmote(i) - 1]->draw(g, emoteX + 2, emoteY + 10);
}
}
if (mEmoteMoved)
{
// Draw the emote image being dragged by the cursor.
- Image* image = mEmoteImg->get(mEmoteMoved-1);
- if (image)
+ AnimatedSprite* sprite = mEmoteImg[mEmoteMoved - 1];
+ if (sprite)
{
- const int tPosX = mCursorPosX - (image->getWidth() / 2);
- const int tPosY = mCursorPosY - (image->getHeight() / 2);
+ const int tPosX = mCursorPosX - (sprite->getWidth() / 2);
+ const int tPosY = mCursorPosY - (sprite->getHeight() / 2);
- g->drawImage(image, tPosX, tPosY);
+ sprite->draw(g, tPosX, tPosY);
}
}
}