aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen
diff options
context:
space:
mode:
authorPaul Gilbert2018-04-28 16:21:30 -0400
committerPaul Gilbert2018-04-28 16:21:30 -0400
commitbd5d097286fd316fd2067ad5681dcccadafb8219 (patch)
treeae5f3ac2bdacac70db54740802262f3951d8e71a /engines/xeen
parente0c7335ea42a3d69ddd026eaf9c274def4075d28 (diff)
downloadscummvm-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')
-rw-r--r--engines/xeen/dialogs/dialogs_spells.cpp58
-rw-r--r--engines/xeen/dialogs/dialogs_spells.h9
-rw-r--r--engines/xeen/spells.cpp47
3 files changed, 68 insertions, 46 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
diff --git a/engines/xeen/dialogs/dialogs_spells.h b/engines/xeen/dialogs/dialogs_spells.h
index c6e46c4dc5..26c3f00428 100644
--- a/engines/xeen/dialogs/dialogs_spells.h
+++ b/engines/xeen/dialogs/dialogs_spells.h
@@ -168,6 +168,15 @@ public:
static void show(XeenEngine *vm);
};
+class DetectMonsters : public ButtonContainer {
+private:
+ DetectMonsters(XeenEngine *vm) : ButtonContainer(vm) {}
+
+ void execute();
+public:
+ static void show(XeenEngine *vm);
+};
+
} // End of namespace Xeen
#endif /* XEEN_DIALOGS_SPELLS_H */
diff --git a/engines/xeen/spells.cpp b/engines/xeen/spells.cpp
index de55dd6802..04d77e1f66 100644
--- a/engines/xeen/spells.cpp
+++ b/engines/xeen/spells.cpp
@@ -428,52 +428,7 @@ void Spells::deadlySwarm() {
}
void Spells::detectMonster() {
- 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();
+ DetectMonsters::show(_vm);
}
void Spells::divineIntervention() {