[Scummvm-cvs-logs] SF.net SVN: scummvm:[41931] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Jun 28 21:57:27 CEST 2009


Revision: 41931
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41931&view=rev
Author:   fingolfin
Date:     2009-06-28 19:57:27 +0000 (Sun, 28 Jun 2009)

Log Message:
-----------
GUI: Replaced ThemeParser::_drawFunction hashmap by a static function getDrawingFunctionCallback which maps strings to draw funcs

Modified Paths:
--------------
    scummvm/trunk/graphics/VectorRenderer.h
    scummvm/trunk/gui/ThemeEngine.cpp
    scummvm/trunk/gui/ThemeEngine.h
    scummvm/trunk/gui/ThemeParser.cpp
    scummvm/trunk/gui/ThemeParser.h

Modified: scummvm/trunk/graphics/VectorRenderer.h
===================================================================
--- scummvm/trunk/graphics/VectorRenderer.h	2009-06-28 19:56:58 UTC (rev 41930)
+++ scummvm/trunk/graphics/VectorRenderer.h	2009-06-28 19:57:27 UTC (rev 41931)
@@ -37,6 +37,10 @@
 namespace Graphics {
 class VectorRenderer;
 
+
+typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const Graphics::DrawStep &);
+
+
 struct DrawStep {
 	struct Color {
 		uint8 r, g, b;
@@ -59,8 +63,11 @@
 		kVectorAlignBottom,
 		kVectorAlignTop,
 		kVectorAlignCenter
-	} xAlign, yAlign;
+	};
 
+	VectorAlignment xAlign;
+	VectorAlignment yAlign;
+
 	uint8 shadow, stroke, factor, radius, bevel; /**< Misc options... */
 
 	uint8 fillMode; /**< active fill mode */
@@ -68,7 +75,7 @@
 
 	uint32 scale; /**< scale of all the coordinates in FIXED POINT with 16 bits mantissa */
 
-	void (VectorRenderer::*drawingCall)(const Common::Rect &, const DrawStep &); /** Pointer to drawing function */
+	DrawingFunctionCallback drawingCall; /**< Pointer to drawing function */
 	Graphics::Surface *blitSrc;
 };
 

Modified: scummvm/trunk/gui/ThemeEngine.cpp
===================================================================
--- scummvm/trunk/gui/ThemeEngine.cpp	2009-06-28 19:56:58 UTC (rev 41930)
+++ scummvm/trunk/gui/ThemeEngine.cpp	2009-06-28 19:57:27 UTC (rev 41931)
@@ -1447,7 +1447,7 @@
 	output.clear();
 }
 
