From abde0f51b3062c158fb52e9dfff23d21d3be03d1 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Sun, 11 Jul 2010 20:05:44 +0200 Subject: 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. --- src/gui/theme.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/gui/theme.cpp') 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 -#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"; -- cgit v1.2.3-70-g09d2