summaryrefslogtreecommitdiff
path: root/src/gui/theme.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-11 20:05:44 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-11 20:05:44 +0200
commitabde0f51b3062c158fb52e9dfff23d21d3be03d1 (patch)
tree4af561ea9e8cd3f7f981cce9817cf57f3e353787 /src/gui/theme.cpp
parent93e1a2a9e5f379945a6efb24598319b605be1dfa (diff)
downloadmana-abde0f51b3062c158fb52e9dfff23d21d3be03d1.tar.gz
mana-abde0f51b3062c158fb52e9dfff23d21d3be03d1.tar.bz2
mana-abde0f51b3062c158fb52e9dfff23d21d3be03d1.tar.xz
mana-abde0f51b3062c158fb52e9dfff23d21d3be03d1.zip
Made the different hard-coded paths and files be now taken from the
data/paths.xml configuration file. Also added default gui theme path in branding and default wallpaper path and file searched respectively in the branding and paths.xml files. Hard-coded values are still used as fallbacks. Resolves: Manasource Mantis #148. Reviewed-by: jaxad0127.
Diffstat (limited to 'src/gui/theme.cpp')
-rw-r--r--src/gui/theme.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index e46616e0..12de1f91 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -40,11 +40,22 @@
#include <algorithm>
-#define GUI_ROOT "graphics/gui/"
-
+static std::string defaultThemePath;
std::string Theme::mThemePath;
Theme *Theme::mInstance = 0;
+// Set the theme path...
+static void initDefaultThemePath()
+{
+ ResourceManager *resman = ResourceManager::getInstance();
+ defaultThemePath = branding.getValue("guiThemePath", "");
+
+ if (!defaultThemePath.empty() && resman->isDirectory(defaultThemePath))
+ return;
+ else
+ defaultThemePath = "graphics/gui/";
+}
+
Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
const std::string &filePath,
const std::string &name):
@@ -55,8 +66,7 @@ Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
mCloseImage(close),
mStickyImageUp(stickyUp),
mStickyImageDown(stickyDown)
-{
-}
+{}
Skin::~Skin()
{
@@ -99,6 +109,8 @@ Theme::Theme():
mMinimumOpacity(-1.0f),
mProgressColors(ProgressColors(THEME_PROG_END))
{
+ initDefaultThemePath();
+
config.addListener("guialpha", this);
loadColors();
@@ -313,7 +325,7 @@ bool Theme::tryThemePath(std::string themePath)
{
if (!themePath.empty())
{
- themePath = GUI_ROOT + themePath;
+ themePath = defaultThemePath + themePath;
if (PHYSFS_exists(themePath.c_str()))
{
mThemePath = themePath;
@@ -331,7 +343,7 @@ void Theme::prepareThemePath()
// Try theme from branding
if (!tryThemePath(branding.getValue("theme", "")))
// Use default
- mThemePath = GUI_ROOT;
+ mThemePath = defaultThemePath;
instance()->loadColors(mThemePath);
}
@@ -356,7 +368,7 @@ std::string Theme::resolveThemePath(const std::string &path)
return getThemePath() + "/" + path;
// Backup
- return std::string(GUI_ROOT) + "/" + path;
+ return std::string(defaultThemePath) + "/" + path;
}
Image *Theme::getImageFromTheme(const std::string &path)
@@ -508,11 +520,11 @@ static int readProgressType(const std::string &type)
void Theme::loadColors(std::string file)
{
- if (file == GUI_ROOT)
+ if (file == defaultThemePath)
return; // No need to reload
if (file == "")
- file = GUI_ROOT;
+ file = defaultThemePath;
file += "/colors.xml";