[Scummvm-cvs-logs] SF.net SVN: scummvm:[44362] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Fri Sep 25 19:33:02 CEST 2009


Revision: 44362
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44362&view=rev
Author:   spalek
Date:     2009-09-25 17:33:00 +0000 (Fri, 25 Sep 2009)

Log Message:
-----------
Added some more const's to the interface of Dragon History

Modified Paths:
--------------
    scummvm/trunk/engines/draci/animation.cpp
    scummvm/trunk/engines/draci/animation.h
    scummvm/trunk/engines/draci/font.cpp
    scummvm/trunk/engines/draci/font.h
    scummvm/trunk/engines/draci/game.h
    scummvm/trunk/engines/draci/screen.cpp
    scummvm/trunk/engines/draci/screen.h
    scummvm/trunk/engines/draci/script.cpp
    scummvm/trunk/engines/draci/script.h
    scummvm/trunk/engines/draci/sprite.cpp
    scummvm/trunk/engines/draci/sprite.h

Modified: scummvm/trunk/engines/draci/animation.cpp
===================================================================
--- scummvm/trunk/engines/draci/animation.cpp	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/animation.cpp	2009-09-25 17:33:00 UTC (rev 44362)
@@ -553,7 +553,7 @@
 	_lastIndex = -1;
 }
 
-int AnimationManager::getLastIndex() {
+int AnimationManager::getLastIndex() const {
 	return _lastIndex;
 }
 

Modified: scummvm/trunk/engines/draci/animation.h
===================================================================
--- scummvm/trunk/engines/draci/animation.h	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/animation.h	2009-09-25 17:33:00 UTC (rev 44362)
@@ -170,7 +170,7 @@
 
 	Animation *getAnimation(int id);
 
-	int getLastIndex();
+	int getLastIndex() const;
 	void deleteAfterIndex(int index);
 
 	int getTopAnimationID(int x, int y);

Modified: scummvm/trunk/engines/draci/font.cpp
===================================================================
--- scummvm/trunk/engines/draci/font.cpp	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/font.cpp	2009-09-25 17:33:00 UTC (rev 44362)
@@ -41,8 +41,6 @@
 	_charData = NULL;
 
 	loadFont(filename);
-
-	_currentFontColour = kFontColour1;
 }
 
 Font::~Font() {
@@ -50,15 +48,6 @@
 }
 
 /**
- * @brief Sets the varying font colour
- * @param colour The new font colour
- */
-
-void Font::setColour(uint8 colour) {
-	_currentFontColour = colour;
-}
-
-/**
  * @brief Loads fonts from a file
  * @param path Path to font file
  * @return true if the font was loaded successfully, false otherwise
@@ -132,7 +121,7 @@
  * @param ty  	Vertical offset on the surface
  */
 
-void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty) const {
+void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) const {
 	assert(dst != NULL);
 	assert(tx >= 0);
 	assert(ty >= 0);
@@ -166,7 +155,7 @@
 			switch (colour) {
 
 			case 254:
-				colour = _currentFontColour;
+				colour = with_colour;
 				break;
 
 			case 253:
@@ -203,8 +192,8 @@
  */
 
 void Font::drawString(Surface *dst, const byte *str, uint len, 
-							int x, int y, int spacing, bool markDirty) const {
-	drawString(dst, Common::String((const char *)str, len), x, y, spacing, markDirty);
+		int x, int y, int with_colour, int spacing, bool markDirty) const {
+	drawString(dst, Common::String((const char *)str, len), x, y, with_colour, spacing, markDirty);
 }
 
 /**
@@ -218,7 +207,7 @@
  */
 
 void Font::drawString(Surface *dst, const Common::String &str, 
-							int x, int y, int spacing, bool markDirty) const {
+		int x, int y, int with_colour, int spacing, bool markDirty) const {
 	assert(dst != NULL);
 	assert(x >= 0);
 	assert(y >= 0);
@@ -243,7 +232,7 @@
 			break;
 		}		
 		
-		drawChar(dst, str[i], curx, cury);
+		drawChar(dst, str[i], curx, cury, with_colour);
 		curx += getCharWidth(str[i]) + spacing;
 	}
 

Modified: scummvm/trunk/engines/draci/font.h
===================================================================
--- scummvm/trunk/engines/draci/font.h	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/font.h	2009-09-25 17:33:00 UTC (rev 44362)
@@ -61,19 +61,17 @@
 	uint8 getFontHeight() const { return _fontHeight; };
 	uint8 getMaxCharWidth() const { return _maxCharWidth; };
 	uint8 getCharWidth(byte chr) const;
-	void drawChar(Surface *dst, uint8 chr, int tx, int ty) const;
+	void drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) const;
 	
-	void drawString(Surface *dst, const byte *str, uint len, int x, int y, 
+	void drawString(Surface *dst, const byte *str, uint len, int x, int y, int with_colour, 
 					int spacing, bool markDirty = true) const;
 	void drawString(Surface *dst, const Common::String &str, 
-					int x, int y, int spacing, bool markDirty = true) const;
+					int x, int y, int with_colour, int spacing, bool markDirty = true) const;
 	
 	uint getStringWidth(const Common::String &str, int spacing = 0) const;
 	uint getStringHeight(const Common::String &str) const;
 	uint getLineWidth(const Common::String &str, uint startIndex, int spacing = 0) const;
 
-	void setColour(uint8 colour);
-
 private:
 	uint8 _fontHeight;
 	uint8 _maxCharWidth;
@@ -93,9 +91,6 @@
 	 */
 	static const unsigned int kCharIndexOffset = 32;
 
