~ubuntu-branches/ubuntu/trusty/manaplus/trusty-proposed

« back to all changes in this revision

Viewing changes to src/gui/widgets/emotepage.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-09-17 10:35:51 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130917103551-az7p3nz9jgxwqjfn
Tags: 1.3.9.15-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "gui/widgets/emotepage.h"
22
22
 
 
23
#include "graphicsvertexes.h"
 
24
 
23
25
#include "resources/imageset.h"
24
26
#include "resources/resourcemanager.h"
25
27
 
34
36
EmotePage::EmotePage(const Widget2 *const widget) :
35
37
    gcn::Widget(),
36
38
    Widget2(widget),
 
39
    gcn::MouseListener(),
 
40
    gcn::WidgetListener(),
37
41
    mEmotes(ResourceManager::getInstance()->getImageSet(
38
42
        "graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)),
39
 
    mSelectedIndex(-1)
 
43
    mVertexes(new ImageCollection),
 
44
    mSelectedIndex(-1),
 
45
    mRedraw(true)
40
46
{
41
47
    addMouseListener(this);
 
48
    addWidgetListener(this);
42
49
}
43
50
 
44
51
EmotePage::~EmotePage()
48
55
        mEmotes->decRef();
49
56
        mEmotes = nullptr;
50
57
    }
 
58
    delete mVertexes;
 
59
    mVertexes = nullptr;
51
60
}
52
61
 
53
62
void EmotePage::draw(gcn::Graphics *graphics)
64
73
    unsigned int x = 0;
65
74
    unsigned int y = 0;
66
75
 
67
 
    FOR_EACH (std::vector<Image*>::const_iterator, it, images)
68
 
    {
69
 
        const Image *const image = *it;
70
 
        if (image)
71
 
        {
72
 
            g->drawImage(image, x, y);
73
 
            x += emoteWidth;
74
 
            if (x + emoteWidth > width)
75
 
            {
76
 
                x = 0;
77
 
                y += emoteHeight;
 
76
    if (openGLMode != RENDER_SAFE_OPENGL)
 
77
    {
 
78
        if (mRedraw)
 
79
        {
 
80
            mRedraw = false;
 
81
            mVertexes->clear();
 
82
            FOR_EACH (std::vector<Image*>::const_iterator, it, images)
 
83
            {
 
84
                const Image *const image = *it;
 
85
                if (image)
 
86
                {
 
87
                    g->calcTile(mVertexes, image, x, y);
 
88
                    x += emoteWidth;
 
89
                    if (x + emoteWidth > width)
 
90
                    {
 
91
                        x = 0;
 
92
                        y += emoteHeight;
 
93
                    }
 
94
                }
 
95
            }
 
96
        }
 
97
        g->drawTile(mVertexes);
 
98
    }
 
99
    else
 
100
    {
 
101
        FOR_EACH (std::vector<Image*>::const_iterator, it, images)
 
102
        {
 
103
            const Image *const image = *it;
 
104
            if (image)
 
105
            {
 
106
                g->drawImage(image, x, y);
 
107
                x += emoteWidth;
 
108
                if (x + emoteWidth > width)
 
109
                {
 
110
                    x = 0;
 
111
                    y += emoteHeight;
 
112
                }
78
113
            }
79
114
        }
80
115
    }
104
139
{
105
140
    mSelectedIndex = -1;
106
141
}
 
142
 
 
143
void EmotePage::widgetResized(const gcn::Event &event A_UNUSED)
 
144
{
 
145
    mRedraw = true;
 
146
}
 
147
 
 
148
void EmotePage::widgetMoved(const gcn::Event &event A_UNUSED)
 
149
{
 
150
    mRedraw = true;
 
151
}