XEEN: Extra comments to sprite resource class

This commit is contained in:
Paul Gilbert 2015-01-24 15:29:02 -05:00
parent 339dfcb2cc
commit c01120aedd

View File

@ -43,6 +43,9 @@ SpriteResource::~SpriteResource() {
clear();
}
/**
* Copy operator for duplicating a sprite resource
*/
SpriteResource &SpriteResource::operator=(const SpriteResource &src) {
delete[] _data;
_index.clear();
@ -58,16 +61,25 @@ SpriteResource &SpriteResource::operator=(const SpriteResource &src) {
return *this;
}
/**
* Load a sprite resource from a given file
*/
void SpriteResource::load(const Common::String &filename) {
File f(filename);
load(f);
}
/**
* Load a sprite resource from a given file and archive
*/
void SpriteResource::load(const Common::String &filename, Common::Archive &archive) {
File f(filename, archive);
load(f);
}
/**
* Load a sprite resource from a stream
*/
void SpriteResource::load(Common::SeekableReadStream &f) {
// Read in a copy of the file
_filesize = f.size();
@ -86,12 +98,18 @@ void SpriteResource::load(Common::SeekableReadStream &f) {
}
}
/**
* Clears the sprite resource
*/
void SpriteResource::clear() {
delete[] _data;
_data = nullptr;
_filesize = 0;
}
/**
* Draws a frame using data at a specific offset in the sprite resource
*/
void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos, int flags) const {
// Get cell header
Common::MemoryReadStream f(_data, _filesize);
@ -229,8 +247,12 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
dest.addDirtyRect(r);
}
/**
* Draw the sprite onto the given surface
*/
void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPos,
int flags, int scale) const {
assert(scale != 0x8000); // TODO: TO test when I find scale value used
if (scale == 0) {
drawOffset(dest, _index[frame]._offset1, destPos, flags);
@ -261,6 +283,9 @@ void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPo
}
}
/**
* Draw the sprite onto the given surface
*/
void SpriteResource::draw(XSurface &dest, int frame) const {
draw(dest, frame, Common::Point());
}