aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDenis Kasak2009-07-01 15:22:36 +0000
committerDenis Kasak2009-07-01 15:22:36 +0000
commitf0fcd7fd8ee28d525f53df364233f4e064123a28 (patch)
treef366019893a12d3f2dfbcca21995deb32a92f573 /engines
parent48959935880a991d14768dac66f41c183eb0dd44 (diff)
downloadscummvm-rg350-f0fcd7fd8ee28d525f53df364233f4e064123a28.tar.gz
scummvm-rg350-f0fcd7fd8ee28d525f53df364233f4e064123a28.tar.bz2
scummvm-rg350-f0fcd7fd8ee28d525f53df364233f4e064123a28.zip
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.
svn-id: r41995
Diffstat (limited to 'engines')
-rw-r--r--engines/draci/draci.cpp15
-rw-r--r--engines/draci/mouse.cpp3
-rw-r--r--engines/draci/sprite.h26
3 files changed, 33 insertions, 11 deletions
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index 3d8a6cc4f9..bbc8b531d6 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -139,8 +139,8 @@ int DraciEngine::go() {
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 @@ int DraciEngine::go() {
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 @@ int DraciEngine::go() {
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 @@ int DraciEngine::go() {
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
diff --git a/engines/draci/mouse.cpp b/engines/draci/mouse.cpp
index d8b9935f2e..008659c415 100644
--- a/engines/draci/mouse.cpp
+++ b/engines/draci/mouse.cpp
@@ -98,7 +98,8 @@ void Mouse::setCursorType(CursorType cur) {
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);
}
}
diff --git a/engines/draci/sprite.h b/engines/draci/sprite.h
index 84c38527d4..a013965e2d 100644
--- a/engines/draci/sprite.h
+++ b/engines/draci/sprite.h
@@ -33,13 +33,29 @@ namespace Draci {
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 @@ public:
~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 @@ public:
void setColour(byte fontColour);
void draw(Surface *surface) const;
-
+
+private:
byte *_text;
uint _length;
uint8 _colour;