summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/emotepage.cpp63
-rw-r--r--src/gui/widgets/emotepage.h10
2 files changed, 63 insertions, 10 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;
+}
diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h
index 0c2582318..f553fa750 100644
--- a/src/gui/widgets/emotepage.h
+++ b/src/gui/widgets/emotepage.h
@@ -25,12 +25,14 @@
#include <guichan/mouselistener.hpp>
#include <guichan/widget.hpp>
+#include <guichan/widgetlistener.hpp>
#include "localconsts.h"
class EmotePage final : public gcn::Widget,
public Widget2,
- public gcn::MouseListener
+ public gcn::MouseListener,
+ public gcn::WidgetListener
{
public:
explicit EmotePage(const Widget2 *const widget);
@@ -45,6 +47,10 @@ class EmotePage final : public gcn::Widget,
int getIndexFromGrid(const int x, const int y) const;
+ void widgetResized(const gcn::Event &event A_UNUSED);
+
+ void widgetMoved(const gcn::Event &event A_UNUSED);
+
void resetAction();
int getSelectedIndex()
@@ -52,7 +58,9 @@ class EmotePage final : public gcn::Widget,
private:
ImageSet *mEmotes;
+ ImageCollection *mVertexes;
int mSelectedIndex;
+ bool mRedraw;
};
#endif // GUI_WIDGETS_EMOTEPAGE_H