[Scummvm-cvs-logs] SF.net SVN: scummvm:[33494] scummvm/branches/gsoc2008-gui/gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Fri Aug 1 17:45:02 CEST 2008
Revision: 33494
http://scummvm.svn.sourceforge.net/scummvm/?rev=33494&view=rev
Author: Tanoku
Date: 2008-08-01 15:45:02 +0000 (Fri, 01 Aug 2008)
Log Message:
-----------
Theme Layout parsing, WIP.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeEval.h
scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp 2008-08-01 14:28:22 UTC (rev 33493)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp 2008-08-01 15:45:02 UTC (rev 33494)
@@ -169,13 +169,23 @@
"<widget name = 'Console' padding = '7, 5, 5, 5' />"
"<widget name = 'TabWidget'>"
- "<child name = 'Tab' size = '75, 27' />"
+ "<child name = 'Tab' size = '75, 27' padding = '0, 0, 8, 0' />"
"<child name = 'NavButton' size = '15, 18' padding = '0, 3, 4, 0' />"
"</widget>"
"</globals>"
- "<dialog name = 'GlobalOptions'>"
- "<widget name = 'scrollbar' />"
+ "<dialog name = 'Launcher'>"
+ "<widget name = 'Version' pos = 'center, 21' size = '247, Globals.Line.Height' />"
+ "<widget name = 'Logo' pos = 'center, 5' size = '283, 80' />"
+ "<widget name = 'GameList' pos = 'Globals.Inset.X, Globals.Inset.Y' size = 'Globals.Inset.Width, Globals.Inset.Height' />"
+
+ "<widget name = 'StartButton' size = 'Globals.Button.Width, Globals.Button.Height' />"
+ "<widget name = 'AddGameButton' size = 'Globals.Button.Width, Globals.Button.Height' />"
+ "<widget name = 'EditGameButton' size = 'Globals.Button.Width, Globals.Button.Height' />"
+ "<widget name = 'RemoveGameButton' size = 'Globals.Button.Width, Globals.Button.Height' />"
+ "<widget name = 'OptionsButton' size = 'Globals.Button.Width, Globals.Button.Height' />"
+ "<widget name = 'AboutButton' size = 'Globals.Button.Width, Globals.Button.Height' />"
+ "<widget name = 'QuittButton' size = 'Globals.Button.Width, Globals.Button.Height' />"
"</dialog>"
"</layout_info>";
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeEval.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeEval.h 2008-08-01 14:28:22 UTC (rev 33493)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeEval.h 2008-08-01 15:45:02 UTC (rev 33494)
@@ -62,6 +62,8 @@
void setVar(const String &name, int val) { _vars[name] = val; }
+ bool hasVar(const Common::String &name) { return _vars.contains(name); }
+
void debugPrint() {
printf("Debug variable list:\n");
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-08-01 14:28:22 UTC (rev 33493)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-08-01 15:45:02 UTC (rev 33494)
@@ -460,12 +460,65 @@
return true;
}
+bool ThemeParser::parserCallback_child(ParserNode *node) {
+ Common::String var = "Globals." + getParentNode(node)->values["name"] + "." + node->values["name"] + ".";
+
+ if (!parseCommonLayoutProps(node, var))
+ return parserError("Error when parsing Layout properties of '%s'.", var.c_str());
+
+ return true;
+}
+
+bool ThemeParser::parserCallback_dialog(ParserNode *node) {
+ Common::String var = "Dialog." + node->values["name"] + ".";
+
+ 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 false;
+ if (!parseIntegerKey(node->values["size"].c_str(), 2, &width, &height)) {
+ Common::StringTokenizer tokenizer(node->values["size"], " ,");
+ Common::String wtoken, htoken;
+ char *parseEnd;
+
+ wtoken = tokenizer.nextToken();
+
+ if (_theme->themeEval()->hasVar(wtoken)) {
+ width = _theme->themeEval()->getVar(wtoken);
+ } else {
+ width = strtol(wtoken.c_str(), &parseEnd, 10);
+
+ if (*parseEnd != 0 && !(*parseEnd == '%' && *(parseEnd + 1) == 0))
+ return false;
+
+ if (wtoken.lastChar() == '%')
+ width = g_system->getOverlayWidth() * width / 100;
+ }
+
+ htoken = tokenizer.nextToken();
+
+ if (_theme->themeEval()->hasVar(htoken)) {
+ height = _theme->themeEval()->getVar(htoken);
+ } else {
+ height = strtol(htoken.c_str(), &parseEnd, 10);
+
+ if (*parseEnd != 0 && !(*parseEnd == '%' && *(parseEnd + 1) == 0))
+ return false;
+
+ if (htoken.lastChar() == '%')
+ height = g_system->getOverlayHeight() * height / 100;
+ }
+
+ if (!tokenizer.empty())
+ return false;
+ }
+
_theme->themeEval()->setVar(var + "Width", width);
_theme->themeEval()->setVar(var + "Height", height);
@@ -474,8 +527,54 @@
if (node->values.contains("pos")) {
int x, y;
- if (!parseIntegerKey(node->values["pos"].c_str(), 2, &x, &y))
- return false;
+ if (!parseIntegerKey(node->values["pos"].c_str(), 2, &x, &y)) {
+ Common::StringTokenizer tokenizer(node->values["pos"], " ,");
+ Common::String xpos, ypos;
+ char *parseEnd;
+
+ xpos = tokenizer.nextToken();
+
+ if (xpos == "center") {
+ if (!_theme->themeEval()->hasVar(var + "Width"))
+ return false;
+
+ x = (g_system->getOverlayWidth() / 2) - (_theme->themeEval()->getVar(var + "Width") / 2);
+
+ } else if (_theme->themeEval()->hasVar(xpos)) {
+ x = _theme->themeEval()->getVar(xpos);
+ } else {
+ x = strtol(xpos.c_str(), &parseEnd, 10);
+
+ if (*parseEnd != 0 && !(*parseEnd == 'r' && *(parseEnd + 1) == 0))
+ return false;
+
+ if (xpos.lastChar() == 'r')
+ x = g_system->getOverlayWidth() - x;
+ }
+
+ ypos = tokenizer.nextToken();
+
+ if (ypos == "center") {
+ if (!_theme->themeEval()->hasVar(var + "Height"))
+ return false;
+
+ y = (g_system->getOverlayHeight() / 2) - (_theme->themeEval()->getVar(var + "Height") / 2);
+
+ } else if (_theme->themeEval()->hasVar(ypos)) {
+ y = _theme->themeEval()->getVar(ypos);
+ } else {
+ y = strtol(ypos.c_str(), &parseEnd, 10);
+
+ if (*parseEnd != 0 && !(*parseEnd == 'b' && *(parseEnd + 1) == 0))
+ return false;
+
+ if (ypos.lastChar() == 'b')
+ y = g_system->getOverlayHeight() - y;
+ }
+
+ if (!tokenizer.empty())
+ return false;
+ }
_theme->themeEval()->setVar(var + "X", x);
_theme->themeEval()->setVar(var + "Y", y);
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.h 2008-08-01 14:28:22 UTC (rev 33493)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.h 2008-08-01 15:45:02 UTC (rev 33494)
@@ -312,7 +312,7 @@
class ThemeParser : public XMLParser {
typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const DrawStep &);
-
+
public:
ThemeParser(GUI::ThemeRenderer *parent);
@@ -460,8 +460,8 @@
bool parserCallback_globals(ParserNode *node) { return true; }
bool parserCallback_def(ParserNode *node);
bool parserCallback_widget(ParserNode *node);
- bool parserCallback_dialog(ParserNode *node) { return true; }
- bool parserCallback_child(ParserNode *node) { return true; }
+ bool parserCallback_dialog(ParserNode *node);
+ bool parserCallback_child(ParserNode *node);
void cleanup();
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