NANCY: Completely disable nancy7 clock

Fixed the CLOK chunk reading, so the parameters that
indicate whether the clock is the day clock (nancy5), or
completely disabled (nancy7) now get read correctly.
This commit is contained in:
Kaloyan Chehlarski 2024-01-27 23:50:10 +01:00
parent 856b4c5192
commit 13dde71233
5 changed files with 34 additions and 18 deletions

Binary file not shown.

View File

@ -567,11 +567,13 @@ CLOK::CLOK(Common::SeekableReadStream *chunkStream) : EngineData(chunkStream) {
s.syncAsUint32LE(timeToKeepOpen);
s.syncAsUint16LE(frameTime);
s.syncAsByte(clockIsDisabled, kGameTypeNancy5);
s.syncAsByte(clockIsDay, kGameTypeNancy5);
s.syncAsUint32LE(countdownTime, kGameTypeNancy5);
s.skip(2, kGameTypeNancy5);
s.syncAsUint32LE(nancy5CountdownTime, kGameTypeNancy5);
s.skip(2, kGameTypeNancy5);
readRectArray(s, nancy5DaySrcs, 3, 3, kGameTypeNancy5);
readRectArray(s, nancy5CountdownSrcs, 13, 13, kGameTypeNancy5);
readRectArray(s, daySrcs, 3, 3, kGameTypeNancy5);
readRectArray(s, countdownSrcs, 13, 13, kGameTypeNancy5);
readRect(s, disabledSrc, kGameTypeNancy5);
}
SPEC::SPEC(Common::SeekableReadStream *chunkStream) : EngineData(chunkStream) {

View File

@ -357,9 +357,13 @@ struct CLOK : public EngineData {
uint32 timeToKeepOpen = 0;
uint16 frameTime = 0;
uint32 nancy5CountdownTime = 0;
Common::Array<Common::Rect> nancy5DaySrcs;
Common::Array<Common::Rect> nancy5CountdownSrcs;
bool clockIsDisabled = false;
bool clockIsDay = false; // nancy5 clock
uint32 countdownTime = 0;
Common::Array<Common::Rect> daySrcs;
Common::Array<Common::Rect> countdownSrcs;
Common::Rect disabledSrc; // possibly useless
};
// Contains data for special effects (fades between scenes/fades to black).

View File

@ -741,7 +741,12 @@ void Scene::synchronize(Common::Serializer &ser) {
}
UI::Clock *Scene::getClock() {
return g_nancy->getGameType() != kGameTypeNancy5 ? (UI::Clock *)_clock : nullptr;
auto *clok = GetEngineData(CLOK);
if (clok->clockIsDisabled || clok->clockIsDay) {
return nullptr;
} else {
return (UI::Clock *)_clock;
}
}
void Scene::init() {
@ -1174,15 +1179,20 @@ void Scene::initStaticData() {
_clock->init();
}
// Init just the clock (nancy2 and up; nancy1 has no clock, only a map button)
if (g_nancy->getGameType() >= kGameTypeNancy2) {
if (g_nancy->getGameType() == kGameTypeNancy5) {
// Nancy 5 uses a custom "clock" that mostly just indicates the in-game day
auto *clok = GetEngineData(CLOK);
if (clok->clockIsDay) {
// nancy5 uses a different "clock" that mostly just indicates the in-game day
_clock = new UI::Nancy5Clock();
} else {
_clock->init();
} else if (!clok->clockIsDisabled) {
_clock = new UI::Clock();
_clock->init();
} else {
// In nancy7 the clock is entirely disabled
_clock = nullptr;
}
_clock->init();
}
_state = kLoad;

View File

@ -198,19 +198,19 @@ void Nancy5Clock::updateGraphics() {
if (_currentDay < 3) {
if (NancySceneState.getEventFlag(59, true) && _currentDay == 1) {
_currentDay = 2;
_drawSurface.create(g_nancy->_graphicsManager->_object0, _clockData->nancy5DaySrcs[2]);
_drawSurface.create(g_nancy->_graphicsManager->_object0, _clockData->daySrcs[2]);
moveTo(_clockData->staticImageDest);
setVisible(true);
setTransparent(true);
} else if (NancySceneState.getEventFlag(58, true) && _currentDay == 0) {
_currentDay = 1;
_drawSurface.create(g_nancy->_graphicsManager->_object0, _clockData->nancy5DaySrcs[1]);
_drawSurface.create(g_nancy->_graphicsManager->_object0, _clockData->daySrcs[1]);
moveTo(_clockData->staticImageDest);
setVisible(true);
setTransparent(true);
} else if (NancySceneState.getEventFlag(57, true) && _currentDay == -1) {
_currentDay = 0;
_drawSurface.create(g_nancy->_graphicsManager->_object0, _clockData->nancy5DaySrcs[0]);
_drawSurface.create(g_nancy->_graphicsManager->_object0, _clockData->daySrcs[0]);
moveTo(_clockData->staticImageDest);
setVisible(true);
setTransparent(true);
@ -221,11 +221,11 @@ void Nancy5Clock::updateGraphics() {
if (NancySceneState.getEventFlag(320, true)) {
_currentDay = 3;
Time timerTime = NancySceneState.getTimerTime();
int32 countdownFrameID = MIN<int32>((uint32)timerTime / (_clockData->nancy5CountdownTime / 12), 13);
int32 countdownFrameID = MIN<int32>((uint32)timerTime / (_clockData->countdownTime / 12), 13);
if (countdownFrameID != _countdownProgress) {
_countdownProgress = countdownFrameID;
_drawSurface.create(g_nancy->_graphicsManager->_object0, _clockData->nancy5CountdownSrcs[_countdownProgress]);
_drawSurface.create(g_nancy->_graphicsManager->_object0, _clockData->countdownSrcs[_countdownProgress]);
moveTo(_clockData->staticImageDest);
setVisible(true);
}