Skip to content

Commit

Permalink
TSAGE: Blue Force - Move identical intro Text classes to common game …
Browse files Browse the repository at this point in the history
…logic
  • Loading branch information
Strangerke committed Oct 19, 2011
1 parent c39e45f commit 1d3fa74
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 200 deletions.
51 changes: 51 additions & 0 deletions engines/tsage/blue_force/blueforce_logic.cpp
Expand Up @@ -1474,6 +1474,57 @@ void SceneMessage::clear() {
g_globals->_sceneManager._hasPalette = true;
}

IntroSceneText::IntroSceneText(): SceneText() {
_action = NULL;
_frameNumber = 0;
_diff = 0;
}

void IntroSceneText::setup(const Common::String &msg, Action *action) {
_frameNumber = BF_GLOBALS._events.getFrameNumber();
_diff = 180;
_action = action;
_fontNumber = 4;
_width = 300;
_textMode = ALIGN_CENTER;
_color1 = BF_GLOBALS._scenePalette._colors.background;
_color2 = _color3 = 0;

SceneText::setup(msg);

// Center the text on-screen
reposition();
_bounds.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);

// Set the new position
_position.x = _bounds.left;
_position.y = _bounds.top;
}

void IntroSceneText::synchronize(Serializer &s) {
SceneText::synchronize(s);
SYNC_POINTER(_action);
s.syncAsUint32LE(_frameNumber);
s.syncAsSint16LE(_diff);
}

void IntroSceneText::dispatch() {
if (_diff) {
uint32 frameNumber = BF_GLOBALS._events.getFrameNumber();
if (_frameNumber < frameNumber) {
_diff -= frameNumber - _frameNumber;
_frameNumber = frameNumber;

if (_diff <= 0) {
// Time has expired, so remove the text and signal the designated action
remove();
if (_action)
_action->signal();
}
}
}
}

} // End of namespace BlueForce

} // End of namespace TsAGE
14 changes: 14 additions & 0 deletions engines/tsage/blue_force/blueforce_logic.h
Expand Up @@ -371,6 +371,20 @@ class SceneMessage: public Action {
virtual void process(Event &event);
};

class IntroSceneText: public SceneText {
public:
Action *_action;
uint32 _frameNumber;
int _diff;
public:
IntroSceneText();
void setup(const Common::String &msg, Action *action);

virtual Common::String getClassName() { return "BFIntroText"; }
virtual void synchronize(Serializer &s);
virtual void dispatch();
};

} // End of namespace BlueForce

} // End of namespace TsAGE
Expand Down
155 changes: 0 additions & 155 deletions engines/tsage/blue_force/blueforce_scenes1.cpp
Expand Up @@ -299,59 +299,6 @@ void Scene109::Action3::signal() {

/*--------------------------------------------------------------------------*/

Scene109::Text::Text(): SceneText() {
_action = NULL;
_frameNumber = 0;
_diff = 0;
}

void Scene109::Text::setup(const Common::String &msg, Action *action) {
_frameNumber = BF_GLOBALS._events.getFrameNumber();
_diff = 180;
_action = action;
_fontNumber = 4;
_width = 300;
_textMode = ALIGN_CENTER;
_color1 = BF_GLOBALS._scenePalette._colors.background;
_color2 = _color3 = 0;

SceneText::setup(msg);

// Center the text on-screen
reposition();
_bounds.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);

// Set the new position
_position.x = _bounds.left;
_position.y = _bounds.top;
}

void Scene109::Text::synchronize(Serializer &s) {
SceneText::synchronize(s);
SYNC_POINTER(_action);
s.syncAsUint32LE(_frameNumber);
s.syncAsSint16LE(_diff);
}

void Scene109::Text::dispatch() {
if (_diff) {
uint32 frameNumber = BF_GLOBALS._events.getFrameNumber();
if (_frameNumber < frameNumber) {
_diff -= frameNumber - _frameNumber;
_frameNumber = frameNumber;

if (_diff <= 0) {
// Time has expired, so remove the text and signal the designated action
remove();
if (_action)
_action->signal();
}
}
}
}

/*--------------------------------------------------------------------------*/

Scene109::Scene109(): PalettedScene() {
}

Expand Down Expand Up @@ -2371,57 +2318,6 @@ void Scene140::Action1::signal() {
}
}

Scene140::Text::Text(): SceneText() {
_action = NULL;
_frameNumber = 0;
_diff = 0;
}

void Scene140::Text::setup(const Common::String &msg, Action *action) {
_frameNumber = BF_GLOBALS._events.getFrameNumber();
_diff = 180;
_action = action;
_fontNumber = 4;
_width = 300;
_textMode = ALIGN_CENTER;
_color1 = BF_GLOBALS._scenePalette._colors.background;
_color2 = _color3 = 0;

SceneText::setup(msg);

// Center the text on-screen
reposition();
_bounds.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);

