Fade palette in/out when entering/leaving a location
svn-id: r50409
This commit is contained in:
parent
d4a0c8a1ad
commit
76b8c33aaf
3 changed files with 36 additions and 8 deletions
|
@ -176,6 +176,9 @@ void Game::start() {
|
|||
// Call the outer loop doing all the hard job.
|
||||
loop(kOuterLoop, false);
|
||||
|
||||
// Fade out the palette after leaving the location.
|
||||
fadePalette(true);
|
||||
|
||||
if (!isReloaded()) {
|
||||
// We are changing location. Run the hero's LOOK
|
||||
// program to trigger a possible cut-scene. This is
|
||||
|
@ -428,6 +431,22 @@ void Game::handleDialogueLoop() {
|
|||
}
|
||||
}
|
||||
|
||||
void Game::fadePalette(bool fading_out) {
|
||||
const byte *startPal = NULL;
|
||||
const byte *endPal = _currentRoom._palette >= 0
|
||||
? _vm->_paletteArchive->getFile(_currentRoom._palette)->_data
|
||||
: NULL;
|
||||
if (fading_out) {
|
||||
startPal = endPal;
|
||||
endPal = NULL;
|
||||
}
|
||||
for (int i = 1; i <= kBlackFadingIterations; ++i) {
|
||||
_vm->_system->delayMillis(kBlackFadingTimeUnit);
|
||||
_vm->_screen->interpolatePalettes(startPal, endPal, 0, kNumColours, i, kBlackFadingIterations);
|
||||
_vm->_screen->copyToScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void Game::advanceAnimationsAndTestLoopExit() {
|
||||
// Fade the palette if requested
|
||||
if (_fadePhase > 0 && (_vm->_system->getMillis() - _fadeTick) >= kFadingTimeUnit) {
|
||||
|
@ -485,7 +504,7 @@ void Game::advanceAnimationsAndTestLoopExit() {
|
|||
// callbacks) and redraw screen
|
||||
_vm->_anims->drawScene(_vm->_screen->getSurface());
|
||||
_vm->_screen->copyToScreen();
|
||||
_vm->_system->delayMillis(20);
|
||||
_vm->_system->delayMillis(kTimeUnit);
|
||||
|
||||
// If the hero has arrived at his destination, after even the last
|
||||
// phase was correctly animated, run the callback.
|
||||
|
@ -1364,10 +1383,11 @@ void Game::enterNewRoom() {
|
|||
loadRoomObjects();
|
||||
loadOverlays();
|
||||
|
||||
// Set room palette
|
||||
const BAFile *f;
|
||||
f = _vm->_paletteArchive->getFile(_currentRoom._palette);
|
||||
_vm->_screen->setPalette(f->_data, 0, kNumColours);
|
||||
// Draw the scene with the black palette and slowly fade into the right palette.
|
||||
_vm->_screen->setPalette(NULL, 0, kNumColours);
|
||||
_vm->_anims->drawScene(_vm->_screen->getSurface());
|
||||
_vm->_screen->copyToScreen();
|
||||
fadePalette(false);
|
||||
|
||||
// Run the program for the gate the dragon came through
|
||||
debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", _newGate);
|
||||
|
|
|
@ -65,9 +65,16 @@ enum SpeechConstants {
|
|||
kStandardSpeed = 60
|
||||
};
|
||||
|
||||
// One fading phase is 50ms.
|
||||
enum FadeConstants {
|
||||
kFadingTimeUnit = 50
|
||||
// One fading phase called from the game scripts is 50ms.
|
||||
kFadingTimeUnit = 50,
|
||||
// Fading in/out when entering/leaving a location takes 15 iterations of (at least) 7ms each.
|
||||
kBlackFadingIterations = 15,
|
||||
kBlackFadingTimeUnit = 7
|
||||
};
|
||||
|
||||
enum AnimationConstants {
|
||||
kTimeUnit = 20
|
||||
};
|
||||
|
||||
/** Inventory related magical constants */
|
||||
|
@ -334,6 +341,7 @@ private:
|
|||
void handleDialogueLoop();
|
||||
void updateTitle(int x, int y);
|
||||
void updateCursor();
|
||||
void fadePalette(bool fading_out);
|
||||
void advanceAnimationsAndTestLoopExit();
|
||||
void handleStatusChangeByMouse();
|
||||
|
||||
|
|
|
@ -881,7 +881,7 @@ void Script::setPalette(const Common::Array<int> ¶ms) {
|
|||
}
|
||||
// Immediately update the palette
|
||||
_vm->_screen->copyToScreen();
|
||||
_vm->_system->delayMillis(20);
|
||||
_vm->_system->delayMillis(kTimeUnit);
|
||||
}
|
||||
|
||||
void Script::quitGame(const Common::Array<int> ¶ms) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue