diff options
author | Paul Gilbert | 2018-04-28 16:21:30 -0400 |
---|---|---|
committer | Paul Gilbert | 2018-04-28 16:21:30 -0400 |
commit | bd5d097286fd316fd2067ad5681dcccadafb8219 (patch) | |
tree | ae5f3ac2bdacac70db54740802262f3951d8e71a /engines/xeen/dialogs/dialogs_spells.cpp | |
parent | e0c7335ea42a3d69ddd026eaf9c274def4075d28 (diff) | |
download | scummvm-rg350-bd5d097286fd316fd2067ad5681dcccadafb8219.tar.gz scummvm-rg350-bd5d097286fd316fd2067ad5681dcccadafb8219.tar.bz2 scummvm-rg350-bd5d097286fd316fd2067ad5681dcccadafb8219.zip |
XEEN: Move Detect Monsters dialog logic into a dialogs_spells.cpp class
Diffstat (limited to 'engines/xeen/dialogs/dialogs_spells.cpp')
-rw-r--r-- | engines/xeen/dialogs/dialogs_spells.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp index bc5313410f..27329e48df 100644 --- a/engines/xeen/dialogs/dialogs_spells.cpp +++ b/engines/xeen/dialogs/dialogs_spells.cpp @@ -1013,4 +1013,62 @@ void IdentifyMonster::execute() { w.close(); } + +/*------------------------------------------------------------------------*/ + +void DetectMonsters::show(XeenEngine *vm) { + DetectMonsters *dlg = new DetectMonsters(vm); + dlg->execute(); + delete dlg; +} + +void DetectMonsters::execute() { + EventsManager &events = *_vm->_events; + Interface &intf = *_vm->_interface; + Map &map = *_vm->_map; + Party &party = *_vm->_party; + Resources &res = *_vm->_resources; + Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; + Window &w = windows[19]; + int ccNum = _vm->_files->_ccNum; + int grid[7][7]; + + SpriteResource sprites(ccNum ? "detectmn.icn" : "detctmon.icn"); + Common::fill(&grid[0][0], &grid[6][6], 0); + + w.open(); + w.writeString(Res.DETECT_MONSTERS); + sprites.draw(w, 0, Common::Point(243, 80)); + + for (int yDiff = 3; yDiff >= -3; --yDiff) { + for (int xDiff = -3; xDiff <= 3; ++xDiff) { + for (uint monIndex = 0; monIndex < map._mobData._monsters.size(); ++monIndex) { + MazeMonster &monster = map._mobData._monsters[monIndex]; + Common::Point pt = party._mazePosition + Common::Point(xDiff, yDiff); + if (monster._position == pt) { + int &gridEntry = grid[yDiff + 3][xDiff + 3]; + if (++gridEntry > 3) + gridEntry = 3; + + sprites.draw(w, gridEntry, Common::Point(271 + xDiff * 9, 102 - yDiff * 7)); + } + } + } + } + + res._globalSprites.draw(w, party._mazeDirection + 1, Common::Point(270, 101)); + sound.playFX(20); + w.update(); + + while (!g_vm->shouldExit() && !events.isKeyMousePressed()) { + events.updateGameCounter(); + intf.draw3d(true); + + events.wait(1, false); + } + + w.close(); +} + } // End of namespace Xeen |