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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Fri Jun 13 19:47:56 CEST 2008


Revision: 32696
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32696&view=rev
Author:   Tanoku
Date:     2008-06-13 10:47:56 -0700 (Fri, 13 Jun 2008)

Log Message:
-----------
Formating conventions.
Function parameter fixes.
Parser fixes.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
    scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.h

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-06-13 16:04:43 UTC (rev 32695)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-06-13 17:47:56 UTC (rev 32696)
@@ -51,39 +51,39 @@
 /********************************************************************
  * DRAWSTEP handling functions
  ********************************************************************/
-void VectorRenderer::drawStep(Common::Rect area, DrawStep *step) {
+void VectorRenderer::drawStep(const Common::Rect &area, const DrawStep &step) {
 
-	if (step->flags & DrawStep::kStepCallbackOnly) {
-		(this->*(step->drawing_call))(&area, step);
+	if (step.flags & DrawStep::kStepCallbackOnly) {
+		(this->*(step.drawing_call))(area, step);
 		return;
 	}
 
-	if (step->flags & DrawStep::kStepSetBG)
-		setBgColor(step->color2.r, step->color2.g, step->color2.b);
+	if (step.flags & DrawStep::kStepSetBG)
+		setBgColor(step.color2.r, step.color2.g, step.color2.b);
 
-	if (step->flags & DrawStep::kStepSetFG)
-		setFgColor(step->color1.r, step->color1.g, step->color1.b);
+	if (step.flags & DrawStep::kStepSetFG)
+		setFgColor(step.color1.r, step.color1.g, step.color1.b);
 
-	if (step->flags & DrawStep::kStepSetGradient)
-		setGradientColors(step->color1.r, step->color1.g, step->color1.b, 
-						  step->color2.r, step->color2.g, step->color2.b);
+	if (step.flags & DrawStep::kStepSetGradient)
+		setGradientColors(step.color1.r, step.color1.g, step.color1.b, 
+						  step.color2.r, step.color2.g, step.color2.b);
 
-	if (step->flags & DrawStep::kStepSetShadow)
-		shadowEnable(step->shadow);
+	if (step.flags & DrawStep::kStepSetShadow)
+		shadowEnable(step.shadow);
 
-	if (step->flags & DrawStep::kStepSetGradientFactor)
-		setGradientFactor(step->factor);
+	if (step.flags & DrawStep::kStepSetGradientFactor)
+		setGradientFactor(step.factor);
 
-	if (step->flags & DrawStep::kStepSetStroke)
-		setStrokeWidth(step->stroke);
+	if (step.flags & DrawStep::kStepSetStroke)
+		setStrokeWidth(step.stroke);
 
-	if (step->flags & DrawStep::kStepSetFillMode)
-		setFillMode((FillMode)step->fill_mode);
+	if (step.flags & DrawStep::kStepSetFillMode)
+		setFillMode((FillMode)step.fill_mode);
 		
-	if (step->flags & DrawStep::kStepSettingsOnly)
+	if (step.flags & DrawStep::kStepSettingsOnly)
 		return;
 
-	(this->*(step->drawing_call))(&area, step);	
+	(this->*(step.drawing_call))(area, step);	
 }
 
 /********************************************************************

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-06-13 16:04:43 UTC (rev 32695)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-06-13 17:47:56 UTC (rev 32696)
@@ -37,6 +37,7 @@
 
 namespace Graphics {
 class VectorRenderer;
+struct DrawStep;
 
 struct DrawStep {
 	uint32 flags; /** Step flags, see DrawStepFlags */
@@ -64,7 +65,7 @@
 
 	uint32 scale; /** scale of all the coordinates in FIXED POINT with 16 bits mantissa */
 
-	void (VectorRenderer::*drawing_call)(Common::Rect*, DrawStep*); /** Pointer to drawing function */
+	void (VectorRenderer::*drawing_call)(const Common::Rect &, const DrawStep &); /** Pointer to drawing function */
 
 	enum DrawStepFlags {
 		kStepCallbackOnly		= (1 << 0),
@@ -77,38 +78,6 @@
 		kStepSetStroke			= (1 << 7),
 		kStepSetFillMode		= (1 << 8)
 	};
-
-	void getPositions(Common::Rect *area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) {
-		if (fill_area) {
-			in_x = area->left;
-			in_y = area->top;
-			in_w = area->width();
-			in_h = area->height();
-		} else {
-			if (!x.relative) in_x = area->left + x.pos; 
-			else in_x = area->left + area->width() - x.pos;
-
-			if (!y.relative) in_y = area->top + y.pos;
-			else in_y = area->top + area->height() - y.pos;
-
-			if (in_x + w > area->right) in_w = area->right - in_x;
-			else in_w = w;
-
-			if (in_y + h > area->bottom) in_h = area->bottom - in_y;
-			else in_h = h;
-		}
-
-		if (scale != (1 << 16) && scale != 0) {
-			in_x = (in_x * scale) >> 16;
-			in_y = (in_y * scale) >> 16;
-			in_w = (in_w * scale) >> 16;
-			in_h = (in_h * scale) >> 16;
-		}
-	}
-
-	uint8 getRadius() {
-		return (((uint32)radius * scale) >> 16);
-	}
 };
 
 VectorRenderer *createRenderer(int mode);
@@ -360,48 +329,76 @@
 			_gradientFactor = factor;
 	}
 