-	/** The varying font colour; initially set to kFontColour1 */
-	uint8 _currentFontColour;
-
 	/** Internal function for freeing fonts when destructing/loading another */
 	void freeFont();
 };

Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/game.h	2009-09-25 17:33:00 UTC (rev 44362)
@@ -105,7 +105,7 @@
 		_data = NULL;
 	}	
 
-	void load(byte *data, uint length) {
+	void load(const byte *data, uint length) {
 		Common::MemoryReadStream mapReader(data, length);
 
 		_realWidth = mapReader.readUint16LE();
@@ -128,7 +128,7 @@
 	int _deltaX, _deltaY;
 	int _mapWidth, _mapHeight;
 	int _byteWidth;
-	byte *_data;
+	const byte *_data;
 };
 
 struct GameObject {

Modified: scummvm/trunk/engines/draci/screen.cpp
===================================================================
--- scummvm/trunk/engines/draci/screen.cpp	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/screen.cpp	2009-09-25 17:33:00 UTC (rev 44362)
@@ -143,7 +143,7 @@
  * @param r Which rectangle to draw
  *		  colour The colour of the rectangle
  */
-void Screen::drawRect(Common::Rect &r, uint8 colour) {
+void Screen::drawRect(Common::Rect r, uint8 colour) {
 
 	// Clip the rectangle to screen size
 	r.clip(_surface->w, _surface->h);

Modified: scummvm/trunk/engines/draci/screen.h
===================================================================
--- scummvm/trunk/engines/draci/screen.h	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/screen.h	2009-09-25 17:33:00 UTC (rev 44362)
@@ -53,7 +53,7 @@
 	void clearScreen();
 	void fillScreen(uint8 colour);
 	Surface *getSurface();	
-	void drawRect(Common::Rect &r, uint8 colour);
+	void drawRect(Common::Rect r, uint8 colour);
 
 private:
 	Surface *_surface;

Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/script.cpp	2009-09-25 17:33:00 UTC (rev 44362)
@@ -907,7 +907,7 @@
  *
  * Reference: the function equivalent to this one is called "Can()" in the original engine.
  */
-bool Script::testExpression(GPL2Program program, uint16 offset) const {
+bool Script::testExpression(const GPL2Program &program, uint16 offset) const {
 	
 	// Initialize program reader
 	Common::MemoryReadStream reader(program._bytecode, program._length);
@@ -987,7 +987,7 @@
  *	value comes from.
  */
 
-int Script::run(GPL2Program program, uint16 offset) {
+int Script::run(const GPL2Program &program, uint16 offset) {
 
 	int oldJump = _jump;
 

Modified: scummvm/trunk/engines/draci/script.h
===================================================================
--- scummvm/trunk/engines/draci/script.h	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/script.h	2009-09-25 17:33:00 UTC (rev 44362)
@@ -42,6 +42,7 @@
 	kNumCommands = 55
 };
 
+// TODO(spalek): shouldn't modify params passed by reference.  Either make it const or copy the parameter.
 typedef void (Script::* GPLHandler)(Common::Queue<int> &);
 typedef int  (Script::* GPLOperatorHandler)(int, int) const;
 typedef int  (Script::* GPLFunctionHandler)(int) const;
@@ -88,8 +89,8 @@
 public:
 	Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); };	
 
-	int run(GPL2Program program, uint16 offset);
-	bool testExpression(GPL2Program, uint16 offset) const;
+	int run(const GPL2Program &program, uint16 offset);
+	bool testExpression(const GPL2Program &program, uint16 offset) const;
 	void endCurrentProgram();
 
 private:

Modified: scummvm/trunk/engines/draci/sprite.cpp
===================================================================
--- scummvm/trunk/engines/draci/sprite.cpp	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/sprite.cpp	2009-09-25 17:33:00 UTC (rev 44362)
@@ -302,7 +302,7 @@
 		return Common::Rect(_x, _y, _x + _width, _y + _height);
 }
 
-Text::Text(const Common::String &str, Font *font, byte fontColour, 
+Text::Text(const Common::String &str, const Font *font, byte fontColour, 
 				int x, int y, uint spacing) {
 	_x = x;
 	_y = y;
@@ -357,9 +357,7 @@
 }
 
 void Text::draw(Surface *surface, bool markDirty) const {
-	_font->setColour(_colour);
-
-	_font->drawString(surface, _text, _x, _y, _spacing);
+	_font->drawString(surface, _text, _x, _y, _colour, _spacing);
 }
 
 // TODO: Handle scaled parameter properly by implementing Text scaling
@@ -367,7 +365,7 @@
 	return Common::Rect(_x, _y, _x + _width, _y + _height);
 }
 
-void Text::setFont(Font *font) {
+void Text::setFont(const Font *font) {
 	_font = font;
 
 	_width = _font->getStringWidth(_text, _spacing);

Modified: scummvm/trunk/engines/draci/sprite.h
===================================================================
--- scummvm/trunk/engines/draci/sprite.h	2009-09-25 16:53:18 UTC (rev 44361)
+++ scummvm/trunk/engines/draci/sprite.h	2009-09-25 17:33:00 UTC (rev 44362)
@@ -121,14 +121,14 @@
 class Text : public Drawable {
 	
 public:
-	Text(const Common::String &str, Font *font, byte fontColour, 
+	Text(const Common::String &str, const Font *font, byte fontColour, 
 		int x, int y, uint spacing = 0);
 	~Text() {};
 	
 	void setText(const Common::String &str);
 	void setColour(byte fontColour);
 	void setSpacing(uint spacing);
-	void setFont(Font *font);
+	void setFont(const Font *font);
 
 	uint getLength() const;
 
@@ -147,7 +147,7 @@
 	uint _length;
 	uint8 _colour;
 	uint _spacing;
-	Font *_font;
+	const Font *_font;
 };
 	
 } // End of namespace Draci


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