// Set the new position
_position.x = _bounds.left;
_position.y = _bounds.top;
}

void Scene140::Text::synchronize(Serializer &s) {
SceneText::synchronize(s);
SYNC_POINTER(_action);
s.syncAsUint32LE(_frameNumber);
s.syncAsSint16LE(_diff);
}

void Scene140::Text::dispatch() {
if (_diff) {
uint32 frameNumber = BF_GLOBALS._events.getFrameNumber();
if (_frameNumber < frameNumber) {
_diff -= frameNumber - _frameNumber;
_frameNumber = frameNumber;

if (_diff <= 0) {
// Time has expired, so remove the text and signal the designated action
remove();
if (_action)
_action->signal();
}
}
}
}

void Scene140::postInit(SceneObjectList *OwnerList) {
SceneExt::postInit();
loadScene(999);
Expand Down Expand Up @@ -2776,57 +2672,6 @@ void Scene160::Action3::signal() {
}
}

Scene160::Text::Text(): SceneText() {
_action = NULL;
_frameNumber = 0;
_diff = 0;
}

void Scene160::Text::setup(const Common::String &msg, Action *action) {
_frameNumber = BF_GLOBALS._events.getFrameNumber();
_diff = 180;
_action = action;
_fontNumber = 4;
_width = 300;
_textMode = ALIGN_CENTER;
_color1 = BF_GLOBALS._scenePalette._colors.background;
_color2 = _color3 = 0;

SceneText::setup(msg);

// Center the text on-screen
reposition();
_bounds.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);

// Set the new position
_position.x = _bounds.left;
_position.y = _bounds.top;
}

void Scene160::Text::synchronize(Serializer &s) {
SceneText::synchronize(s);
SYNC_POINTER(_action);
s.syncAsUint32LE(_frameNumber);
s.syncAsSint16LE(_diff);
}

void Scene160::Text::dispatch() {
if (_diff) {
uint32 frameNumber = BF_GLOBALS._events.getFrameNumber();
if (_frameNumber < frameNumber) {
_diff -= frameNumber - _frameNumber;
_frameNumber = frameNumber;

if (_diff <= 0) {
// Time has expired, so remove the text and signal the designated action
remove();
if (_action)
_action->signal();
}
}
}
}

void Scene160::postInit(SceneObjectList *OwnerList) {
SceneExt::postInit();
loadScene(160);
Expand Down
48 changes: 3 additions & 45 deletions engines/tsage/blue_force/blueforce_scenes1.h
Expand Up @@ -95,27 +95,13 @@ class Scene109: public PalettedScene {
virtual void signal();
};

/* Texts */
class Text: public SceneText {
public:
Action *_action;
uint32 _frameNumber;
int _diff;
public:
Text();
void setup(const Common::String &msg, Action *action);

virtual Common::String getClassName() { return "BF109Text"; }
virtual void synchronize(Serializer &s);
virtual void dispatch();
};
public:
SequenceManager _sequenceManager1, _sequenceManager2, _sequenceManager3;
SequenceManager _sequenceManager4, _sequenceManager5, _sequenceManager6;
SequenceManager _sequenceManager7, _sequenceManager8;
SceneObject _object1, _object2, _protaginist2, _protaginist1, _object5;
SceneObject _drunk, _object7, _bartender, _object9, _object10;
Text _text;
IntroSceneText _text;
Action1 _action1;
Action _action2, _action3;
public:
Expand Down Expand Up @@ -361,26 +347,12 @@ class Scene140: public SceneExt {
public:
virtual void signal();
};
/* Texts */
class Text: public SceneText {
public:
Action *_action;
uint32 _frameNumber;
int _diff;
public:
Text();
void setup(const Common::String &msg, Action *action);

virtual Common::String getClassName() { return "BF140Text"; }
virtual void synchronize(Serializer &s);
virtual void dispatch();
};
public:
Action1 _action1;
ASoundExt _soundExt1;
NamedObject _object1;
NamedObject _object2;
Text _text;
IntroSceneText _text;

void postInit(SceneObjectList *OwnerList);
};
Expand Down Expand Up @@ -413,27 +385,13 @@ class Scene160: public SceneExt {
public:
virtual void signal();
};
/* Texts */
class Text: public SceneText {
public:
Action *_action;
uint32 _frameNumber;
int _diff;
public:
Text();
void setup(const Common::String &msg, Action *action);

virtual Common::String getClassName() { return "BF160Text"; }
virtual void synchronize(Serializer &s);
virtual void dispatch();
};
public:
NamedObject _flag, _kid, _kidBody, _leftOfficer, _grandma, _rightOfficer;
ASound _sound1;
Action1 _action1;
Action2 _action2;
Action3 _action3;
Text _text;
IntroSceneText _text;

void postInit(SceneObjectList *OwnerList);
};
Expand Down

0 comments on commit 1d3fa74

Please sign in to comment.