Made coordinate specification mandatory when constructing objects of type Sprite and Class. Made transforming from columnwise a default (since it was done most of the time anyway). Changed coordinates to use uint instead of uint16.

svn-id: r41996
This commit is contained in:
Denis Kasak 2009-07-01 16:00:27 +00:00
parent f0fcd7fd8e
commit cfadb6cc3d
4 changed files with 25 additions and 20 deletions

View file

@ -178,7 +178,7 @@ int DraciEngine::go() {
// Load frame to memory
f = ar[t];
Sprite sp(f->_data, f->_length, ((kScreenWidth - 50) / 2), 60, true);
Sprite sp(f->_data, f->_length, ((kScreenWidth - 50) / 2), 60, 0);
// Delete previous frame
Common::Rect r(sp.getX(), sp.getY(), sp.getX() + sp.getWidth(), sp.getY() + sp.getHeight());

View file

@ -96,7 +96,7 @@ void Mouse::setCursorType(CursorType cur) {
return;
}
Sprite sp(f->_data, f->_length, 0, 0, true);
Sprite sp(f->_data, f->_length, 0, 0, 0);
CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours);
CursorMan.replaceCursor(sp.getBuffer(), sp.getWidth(), sp.getHeight(),
sp.getWidth() / 2, sp.getHeight() / 2);

View file

@ -53,13 +53,14 @@ static void transformToRows(byte *img, uint16 width, uint16 height) {
/**
* Constructor for loading sprites from a raw data buffer, one byte per pixel.
*/
Sprite::Sprite(byte *raw_data, uint16 width, uint16 height, uint16 x, uint16 y,
bool columnwise) : _data(NULL) {
*/
Sprite::Sprite(byte *raw_data, uint16 width, uint16 height, uint x, uint y,
uint z, bool columnwise) : _data(NULL) {
_width = width;
_height = height;
_x = x;
_y = y;
_z = z;
_data = new byte[width * height];
@ -71,14 +72,16 @@ Sprite::Sprite(byte *raw_data, uint16 width, uint16 height, uint16 x, uint16 y,
}
}
/**
* Constructor for loading sprites from a sprite-formatted buffer, one byte per
* pixel.
*/
Sprite::Sprite(byte *sprite_data, uint16 length, uint16 x, uint16 y,
Sprite::Sprite(byte *sprite_data, uint16 length, uint x, uint y, uint z,
bool columnwise) : _data(NULL) {
_x = x;
_y = y;
_z = z;
Common::MemoryReadStream reader(sprite_data, length);
@ -127,12 +130,13 @@ void Sprite::draw(Surface *surface) const {
}
Text::Text(const Common::String &str, Font *font, byte fontColour,
uint16 x, uint16 y, uint spacing) {
uint x, uint y, uint z, uint spacing) {
uint len = str.size();
_length = len;
_x = x;
_y = y;
_z = z;
_text = new byte[len];
memcpy(_text, str.c_str(), len);

View file

@ -43,19 +43,19 @@ public:
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 uint getX() { return _x; }
virtual uint getY() { return _y; }
virtual uint getZ() { return _z; }
virtual void setX(uint16 x) { _x = x; }
virtual void setY(uint16 y) { _y = y; }
virtual void setZ(uint16 z) { _z = z; }
virtual void setX(uint x) { _x = x; }
virtual void setY(uint y) { _y = y; }
virtual void setZ(uint 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
uint _x, _y; //!< Sprite coordinates
uint _z; //!< Sprite depth position
};
/**
@ -74,11 +74,12 @@ private:
class Sprite : public Drawable {
public:
Sprite(byte *raw_data, uint16 width, uint16 height, uint16 x = 0, uint16 y = 0,
bool columnwise = false);
Sprite(byte *raw_data, uint16 width, uint16 height, uint x, uint y,
uint z, bool columnwise = true);
Sprite(byte *sprite_data, uint16 length, uint16 x = 0, uint16 y = 0,
bool columnwise = false);
Sprite(byte *sprite_data, uint16 length, uint x, uint y,
uint z, bool columnwise = true);
~Sprite();
@ -94,7 +95,7 @@ class Text : public Drawable {
public:
Text(const Common::String &str, Font *font, byte fontColour,
uint16 x = 0, uint16 y = 0, uint spacing = 0);
uint x, uint y, uint z, uint spacing = 0);
~Text();
void setText(const Common::String &str);