[Scummvm-git-logs] scummvm master -> bd5d097286fd316fd2067ad5681dcccadafb8219

dreammaster dreammaster at scummvm.org
Sat Apr 28 22:21:37 CEST 2018


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
bd5d097286 XEEN: Move Detect Monsters dialog logic into a dialogs_spells.cpp class


Commit: bd5d097286fd316fd2067ad5681dcccadafb8219
    https://github.com/scummvm/scummvm/commit/bd5d097286fd316fd2067ad5681dcccadafb8219
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-04-28T16:21:30-04:00

Commit Message:
XEEN: Move Detect Monsters dialog logic into a dialogs_spells.cpp class

Changed paths:
    engines/xeen/dialogs/dialogs_spells.cpp
    engines/xeen/dialogs/dialogs_spells.h
    engines/xeen/spells.cpp


diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp
index bc53134..27329e4 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 c6e46c4..26c3f00 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 de55dd6..04d77e1 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() {





More information about the Scummvm-git-logs mailing list