+	void stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h) {
+		if (step.fill_area) {
+			in_x = area.left;
+			in_y = area.top;
+			in_w = area.width();
+			in_h = area.height();
+		} else {
+			if (!step.x.relative) in_x = area.left + step.x.pos; 
+			else in_x = area.left + area.width() - step.x.pos;
+
+			if (!step.y.relative) in_y = area.top + step.y.pos;
+			else in_y = area.top + area.height() - step.y.pos;
+
+			if (in_x + step.w > area.right) in_w = area.right - in_x;
+			else in_w = step.w;
+
+			if (in_y + step.h > area.bottom) in_h = area.bottom - in_y;
+			else in_h = step.h;
+		}
+
+		if (step.scale != (1 << 16) && step.scale != 0) {
+			in_x = (in_x * step.scale) >> 16;
+			in_y = (in_y * step.scale) >> 16;
+			in_w = (in_w * step.scale) >> 16;
+			in_h = (in_h * step.scale) >> 16;
+		}
+	}
+
 	/**
 	 * DrawStep callback functions for each drawing feature 
 	 */
-	void drawCallback_CIRCLE(Common::Rect *area, DrawStep *step) {
+	void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step) {
 		uint16 x, y, w, h;
-		step->getPositions(area, x, y, w, h);
-		drawCircle(x, y, step->getRadius());
+		stepGetPositions(step, area, x, y, w, h);
+		drawCircle(x, y, (step.radius * step.scale) >> 16);
 	}
 
