[Scummvm-cvs-logs] SF.net SVN: scummvm:[41995] scummvm/branches/gsoc2009-draci/engines/draci
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Wed Jul 1 17:22:37 CEST 2009
Revision: 41995
http://scummvm.svn.sourceforge.net/scummvm/?rev=41995&view=rev
Author: dkasak13
Date: 2009-07-01 15:22:36 +0000 (Wed, 01 Jul 2009)
Log Message:
-----------
Modified Sprite, Text and Drawable to handle data hiding properly since they're no longer just C-like struct containers. Implemented getters/setters accordingly and changed existing code that used those classes.
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
scummvm/branches/gsoc2009-draci/engines/draci/mouse.cpp
scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
Modified: scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp 2009-07-01 15:15:58 UTC (rev 41994)
+++ scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp 2009-07-01 15:22:36 UTC (rev 41995)
@@ -139,8 +139,8 @@
xpos = (kScreenWidth - _font->getStringWidth(testString, 1)) / 2;
ypos += 20;
txt.setText(testString);
- txt._x = xpos;
- txt._y = ypos;
+ txt.setX(xpos);
+ txt.setY(ypos);
txt.draw(surf);
@@ -149,8 +149,8 @@
xpos = 50;
ypos += 20;
txt.setText(testString);
- txt._x = xpos;
- txt._y = ypos;
+ txt.setX(xpos);
+ txt.setY(ypos);
txt.draw(surf);
@@ -170,8 +170,9 @@
ypos = 80;
txt.setText(testString);
txt.setColour(kDefaultTransparent);
- txt._x = xpos;
- txt._y = ypos;
+ txt.setX(xpos);
+ txt.setY(ypos);
+
for (unsigned int t = 0; t < 25; ++t) {
debugC(5, kDraciGeneralDebugLevel, "Drawing frame %d...", t);
@@ -180,7 +181,7 @@
Sprite sp(f->_data, f->_length, ((kScreenWidth - 50) / 2), 60, true);
// Delete previous frame
- Common::Rect r(sp._x, sp._y, sp._x + sp._width, sp._y + sp._height);
+ Common::Rect r(sp.getX(), sp.getY(), sp.getX() + sp.getWidth(), sp.getY() + sp.getHeight());
_screen->drawRect(r, 225);
// Draw dragon
Modified: scummvm/branches/gsoc2009-draci/engines/draci/mouse.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/mouse.cpp 2009-07-01 15:15:58 UTC (rev 41994)
+++ scummvm/branches/gsoc2009-draci/engines/draci/mouse.cpp 2009-07-01 15:22:36 UTC (rev 41995)
@@ -98,7 +98,8 @@
Sprite sp(f->_data, f->_length, 0, 0, true);
CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours);
- CursorMan.replaceCursor(sp._data, sp._width, sp._height, sp._width / 2, sp._height / 2);
+ CursorMan.replaceCursor(sp.getBuffer(), sp.getWidth(), sp.getHeight(),
+ sp.getWidth() / 2, sp.getHeight() / 2);
}
}
Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.h 2009-07-01 15:15:58 UTC (rev 41994)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.h 2009-07-01 15:22:36 UTC (rev 41995)
@@ -33,13 +33,29 @@
class Drawable {
+friend class Sprite;
+friend class Text;
+
public:
virtual void draw(Surface *surface) const = 0;
virtual ~Drawable() {};
+
+ virtual uint16 getWidth() { return _width; }
+ virtual uint16 getHeight() { return _height; }
+ virtual uint16 getX() { return _x; }
+ virtual uint16 getY() { return _y; }
+ virtual uint16 getZ() { return _z; }
+
+ virtual void setX(uint16 x) { _x = x; }
+ virtual void setY(uint16 y) { _y = y; }
+ virtual void setZ(uint16 z) { _z = z; }
+
+private:
uint16 _width; //!< Width of the sprite
uint16 _height; //!< Height of the sprite
uint16 _x, _y; //!< Sprite coordinates
+ uint16 _z; //!< Sprite depth position
};
/**
@@ -66,13 +82,16 @@
~Sprite();
- void draw(Surface *surface) const;
+ void draw(Surface *surface) const;
+ const byte *getBuffer() const { return _data; }
+
+private:
byte *_data; //!< Pointer to a buffer containing raw sprite data (row-wise)
};
class Text : public Drawable {
-
+
public:
Text(const Common::String &str, Font *font, byte fontColour,
uint16 x = 0, uint16 y = 0, uint spacing = 0);
@@ -82,7 +101,8 @@
void setColour(byte fontColour);
void draw(Surface *surface) const;
-
+
+private:
byte *_text;
uint _length;
uint8 _colour;
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