aboutsummaryrefslogtreecommitdiff
path: root/gui/InterfaceManager.cpp
diff options
context:
space:
mode:
authorVicent Marti2008-06-25 22:30:28 +0000
committerVicent Marti2008-06-25 22:30:28 +0000
commit73d5715a799f393e8b2611f2deff1b7f90f6130a (patch)
tree4e35f7a6d984a5f3879c9dab9350a25f399c3fe5 /gui/InterfaceManager.cpp
parent7fd6b3916fce8a61b2235ad720bd7fa7b40a7914 (diff)
downloadscummvm-rg350-73d5715a799f393e8b2611f2deff1b7f90f6130a.tar.gz
scummvm-rg350-73d5715a799f393e8b2611f2deff1b7f90f6130a.tar.bz2
scummvm-rg350-73d5715a799f393e8b2611f2deff1b7f90f6130a.zip
- XMLParser: Improved file stream support
- InterfaceManager: Config file loading/parsing added. - ThemeParser: Fixed GCC warnings/various bugs. svn-id: r32792
Diffstat (limited to 'gui/InterfaceManager.cpp')
-rw-r--r--gui/InterfaceManager.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp
index 5ee3a014ed..0afb71bfd5 100644
--- a/gui/InterfaceManager.cpp
+++ b/gui/InterfaceManager.cpp
@@ -28,6 +28,7 @@
#include "graphics/colormasks.h"
#include "common/system.h"
#include "common/events.h"
+#include "common/config-manager.h"
#include "gui/InterfaceManager.h"
#include "graphics/VectorRenderer.h"
@@ -69,8 +70,9 @@ const char *InterfaceManager::kDrawDataStrings[] = {
InterfaceManager::InterfaceManager() :
_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled),
- _screen(0), _bytesPerPixel(0) {
+ _screen(0), _bytesPerPixel(0), _initOk(false), _themeOk(false) {
_system = g_system;
+ _parser = new ThemeParser();
for (int i = 0; i < kDrawDataMAX; ++i) {
_widgets[i] = 0;
@@ -126,11 +128,50 @@ bool InterfaceManager::addDrawData(DrawData data_id, bool cached) {
_widgets[data_id] = new WidgetDrawData;
_widgets[data_id]->_cached = cached;
_widgets[data_id]->_type = data_id;
- _widgets[data_id]->_scaled = false;
return true;
}
+bool InterfaceManager::loadTheme(Common::String &themeName) {
+ if (!loadThemeXML(themeName)) {
+ warning("Could not parse custom theme '%s'.", themeName.c_str());
+ return false;
+ }
+
+ for (int i = 0; i < kDrawDataMAX; ++i) {
+ if (_widgets[i] == 0) {
+#ifdef REQUIRE_ALL_DD_SETS
+ warning("Error when parsing custom theme '%s': Missing data assets.", themeName.c_str());
+ return false;
+#endif
+ } else if (_widgets[i]->_cached) {
+ // draw the cached widget to the cache surface
+ }
+ }
+
+ _themeOk = true;
+ return true;
+}
+
+bool InterfaceManager::loadThemeXML(Common::String &themeName) {
+ assert(_parser);
+
+ if (ConfMan.hasKey("themepath"))
+ Common::File::addDefaultDirectory(ConfMan.get("themepath"));
+
+#ifdef DATA_PATH
+ Common::File::addDefaultDirectoryRecursive(DATA_PATH);
+#endif
+
+ if (ConfMan.hasKey("extrapath"))
+ Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
+
+ if (!parser()->loadFile(themeName + ".xml"))
+ return false;
+
+ return parser()->parse();
+}
+
bool InterfaceManager::init() {
return false;
}