-	void drawCallback_SQUARE(Common::Rect *area, DrawStep *step) {
+	void drawCallback_SQUARE(const Common::Rect &area, const DrawStep &step) {
 		uint16 x, y, w, h;
-		step->getPositions(area, x, y, w, h);
+		stepGetPositions(step, area, x, y, w, h);
 		drawSquare(x, y, w, h);
 	}
 
-	void drawCallback_LINE(Common::Rect *area, DrawStep *step) {
+	void drawCallback_LINE(const Common::Rect &area, const DrawStep &step) {
 		uint16 x, y, w, h;
-		step->getPositions(area, x, y, w, h);
+		stepGetPositions(step, area, x, y, w, h);
 		drawLine(x, y, x + w, y + w);
 	}
 
-	void drawCallback_ROUNDSQ(Common::Rect *area, DrawStep *step) {
+	void drawCallback_ROUNDSQ(const Common::Rect &area, const DrawStep &step) {
 		uint16 x, y, w, h;
-		step->getPositions(area, x, y, w, h);
+		stepGetPositions(step, area, x, y, w, h);
 		/* HACK! Radius of the rounded squares isn't scaled */
-		drawRoundedSquare(x, y, step->radius, w, h);
+		drawRoundedSquare(x, y, step.radius, w, h);
 	}
 
-	void drawCallback_FILLSURFACE(Common::Rect *area, DrawStep *step) {
+	void drawCallback_FILLSURFACE(const Common::Rect &area, const DrawStep &step) {
 		fillSurface();
 	}
 
-	void drawCallback_TRIANGLE(Common::Rect *area, DrawStep *step) {
+	void drawCallback_TRIANGLE(const Common::Rect &area, const DrawStep &step) {
 		uint16 x, y, w, h;
-		step->getPositions(area, x, y, w, h);
-		drawTriangle(x, y, w, h, (TriangleOrientation)step->extra_data);
+		stepGetPositions(step, area, x, y, w, h);
+		drawTriangle(x, y, w, h, (TriangleOrientation)step.extra_data);
 	}
 
-	void drawCallback_BEVELSQ(Common::Rect *area, DrawStep *step) {
+	void drawCallback_BEVELSQ(const Common::Rect &area, const DrawStep &step) {
 		uint16 x, y, w, h;
-		step->getPositions(area, x, y, w, h);
-		drawBeveledSquare(x, y, w, h, step->extra_data);
+		stepGetPositions(step, area, x, y, w, h);
+		drawBeveledSquare(x, y, w, h, step.extra_data);
 	}
 
 	/**
@@ -411,7 +408,7 @@
 	 * @param area Zone to paint on
 	 * @param step Pointer to a DrawStep struct.
 	 */
-	virtual void drawStep(Common::Rect area, DrawStep *step);
+	virtual void drawStep(const Common::Rect &area, const DrawStep &step);
 
 	/**
 	 * Copies the current surface to the system overlay 

Modified: scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp	2008-06-13 16:04:43 UTC (rev 32695)
+++ scummvm/branches/gsoc2008-gui/gui/InterfaceManager.cpp	2008-06-13 17:47:56 UTC (rev 32696)
@@ -97,7 +97,7 @@
 		drawCached(type, r);
 	} else {
 		for (int i = 0; i < _widgets[type]->_stepCount; ++i)
-			_vectorRenderer->drawStep(r, _widgets[type]->_steps[i]);
+			_vectorRenderer->drawStep(r, *_widgets[type]->_steps[i]);
 	}
 }
 
@@ -205,9 +205,9 @@
 	bool running = true;
 	while (running) { // draw!!
 
-		_vectorRenderer->drawStep(Common::Rect(), &steps[0]);
-		_vectorRenderer->drawStep(area, &steps[1]);
-		_vectorRenderer->drawStep(area, &steps[2]);
+		_vectorRenderer->drawStep(Common::Rect(), steps[0]);
+		_vectorRenderer->drawStep(area, steps[1]);
+		_vectorRenderer->drawStep(area, steps[2]);
 //		_vectorRenderer->drawStep(Common::Rect(32, 32, 256, 256), &steps[3]);
 
 		_vectorRenderer->copyFrame(_system);

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-06-13 16:04:43 UTC (rev 32695)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-06-13 17:47:56 UTC (rev 32696)
@@ -103,14 +103,15 @@
 	skipSpaces();
 
 	Common::String data;
+	char string_start;
 
-	if (_text[_pos] == '"') {
-		data += _text[_pos++];
+	if (_text[_pos] == '"' || _text[_pos] == '\'') {
+		string_start = _text[_pos++];
 
-		while (_text[_pos] != '"')
+		while (_text[_pos] != string_start)
 			data += _text[_pos++];
 
-		data += _text[_pos++];
+		_pos++;
 	} else {
 		while (isValidNameChar(_text[_pos]))
 			data += _text[_pos++];
@@ -131,8 +132,10 @@
 			break;
 
 		skipSpaces();
-		skipComments();
 
+		if (skipComments())
+			continue;
+
 		switch (_state) {
 			case kParserNeedKey:
 				if (_text[_pos++] != '<') {

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	2008-06-13 16:04:43 UTC (rev 32695)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	2008-06-13 17:47:56 UTC (rev 32696)
@@ -38,8 +38,8 @@
 
 class ThemeParser {
 
-	static const int PARSER_MAX_DEPTH = 4;
-	typedef void (ThemeParser::*PARSER_CALLBACK)();
+	static const int kParserMaxDepth = 4;
+	typedef void (ThemeParser::*ParserCallback)();
 
 public:
 	ThemeParser() {
@@ -73,15 +73,16 @@
 			_pos++;
 	}
 
-	inline void skipComments() {
+	inline bool skipComments() {
 		if (_text[_pos] == '/' && _text[_pos + 1] == '*') {
 			_pos += 2;
 			while (_text[_pos++]) {
 				if (_text[_pos - 2] == '*' && _text[_pos - 1] == '/')
 					break;
 			}
-			skipSpaces();
+			return true;
 		}
+		return false;
 	}
 
 	int _pos;
@@ -92,10 +93,10 @@
 	Common::String _error;
 	Common::String _token;
 
-	Common::FixedStack<Common::String, PARSER_MAX_DEPTH> _activeKey;
-	Common::FixedStack<Common::StringMap, PARSER_MAX_DEPTH> _keyValues;
+	Common::FixedStack<Common::String, kParserMaxDepth> _activeKey;
+	Common::FixedStack<Common::StringMap, kParserMaxDepth> _keyValues;
 
-	Common::HashMap<Common::String, PARSER_CALLBACK, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _callbacks;
+	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