Skip to content

Commit

Permalink
TSAGE: Implemented SceneMessage class to show messages before fading …
Browse files Browse the repository at this point in the history
…in a scene

This is used by Blue Force to display 'The Next Day' messages.
  • Loading branch information
dreammaster committed Oct 15, 2011
1 parent a606312 commit f0245ef
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 5 deletions.
72 changes: 72 additions & 0 deletions engines/tsage/blue_force/blueforce_logic.cpp
Expand Up @@ -1391,6 +1391,78 @@ void NamedHotspot::synchronize(Serializer &s) {
s.syncAsSint16LE(_talkLineNum);
}

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

void SceneMessage::remove() {
SceneExt *scene = (SceneExt *)BF_GLOBALS._sceneManager._scene;
if (scene->_focusObject == this)
scene->_focusObject = NULL;

Action::remove();
}

void SceneMessage::signal() {
SceneExt *scene = (SceneExt *)BF_GLOBALS._sceneManager._scene;

switch (_actionIndex++) {
case 0:
scene->_focusObject = this;
BF_GLOBALS._events.setCursor(CURSOR_WALK);
draw();
setDelay(180);
break;
case 1:
clear();
remove();
break;
default:
break;
}
}

void SceneMessage::process(Event &event) {
if ((event.eventType == EVENT_BUTTON_DOWN) ||
((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_RETURN))) {
signal();
}
}


void SceneMessage::draw() {
GfxSurface &surface = BF_GLOBALS._screenSurface;

// Clear the game area
surface.fillRect(Rect(0, 0, SCREEN_WIDTH, BF_INTERFACE_Y), 0);

// Disable scene fade in
BF_GLOBALS._paneRefreshFlag[0] = 0;

// Set up the font
GfxFont &font = BF_GLOBALS._gfxManagerInstance._font;
BF_GLOBALS._scenePalette.setEntry(font._colors.foreground, 255, 255, 255);
BF_GLOBALS._scenePalette.setPalette(font._colors.foreground, 1);

// Write out the message
Rect textRect(0, BF_INTERFACE_Y / 2 - (font.getHeight() / 2), SCREEN_WIDTH,
BF_INTERFACE_Y / 2 + (font.getHeight() / 2));
BF_GLOBALS._gfxManagerInstance._font.writeLines(_message.c_str(), textRect, ALIGN_CENTER);

// TODO: Ideally, saving and loading should be disabled here until the message display is complete
}

void SceneMessage::clear() {
// Fade out the text display
static const uint32 black = 0;
BF_GLOBALS._scenePalette.fade((const byte *)&black, false, 100);

// Refresh the background
BF_GLOBALS._paneRefreshFlag[0] = 0;

// Set up to fade in the game scene
g_globals->_sceneManager._fadeMode = FADEMODE_GRADUAL;
g_globals->_sceneManager._hasPalette = true;
}

} // End of namespace BlueForce

} // End of namespace TsAGE
17 changes: 16 additions & 1 deletion engines/tsage/blue_force/blueforce_logic.h
Expand Up @@ -204,7 +204,7 @@ class SceneExt: public Scene {
bool _savedCanWalk;
int _field37A;

FocusObject *_focusObject;
EventHandler *_focusObject;
Visage _cursorVisage;

Rect _v51C34;
Expand Down Expand Up @@ -356,6 +356,21 @@ class NamedHotspotExt : public NamedHotspot {
}
};

class SceneMessage: public Action {
private:
Common::String _message;

void draw();
void clear();
public:
void setup(const Common::String &msg) { _message = msg; }

virtual Common::String getClassName() { return "SceneMessage"; }
virtual void remove();
virtual void signal();
virtual void process(Event &event);
};

} // End of namespace BlueForce

} // End of namespace TsAGE
Expand Down
8 changes: 4 additions & 4 deletions engines/tsage/blue_force/blueforce_scenes1.cpp
Expand Up @@ -1095,19 +1095,19 @@ void Scene180::postInit(SceneObjectList *OwnerList) {
if ((BF_GLOBALS._bookmark == bLyleStoppedBy) && (BF_GLOBALS._dayNumber == 1)) {
BF_GLOBALS._v501FC = 87;
BF_GLOBALS._v501FA = _sceneBounds.left;
// _unk.setupText(THE_NEXT_DAY);
_sceneMessage.setup(THE_NEXT_DAY);
_sceneMode = 6;
// setAction(&_unk);
setAction(&_sceneMessage, this);
BF_GLOBALS._driveFromScene = 4;
BF_GLOBALS._driveToScene = 4;
BF_GLOBALS._mapLocationId = 4;
} else if (((BF_GLOBALS._bookmark == bDroppedOffLyle) && (BF_GLOBALS._dayNumber == 3)) ||
((BF_GLOBALS._bookmark == bDoneAtLyles) && (BF_GLOBALS._dayNumber == 4))) {
BF_GLOBALS._v501FC = 87;
BF_GLOBALS._v501FA = _sceneBounds.left;
// _unk.setupText(THE_NEXT_DAY);
_sceneMessage.setup(THE_NEXT_DAY);
_sceneMode = 6;
// setAction(&_unk);
setAction(&_sceneMessage, this);
} else if (BF_GLOBALS._dayNumber == 0) {
BF_GLOBALS._player.setPosition(Common::Point(0, 150));
_garageExit.postInit();
Expand Down
1 change: 1 addition & 0 deletions engines/tsage/blue_force/blueforce_scenes1.h
Expand Up @@ -203,6 +203,7 @@ class Scene180: public SceneExt {
NamedHotspot _curb, _sky;
GarageExit _garageExit;
ASoundExt _sound1;
SceneMessage _sceneMessage;
int _fieldC56;

Scene180();
Expand Down

0 comments on commit f0245ef

Please sign in to comment.