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

dreammaster noreply at scummvm.org
Sat Apr 8 06:25:18 UTC 2023


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

Summary:
c8a4f3cc99 MM: MM1: Refactoring color questions into separate view classes
cc2074a2ed MM: MM1: Formatting for enhanced color questions view


Commit: c8a4f3cc99d6e872a093d6b617ec712719509c9f
    https://github.com/scummvm/scummvm/commit/c8a4f3cc99d6e872a093d6b617ec712719509c9f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-04-07T23:25:11-07:00

Commit Message:
MM: MM1: Refactoring color questions into separate view classes

Changed paths:
  A engines/mm/mm1/views/color_questions.cpp
  A engines/mm/mm1/views/color_questions.h
  A engines/mm/mm1/views_enh/color_questions.cpp
  A engines/mm/mm1/views_enh/color_questions.h
    engines/mm/mm1/data/character.h
    engines/mm/mm1/maps/map17.cpp
    engines/mm/mm1/maps/map17.h
    engines/mm/mm1/views/dialogs.h
    engines/mm/mm1/views_enh/dialogs.h
    engines/mm/module.mk


diff --git a/engines/mm/mm1/data/character.h b/engines/mm/mm1/data/character.h
index 61d4ce2b8e1..e9c7ef3c8d1 100644
--- a/engines/mm/mm1/data/character.h
+++ b/engines/mm/mm1/data/character.h
@@ -583,6 +583,13 @@ struct Character : public PrimaryAttributes {
 	 * Returns a string for a given condition
 	 */
 	static Common::String getConditionString(ConditionEnum cond);
+
+	/**
+	 * Returns true if the character has a fatal condition
+	 */
+	bool hasBadCondition() const {
+		return (_condition & BAD_CONDITION) != 0;
+	}
 };
 
 } // namespace MM1
