summaryrefslogtreecommitdiff
path: root/src/gui/widgets/emotepage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/emotepage.cpp')
-rw-r--r--src/gui/widgets/emotepage.cpp63
1 files changed, 54 insertions, 9 deletions
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index 0ab05b6e3..ce61a865f 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -20,6 +20,8 @@
#include "gui/widgets/emotepage.h"
+#include "graphicsvertexes.h"
+
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
@@ -34,11 +36,16 @@ namespace
EmotePage::EmotePage(const Widget2 *const widget) :
gcn::Widget(),
Widget2(widget),
+ gcn::MouseListener(),
+ gcn::WidgetListener(),
mEmotes(ResourceManager::getInstance()->getImageSet(
"graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)),
- mSelectedIndex(-1)
+ mVertexes(new ImageCollection),
+ mSelectedIndex(-1),
+ mRedraw(true)
{
addMouseListener(this);
+ addWidgetListener(this);
}
EmotePage::~EmotePage()
@@ -48,6 +55,8 @@ EmotePage::~EmotePage()
mEmotes->decRef();
mEmotes = nullptr;
}
+ delete mVertexes;
+ mVertexes = nullptr;
}
void EmotePage::draw(gcn::Graphics *graphics)
@@ -64,17 +73,43 @@ void EmotePage::draw(gcn::Graphics *graphics)
unsigned int x = 0;
unsigned int y = 0;
- FOR_EACH (std::vector<Image*>::const_iterator, it, images)
+ if (openGLMode != RENDER_SAFE_OPENGL)
+ {
+ if (mRedraw)
+ {
+ mRedraw = false;
+ mVertexes->clear();
+ FOR_EACH (std::vector<Image*>::const_iterator, it, images)
+ {
+ const Image *const image = *it;
+ if (image)
+ {
+ g->calcTile(mVertexes, image, x, y);
+ x += emoteWidth;
+ if (x + emoteWidth > width)
+ {
+ x = 0;
+ y += emoteHeight;
+ }
+ }
+ }
+ }
+ g->drawTile(mVertexes);
+ }
+ else
{
- const Image *const image = *it;
- if (image)
+ FOR_EACH (std::vector<Image*>::const_iterator, it, images)
{
- g->drawImage(image, x, y);
- x += emoteWidth;
- if (x + emoteWidth > width)
+ const Image *const image = *it;
+ if (image)
{
- x = 0;
- y += emoteHeight;
+ g->drawImage(image, x, y);
+ x += emoteWidth;
+ if (x + emoteWidth > width)
+ {
+ x = 0;
+ y += emoteHeight;
+ }
}
}
}
@@ -104,3 +139,13 @@ void EmotePage::resetAction()
{
mSelectedIndex = -1;
}
+
+void EmotePage::widgetResized(const gcn::Event &event A_UNUSED)
+{
+ mRedraw = true;
+}
+
+void EmotePage::widgetMoved(const gcn::Event &event A_UNUSED)
+{
+ mRedraw = true;
+}