[Scummvm-git-logs] scummvm master -> 0edaaf026571172edaacbd5f278c546c26df3f57

dreammaster noreply at scummvm.org
Sun Feb 5 04:50:58 UTC 2023


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:
0edaaf0265 MM: MM1: Added enhanced mode automap dialog


Commit: 0edaaf026571172edaacbd5f278c546c26df3f57
    https://github.com/scummvm/scummvm/commit/0edaaf026571172edaacbd5f278c546c26df3f57
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-04T20:50:46-08:00

Commit Message:
MM: MM1: Added enhanced mode automap dialog

Changed paths:
  A engines/mm/mm1/views_enh/map_popup.cpp
  A engines/mm/mm1/views_enh/map_popup.h
    devtools/create_mm/files/mm1/strings_en.yml
    engines/mm/mm1/metaengine.cpp
    engines/mm/mm1/views_enh/dialogs.h
    engines/mm/mm1/views_enh/game_commands.cpp
    engines/mm/mm1/views_enh/map.cpp
    engines/mm/mm1/views_enh/map.h
    engines/mm/mm1/views_enh/scroll_popup.cpp
    engines/mm/mm1/views_enh/text_view.cpp
    engines/mm/module.mk


diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index 7cee838c92d..22c98afa0cc 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -421,6 +421,11 @@ dialogs:
 			14: "thrashes at"
 			99: "shoots at"
 enhdialogs:
+	map:
+		north: "North"
+		south: "South"
+		east: "East"
+		west: "West"
 	character:
 		stats:
 			might: "mgt"