diff --git a/engines/mm/mm1/maps/map17.cpp b/engines/mm/mm1/maps/map17.cpp
index 102a6c94ebf..674a902cb25 100644
--- a/engines/mm/mm1/maps/map17.cpp
+++ b/engines/mm/mm1/maps/map17.cpp
@@ -30,7 +30,6 @@ namespace MM1 {
 namespace Maps {
 
 #define VAL1 509
-#define COLOR 510
 #define CORRECT_ANSWERS 511
 
 void Map17::special() {
@@ -66,8 +65,8 @@ void Map17::special() {
 
 	} else if (getRandomNumber(30) == 10) {
 		g_maps->_mapPos = Common::Point(15, 15);
-		send(SoundMessage(STRING["maps.map17.wave"]));
 		updateGame();
+		send(SoundMessage(STRING["maps.map17.wave"]));
 
 	} else {
 		none160();
@@ -81,7 +80,7 @@ void Map17::special00() {
 void Map17::special01() {
 	SoundMessage msg(STRING["maps.map17.bridge"],
 		[]() {
-			static_cast<Map17 *>(g_maps->_currentMap)->askQuestion();
+			g_events->send("ColorQuestions", GameMessage("DISPLAY"));
 		}
 	);
 
@@ -102,7 +101,7 @@ void Map17::special03() {
 	g_maps->clearSpecial();
 	g_globals->_encounters.execute();
 }
-
+/*
 void Map17::askQuestion(uint partyIndex) {
 	if (partyIndex >= g_globals->_party.size()) {
 		// Entire party has answered the question
@@ -163,7 +162,7 @@ void Map17::askQuestion(uint partyIndex) {
 		send(msg);
 	}
 }
-
+*/
 } // namespace Maps
 } // namespace MM1
 } // namespace MM
diff --git a/engines/mm/mm1/maps/map17.h b/engines/mm/mm1/maps/map17.h
index dccf5b448d1..e01a676af83 100644
--- a/engines/mm/mm1/maps/map17.h
+++ b/engines/mm/mm1/maps/map17.h
@@ -54,11 +54,6 @@ public:
 	 * Handles all special stuff that happens on the map
 	 */
 	void special() override;
-
-	/**
-	 * Ask a given party member a question
-	 */
-	void askQuestion(uint partyIndex = 0);
 };
 
 } // namespace Maps
diff --git a/engines/mm/mm1/views/color_questions.cpp b/engines/mm/mm1/views/color_questions.cpp
new file mode 100644
index 00000000000..f5ffe8d434b
--- /dev/null
+++ b/engines/mm/mm1/views/color_questions.cpp
@@ -0,0 +1,127 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "mm/mm1/views/color_questions.h"
+#include "mm/mm1/maps/map17.h"
+#include "mm/mm1/globals.h"
+
+namespace MM {
+namespace MM1 {
+namespace Views {
+
+#define COLOR 510
+#define CORRECT_ANSWERS 511
+
+ColorQuestions::ColorQuestions() : TextView("ColorQuestions") {
+	_bounds = getLineBounds(20, 24);
+}
+
+bool ColorQuestions::msgFocus(const FocusMessage &msg) {
+	TextView::msgFocus(msg);
+	_showingResponse = false;
+
+	// Find first non-incapacitated party member
+	_charIndex = -1;
+	moveToNextChar();
+
+	return true;
+}
+
+void ColorQuestions::draw() {
+	clearSurface();
+
+	writeString(0, 0, STRING["maps.map17.color"]);
+	writeString(0, 2, STRING["maps.map17.options"]);
+
+	if (_showingResponse) {
+		const Character &c = g_globals->_party[_charIndex];
+
+		Common::String result = STRING[c.hasBadCondition() ?
+			"maps.map17.wrong" : "maps.map17.correct"];
+		writeString(16, 6, result);
+	}
+
+}
+
+bool ColorQuestions::msgKeypress(const KeypressMessage &msg) {
+	if (endDelay())
+		return true;
+
+	if (!_showingResponse && msg.keycode >= Common::KEYCODE_1 && msg.keycode <= Common::KEYCODE_9) {
+		Maps::Map17 &map = *static_cast<Maps::Map17 *>(g_maps->_currentMap);
+		map[COLOR] = msg.ascii - '1';
+
+		Character &c = *g_globals->_currCharacter;
+		int color = c._flags[2] & 0xf;
+
+		// If a color hasn't been designated yet from talking to Gypsy,
+		// or it has but the wrong color is selected, eradicate them
+		if (!color || (color & 7) != map[COLOR]) {
+			c._condition = ERADICATED;
+		} else {
+			map[CORRECT_ANSWERS]++;
+			c._flags[4] |= CHARFLAG4_80;
+		}
+
+		// Show the response
+		_showingResponse = true;
+		redraw();
+
+		return true;
+	}
+
+	return false;
+}
+
+bool ColorQuestions::msgAction(const ActionMessage &msg) {
+	if (endDelay())
+		return true;
+
+	return false;
+}
+
+void ColorQuestions::timeout() {
+	// Move to next non-incapacitated character
+	_showingResponse = false;
+	moveToNextChar();
+
+	if (_charIndex >= (int)g_globals->_party.size()) {
+		// All of party questioned
+		close();
+		g_maps->_mapPos.y = 2;
+		g_maps->_currentMap->updateGame();
+
+	} else {
+		// Prompt response for next party member
+		redraw();
+	}
+}
+
+void ColorQuestions::moveToNextChar() {
+	do {
+		++_charIndex;
+	} while (_charIndex < (int)g_globals->_party.size() &&
+		g_globals->_party[_charIndex].hasBadCondition());
+}
+
+} // namespace Views
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views/color_questions.h b/engines/mm/mm1/views/color_questions.h
new file mode 100644
index 00000000000..90d82fd1582
--- /dev/null
+++ b/engines/mm/mm1/views/color_questions.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef MM1_VIEWS_COLOR_QUESTIONS_H
+#define MM1_VIEWS_COLOR_QUESTIONS_H
+
+#include "mm/mm1/views/text_view.h"
+
+namespace MM {
+namespace MM1 {
+namespace Views {
+
+class ColorQuestions : public TextView {
+private:
+	int _charIndex = 0;
+	bool _showingResponse = false;
+
+	void moveToNextChar();
+public:
+	ColorQuestions();
+	virtual ~ColorQuestions() {}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	void draw() override;
+	bool msgKeypress(const KeypressMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
+	void timeout() override;
+};
+
+} // namespace Views
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/mm1/views/dialogs.h b/engines/mm/mm1/views/dialogs.h
index 8aa44257b8a..d5afba41807 100644
--- a/engines/mm/mm1/views/dialogs.h
+++ b/engines/mm/mm1/views/dialogs.h
@@ -27,6 +27,7 @@
 #include "mm/mm1/views/bash.h"
 #include "mm/mm1/views/characters.h"
 #include "mm/mm1/views/character_view_combat.h"
+#include "mm/mm1/views/color_questions.h"
 #include "mm/mm1/views/combat.h"
 #include "mm/mm1/views/create_characters.h"
 #include "mm/mm1/views/dead.h"
@@ -94,6 +95,7 @@ private:
 	Views::CharacterInfo _characterInfo;
 	Views::Characters _characters;
 	Views::CharacterViewCombat _characterViewCombat;
+	Views::ColorQuestions _colorQuestions;
 	Views::Combat _combat;
 	Views::CreateCharacters _createCharacters;
 	Views::Dead _dead;
diff --git a/engines/mm/mm1/views_enh/color_questions.cpp b/engines/mm/mm1/views_enh/color_questions.cpp
new file mode 100644
index 00000000000..c4fa9e5bb3f
--- /dev/null
+++ b/engines/mm/mm1/views_enh/color_questions.cpp
@@ -0,0 +1,127 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "mm/mm1/views_enh/color_questions.h"
+#include "mm/mm1/maps/map17.h"
+#include "mm/mm1/globals.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+#define COLOR 510
+#define CORRECT_ANSWERS 511
+
+ColorQuestions::ColorQuestions() : ScrollView("ColorQuestions") {
+	setBounds(Common::Rect(0, 144, 234, 200));
+}
+
+bool ColorQuestions::msgFocus(const FocusMessage &msg) {
+	ScrollView::msgFocus(msg);
+	_showingResponse = false;
+
+	// Find first non-incapacitated party member
+	_charIndex = -1;
+	moveToNextChar();
+
+	return true;
+}
+
+void ColorQuestions::draw() {
+	clearSurface();
+
+	writeString(0, 0, STRING["maps.map17.color"]);
+	writeString(0, 2, STRING["maps.map17.options"]);
+
+	if (_showingResponse) {
+		const Character &c = g_globals->_party[_charIndex];
+
+		Common::String result = STRING[c.hasBadCondition() ?
+			"maps.map17.wrong" : "maps.map17.correct"];
+		writeString(16, 6, result);
+	}
+
+}
+
+bool ColorQuestions::msgKeypress(const KeypressMessage &msg) {
+	if (endDelay())
+		return true;
+
+	if (!_showingResponse && msg.keycode >= Common::KEYCODE_1 && msg.keycode <= Common::KEYCODE_9) {
+		Maps::Map17 &map = *static_cast<Maps::Map17 *>(g_maps->_currentMap);
+		map[COLOR] = msg.ascii - '1';
+
+		Character &c = *g_globals->_currCharacter;
+		int color = c._flags[2] & 0xf;
+
+		// If a color hasn't been designated yet from talking to Gypsy,
+		// or it has but the wrong color is selected, eradicate them
+		if (!color || (color & 7) != map[COLOR]) {
+			c._condition = ERADICATED;
+		} else {
+			map[CORRECT_ANSWERS]++;
+			c._flags[4] |= CHARFLAG4_80;
+		}
+
+		// Show the response
+		_showingResponse = true;
+		redraw();
+
+		return true;
+	}
+
+	return false;
+}
+
+bool ColorQuestions::msgAction(const ActionMessage &msg) {
+	if (endDelay())
+		return true;
+
+	return false;
+}
+
+void ColorQuestions::timeout() {
+	// Move to next non-incapacitated character
+	_showingResponse = false;
+	moveToNextChar();
+
+	if (_charIndex >= (int)g_globals->_party.size()) {
+		// All of party questioned
+		close();
+		g_maps->_mapPos.y = 2;
+		g_maps->_currentMap->updateGame();
+
+	} else {
+		// Prompt response for next party member
+		redraw();
+	}
+}
+
+void ColorQuestions::moveToNextChar() {
+	do {
+		++_charIndex;
+	} while (_charIndex < (int)g_globals->_party.size() &&
+		g_globals->_party[_charIndex].hasBadCondition());
+}
+
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views_enh/color_questions.h b/engines/mm/mm1/views_enh/color_questions.h
new file mode 100644
index 00000000000..857b62ab301
--- /dev/null
+++ b/engines/mm/mm1/views_enh/color_questions.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef MM1_VIEWS_ENH_COLOR_QUESTIONS_H
+#define MM1_VIEWS_ENH_COLOR_QUESTIONS_H
+
+#include "mm/mm1/views_enh/scroll_view.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+class ColorQuestions : public ScrollView {
+private:
+	int _charIndex = 0;
+	bool _showingResponse = false;
+
+	void moveToNextChar();
+public:
+	ColorQuestions();
+	virtual ~ColorQuestions() {
+	}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	void draw() override;
+	bool msgKeypress(const KeypressMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
+	void timeout() override;
+};
+
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/mm1/views_enh/dialogs.h b/engines/mm/mm1/views_enh/dialogs.h
index 816e8ae966f..4e9411dd242 100644
--- a/engines/mm/mm1/views_enh/dialogs.h
+++ b/engines/mm/mm1/views_enh/dialogs.h
@@ -29,6 +29,7 @@
 #include "mm/mm1/views_enh/character_inventory.h"
 #include "mm/mm1/views_enh/character_select.h"
 #include "mm/mm1/views_enh/characters.h"
+#include "mm/mm1/views_enh/color_questions.h"
 #include "mm/mm1/views_enh/combat.h"
 #include "mm/mm1/views_enh/confirm.h"
 #include "mm/mm1/views_enh/create_characters.h"
@@ -100,6 +101,7 @@ private:
 	ViewsEnh::CharacterInventory _characterInventory;
 	ViewsEnh::CharacterSelect _characterSelect;
 	ViewsEnh::Characters _characters;
+	ViewsEnh::ColorQuestions _colorQuestions;
 	ViewsEnh::Combat _combat;
 	ViewsEnh::Confirm _confirm;
 	ViewsEnh::CreateCharacters _createCharacters;
diff --git a/engines/mm/module.mk b/engines/mm/module.mk
index 43308b91eba..419c911678b 100644
--- a/engines/mm/module.mk
+++ b/engines/mm/module.mk
@@ -106,6 +106,7 @@ MODULE_OBJS += \
 	mm1/views/character_manage.o \
 	mm1/views/character_view_combat.o \
 	mm1/views/characters.o \
+	mm1/views/color_questions.o \
 	mm1/views/combat.o \
 	mm1/views/create_characters.o \
 	mm1/views/dead.o \
@@ -137,6 +138,7 @@ MODULE_OBJS += \
 	mm1/views_enh/character_select.o \
 	mm1/views_enh/character_view.o \
 	mm1/views_enh/characters.o \
+	mm1/views_enh/color_questions.o \
 	mm1/views_enh/combat.o \
 	mm1/views_enh/confirm.o \
 	mm1/views_enh/create_characters.o \


Commit: cc2074a2ed4721bdbc15d1dbda8d2f92356a28cb
    https://github.com/scummvm/scummvm/commit/cc2074a2ed4721bdbc15d1dbda8d2f92356a28cb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-04-07T23:25:12-07:00

Commit Message:
MM: MM1: Formatting for enhanced color questions view

Changed paths:
    devtools/create_mm/files/mm1/strings_en.yml
    engines/mm/mm1/maps/map17.cpp
    engines/mm/mm1/views_enh/color_questions.cpp


diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index f91fae6d80e..b129fbe5cc0 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -1236,6 +1236,16 @@ maps:
 		correct: "Correct!"
 		islands: "Atop this peak 5 islands can be seen\nto the southeast"
 		wave: "A tidal wave sweeps the party away!"
+	emap17:
+		options:
+			1: "Red Thorac"
+			2: "Blue Ogram"
+			3: "Green Bagar"
+			4: "Yellow Limra"
+			5: "Purple Sagran"
+			6: "Orange Oolak"
+			7: "Black Dresidion"
+			8: "White Dilithium"
 
 	map18:
 		passage: "Cavernous passage to Erliquin,\ntake it (Y/N)?"
diff --git a/engines/mm/mm1/maps/map17.cpp b/engines/mm/mm1/maps/map17.cpp
index 674a902cb25..b5a12dd7288 100644
--- a/engines/mm/mm1/maps/map17.cpp
+++ b/engines/mm/mm1/maps/map17.cpp
@@ -80,7 +80,7 @@ void Map17::special00() {
 void Map17::special01() {
 	SoundMessage msg(STRING["maps.map17.bridge"],
 		[]() {
-			g_events->send("ColorQuestions", GameMessage("DISPLAY"));
+			g_events->addView("ColorQuestions");
 		}
 	);
 
diff --git a/engines/mm/mm1/views_enh/color_questions.cpp b/engines/mm/mm1/views_enh/color_questions.cpp
index c4fa9e5bb3f..992db51200b 100644
--- a/engines/mm/mm1/views_enh/color_questions.cpp
+++ b/engines/mm/mm1/views_enh/color_questions.cpp
@@ -46,10 +46,17 @@ bool ColorQuestions::msgFocus(const FocusMessage &msg) {
 }
 
 void ColorQuestions::draw() {
-	clearSurface();
+	ScrollView::draw();
 
-	writeString(0, 0, STRING["maps.map17.color"]);
-	writeString(0, 2, STRING["maps.map17.options"]);
+	setReduced(false);
+	writeLine(0, STRING["maps.map17.color"]);
+
+	setReduced(true);
+	for (int option = 0; option < 8; ++option) {
+		Common::String prefix = Common::String::format("%c) ", '1' + option);
+		writeLine(option / 2 + 1, prefix, ALIGN_RIGHT, 20 + 105 * (option % 2));
+		writeString(STRING[Common::String::format("maps.emap17.options.%d", option + 1)]);
+	}
 
 	if (_showingResponse) {
 		const Character &c = g_globals->_party[_charIndex];




More information about the Scummvm-git-logs mailing list