[Scummvm-cvs-logs] SF.net SVN: scummvm: [32808] scummvm/branches/gsoc2008-gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Thu Jun 26 21:54:56 CEST 2008
Revision: 32808
http://scummvm.svn.sourceforge.net/scummvm/?rev=32808&view=rev
Author: Tanoku
Date: 2008-06-26 12:54:55 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
- MILESTONE: A widget is drawn on screen loaded straight from its XML description. Yippie.
- XMLParser: Bugfixes.
- ThemeParser: Support for default color values.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
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-06-26 19:42:59 UTC (rev 32807)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.cpp 2008-06-26 19:54:55 UTC (rev 32808)
@@ -61,10 +61,12 @@
printf("%s%s%s\n", startFull ? "" : "...", endFull ? "" : "...", lineStr);
+ int cursor = MIN(_pos - lineStart, 70);
+
if (!startFull)
- lineStart -= 3;
+ cursor += 3;
- for (int i = 0; i < _pos - lineStart; ++i)
+ while (cursor--)
printf(" ");
printf("^\n");
Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp 2008-06-26 19:42:59 UTC (rev 32807)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp 2008-06-26 19:54:55 UTC (rev 32808)
@@ -261,23 +261,12 @@
_system->showOverlay();
- Graphics::DrawStep *steps = new Graphics::DrawStep[2];
-
- steps[0].gradColor1.r = 214;
- steps[0].gradColor1.g = 113;
- steps[0].gradColor1.b = 8;
- steps[0].gradColor1.set = true;
- steps[0].gradColor2.r = 240;
- steps[0].gradColor2.g = 200;
- steps[0].gradColor2.b = 25;
- steps[0].gradColor2.set = true;
- steps[0].fillMode = VectorRenderer::kFillGradient;
- steps[0].drawingCall = &VectorRenderer::drawCallback_FILLSURFACE;
-
bool running = true;
while (running) { // draw!!
- _vectorRenderer->drawStep(Common::Rect(), steps[0]);
+ drawDD(kDDMainDialogBackground, Common::Rect());
+ drawDD(kDDButtonIdle, Common::Rect(32, 32, 128, 128));
+
_vectorRenderer->copyFrame(_system);
Common::Event event;
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp 2008-06-26 19:42:59 UTC (rev 32807)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp 2008-06-26 19:54:55 UTC (rev 32808)
@@ -43,9 +43,13 @@
"<color name = 'green' rgb = '0, 255, 0' />"
"<color name = 'blue' rgb = '0, 0, 255' />"
"</palette>"
+ "<default fill = 'gradient' fg_color = '255, 255, 255' />"
"<drawdata id = 'mainmenu_bg' cache = false>"
- "<drawstep func = 'roundedsq' radius = 8 fill = 'none' color = '0, 1, 2' size = 'auto' />"
+ "<drawstep func = 'fill' fill = 'gradient' gradient_start = '214, 113, 8' gradient_end = '240, 200, 25' />"
"</drawdata>"
+ "<drawdata id = 'button_idle' cache = false>"
+ "<drawstep func = 'roundedsq' radius = '8' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' size = 'auto' />"
+ "</drawdata>"
"</render_info>";
if (!parser()->loadBuffer(defaultXML, true))
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-06-26 19:42:59 UTC (rev 32807)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp 2008-06-26 19:54:55 UTC (rev 32808)
@@ -46,6 +46,7 @@
_callbacks["color"] = &ThemeParser::parserCallback_color;
_callbacks["render_info"] = &ThemeParser::parserCallback_renderInfo;
_callbacks["layout_info"] = &ThemeParser::parserCallback_layoutInfo;
+ _callbacks["default"] = &ThemeParser::parserCallback_defaultSet;
_drawFunctions["circle"] = &Graphics::VectorRenderer::drawCallback_CIRCLE;
_drawFunctions["square"] = &Graphics::VectorRenderer::drawCallback_SQUARE;
@@ -55,6 +56,9 @@
_drawFunctions["triangle"] = &Graphics::VectorRenderer::drawCallback_TRIANGLE;
_drawFunctions["fill"] = &Graphics::VectorRenderer::drawCallback_FILLSURFACE;
_drawFunctions["void"] = &Graphics::VectorRenderer::drawCallback_VOID;
+
+ _defaultStepGlobal = defaultDrawStep();
+ _defaultStepLocal = 0;
}
bool ThemeParser::keyCallback(Common::String keyName) {
@@ -65,8 +69,7 @@
return (this->*(_callbacks[_activeKey.top()->name]))();
}
-Graphics::DrawStep *ThemeParser::newDrawStep() {
-
+Graphics::DrawStep *ThemeParser::defaultDrawStep() {
Graphics::DrawStep *step = new DrawStep;
step->fgColor.set = false;
@@ -85,6 +88,42 @@
return step;
}
+Graphics::DrawStep *ThemeParser::newDrawStep() {
+ assert(_defaultStepGlobal);
+ Graphics::DrawStep *step = new DrawStep;
+
+ if (_defaultStepLocal) {
+ memcpy(step, _defaultStepLocal, sizeof(DrawStep));
+ } else {
+ memcpy(step, _defaultStepGlobal, sizeof(DrawStep));
+ }
+
+ return step;
+}
+
+bool ThemeParser::parserCallback_defaultSet() {
+ ParserNode *defNode = getActiveNode();
+ ParserNode *parentNode = getParentNode(defNode);
+ Graphics::DrawStep *step = 0;
+
+ if (parentNode == 0)
+ return parserError("The <default> key must be contained inside <render_info> keys.");
+
+ if (parentNode->name == "render_info") {
+ step = _defaultStepGlobal;
+ } else if (parentNode->name == "drawdata") {
+ if (_defaultStepLocal == 0)
+ _defaultStepLocal = new DrawStep;
+
+ memcpy(_defaultStepLocal, _defaultStepGlobal, sizeof(DrawStep));
+ step = _defaultStepLocal;
+ } else {
+ return parserError("<default> key out of scope. Must be inside <drawdata> or <render_info> keys.");
+ }
+
+ return parseDrawStep(defNode, step, false);
+}
+
bool ThemeParser::parserCallback_renderInfo() {
ParserNode *infoNode = getActiveNode();
@@ -159,6 +198,10 @@
assert(drawdataNode->values.contains("id"));
Graphics::DrawStep *drawstep = newDrawStep();
+
+ if (!stepNode->values.contains("func"))
+ return parserError("All Draw Steps must contain a 'func' definition.");
+
Common::String functionName = stepNode->values["func"];
if (_drawFunctions.contains(functionName) == false)
@@ -166,6 +209,56 @@
drawstep->drawingCall = _drawFunctions[functionName];
+ if (!parseDrawStep(stepNode, drawstep, true))
+ return false;
+
+ g_InterfaceManager.addDrawStep(drawdataNode->values["id"], drawstep);
+ return true;
+}
+
+bool ThemeParser::parserCallback_DRAWDATA() {
+ ParserNode *drawdataNode = _activeKey.top();
+ bool cached = false;
+
+ assert(drawdataNode->name == "drawdata");
+
+ if (getParentNode(drawdataNode) == 0 || getParentNode(drawdataNode)->name != "render_info")
+ return parserError("DrawData keys must be contained inside a <render_info> section.");
+
+ if (drawdataNode->values.contains("id") == false)
+ return parserError("DrawData keys must contain an identifier.");
+
+ InterfaceManager::DrawData id = g_InterfaceManager.getDrawDataId(drawdataNode->values["id"]);
+
+ if (id == -1)
+ 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;
+ }
+
+ // Both Max and Johannes suggest using a non-platform specfic approach based on available
+ // resources and active resolution. getHostPlatformString() has been removed, so fix this.
+
+/* if (drawdataNode->values.contains("platform")) {
+ if (drawdataNode->values["platform"].compareToIgnoreCase(Common::getHostPlatformString()) != 0) {
+ drawdataNode->ignore = true;
+ return true;
+ }
+ }*/
+
+ if (g_InterfaceManager.addDrawData(id, cached) == false)
+ return parserError("Repeated DrawData: Only one set of Drawing Data for a widget may be specified on each platform.");
+
+ if (_defaultStepLocal) {
+ delete _defaultStepLocal;
+ _defaultStepLocal = 0;
+ }
+
+ return true;
+}
+
+bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawstep, bool functionSpecific) {
int red, green, blue, w, h;
Common::String val;
@@ -226,42 +319,47 @@
__PARSER_ASSIGN_RGB(gradColor1, "gradient_start");
__PARSER_ASSIGN_RGB(gradColor2, "gradient_end");
- if (functionName == "roundedsq" || functionName == "circle") {
- __PARSER_ASSIGN_INT(radius, "radius", true)
- }
+ if (functionSpecific) {
+ assert(stepNode->values.contains("func"));
+ Common::String functionName = stepNode->values["func"];
- if (functionName == "bevelsq") {
- __PARSER_ASSIGN_INT(extraData, "bevel", true);
- }
+ if (functionName == "roundedsq" || functionName == "circle") {
+ __PARSER_ASSIGN_INT(radius, "radius", true)
+ }
- if (functionName == "triangle") {
- drawstep->extraData = VectorRenderer::kTriangleUp;
+ if (functionName == "bevelsq") {
+ __PARSER_ASSIGN_INT(extraData, "bevel", true);
+ }
- if (stepNode->values.contains("orientation")) {
- val = stepNode->values["orientation"];
+ if (functionName == "triangle") {
+ drawstep->extraData = VectorRenderer::kTriangleUp;
- if ( val == "top")
- drawstep->extraData = VectorRenderer::kTriangleUp;
- else if (val == "bottom")
- drawstep->extraData = VectorRenderer::kTriangleDown;
- else if (val == "left")
- drawstep->extraData = VectorRenderer::kTriangleLeft;
- else if (val == "right")
- drawstep->extraData = VectorRenderer::kTriangleRight;
- else
- return parserError("'%s' is not a valid value for triangle orientation.", val.c_str());
+ if (stepNode->values.contains("orientation")) {
+ val = stepNode->values["orientation"];
+
+ if ( val == "top")
+ drawstep->extraData = VectorRenderer::kTriangleUp;
+ else if (val == "bottom")
+ drawstep->extraData = VectorRenderer::kTriangleDown;
+ else if (val == "left")
+ drawstep->extraData = VectorRenderer::kTriangleLeft;
+ else if (val == "right")
+ drawstep->extraData = VectorRenderer::kTriangleRight;
+ else
+ return parserError("'%s' is not a valid value for triangle orientation.", val.c_str());
+ }
}
- }
- if (stepNode->values.contains("size")) {
- if (stepNode->values["size"] == "auto") {
- drawstep->fillArea = true;
- } else if (sscanf(stepNode->values["size"].c_str(), "%d, %d", &w, &h) == 2) {
- drawstep->fillArea = false;
- drawstep->w = w;
- drawstep->h = h;
- } else {
- return parserError("Invalid value in 'size' subkey: Valid options are 'auto' or 'X, X' to define width and height.");
+ if (stepNode->values.contains("size")) {
+ if (stepNode->values["size"] == "auto") {
+ drawstep->fillArea = true;
+ } else if (sscanf(stepNode->values["size"].c_str(), "%d, %d", &w, &h) == 2) {
+ drawstep->fillArea = false;
+ drawstep->w = w;
+ drawstep->h = h;
+ } else {
+ return parserError("Invalid value in 'size' subkey: Valid options are 'auto' or 'X, X' to define width and height.");
+ }
}
}
@@ -282,46 +380,8 @@
#undef __PARSER_ASSIGN_INT
#undef __PARSER_ASSIGN_RGB
- g_InterfaceManager.addDrawStep(drawdataNode->values["id"], drawstep);
return true;
}
-bool ThemeParser::parserCallback_DRAWDATA() {
- ParserNode *drawdataNode = _activeKey.top();
- bool cached = false;
-
- assert(drawdataNode->name == "drawdata");
-
- if (getParentNode(drawdataNode) == 0 || getParentNode(drawdataNode)->name != "render_info")
- return parserError("DrawData keys must be contained inside a <render_info> section.");
-
- if (drawdataNode->values.contains("id") == false)
- return parserError("DrawData keys must contain an identifier.");
-
- InterfaceManager::DrawData id = g_InterfaceManager.getDrawDataId(drawdataNode->values["id"]);
-
- if (id == -1)
- 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;
- }
-
- // Both Max and Johannes suggest using a non-platform specfic approach based on available
- // resources and active resolution. getHostPlatformString() has been removed, so fix this.
-
-/* if (drawdataNode->values.contains("platform")) {
- if (drawdataNode->values["platform"].compareToIgnoreCase(Common::getHostPlatformString()) != 0) {
- drawdataNode->ignore = true;
- return true;
- }
- }*/
-
- if (g_InterfaceManager.addDrawData(id, cached) == false)
- return parserError("Repeated DrawData: Only one set of Drawing Data for a widget may be specified on each platform.");
-
- return true;
}
-}
-
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.h 2008-06-26 19:42:59 UTC (rev 32807)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.h 2008-06-26 19:54:55 UTC (rev 32808)
@@ -324,6 +324,7 @@
bool parserCallback_color();
bool parserCallback_renderInfo();
bool parserCallback_layoutInfo();
+ bool parserCallback_defaultSet();
bool validateKeyIntSigned(const char *key) {
@@ -345,7 +346,12 @@
}
Graphics::DrawStep *newDrawStep();
+ Graphics::DrawStep *defaultDrawStep();
+ bool parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawstep, bool functionSpecific);
+ Graphics::DrawStep *_defaultStepGlobal;
+ Graphics::DrawStep *_defaultStepLocal;
+
Common::HashMap<Common::String, DrawingFunctionCallback, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _drawFunctions;
Common::HashMap<Common::String, ParserCallback, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _callbacks;
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