summaryrefslogtreecommitdiff
path: root/src/gui/theme.cpp
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 /src/gui/theme.cpp
parentcf9b1182f06b1336f0d1071c267ea36c990430fa (diff)
downloadManaVerse-46087564d4184b28740b0c45c1bac199ab1942ec.tar.gz
ManaVerse-46087564d4184b28740b0c45c1bac199ab1942ec.tar.bz2
ManaVerse-46087564d4184b28740b0c45c1bac199ab1942ec.tar.xz
ManaVerse-46087564d4184b28740b0c45c1bac199ab1942ec.zip
Improve theme usage.
Removed instance method.
Diffstat (limited to 'src/gui/theme.cpp')
-rw-r--r--src/gui/theme.cpp34
1 files changed, 12 insertions, 22 deletions
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)
{