TSAGE: Implemented SceneMessage class to show messages before fading in a scene
This is used by Blue Force to display 'The Next Day' messages.
This commit is contained in:
parent
a606312c22
commit
f0245ef09a
4 changed files with 93 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -204,7 +204,7 @@ public:
|
|||
bool _savedCanWalk;
|
||||
int _field37A;
|
||||
|
||||
FocusObject *_focusObject;
|
||||
EventHandler *_focusObject;
|
||||
Visage _cursorVisage;
|
||||
|
||||
Rect _v51C34;
|
||||
|
@ -356,6 +356,21 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
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
|
||||
|
|
|
@ -1095,9 +1095,9 @@ 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;
|
||||
|
@ -1105,9 +1105,9 @@ void Scene180::postInit(SceneObjectList *OwnerList) {
|
|||
((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();
|
||||
|
|
|
@ -203,6 +203,7 @@ public:
|
|||
NamedHotspot _curb, _sky;
|
||||
GarageExit _garageExit;
|
||||
ASoundExt _sound1;
|
||||
SceneMessage _sceneMessage;
|
||||
int _fieldC56;
|
||||
|
||||
Scene180();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue