aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorDmitry Iskrich2016-05-28 18:07:21 +0300
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit44e46db5de4211c8056962531fb6483ffe7bebeb (patch)
treef06ef8cdd7da6e1140bbee57c12871b3004543bf /engines/director
parent604fa102ff35f02b71506fa0b67283ed00139872 (diff)
downloadscummvm-rg350-44e46db5de4211c8056962531fb6483ffe7bebeb.tar.gz
scummvm-rg350-44e46db5de4211c8056962531fb6483ffe7bebeb.tar.bz2
scummvm-rg350-44e46db5de4211c8056962531fb6483ffe7bebeb.zip
DIRECTOR: Refactor cast data loading
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/score.cpp80
-rw-r--r--engines/director/score.h13
2 files changed, 35 insertions, 58 deletions
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 1b75414791..658f1e7c17 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -64,7 +64,7 @@ Score::Score(Common::SeekableReadStream &stream) {
void Score::loadConfig(Common::SeekableReadStream &stream) {
/*uint16 unk1 = */ stream.readUint16BE();
/*ver1 = */ stream.readUint16BE();
- _movieRect = readRect(stream);
+ _movieRect = Score::readRect(stream);
_castArrayStart = stream.readUint16BE();
_castArrayEnd = stream.readUint16BE();
@@ -88,19 +88,19 @@ void Score::loadCastData(Common::SeekableReadStream &stream) {
uint8 castType = stream.readByte();
switch (castType) {
case kCastBitmap:
- _casts[id] = getBitmapCast(stream);
+ _casts[id] = new BitmapCast(stream);
_casts[id]->type = kCastBitmap;
break;
case kCastText:
- _casts[id] = getTextCast(stream);
+ _casts[id] = new TextCast(stream);
_casts[id]->type = kCastText;
break;
case kCastShape:
- _casts[id] = getShapeCast(stream);
+ _casts[id] = new ShapeCast(stream);
_casts[id]->type = kCastShape;
break;
case kCastButton:
- _casts[id] = getButtonCast(stream);
+ _casts[id] = new ButtonCast(stream);
_casts[id]->type = kCastButton;
break;
default:
@@ -119,67 +119,43 @@ void Score::loadCastData(Common::SeekableReadStream &stream) {
}
}
-BitmapCast *Score::getBitmapCast(Common::SeekableReadStream &stream) {
- BitmapCast *cast = new BitmapCast();
+BitmapCast::BitmapCast(Common::SeekableReadStream &stream) {
/*byte flags = */ stream.readByte();
/*uint16 someFlaggyThing = */ stream.readUint16BE();
- cast->initialRect = readRect(stream);
- cast->boundingRect = readRect(stream);
- cast->regY = stream.readUint16BE();
- cast->regX = stream.readUint16BE();
+ initialRect = Score::readRect(stream);
+ boundingRect = Score::readRect(stream);
+ regY = stream.readUint16BE();
+ regX = stream.readUint16BE();
/*uint16 unk1 =*/ stream.readUint16BE();
/*uint16 unk2 =*/ stream.readUint16BE();
- return cast;
}
-TextCast *Score::getTextCast(Common::SeekableReadStream &stream) {
- TextCast *cast = new TextCast();
+TextCast::TextCast(Common::SeekableReadStream &stream) {
/*byte flags =*/ stream.readByte();
- cast->borderSize = stream.readByte();
- cast->gutterSize = stream.readByte();
- cast->boxShadow = stream.readByte();
- cast->textType = stream.readByte();
- cast->textAlign = stream.readUint16BE();
+ borderSize = stream.readByte();
+ gutterSize = stream.readByte();
+ boxShadow = stream.readByte();
+ textType = stream.readByte();
+ textAlign = stream.readUint16BE();
stream.skip(6); //palinfo
/*uint32 unk1 = */ stream.readUint32BE();
- cast->initialRect = readRect(stream);
- cast->textShadow = stream.readByte();
- cast->textFlags = stream.readByte();
+ initialRect = Score::readRect(stream);
+ textShadow = stream.readByte();
+ textFlags = stream.readByte();
/*uint16 unk2 =*/ stream.readUint16BE();
- return cast;
}
-ShapeCast *Score::getShapeCast(Common::SeekableReadStream &stream) {
- ShapeCast *cast = new ShapeCast();
+ShapeCast::ShapeCast(Common::SeekableReadStream &stream) {
/*byte flags = */ stream.readByte();
/*unk1 = */ stream.readByte();
- cast->shapeType = stream.readByte();
- cast->initialRect = readRect(stream);
- cast->pattern = stream.readUint16BE();
- cast->fgCol = stream.readByte();
- cast->bgCol = stream.readByte();
- cast->fillType = stream.readByte();
- cast->lineThickness = stream.readByte();
- cast->lineDirection = stream.readByte();
- return cast;
-}
-
-ButtonCast *Score::getButtonCast(Common::SeekableReadStream &stream) {
- ButtonCast *cast = new ButtonCast();
- /*byte flags =*/ stream.readByte();
- cast->borderSize = stream.readByte();
- cast->gutterSize = stream.readByte();
- cast->boxShadow = stream.readByte();
- cast->textType = stream.readByte();
- cast->textAlign = stream.readUint16BE();
- stream.skip(6); //palinfo
- /*uint32 unk1 = */ stream.readUint32BE();
- cast->initialRect = readRect(stream);
- cast->textShadow = stream.readByte();
- cast->textFlags = stream.readByte();
- /*uint16 unk2 =*/ stream.readUint16BE();
- cast->buttonType = stream.readUint16BE();
- return cast;
+ shapeType = stream.readByte();
+ initialRect = Score::readRect(stream);
+ pattern = stream.readUint16BE();
+ fgCol = stream.readByte();
+ bgCol = stream.readByte();
+ fillType = stream.readByte();
+ lineThickness = stream.readByte();
+ lineDirection = stream.readByte();
}
Common::Rect Score::readRect(Common::SeekableReadStream &stream) {
diff --git a/engines/director/score.h b/engines/director/score.h
index 9e729c2570..299a26cf40 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -76,6 +76,7 @@ struct Cast {
};
struct BitmapCast : Cast {
+ BitmapCast(Common::SeekableReadStream &stream);
Common::Rect boundingRect;
uint16 regX;
uint16 regY;
@@ -83,6 +84,7 @@ struct BitmapCast : Cast {
};
struct ShapeCast : Cast {
+ ShapeCast(Common::SeekableReadStream &stream);
byte shapeType;
uint16 pattern;
byte fgCol;
@@ -93,6 +95,7 @@ struct ShapeCast : Cast {
};
struct TextCast : Cast {
+ TextCast(Common::SeekableReadStream &stream);
byte borderSize;
byte gutterSize;
byte boxShadow;
@@ -104,6 +107,9 @@ struct TextCast : Cast {
};
struct ButtonCast : TextCast {
+ ButtonCast(Common::SeekableReadStream &stream) : TextCast(stream) {
+ buttonType = stream.readUint16BE();
+ }
//TODO types?
uint16 buttonType;
};
@@ -150,7 +156,6 @@ public:
uint8 _skipFrameFlag;
uint8 _blend;
Common::Array<Sprite *> _sprites;
-
};
class Score {
@@ -159,14 +164,10 @@ public:
void readVersion(uint32 rid);
void loadConfig(Common::SeekableReadStream &stream);
void loadCastData(Common::SeekableReadStream &stream);
+ static Common::Rect readRect(Common::SeekableReadStream &stream);
void play();
private:
- BitmapCast *getBitmapCast(Common::SeekableReadStream &stream);
- TextCast *getTextCast(Common::SeekableReadStream &stream);
- ButtonCast *getButtonCast(Common::SeekableReadStream &stream);
- ShapeCast *getShapeCast(Common::SeekableReadStream &stream);
- Common::Rect readRect(Common::SeekableReadStream &stream);
void processEvents();
void display();