summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
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);
}