[Scummvm-cvs-logs] SF.net SVN: scummvm:[33488] scummvm/branches/gsoc2008-gui

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Fri Aug 1 12:18:48 CEST 2008


Revision: 33488
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33488&view=rev
Author:   Tanoku
Date:     2008-08-01 10:18:47 +0000 (Fri, 01 Aug 2008)

Log Message:
-----------
Support for XML layout with unspecified keys.
XML Layout parsing. WIP.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
    scummvm/branches/gsoc2008-gui/common/xmlparser.h
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.h

Modified: scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/common/xmlparser.cpp	2008-08-01 10:12:02 UTC (rev 33487)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.cpp	2008-08-01 10:18:47 UTC (rev 33488)
@@ -112,7 +112,7 @@
 			return parserError("Missing required property '%s' inside key '%s'", i->name.c_str(), key->name.c_str());
 	}
 	
-	if (localMap.empty() == false)
+	if (key->layout.anyProps == false && localMap.empty() == false)
 		return parserError("Unhandled property inside key '%s': '%s'", key->name.c_str(), localMap.begin()->_key.c_str());
 
 	// check if any of the parents must be ignored.

Modified: scummvm/branches/gsoc2008-gui/common/xmlparser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/common/xmlparser.h	2008-08-01 10:12:02 UTC (rev 33487)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.h	2008-08-01 10:18:47 UTC (rev 33488)
@@ -108,6 +108,10 @@
 	contained children keys, using the XML_KEY() macro again.
 	The scope of a XML key is closed with the KEY_END() macro.
 	
+	Keys which may contain any kind of Property names may be defined with the
+	XML_PROP_ANY() macro instead of the XML_PROP() macro. This macro takes no
+	arguments.
+	
 	As an example, the following XML layout:
 	
 		XML_KEY(palette)
@@ -178,6 +182,7 @@
 	
 #define XML_KEY(keyName) {\
 		lay = new XMLKeyLayout; \
+		lay->anyProps = false; \
 		lay->custom = new kLocalParserName::CustomParserCallback; \
 		((kLocalParserName::CustomParserCallback*)(lay->custom))->callback = (&kLocalParserName::parserCallback_##keyName); \
 		layout.top()->children[#keyName] = lay; \
@@ -189,6 +194,9 @@
 		prop.name = #propName; \
 		prop.required = req; \
 		layout.top()->properties.push_back(prop); }\
+		
+#define XML_PROP_ANY() {\
+		layout.top()->anyProps = true; }
 	
 #define CUSTOM_XML_PARSER(parserName) \
 	protected: \
@@ -291,6 +299,7 @@
 		};
 		
 		Common::List<XMLKeyProperty> properties;
+		bool anyProps;
 		ChildMap children;
 		
 		~XMLKeyLayout() {

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-08-01 10:12:02 UTC (rev 33487)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-08-01 10:18:47 UTC (rev 33488)
@@ -446,7 +446,6 @@
 
 bool ThemeParser::parserCallback_widget(ParserNode *node) {
 	Common::String var;
-	int width, height, x, y, paddingL, paddingR, paddingT, paddingB;
 	
 	if (getParentNode(node)->name == "globals")
 		var = "Globals." + node->values["name"] + ".";
@@ -455,25 +454,38 @@
 	else 
 		assert(!"Corruption in XML parser.");
 	
+	if (!parseCommonLayoutProps(node, var))
+		return parserError("Error when parsing Layout properties of '%s'.", var.c_str());
+	
+	return true;
+}
+
+bool ThemeParser::parseCommonLayoutProps(ParserNode *node, const Common::String &var) {
 	if (node->values.contains("size")) {
+		int width, height;
+		
 		if (!parseIntegerKey(node->values["size"].c_str(), 2, &width, &height))
-			return parserError("Invalid definition for '%sSize'.", var.c_str());
+			return false;
 		
 		_theme->themeEval()->setVar(var + "Width", width);
 		_theme->themeEval()->setVar(var + "Height", height);
 	}
 	
 	if (node->values.contains("pos")) {
+		int x, y;
+		
 		if (!parseIntegerKey(node->values["pos"].c_str(), 2, &x, &y))
-			return parserError("Invalid definition for '%sPosition'.", var.c_str());
+			return false;
 		
 		_theme->themeEval()->setVar(var + "X", x);
 		_theme->themeEval()->setVar(var + "Y", y);
 	}
 	
 	if (node->values.contains("padding")) {
+		int paddingL, paddingR, paddingT, paddingB;
+		
 		if (!parseIntegerKey(node->values["padding"].c_str(), 4, &paddingL, &paddingR, &paddingT, &paddingB))
-			return parserError("Invalid definition for '%sPadding'.", var.c_str());
+			return false;
 		
 		_theme->themeEval()->setVar(var + "Padding.Left", paddingL);
 		_theme->themeEval()->setVar(var + "Padding.Right", paddingR);

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	2008-08-01 10:12:02 UTC (rev 33487)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	2008-08-01 10:18:47 UTC (rev 33488)
@@ -468,6 +468,7 @@
 	Graphics::DrawStep *newDrawStep();
 	Graphics::DrawStep *defaultDrawStep();
 	bool parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawstep, bool functionSpecific);
+	bool parseCommonLayoutProps(ParserNode *node, const Common::String &var);
 
 	Graphics::DrawStep *_defaultStepGlobal;
 	Graphics::DrawStep *_defaultStepLocal;


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