NEVERHOOD: Implement cheat framework and "itsshowtime" cheat

This commit is contained in:
Vladimir Serbinenko 2023-01-10 20:57:03 +01:00
parent 0ca10425b6
commit de56f3f6be
4 changed files with 20 additions and 0 deletions

View File

@ -464,6 +464,13 @@ uint32 DiskplayerScene::handleMessage(int messageNum, const MessageParam &param,
}
}
break;
case NM_CHEAT:
if (param.asInteger() == 0x2C034A29 && !_dropKey && !_hasAllDisks) { // "itsshowtime"
for (uint i = 0; i < 20; i++)
setSubVar(VA_HAS_TAPE, i, 1);
sendMessage(_parentModule, 0x1009, 0);
}
break;
case NM_ANIMATION_UPDATE:
tuneIn();
break;

View File

@ -142,6 +142,17 @@ void GameModule::handleAsciiKey(char key) {
debug(2, "GameModule::handleAsciiKey()");
sendMessage(_childObject, 0x000A, (uint32)key);
}
if (key == '\n' || key == '\r') {
if (!_currentCheat.empty() && _childObject) {
uint32 cheatHash = calcHash(_currentCheat.c_str());
debug(2, "GameModule: cheat=\"%s\" (0x%08x)", _currentCheat.c_str(), cheatHash);
sendMessage(_childObject, NM_CHEAT, cheatHash);
} else if (!_currentCheat.empty())
debug(2, "GameModule: cheat=\"%s\" but no child", _currentCheat.c_str());
_currentCheat.clear();
} else if (key)
_currentCheat += key;
}
void GameModule::handleKeyDown(Common::KeyCode keyCode) {

View File

@ -68,6 +68,7 @@ protected:
bool _restartGameRequested;
bool _canRequestMainMenu;
bool _mainMenuRequested;
Common::String _currentCheat;
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
void createModuleByHash(uint32 nameHash);
void updateModule();

View File

@ -32,6 +32,7 @@ enum NeverhoodMessage {
NM_MOUSE_SHOW = 0x101E,
NM_KEYPRESS_SPACE = 0x0009,
NM_KEYPRESS_ESC = 0x000C,
NM_CHEAT = 0x000D,
NM_ANIMATION_START = 0x100D,
NM_SCENE_LEAVE = 0x1019,
NM_PRIORITY_CHANGE = 0x1022,