summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-16 14:14:29 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-16 14:14:29 +0300
commit46087564d4184b28740b0c45c1bac199ab1942ec (patch)
tree0591b36aba2ae392eb569828930f030850cbc769
parentcf9b1182f06b1336f0d1071c267ea36c990430fa (diff)
downloadmanaplus-46087564d4184b28740b0c45c1bac199ab1942ec.tar.gz
manaplus-46087564d4184b28740b0c45c1bac199ab1942ec.tar.bz2
manaplus-46087564d4184b28740b0c45c1bac199ab1942ec.tar.xz
manaplus-46087564d4184b28740b0c45c1bac199ab1942ec.zip
Improve theme usage.
Removed instance method.
-rw-r--r--src/client.cpp12
-rw-r--r--src/gui/gui.cpp3
-rw-r--r--src/gui/theme.cpp34
-rw-r--r--src/gui/theme.h20
-rw-r--r--src/gui/widgets/browserbox.cpp2
-rw-r--r--src/gui/widgets/button.cpp12
-rw-r--r--src/gui/widgets/checkbox.cpp10
-rw-r--r--src/gui/widgets/desktop.cpp5
-rw-r--r--src/gui/widgets/dropdown.cpp17
-rw-r--r--src/gui/widgets/itemcontainer.cpp7
-rw-r--r--src/gui/widgets/label.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp7
-rw-r--r--src/gui/widgets/playerbox.cpp1
-rw-r--r--src/gui/widgets/popup.cpp2
-rw-r--r--src/gui/widgets/progressbar.cpp4
-rw-r--r--src/gui/widgets/radiobutton.cpp4
-rw-r--r--src/gui/widgets/scrollarea.cpp11
-rw-r--r--src/gui/widgets/slider.cpp5
-rw-r--r--src/gui/widgets/tabs/tab.cpp6
-rw-r--r--src/gui/widgets/textfield.cpp4
-rw-r--r--src/gui/widgets/textpreview.cpp2
-rw-r--r--src/gui/widgets/window.cpp4
-rw-r--r--src/gui/windowmenu.cpp4
-rw-r--r--src/gui/windows/equipmentwindow.cpp2
-rw-r--r--src/text.cpp4
-rw-r--r--src/touchmanager.cpp2
26 files changed, 70 insertions, 116 deletions
diff --git a/src/client.cpp b/src/client.cpp
index d8cd1f6f2..24a10574e 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -399,6 +399,7 @@ void Client::gameInit()
initTitle();
+ theme = new Theme;
Theme::selectSkin();
touchManager.init();
@@ -998,8 +999,7 @@ int Client::gameExec()
mumbleManager = new MumbleManager();
#endif
- if (Theme::instance())
- mSkin = Theme::instance()->load("windowmenu.xml", "");
+ mSkin = theme->load("windowmenu.xml", "");
if (mSkin)
{
mButtonPadding = mSkin->getPadding();
@@ -1256,7 +1256,7 @@ int Client::gameExec()
{
// Don't allow an alpha opacity
// lower than the default value
- Theme::instance()->setMinimumOpacity(0.8F);
+ theme->setMinimumOpacity(0.8F);
mCurrentDialog = new ServerDialog(&mCurrentServer,
mConfigDir);
@@ -1298,7 +1298,7 @@ int Client::gameExec()
logger->log1("State: LOGIN");
// Don't allow an alpha opacity
// lower than the default value
- Theme::instance()->setMinimumOpacity(0.8F);
+ theme->setMinimumOpacity(0.8F);
loginData.updateType
= serverConfig.getValue("updateType", 1);
@@ -1505,7 +1505,7 @@ int Client::gameExec()
logger->log1("State: CHAR SELECT");
// Don't allow an alpha opacity
// lower than the default value
- Theme::instance()->setMinimumOpacity(0.8F);
+ theme->setMinimumOpacity(0.8F);
mCurrentDialog = new CharSelectDialog(&loginData);
mCurrentDialog->postInit();
@@ -1571,7 +1571,7 @@ int Client::gameExec()
soundManager.fadeOutMusic(1000);
// Allow any alpha opacity
- Theme::instance()->setMinimumOpacity(-1.0F);
+ theme->setMinimumOpacity(-1.0F);
if (chatLogger)
chatLogger->setServerName(mServerName);
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index deed890ae..b17ae3ba8 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -316,7 +316,8 @@ Gui::~Gui()
delete guiInput;
guiInput = nullptr;
- Theme::deleteInstance();
+ delete theme;
+ theme = nullptr;
if (Widget::widgetExists(mTop))
setTop(nullptr);
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 1a504f680..a3603d0e9 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -46,7 +46,7 @@ std::string Theme::mThemePath;
std::string Theme::mThemeName;
std::string Theme::mScreenDensity;
-Theme *Theme::mInstance = nullptr;
+Theme *theme = nullptr;
// Set the theme path...
static void initDefaultThemePath()
@@ -245,27 +245,13 @@ Theme::~Theme()
delete_all(mProgressColors);
}
-Theme *Theme::instance()
-{
- if (!mInstance)
- mInstance = new Theme;
-
- return mInstance;
-}
-
-void Theme::deleteInstance()
-{
- delete mInstance;
- mInstance = nullptr;
-}
-
Color Theme::getProgressColor(const int type, const float progress)
{
int color[3] = {0, 0, 0};
- if (mInstance)
+ if (theme)
{
- const DyePalette *const dye = mInstance->mProgressColors[type];
+ const DyePalette *const dye = theme->mProgressColors[type];
if (dye)
dye->getColor(progress, color);
@@ -639,8 +625,8 @@ bool Theme::tryThemePath(const std::string &themeName)
{
mThemePath = path;
mThemeName = themeName;
- if (instance())
- instance()->loadColors("");
+ if (theme)
+ theme->loadColors("");
return true;
}
}
@@ -703,7 +689,7 @@ void Theme::prepareThemePath()
if (mThemePath.empty())
mThemePath = "graphics/gui";
- instance()->loadColors(mThemePath);
+ theme->loadColors(mThemePath);
logger->log("Selected Theme: " + mThemePath);
}
@@ -1191,7 +1177,9 @@ void Theme::unloadRect(const ImageRect &rect, const int start,
Image *Theme::getImageFromThemeXml(const std::string &name,
const std::string &name2)
{
- Theme *const theme = Theme::instance();
+ if (!theme)
+ return nullptr;
+
Skin *const skin = theme->load(name, name2, false);
if (skin)
{
@@ -1212,7 +1200,9 @@ ImageSet *Theme::getImageSetFromThemeXml(const std::string &name,
const std::string &name2,
const int w, const int h)
{
- Theme *const theme = Theme::instance();
+ if (!theme)
+ return nullptr;
+
Skin *const skin = theme->load(name, name2, false);
if (skin)
{
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 86543ea64..5f902e206 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -40,9 +40,12 @@
class DyePalette;
class Image;
class ImageSet;
+class Theme;
const int THEME_PALETTES = 5;
+extern Theme *theme;
+
struct ThemeInfo final
{
ThemeInfo() :
@@ -176,11 +179,11 @@ class Skin final
class Theme final : public Palette, public ConfigListener
{
public:
- A_DELETE_COPY(Theme)
+ Theme();
- static Theme *instance() A_WARN_UNUSED;
+ ~Theme();
- static void deleteInstance();
+ A_DELETE_COPY(Theme)
static void prepareThemePath();
@@ -453,15 +456,15 @@ class Theme final : public Palette, public ConfigListener
inline static const Color &getThemeColor(const int type,
const int alpha = 255)
A_WARN_UNUSED
- { return mInstance->getColor(type, alpha); }
+ { return theme->getColor(type, alpha); }
static const Color &getThemeCharColor(const signed char c,
bool &valid) A_WARN_UNUSED
- { return mInstance->getCharColor(c, valid); }
+ { return theme->getCharColor(c, valid); }
static int getThemeIdByChar(const signed char c,
bool &valid) A_WARN_UNUSED
- { return mInstance->getIdByChar(c, valid); }
+ { return theme->getIdByChar(c, valid); }
static Color getProgressColor(const int type,
const float progress) A_WARN_UNUSED;
@@ -513,10 +516,6 @@ class Theme final : public Palette, public ConfigListener
static ThemeInfo *loadInfo(const std::string &themeName) A_WARN_UNUSED;
private:
- Theme();
-
- ~Theme();
-
Skin *readSkin(const std::string &filename0,
const bool full) A_WARN_UNUSED;
@@ -529,7 +528,6 @@ class Theme final : public Palette, public ConfigListener
static std::string mThemePath;
static std::string mThemeName;
static std::string mScreenDensity;
- static Theme *mInstance;
static bool tryThemePath(const std::string &themePath) A_WARN_UNUSED;
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 25f821905..010d3d9f3 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -88,7 +88,6 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
mBackgroundColor = getThemeColor(Theme::BACKGROUND);
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load(skin, "browserbox.xml");
if (mInstances == 0)
@@ -140,7 +139,6 @@ BrowserBox::~BrowserBox()
if (gui)
gui->removeDragged(this);
- Theme *const theme = Theme::instance();
if (theme)
{
theme->unload(mSkin);
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 308c75413..8ac4251cf 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -337,13 +337,10 @@ void Button::init()
if (mInstances == 0)
{
- if (Theme::instance())
+ if (theme)
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
- {
- button[mode] = Theme::instance()->load(
- data[mode], "button.xml");
- }
+ button[mode] = theme->load(data[mode], "button.xml");
}
updateAlpha();
@@ -359,9 +356,8 @@ Button::~Button()
mInstances--;
- if (mInstances == 0 && Theme::instance())
+ if (mInstances == 0 && theme)
{
- Theme *const theme = Theme::instance();
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
theme->unload(button[mode]);
}
@@ -420,7 +416,7 @@ void Button::loadImageSet(const std::string &imageName)
void Button::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index f01495bcf..c44c88980 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -106,9 +106,9 @@ CheckBox::CheckBox(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(Theme::CHECKBOX_OUTLINE);
if (instances == 0)
{
- if (Theme::instance())
+ if (theme)
{
- mSkin = Theme::instance()->load("checkbox.xml", "");
+ mSkin = theme->load("checkbox.xml", "");
updateAlpha();
}
}
@@ -142,8 +142,8 @@ CheckBox::~CheckBox()
if (instances == 0)
{
- if (Theme::instance())
- Theme::instance()->unload(mSkin);
+ if (theme)
+ theme->unload(mSkin);
}
}
@@ -162,7 +162,7 @@ void CheckBox::draw(Graphics *const graphics)
void CheckBox::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 0ff1b17c9..6ae892c81 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -51,7 +51,6 @@ Desktop::Desktop(const Widget2 *const widget) :
Wallpaper::loadWallpapers();
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load("desktop.xml", "");
@@ -80,8 +79,8 @@ Desktop::~Desktop()
mWallpaper->decRef();
mWallpaper = nullptr;
}
- if (Theme::instance())
- Theme::instance()->unload(mSkin);
+ if (theme)
+ theme->unload(mSkin);
}
void Desktop::postInit()
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index b1a3c4ac1..53f4a623b 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -85,13 +85,12 @@ DropDown::DropDown(const Widget2 *const widget,
mPopup->setHeight(100);
// Initialize graphics
- if (instances == 0)
+ if (instances == 0 && theme)
{
// Load the background skin
for (int i = 0; i < 2; i ++)
{
- Skin *const skin = Theme::instance()->load(
- dropdownFiles[i], "dropdown.xml");
+ Skin *const skin = theme->load(dropdownFiles[i], "dropdown.xml");
if (skin)
{
if (!i)
@@ -111,7 +110,7 @@ DropDown::DropDown(const Widget2 *const widget,
}
}
if (i)
- Theme::instance()->unload(skin);
+ theme->unload(skin);
}
else
{
@@ -121,11 +120,8 @@ DropDown::DropDown(const Widget2 *const widget,
}
// get the border skin
- if (Theme::instance())
- {
- Theme::instance()->loadRect(skinRect,
- "dropdown_background.xml", "");
- }
+ if (theme)
+ theme->loadRect(skinRect, "dropdown_background.xml", "");
}
instances++;
@@ -181,7 +177,6 @@ DropDown::~DropDown()
buttons[f][i]->decRef();
}
}
- Theme *const theme = Theme::instance();
if (theme)
{
theme->unload(mSkin);
@@ -193,7 +188,7 @@ DropDown::~DropDown()
void DropDown::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index fe666e6f7..ecabc226f 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -168,8 +168,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
mName(),
mItemPopup(new ItemPopup),
mShowMatrix(nullptr),
- mSkin(Theme::instance() ? Theme::instance()->load(
- "itemcontainer.xml", "") : nullptr),
+ mSkin(theme ? theme->load("itemcontainer.xml", "") : nullptr),
mEquipedColor(getThemeColor(Theme::ITEM_EQUIPPED)),
mEquipedColor2(getThemeColor(Theme::ITEM_EQUIPPED_OUTLINE)),
mUnEquipedColor(getThemeColor(Theme::ITEM_NOT_EQUIPPED)),
@@ -215,8 +214,8 @@ ItemContainer::~ItemContainer()
mProtectedImg = nullptr;
}
- if (Theme::instance())
- Theme::instance()->unload(mSkin);
+ if (theme)
+ theme->unload(mSkin);
delete mItemPopup;
mItemPopup = nullptr;
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index b500ec7bb..7318fc3d1 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -105,7 +105,6 @@ Label::~Label()
mInstances --;
if (mInstances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
}
@@ -117,7 +116,6 @@ void Label::init()
mForegroundColor2 = getThemeColor(Theme::LABEL_OUTLINE);
if (mInstances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load("label.xml", "");
}
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 6f0c192c6..f2a23253e 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -111,7 +111,6 @@ ListBox::ListBox(const Widget2 *const widget,
mForegroundColor = getThemeColor(Theme::LISTBOX);
mForegroundColor2 = getThemeColor(Theme::LISTBOX_OUTLINE);
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load(skin, "listbox.xml");
@@ -138,14 +137,14 @@ ListBox::~ListBox()
if (gui)
gui->removeDragged(this);
- if (Theme::instance())
- Theme::instance()->unload(mSkin);
+ if (theme)
+ theme->unload(mSkin);
}
void ListBox::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
mAlpha = alpha;
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 2ba452620..6f68f8689 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -86,7 +86,6 @@ void PlayerBox::init(std::string name, std::string selectedName)
setFrameSize(2);
addMouseListener(this);
- Theme *const theme = Theme::instance();
if (theme)
{
if (name.empty())
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 1114b4a5e..a8bcec4ea 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -51,7 +51,6 @@ Popup::Popup(const std::string &name,
if (skin == "")
skin = "popup.xml";
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->load(skin, "popup.xml");
@@ -78,7 +77,6 @@ Popup::~Popup()
if (mSkin)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
mSkin = nullptr;
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 5bccd61ca..e2ff95228 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -70,7 +70,6 @@ ProgressBar::ProgressBar(const Widget2 *const widget,
addWidgetListener(this);
setSize(width, height);
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->load(skin, "progressbar.xml");
@@ -94,7 +93,6 @@ ProgressBar::~ProgressBar()
gui->removeDragged(this);
mInstances--;
- Theme *const theme = Theme::instance();
if (mSkin)
{
if (theme)
@@ -142,7 +140,7 @@ void ProgressBar::logic()
void ProgressBar::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
mAlpha = alpha;
}
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 411216455..4841ececb 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -110,7 +110,6 @@ RadioButton::RadioButton(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(Theme::RADIOBUTTON_OUTLINE);
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->load("radio.xml", "");
@@ -142,7 +141,6 @@ RadioButton::~RadioButton()
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
}
@@ -151,7 +149,7 @@ RadioButton::~RadioButton()
void RadioButton::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 47b8b0985..571297ace 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -195,7 +195,6 @@ void ScrollArea::init(std::string skinName)
// +++ here probably need move background from static
if (skinName == "")
skinName = "scroll_background.xml";
- Theme *const theme = Theme::instance();
if (theme)
{
theme->loadRect(background, skinName, "scroll_background.xml");
@@ -207,8 +206,9 @@ void ScrollArea::init(std::string skinName)
for (int i = 0; i < 2; i ++)
{
- Skin *const skin = Theme::instance()->load(
- buttonFiles[i], "scrollbuttons.xml");
+ Skin *skin = nullptr;
+ if (theme)
+ skin = theme->load(buttonFiles[i], "scrollbuttons.xml");
if (skin)
{
const ImageRect &rect = skin->getBorder();
@@ -230,7 +230,8 @@ void ScrollArea::init(std::string skinName)
for (int f = UP; f < BUTTONS_DIR; f ++)
buttons[f][i] = nullptr;
}
- Theme::instance()->unload(skin);
+ if (theme)
+ theme->unload(skin);
}
}
mScrollbarWidth = mScrollbarSize;
@@ -290,7 +291,7 @@ void ScrollArea::logic()
void ScrollArea::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 700d31416..c9ea9e6c2 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -133,7 +133,7 @@ Slider::~Slider()
delete mVertexes;
mVertexes = nullptr;
mInstances--;
- if (mInstances == 0 && Theme::instance())
+ if (mInstances == 0)
{
for (int mode = 0; mode < 2; mode ++)
Theme::unloadRect(buttons[mode]);
@@ -153,7 +153,6 @@ void Slider::init()
// Load resources
if (mInstances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
{
for (int mode = 0; mode < 2; mode ++)
@@ -171,7 +170,7 @@ void Slider::init()
void Slider::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index ede69619e..1e5733a2b 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -123,9 +123,8 @@ Tab::~Tab()
gui->removeDragged(this);
mInstances--;
- if (mInstances == 0 && Theme::instance())
+ if (mInstances == 0 && theme)
{
- Theme *const theme = Theme::instance();
for (int mode = 0; mode < TAB_COUNT; mode ++)
theme->unload(tabImg[mode]);
}
@@ -154,7 +153,6 @@ void Tab::init()
if (mInstances == 0)
{
// Load the skin
- Theme *const theme = Theme::instance();
if (theme)
{
for (int mode = 0; mode < TAB_COUNT; mode ++)
@@ -177,7 +175,7 @@ void Tab::init()
void Tab::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 7fe8c1bf3..0a1caa0e5 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -125,7 +125,6 @@ TextField::TextField(const Widget2 *restrict const widget,
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->loadSkinRect(skin, "textfield.xml",
@@ -160,7 +159,6 @@ TextField::~TextField()
instances--;
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
{
theme->unload(mSkin);
@@ -172,7 +170,7 @@ TextField::~TextField()
void TextField::updateAlpha()
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 10bd936c6..45e71b800 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -50,7 +50,6 @@ TextPreview::TextPreview(const Widget2 *const widget,
{
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
mSkin = theme->load("textpreview.xml", "");
}
@@ -72,7 +71,6 @@ TextPreview::~TextPreview()
if (instances == 0)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 5a636013b..dda03a438 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -155,7 +155,6 @@ Window::Window(const std::string &caption, const bool modal,
int childPalette = 1;
// Loads the skin
- Theme *const theme = Theme::instance();
if (theme)
{
mSkin = theme->load(skin, "window.xml");
@@ -236,7 +235,6 @@ Window::~Window()
if (mSkin)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
mSkin = nullptr;
@@ -1207,7 +1205,7 @@ bool Window::isResizeAllowed(const MouseEvent &event) const
int Window::getGuiAlpha() const
{
const float alpha = std::max(client->getGuiAlpha(),
- Theme::instance()->getMinimumOpacity());
+ theme->getMinimumOpacity());
return static_cast<int>(alpha * 255.0F);
}
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 795f2ad5a..03d4d15a8 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -46,8 +46,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
ActionListener(),
SelectionListener(),
MouseListener(),
- mSkin(Theme::instance() ? Theme::instance()->load("windowmenu.xml", "")
- : nullptr),
+ mSkin(theme ? theme->load("windowmenu.xml", "") : nullptr),
mPadding(mSkin ? mSkin->getPadding() : 1),
mSpacing(mSkin ? mSkin->getOption("spacing", 3) : 3),
mTextPopup(new TextPopup),
@@ -196,7 +195,6 @@ WindowMenu::~WindowMenu()
mButtonTexts.clear();
if (mSkin)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
mSkin = nullptr;
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index c45595dff..3799015e5 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -122,7 +122,7 @@ void EquipmentWindow::postInit()
mUnequip->setEnabled(false);
ImageRect rect;
- Theme::instance()->loadRect(rect, "equipment_background.xml", "", 0, 1);
+ theme->loadRect(rect, "equipment_background.xml", "", 0, 1);
mSlotBackground = rect.grid[0];
mSlotHighlightedBackground = rect.grid[1];
add(mPlayerBox);
diff --git a/src/text.cpp b/src/text.cpp
index 27d794d33..caf5328d6 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -55,9 +55,9 @@ Text::Text(const std::string &text, const int x, const int y,
if (!textManager)
{
textManager = new TextManager;
- if (Theme::instance())
+ if (theme)
{
- Theme::instance()->loadRect(mBubble, "bubble.xml", "");
+ theme->loadRect(mBubble, "bubble.xml", "");
}
else
{
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index b1ed41fdc..b9681c337 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -122,7 +122,6 @@ void TouchManager::loadTouchItem(TouchItem **item, const std::string &name,
const TouchFuncPtr fOut)
{
*item = nullptr;
- Theme *const theme = Theme::instance();
if (!theme)
return;
ImageRect *images = new ImageRect;
@@ -394,7 +393,6 @@ void TouchManager::loadPad()
void TouchManager::loadButtons()
{
const int sz = (mButtonsSize + 1) * 50;
- Theme *const theme = Theme::instance();
if (!theme)
return;
Skin *const skin = theme->load("dbutton.xml", "");