From 55fc09571f52c26392a0b54951db650968e99ff2 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sat, 18 Nov 2017 00:49:23 +0000 Subject: SUPERNOVA: Fix handling of room brightness There were several issues with the brighness due to the different implementation between the original and the code in scummvm. The code has now been modified to be much closer to the original, which fixed those issues and allowed to remove workarounds that had been added in various places to deal with those issues (but those workarounds had their own issues such as fade in happening too soon before switching to the new room). --- engines/supernova/rooms.cpp | 3 --- engines/supernova/state.cpp | 25 +++++++++++++++++++------ engines/supernova/state.h | 1 + engines/supernova/supernova.cpp | 16 +++++++++------- 4 files changed, 29 insertions(+), 16 deletions(-) (limited to 'engines/supernova') diff --git a/engines/supernova/rooms.cpp b/engines/supernova/rooms.cpp index 3c3ef9481d..5dfb6c8e69 100644 --- a/engines/supernova/rooms.cpp +++ b/engines/supernova/rooms.cpp @@ -1020,8 +1020,6 @@ void ShipCabinR3::onEntrance() { for (int i = 0; i < 3; ++i) _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(i)); - _vm->paletteBrightness(); - _vm->paletteFadeIn(); setRoomSeen(true); } @@ -2243,7 +2241,6 @@ bool ArsanoMeetup2::interact(Action verb, Object &obj1, Object &obj2) { _gm->loadTime(); _gm->_rooms[CAVE]->getObject(1)->_exitRoom = MEETUP3; _gm->_state._dream = true; - _vm->paletteFadeIn(); } } else { _gm->changeRoom(MEETUP2); diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp index 1e7ebc8ef4..3907370b62 100644 --- a/engines/supernova/state.cpp +++ b/engines/supernova/state.cpp @@ -325,6 +325,7 @@ void GameManager::initState() { _processInput = false; _guiEnabled = true; _animationEnabled = true; + _roomBrightness = 255; _mouseClicked = false; _keyPressed = false; _mouseX = -1; @@ -832,7 +833,6 @@ void GameManager::supernovaEvent() { _rooms[MEETUP2]->removeSentence(0, 1); } _rooms[MEETUP2]->removeSentence(1, 1); - _vm->paletteFadeIn(); } _rooms[AIRLOCK]->getObject(4)->setProperty(WORN); _rooms[AIRLOCK]->getObject(5)->setProperty(WORN); @@ -1048,7 +1048,12 @@ void GameManager::mousePosDialog(int x, int y) { } void GameManager::turnOff() { + if (_state._powerOff) + return; + _state._powerOff = true; + roomBrightness(); + _vm->paletteBrightness(); } void GameManager::turnOn() { @@ -1191,18 +1196,19 @@ void GameManager::mouseInput3() { } void GameManager::roomBrightness() { - _vm->_brightness = 255; + _roomBrightness = 255; if ((_currentRoom->getId() != OUTSIDE) && (_currentRoom->getId() < ROCKS) ) { if (_state._powerOff) - _vm->_brightness = 153; + _roomBrightness = 153; } else if (_currentRoom->getId() == CAVE) { - _vm->_brightness = 0; + _roomBrightness = 0; } else if (_currentRoom->getId() == GUARD3) { if (_state._powerOff) - _vm->_brightness = 0; + _roomBrightness = 0; } - _vm->paletteBrightness(); + if (_vm->_brightness != 0) + _vm->_brightness = _roomBrightness; } void GameManager::changeRoom(RoomID id) { @@ -1613,6 +1619,7 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) { getInput(); _vm->renderRoom(*_currentRoom); roomBrightness(); + _vm->paletteBrightness(); _vm->renderMessage(kStringGenericInteract_12); } else if ((verb == ACTION_LOOK) && (obj1._id == KEYCARD2)) { _vm->renderMessage(obj1._description); @@ -1930,7 +1937,13 @@ void GameManager::executeRoom() { drawStatus(); drawCommandBox(); } + roomBrightness(); + if (_vm->_brightness == 0) + _vm->paletteFadeIn(); + else + _vm->paletteBrightness(); + if (!_currentRoom->hasSeen()) _currentRoom->onEntrance(); } diff --git a/engines/supernova/state.h b/engines/supernova/state.h index bd08371372..9cbd68cd34 100644 --- a/engines/supernova/state.h +++ b/engines/supernova/state.h @@ -119,6 +119,7 @@ public: bool _processInput; bool _guiEnabled; bool _animationEnabled; + byte _roomBrightness; Action _inputVerb; Object *_currentInputObject; Object *_inputObject[2]; diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index 56ea113eac..395fd781f2 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -706,10 +706,11 @@ void SupernovaEngine::paletteBrightness() { } void SupernovaEngine::paletteFadeOut() { - while (_brightness > 10) { - _menuBrightness = _brightness; + while (_menuBrightness > 10) { + _menuBrightness -= 10; + if (_brightness > _menuBrightness) + _brightness = _menuBrightness; paletteBrightness(); - _brightness -= 10; _system->updateScreen(); _system->delayMillis(_delay); } @@ -720,15 +721,16 @@ void SupernovaEngine::paletteFadeOut() { } void SupernovaEngine::paletteFadeIn() { - while (_brightness < 245) { - _menuBrightness = _brightness; + while (_menuBrightness < 245) { + if (_brightness < _gm->_roomBrightness) + _brightness += 10; + _menuBrightness += 10; paletteBrightness(); - _brightness += 10; _system->updateScreen(); _system->delayMillis(_delay); } _menuBrightness = 255; - _brightness = 255; + _brightness = _gm->_roomBrightness; paletteBrightness(); _system->updateScreen(); } -- cgit v1.2.3