diff options
author | Max Horn | 2008-11-04 19:49:26 +0000 |
---|---|---|
committer | Max Horn | 2008-11-04 19:49:26 +0000 |
commit | 817d2078cca738af631380467a42b2e87e9c1d57 (patch) | |
tree | 51930b792b91e6eb763f57a24d5f8eed1f652941 /gui | |
parent | 61aadb378d654425d55b8cf9f91df4283b46de7e (diff) | |
download | scummvm-rg350-817d2078cca738af631380467a42b2e87e9c1d57.tar.gz scummvm-rg350-817d2078cca738af631380467a42b2e87e9c1d57.tar.bz2 scummvm-rg350-817d2078cca738af631380467a42b2e87e9c1d57.zip |
Some cleanup / handle the case where the themepath is neither pointing to a dir nor to a .zip file
svn-id: r34897
Diffstat (limited to 'gui')
-rw-r--r-- | gui/ThemeEngine.cpp | 21 | ||||
-rw-r--r-- | gui/ThemeEngine.h | 4 |
2 files changed, 15 insertions, 10 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index df3f3af4f4..cbcd32fd4c 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -487,18 +487,19 @@ bool ThemeEngine::addDrawData(const Common::String &data, bool cached) { /********************************************************** * Theme XML loading *********************************************************/ -bool ThemeEngine::loadTheme(Common::String fileName) { +bool ThemeEngine::loadTheme(const Common::String &fileName) { unloadTheme(); - if (fileName != "builtin") + bool tryAgain = false; + if (fileName != "builtin") { ImageMan.addArchive(fileName); + if (!loadThemeXML(fileName)) { + warning("Could not parse custom theme '%s'. Falling back to default theme", fileName.c_str()); + tryAgain = true; // Fall back to default builtin theme + } + } - if (fileName == "builtin") { - if (!loadDefaultXML()) - error("Could not load default embedded theme"); - } else if (!loadThemeXML(fileName)) { - warning("Could not parse custom theme '%s'. Falling back to default theme", fileName.c_str()); - + if (fileName == "builtin" || tryAgain) { if (!loadDefaultXML()) // if we can't load the embedded theme, this is a complete failure error("Could not load default embedded theme"); } @@ -571,9 +572,13 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeName) { #endif } else if (node.isDirectory()) { + warning("Don't know how to open theme '%s'", themeName.c_str()); archive = new Common::FSDirectory(node); } + if (!archive) + return false; + Common::File themercFile; // FIXME: Possibly dereferencing a NULL pointer here if the node's // name doesn't have a ".zip" suffix and the node is not a directory. diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index f164b8831c..0b054c53f5 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -476,8 +476,8 @@ public: return _initOk && _themeOk; } - /** Custom implementation of the GUI::Theme API, changed to use the XML parser. */ - bool loadTheme(Common::String themeName); + /** Load the them from the file with the specified name. */ + bool loadTheme(const Common::String &fileName); /** * Changes the active graphics mode of the GUI; may be used to either |