-void ThemeEngine::listUsableThemes(Common::FSNode node, Common::List<ThemeDescriptor> &list, int depth) {
+void ThemeEngine::listUsableThemes(const Common::FSNode &node, Common::List<ThemeDescriptor> &list, int depth) {
 	if (!node.exists() || !node.isReadable() || !node.isDirectory())
 		return;
 

Modified: scummvm/trunk/gui/ThemeEngine.h
===================================================================
--- scummvm/trunk/gui/ThemeEngine.h	2009-06-28 19:56:58 UTC (rev 41930)
+++ scummvm/trunk/gui/ThemeEngine.h	2009-06-28 19:57:27 UTC (rev 41931)
@@ -529,7 +529,7 @@
 
 	static Common::String getThemeFile(const Common::String &id);
 	static Common::String getThemeId(const Common::String &filename);
-	static void listUsableThemes(Common::FSNode node, Common::List<ThemeDescriptor> &list, int depth=-1);
+	static void listUsableThemes(const Common::FSNode &node, Common::List<ThemeDescriptor> &list, int depth = -1);
 
 protected:
 	OSystem *_system; /** Global system object. */

Modified: scummvm/trunk/gui/ThemeParser.cpp
===================================================================
--- scummvm/trunk/gui/ThemeParser.cpp	2009-06-28 19:56:58 UTC (rev 41930)
+++ scummvm/trunk/gui/ThemeParser.cpp	2009-06-28 19:57:27 UTC (rev 41931)
@@ -23,17 +23,11 @@
  *
  */
 
-#include "common/util.h"
-#include "common/system.h"
-#include "common/events.h"
-#include "common/hashmap.h"
-#include "common/hash-str.h"
-#include "common/xmlparser.h"
-
 #include "gui/ThemeEngine.h"
 #include "gui/ThemeEval.h"
 #include "gui/ThemeParser.h"
 #include "gui/GuiManager.h"
+
 #include "graphics/VectorRenderer.h"
 
 namespace GUI {
@@ -86,19 +80,6 @@
 
 
 ThemeParser::ThemeParser(ThemeEngine *parent) : XMLParser() {
-
-	_drawFunctions["circle"]  = &Graphics::VectorRenderer::drawCallback_CIRCLE;
-	_drawFunctions["square"]  = &Graphics::VectorRenderer::drawCallback_SQUARE;
-	_drawFunctions["roundedsq"]  = &Graphics::VectorRenderer::drawCallback_ROUNDSQ;
-	_drawFunctions["bevelsq"]  = &Graphics::VectorRenderer::drawCallback_BEVELSQ;
-	_drawFunctions["line"]  = &Graphics::VectorRenderer::drawCallback_LINE;
-	_drawFunctions["triangle"]  = &Graphics::VectorRenderer::drawCallback_TRIANGLE;
-	_drawFunctions["fill"]  = &Graphics::VectorRenderer::drawCallback_FILLSURFACE;
-	_drawFunctions["tab"]  = &Graphics::VectorRenderer::drawCallback_TAB;
-	_drawFunctions["void"]  = &Graphics::VectorRenderer::drawCallback_VOID;
-	_drawFunctions["bitmap"] = &Graphics::VectorRenderer::drawCallback_BITMAP;
-	_drawFunctions["cross"] = &Graphics::VectorRenderer::drawCallback_CROSS;
-
 	_defaultStepGlobal = defaultDrawStep();
 	_defaultStepLocal = 0;
 	_theme = parent;
@@ -107,8 +88,6 @@
 ThemeParser::~ThemeParser() {
 	delete _defaultStepGlobal;
 	delete _defaultStepLocal;
-	_palette.clear();
-	_drawFunctions.clear();
 }
 
 void ThemeParser::cleanup() {
@@ -281,16 +260,45 @@
 }
 
 
+static Graphics::DrawingFunctionCallback getDrawingFunctionCallback(const Common::String &name) {
+
+	if (name == "circle")
+		return &Graphics::VectorRenderer::drawCallback_CIRCLE;
+	if (name == "square")
+		return &Graphics::VectorRenderer::drawCallback_SQUARE;
+	if (name == "roundedsq")
+		return &Graphics::VectorRenderer::drawCallback_ROUNDSQ;
+	if (name == "bevelsq")
+		return &Graphics::VectorRenderer::drawCallback_BEVELSQ;
+	if (name == "line")
+		return &Graphics::VectorRenderer::drawCallback_LINE;
+	if (name == "triangle")
+		return &Graphics::VectorRenderer::drawCallback_TRIANGLE;
+	if (name == "fill")
+		return &Graphics::VectorRenderer::drawCallback_FILLSURFACE;
+	if (name == "tab")
+		return &Graphics::VectorRenderer::drawCallback_TAB;
+	if (name == "void")
+		return &Graphics::VectorRenderer::drawCallback_VOID;
+	if (name == "bitmap")
+		return &Graphics::VectorRenderer::drawCallback_BITMAP;
+	if (name == "cross")
+		return &Graphics::VectorRenderer::drawCallback_CROSS;
+
+	return 0;
+}
+
+
 bool ThemeParser::parserCallback_drawstep(ParserNode *node) {
 	Graphics::DrawStep *drawstep = newDrawStep();
 
 	Common::String functionName = node->values["func"];
 
-	if (_drawFunctions.contains(functionName) == false)
+	drawstep->drawingCall = getDrawingFunctionCallback(functionName);
+
+	if (drawstep->drawingCall == 0)
 		return parserError("%s is not a valid drawing function name", functionName.c_str());
 
-	drawstep->drawingCall = _drawFunctions[functionName];
-
 	if (!parseDrawStep(node, drawstep, true))
 		return false;
 

Modified: scummvm/trunk/gui/ThemeParser.h
===================================================================
--- scummvm/trunk/gui/ThemeParser.h	2009-06-28 19:56:58 UTC (rev 41930)
+++ scummvm/trunk/gui/ThemeParser.h	2009-06-28 19:57:27 UTC (rev 41931)
@@ -27,7 +27,6 @@
 #define THEME_PARSER_H
 
 #include "common/scummsys.h"
-#include "common/system.h"
 #include "common/xmlparser.h"
 
 namespace GUI {
@@ -35,8 +34,6 @@
 class ThemeEngine;
 
 class ThemeParser : public Common::XMLParser {
-	typedef void (Graphics::VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const Graphics::DrawStep &);
-
 public:
 	ThemeParser(ThemeEngine *parent);
 
@@ -249,8 +246,6 @@
 	Graphics::DrawStep *_defaultStepGlobal;
 	Graphics::DrawStep *_defaultStepLocal;
 
-	Common::HashMap<Common::String, DrawingFunctionCallback, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _drawFunctions;
-
 	struct PaletteColor {
 		uint8 r, g, b;
 	};


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