[Scummvm-cvs-logs] SF.net SVN: scummvm: [32792] scummvm/branches/gsoc2008-gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Thu Jun 26 00:30:28 CEST 2008
Revision: 32792
http://scummvm.svn.sourceforge.net/scummvm/?rev=32792&view=rev
Author: Tanoku
Date: 2008-06-25 15:30:28 -0700 (Wed, 25 Jun 2008)
Log Message:
-----------
- XMLParser: Improved file stream support
- InterfaceManager: Config file loading/parsing added.
- ThemeParser: Fixed GCC warnings/various bugs.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
scummvm/branches/gsoc2008-gui/common/xmlparser.h
scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h
scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
Modified: scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/common/xmlparser.cpp 2008-06-25 22:13:18 UTC (rev 32791)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.cpp 2008-06-25 22:30:28 UTC (rev 32792)
@@ -148,6 +148,9 @@
bool XMLParser::parse() {
+ if (_text.ready() == false)
+ return parserError("XML stream not ready for reading.");
+
bool activeClosure = false;
bool selfClosure = false;
Modified: scummvm/branches/gsoc2008-gui/common/xmlparser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/common/xmlparser.h 2008-06-25 22:13:18 UTC (rev 32791)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.h 2008-06-25 22:30:28 UTC (rev 32792)
@@ -70,6 +70,10 @@
delete _stream;
_stream = s;
}
+
+ bool ready() {
+ return _stream != 0;
+ }
};
/**
@@ -116,7 +120,7 @@
int depth;
};
- virtual bool loadFile(const char *filename) {
+ virtual bool loadFile(Common::String filename) {
Common::File *f = new Common::File;
if (!f->open(filename, Common::File::kFileReadMode))
Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp 2008-06-25 22:13:18 UTC (rev 32791)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp 2008-06-25 22:30:28 UTC (rev 32792)
@@ -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 @@
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 @@
_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;
}
Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h 2008-06-25 22:13:18 UTC (rev 32791)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.h 2008-06-25 22:30:28 UTC (rev 32792)
@@ -33,6 +33,7 @@
#include "graphics/surface.h"
#include "graphics/fontman.h"
+#include "gui/ThemeParser.h"
#include "graphics/VectorRenderer.h"
namespace GUI {
@@ -143,6 +144,7 @@
~InterfaceManager() {
freeRenderer();
freeScreen();
+ delete _parser;
}
void setGraphicsMode(Graphics_Mode mode);
@@ -180,9 +182,21 @@
void addDrawStep(Common::String &drawDataId, Graphics::DrawStep *step);
bool addDrawData(DrawData data_id, bool cached);
+ ThemeParser *parser() {
+ return _parser;
+ }
+
+ bool ready() {
+ return _initOk && _themeOk;
+ }
+
+ bool loadTheme(Common::String &themeName);
+
protected:
template<typename PixelType> void screenInit();
+ bool loadThemeXML(Common::String &themeName);
+
void freeRenderer() {
delete _vectorRenderer;
_vectorRenderer = 0;
@@ -205,6 +219,7 @@
OSystem *_system;
Graphics::VectorRenderer *_vectorRenderer;
Graphics::Surface *_screen;
+ GUI::ThemeParser *_parser;
int _bytesPerPixel;
Graphics_Mode _graphicsMode;
@@ -215,17 +230,16 @@
WidgetDrawData *_widgets[kDrawDataMAX];
bool _initOk;
+ bool _themeOk;
bool _caching;
};
struct WidgetDrawData {
- Common::Rect _realSize;
- bool _scaled;
-
Common::Array<Graphics::DrawStep*> _steps;
bool _cached;
Graphics::Surface *_surfaceCache;
+ uint32 _cachedW, _cachedH;
InterfaceManager::DrawData _type;
};
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-06-25 22:13:18 UTC (rev 32791)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-06-25 22:30:28 UTC (rev 32792)
@@ -237,7 +237,7 @@
else if (val == "right")
drawstep->extraData = VectorRenderer::kTriangleRight;
else
- return parserError("'%s' is not a valid value for triangle orientation.", stepNode->values["orientation"].c_str());
+ return parserError("'%s' is not a valid value for triangle orientation.", val.c_str());
}
}
@@ -289,7 +289,7 @@
InterfaceManager::DrawData id = g_InterfaceManager.getDrawDataId(drawdataNode->values["id"]);
if (id == -1)
- return parserError("%d is not a valid DrawData set identifier.", drawdataNode->values["id"].c_str());
+ return parserError("%s is not a valid DrawData set identifier.", drawdataNode->values["id"].c_str());
if (drawdataNode->values.contains("cached") && drawdataNode->values["cached"] == "true") {
cached = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list