diff --git a/engines/mm/mm1/metaengine.cpp b/engines/mm/mm1/metaengine.cpp
index afcaece8f9b..5f085ea2eda 100644
--- a/engines/mm/mm1/metaengine.cpp
+++ b/engines/mm/mm1/metaengine.cpp
@@ -75,6 +75,7 @@ static const KeybindingRecord NORMAL_KEYS[] = {
 	{ KEYBIND_STRAFE_LEFT, "STRAFE_LEFT", "Strafe Left", "C+LEFT", nullptr },
 	{ KEYBIND_STRAFE_RIGHT, "STRAFE_RIGHT", "Strafe Right", "C+RIGHT", nullptr },
 
+	{ KEYBIND_MAP, "MAP", "Show Map", "m", nullptr },
 	{ KEYBIND_MINIMAP, "MINIMAP", "Toggle Minimap", "=", nullptr },
 	{ KEYBIND_ORDER, "ORDER", "Reorder Party", "o", nullptr },
 	{ KEYBIND_PROTECT, "PROTECT", "Protect", "p", nullptr },
diff --git a/engines/mm/mm1/views_enh/dialogs.h b/engines/mm/mm1/views_enh/dialogs.h
index 4707d78ab7b..27802e22e82 100644
--- a/engines/mm/mm1/views_enh/dialogs.h
+++ b/engines/mm/mm1/views_enh/dialogs.h
@@ -33,6 +33,7 @@
 //#include "mm/mm1/views/char.h"
 #include "mm/mm1/views_enh/character_info.h"
 #include "mm/mm1/views_enh/game.h"
+#include "mm/mm1/views_enh/map_popup.h"
 #include "mm/mm1/views_enh/locations/market.h"
 #include "mm/mm1/views_enh/locations/temple.h"
 
@@ -55,6 +56,7 @@ private:
 	Views::Title _title;
 //	Views::ViewCharacters _viewCharacters;
 //	Views::ViewCharacter _viewCharacter;
+	ViewsEnh::MapPopup _mapPopup;
 	ViewsEnh::Locations::Market _market;
 	ViewsEnh::Locations::Temple _temple;
 public:
diff --git a/engines/mm/mm1/views_enh/game_commands.cpp b/engines/mm/mm1/views_enh/game_commands.cpp
index 95f11bf790e..f3f32df7228 100644
--- a/engines/mm/mm1/views_enh/game_commands.cpp
+++ b/engines/mm/mm1/views_enh/game_commands.cpp
@@ -54,9 +54,15 @@ GameCommands::GameCommands(UIElement *owner) :
 }
 
 bool GameCommands::msgAction(const ActionMessage & msg) {
-	if (msg._action == KEYBIND_MINIMAP) {
+	switch (msg._action) {
+	case KEYBIND_MINIMAP:
 		_minimap.toggleMinimap();
 		return true;
+	case KEYBIND_MAP:
+		addView("MapPopup");
+		return true;
+	default:
+		break;
 	}
 
 	return false;
diff --git a/engines/mm/mm1/views_enh/map.cpp b/engines/mm/mm1/views_enh/map.cpp
index 258ba15130f..c116f25ae02 100644
--- a/engines/mm/mm1/views_enh/map.cpp
+++ b/engines/mm/mm1/views_enh/map.cpp
@@ -26,11 +26,6 @@ namespace MM {
 namespace MM1 {
 namespace ViewsEnh {
 
-#define BORDER_SIZE 1
-#define TILE_W 10
-#define TILE_H 8
-
-
 Map::Map(UIElement *owner) : UIElement("Map", owner) {
 }
 
@@ -40,12 +35,12 @@ void Map::draw() {
 	Graphics::ManagedSurface s = getSurface();
 
 	g_globals->_globalSprites.draw(&s, 15,
-		Common::Point(BORDER_SIZE, BORDER_SIZE));
+		Common::Point(MAP_BORDER_SIZE, MAP_BORDER_SIZE));
 
-	assert((_bounds.width() - BORDER_SIZE * 2) % TILE_W == 0);
-	assert((_bounds.height() - BORDER_SIZE * 2) % TILE_H == 0);
-	int totalX = (_bounds.width() - BORDER_SIZE * 2) / TILE_W,
-		totalY = (_bounds.height() - BORDER_SIZE * 2) / TILE_H;
+	assert((_bounds.width() - MAP_BORDER_SIZE * 2) % MAP_TILE_W == 0);
+	assert((_bounds.height() - MAP_BORDER_SIZE * 2) % MAP_TILE_H == 0);
+	int totalX = (_bounds.width() - MAP_BORDER_SIZE * 2) / MAP_TILE_W,
+		totalY = (_bounds.height() - MAP_BORDER_SIZE * 2) / MAP_TILE_H;
 
 	int currentX = maps._mapPos.x;
 	int currentY = maps._mapPos.y;
@@ -55,17 +50,17 @@ void Map::draw() {
 		MAP_H - totalY);
 
 	// Iterate through the cells
-	for (int yp = BORDER_SIZE, mazeY = yStart + totalY - 1;
-			mazeY >= yStart; yp += TILE_H, --mazeY) {
-		for (int xp = BORDER_SIZE, mazeX = xStart;
-				mazeX < (xStart + totalX); xp += TILE_W, ++mazeX) {
+	for (int yp = MAP_BORDER_SIZE, mazeY = yStart + totalY - 1;
+			mazeY >= yStart; yp += MAP_TILE_H, --mazeY) {
+		for (int xp = MAP_BORDER_SIZE, mazeX = xStart;
+				mazeX < (xStart + totalX); xp += MAP_TILE_W, ++mazeX) {
 			byte visited = map._visited[mazeY * MAP_W + mazeX];
 
 			if (!visited) {
 				g_globals->_tileSprites.draw(&s, 1,
 					Common::Point(xp, yp));
 			} else {
-				Common::Rect r(xp, yp, xp + TILE_W, yp + TILE_H);
+				Common::Rect r(xp, yp, xp + MAP_TILE_W, yp + MAP_TILE_H);
 				byte walls = map._walls[mazeY * MAP_W + mazeX];
 				int wallsW = walls & 3;
 				int wallsS = (walls >> 2) & 3;
diff --git a/engines/mm/mm1/views_enh/map.h b/engines/mm/mm1/views_enh/map.h
index e17189c43c7..52065d42d10 100644
--- a/engines/mm/mm1/views_enh/map.h
+++ b/engines/mm/mm1/views_enh/map.h
@@ -28,6 +28,10 @@ namespace MM {
 namespace MM1 {
 namespace ViewsEnh {
 
+#define MAP_BORDER_SIZE 1
+#define MAP_TILE_W 10
+#define MAP_TILE_H 8
+
 class Map : public UIElement {
 public:
 	Map(UIElement *owner);
diff --git a/engines/mm/mm1/views_enh/map_popup.cpp b/engines/mm/mm1/views_enh/map_popup.cpp
new file mode 100644
index 00000000000..291bd2ba8b0
--- /dev/null
+++ b/engines/mm/mm1/views_enh/map_popup.cpp
@@ -0,0 +1,94 @@
+/* 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/map_popup.h"
+#include "mm/mm1/maps/maps.h"
+#include "mm/mm1/globals.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+#define ENTIRE_MAP_W (MAP_W * MAP_TILE_W)
+#define ENTIRE_MAP_H (MAP_H * MAP_TILE_H)
+
+MapPopup::MapPopup() : ScrollPopup("MapPopup"),
+		_map(this) {
+	// Center 16x16 map area
+	Common::Rect area(
+		(320 / 2) - (ENTIRE_MAP_W / 2) - 1,
+		(200 / 2) - (ENTIRE_MAP_H / 2) - 1,
+		(320 / 2) + (ENTIRE_MAP_W / 2) + 1,
+		(200 / 2) + (ENTIRE_MAP_H / 2) + 1
+	);
+	_map.setBounds(area);
+
+	// Allow room for scroll edges, and line at top & bottom
+	area.left -= 9;
+	area.right += 9;
+	area.top -= 17;
+	area.bottom += 17;
+	setBounds(area);
+}
+
+void MapPopup::draw() {
+	ScrollPopup::draw();
+
+	// Write the map name
+	Maps::Map &map = *g_maps->_currentMap;
+	Common::String mapName = map.getName();
+	mapName.setChar(toupper(mapName[0]), 0);
+	writeString(0, 0, mapName, ALIGN_MIDDLE);
+
+	// Write direction
+	Common::String dir;
+	switch (g_maps->_forwardMask) {
+	case Maps::DIRMASK_N:
+		dir = STRING["enhdialogs.map.north"];
+		break;
+	case Maps::DIRMASK_S:
+		dir = STRING["enhdialogs.map.south"];
+		break;
+	case Maps::DIRMASK_E:
+		dir = STRING["enhdialogs.map.east"];
+		break;
+	case Maps::DIRMASK_W:
+		dir = STRING["enhdialogs.map.west"];
+		break;
+	default:
+		break;
+	}
+	writeString(0, _innerBounds.height() - 9, dir, ALIGN_MIDDLE);
+
+	// Write position
+	writeString(2, _innerBounds.height() - 9,
+		Common::String::format("X = %d", g_maps->_mapPos.x),
+		ALIGN_LEFT
+	);
+	writeString(0, _innerBounds.height() - 9,
+		Common::String::format("Y = %d", g_maps->_mapPos.y),
+		ALIGN_RIGHT
+	);
+}
+
+} // namespace Views
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views_enh/map_popup.h b/engines/mm/mm1/views_enh/map_popup.h
new file mode 100644
index 00000000000..dd215e38757
--- /dev/null
+++ b/engines/mm/mm1/views_enh/map_popup.h
@@ -0,0 +1,46 @@
+/* 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_MAP_POPUP_H
+#define MM1_VIEWS_ENH_MAP_POPUP_H
+
+#include "mm/mm1/views_enh/scroll_popup.h"
+#include "mm/mm1/views_enh/map.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+class MapPopup : public ScrollPopup {
+private:
+	Map _map;
+public:
+	MapPopup();
+	virtual ~MapPopup() {}
+
+	void draw() override;
+};
+
+} // namespace Views
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/mm1/views_enh/scroll_popup.cpp b/engines/mm/mm1/views_enh/scroll_popup.cpp
index b33112a4c1e..64b600f3d21 100644
--- a/engines/mm/mm1/views_enh/scroll_popup.cpp
+++ b/engines/mm/mm1/views_enh/scroll_popup.cpp
@@ -26,7 +26,7 @@ namespace MM1 {
 namespace ViewsEnh {
 
 ScrollPopup::ScrollPopup(const Common::String &name) :
-		ScrollText("ScrollPopup") {
+		ScrollText(name) {
 }
 
 bool ScrollPopup::msgKeypress(const KeypressMessage &msg) {
diff --git a/engines/mm/mm1/views_enh/text_view.cpp b/engines/mm/mm1/views_enh/text_view.cpp
index 191354435df..61e2705d91f 100644
--- a/engines/mm/mm1/views_enh/text_view.cpp
+++ b/engines/mm/mm1/views_enh/text_view.cpp
@@ -109,13 +109,20 @@ void TextView::writeString(int x, int y, const Common::String &str,
 		if (line != lines.front())
 			newLine();
 
-		if (align != ALIGN_LEFT && x == 0) {
+		if (align != ALIGN_LEFT) {
 			int strWidth = getFont()->getStringWidth(line);
 
+			if (x == 0) {
+				if (align == ALIGN_MIDDLE)
+					x = _innerBounds.width() / 2;
+				else
+					x = _innerBounds.width();
+			}
+
 			if (align == ALIGN_MIDDLE)
-				_textPos.x = MAX((_innerBounds.width() - strWidth) / 2, 0);
+				_textPos.x = MAX(x - (strWidth / 2), 0);
 			else
-				_textPos.x = MAX(_innerBounds.width() - strWidth, 0);
+				_textPos.x = MAX(x - strWidth, 0);
 		}
 
 		writeString(line);
diff --git a/engines/mm/module.mk b/engines/mm/module.mk
index 110fe69181b..859e9055f72 100644
--- a/engines/mm/module.mk
+++ b/engines/mm/module.mk
@@ -118,6 +118,7 @@ MODULE_OBJS := \
 	mm1/views_enh/game_commands.o \
 	mm1/views_enh/game_messages.o \
 	mm1/views_enh/map.o \
+	mm1/views_enh/map_popup.o \
 	mm1/views_enh/scroll_popup.o \
 	mm1/views_enh/scroll_text.o \
 	mm1/views_enh/scroll_view.o \




More information about the Scummvm-git-logs mailing list