summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-14 22:13:04 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-14 22:13:04 +0300
commit41f47b3b0a9e0350b4955d4c05845eeca5143663 (patch)
treed89a0651d83f1de32b4ecd371f524b8dc902fe49 /src/gui
parentd0b0c1c8bbb8ce9fbf93887ed7dae5f779d17a21 (diff)
downloadplus-41f47b3b0a9e0350b4955d4c05845eeca5143663.tar.gz
plus-41f47b3b0a9e0350b4955d4c05845eeca5143663.tar.bz2
plus-41f47b3b0a9e0350b4955d4c05845eeca5143663.tar.xz
plus-41f47b3b0a9e0350b4955d4c05845eeca5143663.zip
add icons into tabs in chat emotes window.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/emotewindow.cpp38
-rw-r--r--src/gui/emotewindow.h2
-rw-r--r--src/gui/theme.cpp13
3 files changed, 41 insertions, 12 deletions
diff --git a/src/gui/emotewindow.cpp b/src/gui/emotewindow.cpp
index f0b9f905f..848c9db34 100644
--- a/src/gui/emotewindow.cpp
+++ b/src/gui/emotewindow.cpp
@@ -35,6 +35,8 @@
#include "utils/gettext.h"
+#include "resources/imageset.h"
+
#include <guichan/font.hpp>
#include "debug.h"
@@ -59,7 +61,8 @@ EmoteWindow::EmoteWindow() :
mScrollColorPage(new ScrollArea(mColorPage, false, "emotepage.xml")),
mFontModel(new NamesModel),
mFontPage(new ListBox(this, mFontModel, "")),
- mScrollFontPage(new ScrollArea(mFontPage, false, "fontpage.xml"))
+ mScrollFontPage(new ScrollArea(mFontPage, false, "fontpage.xml")),
+ mImageSet(Theme::getImageSetFromThemeXml("emotetabs.xml", "", 17, 16))
{
setShowTitle(false);
setResizable(true);
@@ -85,12 +88,28 @@ EmoteWindow::EmoteWindow() :
mFontModel->fillFromArray(&fontSizeList[0], fontSizeListSize);
mFontPage->setCenter(true);
- // TRANSLATORS: emotes tab name
- mTabs->addTab(_("Emotes"), mEmotePage);
- // TRANSLATORS: emotes tab name
- mTabs->addTab(_("Colors"), mScrollColorPage);
- // TRANSLATORS: emotes tab name
- mTabs->addTab(_("Fonts"), mScrollFontPage);
+ if (mImageSet && mImageSet->size() >= 3)
+ {
+ for (int f = 0; f < 3; f ++)
+ {
+ Image *const image = mImageSet->get(f);
+ if (image)
+ image->incRef();
+ }
+
+ mTabs->addTab(mImageSet->get(0), mEmotePage);
+ mTabs->addTab(mImageSet->get(1), mScrollColorPage);
+ mTabs->addTab(mImageSet->get(2), mScrollFontPage);
+ }
+ else
+ {
+ // TRANSLATORS: emotes tab name
+ mTabs->addTab(_("Emotes"), mEmotePage);
+ // TRANSLATORS: emotes tab name
+ mTabs->addTab(_("Colors"), mScrollColorPage);
+ // TRANSLATORS: emotes tab name
+ mTabs->addTab(_("Fonts"), mScrollFontPage);
+ }
mEmotePage->setActionEventId("emote");
mColorPage->setActionEventId("color");
@@ -115,6 +134,11 @@ EmoteWindow::~EmoteWindow()
mFontModel = nullptr;
delete mScrollFontPage;
mScrollFontPage = nullptr;
+ if (mImageSet)
+ {
+ mImageSet->decRef();
+ mImageSet = nullptr;
+ }
}
void EmoteWindow::show()
diff --git a/src/gui/emotewindow.h b/src/gui/emotewindow.h
index db83b8b39..f65636e1a 100644
--- a/src/gui/emotewindow.h
+++ b/src/gui/emotewindow.h
@@ -28,6 +28,7 @@
class ColorModel;
class ColorPage;
class EmotePage;
+class ImageSet;
class ListBox;
class NamesModel;
class ScrollArea;
@@ -71,6 +72,7 @@ class EmoteWindow final : public Window
NamesModel *mFontModel;
ListBox *mFontPage;
ScrollArea *mScrollFontPage;
+ ImageSet *mImageSet;
};
extern EmoteWindow *emoteWindow;
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index f117563b5..36841b53d 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -1205,11 +1205,14 @@ ImageSet *Theme::getImageSetFromThemeXml(const std::string &name,
if (rect.grid[0])
{
Image *const image = rect.grid[0];
-
- ResourceManager *const resman = ResourceManager::getInstance();
- ImageSet *const imageSet = resman->getSubImageSet(image, w, h);
- theme->unload(skin);
- return imageSet;
+ const SDL_Rect &rect = image->mBounds;
+ if (rect.w && rect.h)
+ {
+ ResourceManager *const resman = ResourceManager::getInstance();
+ ImageSet *const imageSet = resman->getSubImageSet(image, w, h);
+ theme->unload(skin);
+ return imageSet;
+ }
}
theme->unload(skin);
}