aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2009-06-28 19:57:27 +0000
committerMax Horn2009-06-28 19:57:27 +0000
commita882a6f46779768f15d38e350781785d975e5007 (patch)
tree84a9524aa63cc8bfbf5cae69c4312ca778ce4bbb
parent531e7a8c78d1374e1a5aba606339fd8155eb3dee (diff)
downloadscummvm-rg350-a882a6f46779768f15d38e350781785d975e5007.tar.gz
scummvm-rg350-a882a6f46779768f15d38e350781785d975e5007.tar.bz2
scummvm-rg350-a882a6f46779768f15d38e350781785d975e5007.zip
GUI: Replaced ThemeParser::_drawFunction hashmap by a static function getDrawingFunctionCallback which maps strings to draw funcs
svn-id: r41931
-rw-r--r--graphics/VectorRenderer.h11
-rw-r--r--gui/ThemeEngine.cpp2
-rw-r--r--gui/ThemeEngine.h2
-rw-r--r--gui/ThemeParser.cpp58
-rw-r--r--gui/ThemeParser.h5
5 files changed, 44 insertions, 34 deletions
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index acc2f77357..136a8d55b3 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -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,7 +63,10 @@ struct DrawStep {
kVectorAlignBottom,
kVectorAlignTop,
kVectorAlignCenter
- } xAlign, yAlign;
+ };
+
+ VectorAlignment xAlign;
+ VectorAlignment yAlign;
uint8 shadow, stroke, factor, radius, bevel; /**< Misc options... */
@@ -68,7 +75,7 @@ struct DrawStep {
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;
};
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 4628ec436b..166b11afe3 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -1447,7 +1447,7 @@ void ThemeEngine::listUsableThemes(Common::List<ThemeDescriptor> &list) {
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;
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index a8e63098fb..fd2d9c65fd 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -529,7 +529,7 @@ private:
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. */
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 2e7e2d3214..8897eef9d7 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -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 @@ static GUI::ThemeEngine::TextAlignVertical parseTextVAlign(const Common::String
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(ThemeEngine *parent) : XMLParser() {
ThemeParser::~ThemeParser() {
delete _defaultStepGlobal;
delete _defaultStepLocal;
- _palette.clear();
- _drawFunctions.clear();
}
void ThemeParser::cleanup() {
@@ -281,15 +260,44 @@ bool ThemeParser::parserCallback_color(ParserNode *node) {
}
+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)
- return parserError("%s is not a valid drawing function name", functionName.c_str());
+ drawstep->drawingCall = getDrawingFunctionCallback(functionName);
- drawstep->drawingCall = _drawFunctions[functionName];
+ if (drawstep->drawingCall == 0)
+ return parserError("%s is not a valid drawing function name", functionName.c_str());
if (!parseDrawStep(node, drawstep, true))
return false;
diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h
index 7c9d39030b..e261b6b842 100644
--- a/gui/ThemeParser.h
+++ b/gui/ThemeParser.h
@@ -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 @@ namespace GUI {
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 @@ protected:
Graphics::DrawStep *_defaultStepGlobal;
Graphics::DrawStep *_defaultStepLocal;
- Common::HashMap<Common::String, DrawingFunctionCallback, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _drawFunctions;
-
struct PaletteColor {
uint8 r, g, b;
};