diff options
Diffstat (limited to 'src/gui/theme.cpp')
-rw-r--r-- | src/gui/theme.cpp | 30 |
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"; |