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

dreammaster noreply at scummvm.org
Sat Mar 4 06:43:46 UTC 2023


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

Summary:
02e4fcd121 MM: MM1: Beginnings of enhanced character view/manage views
c45416c53a MM: MM1: Fix right click mouse button messages
9dc853b088 MM: MM1: Make SpriteResource draw methods const
347c99e288 MM: MM1: Stats display for character view
0dca7c38a0 MM: MM1: More character info display


Commit: 02e4fcd12123847679549a78c9fe036976956243
    https://github.com/scummvm/scummvm/commit/02e4fcd12123847679549a78c9fe036976956243
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-03-03T22:43:01-08:00

Commit Message:
MM: MM1: Beginnings of enhanced character view/manage views

Changed paths:
  A engines/mm/mm1/views_enh/character_base.cpp
  A engines/mm/mm1/views_enh/character_base.h
  A engines/mm/mm1/views_enh/character_manage.cpp
  A engines/mm/mm1/views_enh/character_manage.h
  A engines/mm/mm1/views_enh/character_view.h
    engines/mm/mm1/views/character_base.h
    engines/mm/mm1/views_enh/characters.cpp
    engines/mm/mm1/views_enh/characters.h
    engines/mm/mm1/views_enh/locations/inn.cpp
    engines/mm/mm1/views_enh/locations/inn.h
    engines/mm/module.mk


diff --git a/engines/mm/mm1/views/character_base.h b/engines/mm/mm1/views/character_base.h
index 7ddc4140f3b..ff37a7712c5 100644
--- a/engines/mm/mm1/views/character_base.h
+++ b/engines/mm/mm1/views/character_base.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef MM1_VIEWS_VIEW_CHARACTER_BASE_H
-#define MM1_VIEWS_VIEW_CHARACTER_BASE_H
+#ifndef MM1_VIEWS_CHARACTER_BASE_H
+#define MM1_VIEWS_CHARACTER_BASE_H
 
 #include "common/array.h"
 #include "mm/mm1/views/text_view.h"
diff --git a/engines/mm/mm1/views_enh/character_base.cpp b/engines/mm/mm1/views_enh/character_base.cpp
new file mode 100644
index 00000000000..26ea8db7a7b
--- /dev/null
+++ b/engines/mm/mm1/views_enh/character_base.cpp
@@ -0,0 +1,179 @@
+/* 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/character_base.h"
+#include "mm/mm1/utils/strings.h"
+#include "mm/mm1/globals.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+void CharacterBase::printStats() {
+	Character &re = *g_globals->_currCharacter;
+	printSummary();
+
+	writeString(0, 2, STRING["stats.attributes.int"]);
+	writeNumber(re._intelligence);
+	_textPos.x = 8;
+	writeString(STRING["stats.attributes.level"]);
+	writeNumber(re._level);
+	_textPos.x = 18;
+	writeString(STRING["stats.attributes.age"]);
+	writeNumber(re._level);
+	_textPos.x = 27;
+	writeString(STRING["stats.attributes.exp"]);
+	writeNumber(re._exp);
+
+	newLine();
+	writeString(STRING["stats.attributes.mgt"]);
+	writeNumber(re._might);
+
+	newLine();
+	writeString(STRING["stats.attributes.per"]);
+	writeNumber(re._personality);
+	_textPos.x = 8;
+	writeString(STRING["stats.attributes.sp"]);
+	writeNumber(re._sp._current);
+	_textPos.x = 16;
+	writeChar('/');
+	writeNumber(re._sp._base);
+	_textPos.x = 22;
+	writeChar('(');
+	writeNumber(re._spellLevel._current);
+	writeChar(')');
+	_textPos.x = 26;
+	writeString(STRING["stats.attributes.gems"]);
+	writeNumber(re._gems);
+
+	newLine();
+	writeString(STRING["stats.attributes.end"]);
+	writeNumber(re._endurance);
+
+	newLine();
+	writeString(STRING["stats.attributes.spd"]);
+	writeNumber(re._speed);
+	_textPos.x = 8;
+	writeString(STRING["stats.attributes.hp"]);
+	writeNumber(re._hpCurrent);
+	_textPos.x = 16;
+	writeChar('/');
+	writeNumber(re._hpMax);
+	_textPos.x = 26;
+	writeString(STRING["stats.attributes.gold"]);
+	writeNumber(re._gold);
+
+	newLine();
+	writeString(STRING["stats.attributes.acy"]);
+	writeNumber(re._accuracy);
+
+	newLine();
+	writeString(STRING["stats.attributes.luc"]);
+	writeNumber(re._luck);
+	_textPos.x = 8;
+	writeString(STRING["stats.attributes.ac"]);
+	writeNumber(re._ac);
+	_textPos.x = 26;
+	writeString(STRING["stats.attributes.food"]);
+	writeNumber(re._food);
+
+	newLine();
+	newLine();
+	printCondition();
+	printInventory();
+}
+
+void CharacterBase::printSummary() {
+	Character &re = *g_globals->_currCharacter;
+	writeString(1, 0, re._name);
+
+	_textPos.x = 17;
+	writeString(": ");
+
+	writeChar((re._sex == MALE) ? 'M' : (re._sex == FEMALE ? 'F' : 'O'));
+
+	_textPos.x++;
+	writeString((re._alignment >= GOOD && re._alignment <= EVIL) ?
+		STRING[Common::String::format("stats.alignments.%d", re._alignment)] :
+		STRING["stats.none"]
+	);
+
+	if (re._race >= HUMAN && re._race <= HALF_ORC)
+		writeString(26, 0, STRING[Common::String::format("stats.races.%d", re._race)]);
+	else
+		writeString(26, 0, STRING["stats.none"]);
+
+	if (re._class >= KNIGHT && re._class <= ROBBER)
+		writeString(32, 0, STRING[Common::String::format("stats.classes.%d", re._class)]);
+	else
+		writeString(32, 0, STRING["stats.none"]);
+}
+
+void CharacterBase::printCondition() {
+	Character &c = *g_globals->_currCharacter;
+	writeString(STRING["stats.attributes.cond"]);
+	_textPos.x++;
+
+	writeString(c.getConditionString());
+}
+
+void CharacterBase::printInventory() {
+	Character &re = *g_globals->_currCharacter;
+	writeString(0, 12, STRING["stats.inventory"]);
+
+	// Print the equipped and backpack items
+	for (int i = 0; i < INVENTORY_COUNT; ++i) {
+		// Equippied item
+		writeChar(0, 13 + i, '1' + i);
+		writeChar(')');
+		_textPos.x++;
+		if (re._equipped[i])
+			writeString(STRING[Common::String::format("stats.items.%d",
+				(int)re._equipped[i]._id)]);
+
+		// Backpack item
+		writeChar(20, 13 + i, 'A' + i);
+		writeChar(')');
+		_textPos.x++;
+		if (re._backpack[i])
+			writeString(STRING[Common::String::format("stats.items.%d",
+			(int)re._backpack[i]._id)]);
+	}
+}
+
+void CharacterBase::draw() {
+	assert(g_globals->_currCharacter);
+	clearSurface();
+	printStats();
+}
+
+bool CharacterBase::msgAction(const ActionMessage &msg) {
+	if (msg._action == KEYBIND_ESCAPE) {
+		close();
+		return true;
+	}
+
+	return false;
+}
+
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views_enh/character_base.h b/engines/mm/mm1/views_enh/character_base.h
new file mode 100644
index 00000000000..5acb0e15b32
--- /dev/null
+++ b/engines/mm/mm1/views_enh/character_base.h
@@ -0,0 +1,61 @@
+/* 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_CHARACTER_BASE_H
+#define MM1_VIEWS_ENH_CHARACTER_BASE_H
+
+#include "common/array.h"
+#include "mm/mm1/views_enh/scroll_view.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+/**
+ * Base class for showing character information.
+ * MM1 has three character dialogs:
+ * 1) Character management from Create Characters
+ * 2) Inn that allows simply viewing characters
+ * 3) In-game character display
+ */
+class CharacterBase : public ScrollView {
+private:
+	void printStats();
+	void printSummary();
+	void printInventory();
+protected:
+	void printCondition();
+
+public:
+	CharacterBase(const Common::String &name) : ScrollView(name) {}
+	~CharacterBase() {}
+
+	bool msgAction(const ActionMessage &msg) override;
+	void draw() override;
+
+	void escToGoBack(int xp = 0) {}
+};
+
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/mm1/views_enh/character_manage.cpp b/engines/mm/mm1/views_enh/character_manage.cpp
new file mode 100644
index 00000000000..1169ad9aafd
--- /dev/null
+++ b/engines/mm/mm1/views_enh/character_manage.cpp
@@ -0,0 +1,123 @@
+/* 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/character_manage.h"
+#include "mm/mm1/utils/strings.h"
+#include "mm/mm1/globals.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+void CharacterManage::draw() {
+	assert(g_globals->_currCharacter);
+	CharacterBase::draw();
+
+	switch (_state) {
+	case DISPLAY:
+		writeString(6, 21, STRING["dialogs.view_character.rename"]);
+		writeString(6, 22, STRING["dialogs.view_character.delete"]);
+		escToGoBack();
+		break;
+
+	case RENAME:
+		writeString(6, 21, STRING["dialogs.view_character.name"]);
+		writeString(_newName);
+		writeChar('_');
+		break;
+
+	case DELETE:
+		writeString(6, 21, STRING["dialogs.view_character.are_you_sure"]);
+		break;
+	}
+}
+
+bool CharacterManage::msgKeypress(const KeypressMessage &msg) {
+	switch (_state) {
+	case DISPLAY:
+		if ((msg.flags & Common::KBD_CTRL) && msg.keycode == Common::KEYCODE_n) {
+			_state = RENAME;
+			_newName = "";
+			redraw();
+		} else if ((msg.flags & Common::KBD_CTRL) && msg.keycode == Common::KEYCODE_d) {
+			_state = DELETE;
+			redraw();
+		}
+		break;
+
+	case RENAME:
+		if (msg.ascii >= 32 && msg.ascii <= 127) {
+			_newName += toupper(msg.ascii);
+			redraw();
+		}
+		if (msg.keycode == Common::KEYCODE_RETURN || _newName.size() == 15) {
+			strncpy(g_globals->_currCharacter->_name, _newName.c_str(), 16);
+			_state = DISPLAY;
+			redraw();
+		} else if (msg.keycode == Common::KEYCODE_BACKSPACE &&
+				!_newName.empty()) {
+			_newName.deleteLastChar();
+			redraw();
+		}
+		break;
+
+	case DELETE:
+		if (msg.keycode == Common::KEYCODE_y) {
+			// Removes the character and returns to View All Characters
+			g_globals->_roster.remove(g_globals->_currCharacter);
+			close();
+		} else {
+			// Any other keypress returns to display mode
+			redraw();
+		}
+
+		_state = DISPLAY;
+		break;
+	}
+
+	return true;
+}
+
+bool CharacterManage::msgAction(const ActionMessage &msg) {
+	if (msg._action == KEYBIND_ESCAPE) {
+		if (_state != DISPLAY) {
+			redraw();
+		} else {
+			close();
+		}
+
+		_state = DISPLAY;
+		return true;
+	} else if (msg._action >= KEYBIND_VIEW_PARTY1 &&
+			msg._action <= KEYBIND_VIEW_PARTY6 &&
+			_state == DISPLAY) {
+		g_globals->_currCharacter = &g_globals->_party[
+			msg._action - KEYBIND_VIEW_PARTY1];
+		addView();
+		return true;
+	}
+
+	return false;
+}
+
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views_enh/character_manage.h b/engines/mm/mm1/views_enh/character_manage.h
new file mode 100644
index 00000000000..714cbfac794
--- /dev/null
+++ b/engines/mm/mm1/views_enh/character_manage.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_CHARACTER_MANAGE_H
+#define MM1_VIEWS_ENH_CHARACTER_MANAGE_H
+
+#include "common/array.h"
+#include "mm/mm1/views_enh/character_base.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+/**
+ * Character management dialog
+ */
+class CharacterManage : public CharacterBase {
+	enum ViewState { DISPLAY = 0, RENAME = 1, DELETE = 2 };
+	ViewState _state = DISPLAY;
+	Common::String _newName;
+public:
+	CharacterManage() : CharacterBase("CharacterManage") {}
+	virtual ~CharacterManage() {}
+
+	void draw() override;
+	bool msgKeypress(const KeypressMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
+};
+
+
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/mm1/views_enh/character_view.h b/engines/mm/mm1/views_enh/character_view.h
new file mode 100644
index 00000000000..260e009e02a
--- /dev/null
+++ b/engines/mm/mm1/views_enh/character_view.h
@@ -0,0 +1,50 @@
+/* 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_CHARACTER_VIEW_H
+#define MM1_VIEWS_ENH_CHARACTER_VIEW_H
+
+#include "common/array.h"
+#include "mm/mm1/views_enh/character_base.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+/**
+ * Character view from the inn screen
+ */
+class CharacterView : public CharacterBase {
+public:
+	CharacterView() : CharacterBase("CharacterView") {}
+	virtual ~CharacterView() {}
+
+	void draw() override {
+		CharacterBase::draw();
+		escToGoBack();
+	}
+};
+
+} // namespace Views
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/mm1/views_enh/characters.cpp b/engines/mm/mm1/views_enh/characters.cpp
index 27796f49d38..4e7c4447432 100644
--- a/engines/mm/mm1/views_enh/characters.cpp
+++ b/engines/mm/mm1/views_enh/characters.cpp
@@ -37,6 +37,7 @@ void Characters::draw() {
 	ScrollView::draw();
 	Graphics::ManagedSurface s = getSurface();
 	Roster &roster = g_globals->_roster;
+	_charIndexes.clear();
 
 	// Write title
 	setReduced(false);
@@ -49,10 +50,12 @@ void Characters::draw() {
 		// Write out the roster
 		setReduced(true);
 
-		for (uint idx = 0; idx < ROSTER_COUNT; ++idx) {
-			if (!roster._towns[idx])
+		for (uint charNum = 0; charNum < ROSTER_COUNT; ++charNum) {
+			if (!roster._towns[charNum])
 				continue;
-			Character &c = roster[idx];
+			Character &c = roster[charNum];
+			_charIndexes.push_back(charNum);
+			int idx = _charIndexes.size() - 1;
 
 			// Build up character portrait and/or frame
 			Graphics::ManagedSurface portrait;
@@ -76,13 +79,14 @@ void Characters::draw() {
 
 bool Characters::msgMouseDown(const MouseDownMessage &msg) {
 	// Cycle through portraits
-	for (uint idx = 0; idx < _charNums.size(); ++idx) {
+	for (uint idx = 0; idx < _charIndexes.size(); ++idx) {
 		Common::Point pt(_innerBounds.left + _innerBounds.width() / 3
 			* (idx % 3), 20 + 20 * (idx / 3));
 
 		if (Common::Rect(pt.x, pt.y, pt.x + 19, pt.y + 19).contains(msg._pos)) {
-			showCharacter(idx);
-			break;
+			g_globals->_currCharacter = &g_globals->_roster[_charIndexes[idx]];
+			_characterView.addView();
+			return true;
 		}
 	}
 
@@ -91,8 +95,9 @@ bool Characters::msgMouseDown(const MouseDownMessage &msg) {
 
 bool Characters::msgKeypress(const KeypressMessage &msg) {
 	if (msg.keycode >= Common::KEYCODE_a &&
-		msg.keycode < (Common::KeyCode)(Common::KEYCODE_a + _charNums.size())) {
-		showCharacter(msg.keycode - Common::KEYCODE_a);
+			msg.keycode < (Common::KeyCode)(Common::KEYCODE_a + _charIndexes.size())) {
+		g_globals->_currCharacter = &g_globals->_roster[_charIndexes[msg.keycode - Common::KEYCODE_a]];
+		_characterView.addView();
 		return true;
 	}
 
@@ -109,10 +114,6 @@ bool Characters::msgAction(const ActionMessage &msg) {
 	}
 }
 
-void Characters::showCharacter(uint charIndex) {
-	warning("TODO: Show character %d", charIndex);
-}
-
 } // namespace ViewsEnh
 } // namespace MM1
 } // namespace MM
diff --git a/engines/mm/mm1/views_enh/characters.h b/engines/mm/mm1/views_enh/characters.h
index 5c2f640bd9e..e42f5b048ab 100644
--- a/engines/mm/mm1/views_enh/characters.h
+++ b/engines/mm/mm1/views_enh/characters.h
@@ -23,6 +23,7 @@
 #define MM1_VIEWS_ENH_LOCATIONS_Characters_H
 
 #include "mm/mm1/views_enh/locations/location.h"
+#include "mm/mm1/views_enh/character_manage.h"
 #include "mm/mm1/data/character.h"
 #include "mm/mm1/data/int_array.h"
 
@@ -32,13 +33,9 @@ namespace ViewsEnh {
 
 class Characters : public ScrollView {
 private:
+	CharacterManage _characterView;
 	Shared::Xeen::SpriteResource _escSprite;
-	Common::Array<uint> _charNums;
-
-	/**
-	 * Show a character
-	 */
-	void showCharacter(uint charIndex);
+	Common::Array<uint> _charIndexes;
 
 public:
 	Characters();
diff --git a/engines/mm/mm1/views_enh/locations/inn.cpp b/engines/mm/mm1/views_enh/locations/inn.cpp
index 99a1a466246..7059945051e 100644
--- a/engines/mm/mm1/views_enh/locations/inn.cpp
+++ b/engines/mm/mm1/views_enh/locations/inn.cpp
@@ -127,15 +127,21 @@ bool Inn::msgMouseDown(const MouseDownMessage &msg) {
 			* (idx % 3), 20 + 20 * (idx / 3));
 
 		if (Common::Rect(pt.x, pt.y, pt.x + 19, pt.y + 19).contains(msg._pos)) {
-			// Toggle in party
 			int charNum = _charNums[idx];
-			if (_partyChars.contains(charNum))
-				_partyChars.remove(charNum);
-			else
-				_partyChars.push_back(charNum);
 
-			setButtonEnabled(0, !_partyChars.empty());
-			redraw();
+			if (msg._button == MouseMessage::MB_LEFT) {
+				// Toggle in party
+				if (_partyChars.contains(charNum))
+					_partyChars.remove(charNum);
+				else
+					_partyChars.push_back(charNum);
+
+				setButtonEnabled(0, !_partyChars.empty());
+				redraw();
+			} else {
+				g_globals->_currCharacter = &g_globals->_roster[charNum];
+				_characterView.addView();
+			}
 			break;
 		}
 	}
@@ -161,7 +167,7 @@ bool Inn::msgKeypress(const KeypressMessage &msg) {
 		} else if (msg.flags == 0) {
 			// View character
 			g_globals->_currCharacter = &g_globals->_roster[charNum];
-			//_characterView.addView();
+			_characterView.addView();
 		}
 		return true;
 
diff --git a/engines/mm/mm1/views_enh/locations/inn.h b/engines/mm/mm1/views_enh/locations/inn.h
index 9414fbadad8..9c2929e2060 100644
--- a/engines/mm/mm1/views_enh/locations/inn.h
+++ b/engines/mm/mm1/views_enh/locations/inn.h
@@ -22,7 +22,8 @@
 #ifndef MM1_VIEWS_ENH_LOCATIONS_INN_H
 #define MM1_VIEWS_ENH_LOCATIONS_INN_H
 
-#include "mm/mm1/views_enh/locations/location.h"
+#include "mm/mm1/views_enh/scroll_view.h"
+#include "mm/mm1/views_enh/character_view.h"
 #include "mm/mm1/data/character.h"
 #include "mm/mm1/data/int_array.h"
 
@@ -33,6 +34,7 @@ namespace Locations {
 
 class Inn : public ScrollView {
 private:
+	CharacterView _characterView;
 	Shared::Xeen::SpriteResource _escSprite;
 	Common::Array<uint> _charNums;
 	IntArray _partyChars;
diff --git a/engines/mm/module.mk b/engines/mm/module.mk
index d14aaa5d4b6..acda61701b8 100644
--- a/engines/mm/module.mk
+++ b/engines/mm/module.mk
@@ -125,7 +125,9 @@ MODULE_OBJS += \
 	mm1/views_enh/spells/cast_spell.o \
 	mm1/views_enh/spells/spellbook.o \
 	mm1/views_enh/button_container.o \
+	mm1/views_enh/character_base.o \
 	mm1/views_enh/character_info.o \
+	mm1/views_enh/character_manage.o \
 	mm1/views_enh/character_select.o \
 	mm1/views_enh/characters.o \
 	mm1/views_enh/dialogs.o \


Commit: c45416c53a7198f58eebc33961db178afd102bf2
    https://github.com/scummvm/scummvm/commit/c45416c53a7198f58eebc33961db178afd102bf2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-03-03T22:43:02-08:00

Commit Message:
MM: MM1: Fix right click mouse button messages

Changed paths:
    engines/mm/mm1/messages.cpp


diff --git a/engines/mm/mm1/messages.cpp b/engines/mm/mm1/messages.cpp
index e1378ff551f..474e676a56d 100644
--- a/engines/mm/mm1/messages.cpp
+++ b/engines/mm/mm1/messages.cpp
@@ -28,9 +28,11 @@ namespace MM1 {
 MouseMessage::MouseMessage(Common::EventType type,
 		const Common::Point &pos) : Message(), _pos(pos) {
 	switch (type) {
+	case Common::EVENT_RBUTTONDOWN:
 	case Common::EVENT_RBUTTONUP:
 		_button = MB_RIGHT;
 		break;
+	case Common::EVENT_MBUTTONDOWN:
 	case Common::EVENT_MBUTTONUP:
 		_button = MB_MIDDLE;
 		break;


Commit: 9dc853b088d779df065277a2379c851748963eac
    https://github.com/scummvm/scummvm/commit/9dc853b088d779df065277a2379c851748963eac
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-03-03T22:43:02-08:00

Commit Message:
MM: MM1: Make SpriteResource draw methods const

Changed paths:
    engines/mm/mm1/views_enh/characters.cpp
    engines/mm/mm1/views_enh/locations/inn.cpp
    engines/mm/shared/xeen/sprites.cpp
    engines/mm/shared/xeen/sprites.h


diff --git a/engines/mm/mm1/views_enh/characters.cpp b/engines/mm/mm1/views_enh/characters.cpp
index 4e7c4447432..0e31bfa5565 100644
--- a/engines/mm/mm1/views_enh/characters.cpp
+++ b/engines/mm/mm1/views_enh/characters.cpp
@@ -53,7 +53,7 @@ void Characters::draw() {
 		for (uint charNum = 0; charNum < ROSTER_COUNT; ++charNum) {
 			if (!roster._towns[charNum])
 				continue;
-			Character &c = roster[charNum];
+			const Character &c = roster[charNum];
 			_charIndexes.push_back(charNum);
 			int idx = _charIndexes.size() - 1;
 
diff --git a/engines/mm/mm1/views_enh/locations/inn.cpp b/engines/mm/mm1/views_enh/locations/inn.cpp
index 7059945051e..bc3d5ec69e8 100644
--- a/engines/mm/mm1/views_enh/locations/inn.cpp
+++ b/engines/mm/mm1/views_enh/locations/inn.cpp
@@ -89,7 +89,7 @@ void Inn::draw() {
 
 		for (uint idx = 0; idx < _charNums.size(); ++idx) {
 			uint charNum = _charNums[idx];
-			Character &c = g_globals->_roster[charNum];
+			const Character &c = g_globals->_roster[charNum];
 			bool isInParty = _partyChars.contains(charNum);
 
 			// Build up character portrait and/or frame
diff --git a/engines/mm/shared/xeen/sprites.cpp b/engines/mm/shared/xeen/sprites.cpp
index 1e40aa6bba6..97fa01aa11b 100644
--- a/engines/mm/shared/xeen/sprites.cpp
+++ b/engines/mm/shared/xeen/sprites.cpp
@@ -114,12 +114,12 @@ void SpriteResource::clear() {
 }
 
 void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPos,
-	uint flags, int scale) {
+		uint flags, int scale) const {
 	draw(dest, frame, destPos, Common::Rect(0, 0, dest.w, dest.h), flags, scale);
 }
 
 void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPos,
-	const Common::Rect &bounds, uint flags, int scale) {
+	const Common::Rect &bounds, uint flags, int scale) const {
 	Common::Rect r = bounds;
 	if (flags & SPRFLAG_BOTTOM_CLIPPED)
 		r.clip(SCREEN_WIDTH, _clippedBottom);
@@ -158,11 +158,11 @@ void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPo
 	delete drawer;
 }
 
-void SpriteResource::draw(XSurface &dest, int frame) {
+void SpriteResource::draw(XSurface &dest, int frame) const {
 	draw(dest, frame, Common::Point());
 }
 
-void SpriteResource::draw(Graphics::ManagedSurface *dest, int frame, const Common::Point &destPos) {
+void SpriteResource::draw(Graphics::ManagedSurface *dest, int frame, const Common::Point &destPos) const {
 	XSurface tmp;
 	tmp.w = dest->w;
 	tmp.h = dest->h;
diff --git a/engines/mm/shared/xeen/sprites.h b/engines/mm/shared/xeen/sprites.h
index 2edb1649311..5a5c6624f33 100644
--- a/engines/mm/shared/xeen/sprites.h
+++ b/engines/mm/shared/xeen/sprites.h
@@ -69,7 +69,7 @@ protected:
 	 * Draw the sprite onto the given surface
 	 */
 	void draw(XSurface &dest, int frame, const Common::Point &destPos,
-		const Common::Rect &bounds, uint flags = 0, int scale = 0);
+		const Common::Rect &bounds, uint flags = 0, int scale = 0) const;
 
 	/**
 	 * Deep copy assuming that the current instance is clean
@@ -107,19 +107,19 @@ public:
 	 *					1..15   -> reduces the sprite: the higher, the smaller it'll be
 	 */
 	void draw(XSurface &dest, int frame, const Common::Point &destPos,
-		uint flags = 0, int scale = 0);
+		uint flags = 0, int scale = 0) const;
 
 	/**
 	 * Draw the sprite onto the given surface
 	 * @param dest		Destination surface
 	 * @param frame		Frame number
 	 */
-	void draw(XSurface &dest, int frame);
+	void draw(XSurface &dest, int frame) const;
 
 	/**
 	 * Draw the sprite onto a given surface
 	 */
-	void draw(Graphics::ManagedSurface *dest, int frame, const Common::Point &destPos);
+	void draw(Graphics::ManagedSurface *dest, int frame, const Common::Point &destPos) const;
 
 	/**
 	 * Gets the size of a sprite


Commit: 347c99e288f6b53b44a2a04a7611ff4aed64208d
    https://github.com/scummvm/scummvm/commit/347c99e288f6b53b44a2a04a7611ff4aed64208d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-03-03T22:43:02-08:00

Commit Message:
MM: MM1: Stats display for character view

Changed paths:
    devtools/create_mm/files/mm1/strings_en.yml
    engines/mm/mm1/views_enh/character_base.cpp
    engines/mm/mm1/views_enh/character_manage.cpp


diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index e156f4d8da4..58edeee9bdb 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -579,20 +579,20 @@ stats:
 		asleep: "Asleep"
 	attributes:
 		int: "Int="
-		level: "lEvel="
+		level: "Level="
 		age: "Age="
 		exp: "Exp="
 		mgt: "Mgt="
 		per: "Per="
-		sp: "Xp="
+		sp: "SP="
 		gems: "Gems="
 		end: "End="
 		spd: "Spd="
-		hp: "Hp="
+		hp: "HP="
 		gold: "Gold="
 		acy: "Acy="
 		luc: "Luc="
-		ac: "ac="
+		ac: "AC="
 		food: "Food="
 		cond: "Cond="
 	towns:
diff --git a/engines/mm/mm1/views_enh/character_base.cpp b/engines/mm/mm1/views_enh/character_base.cpp
index 26ea8db7a7b..43ca60ad895 100644
--- a/engines/mm/mm1/views_enh/character_base.cpp
+++ b/engines/mm/mm1/views_enh/character_base.cpp
@@ -27,104 +27,87 @@ namespace MM {
 namespace MM1 {
 namespace ViewsEnh {
 
+#define COL1_X 30
+#define COL3_X 220
+
 void CharacterBase::printStats() {
-	Character &re = *g_globals->_currCharacter;
+	const Character &c = *g_globals->_currCharacter;
 	printSummary();
 
-	writeString(0, 2, STRING["stats.attributes.int"]);
-	writeNumber(re._intelligence);
-	_textPos.x = 8;
-	writeString(STRING["stats.attributes.level"]);
-	writeNumber(re._level);
-	_textPos.x = 18;
-	writeString(STRING["stats.attributes.age"]);
-	writeNumber(re._level);
-	_textPos.x = 27;
-	writeString(STRING["stats.attributes.exp"]);
-	writeNumber(re._exp);
-
-	newLine();
-	writeString(STRING["stats.attributes.mgt"]);
-	writeNumber(re._might);
-
-	newLine();
-	writeString(STRING["stats.attributes.per"]);
-	writeNumber(re._personality);
-	_textPos.x = 8;
-	writeString(STRING["stats.attributes.sp"]);
-	writeNumber(re._sp._current);
-	_textPos.x = 16;
-	writeChar('/');
-	writeNumber(re._sp._base);
-	_textPos.x = 22;
-	writeChar('(');
-	writeNumber(re._spellLevel._current);
-	writeChar(')');
-	_textPos.x = 26;
-	writeString(STRING["stats.attributes.gems"]);
-	writeNumber(re._gems);
-
-	newLine();
-	writeString(STRING["stats.attributes.end"]);
-	writeNumber(re._endurance);
-
-	newLine();
-	writeString(STRING["stats.attributes.spd"]);
-	writeNumber(re._speed);
-	_textPos.x = 8;
-	writeString(STRING["stats.attributes.hp"]);
-	writeNumber(re._hpCurrent);
-	_textPos.x = 16;
-	writeChar('/');
-	writeNumber(re._hpMax);
-	_textPos.x = 26;
-	writeString(STRING["stats.attributes.gold"]);
-	writeNumber(re._gold);
-
-	newLine();
-	writeString(STRING["stats.attributes.acy"]);
-	writeNumber(re._accuracy);
-
-	newLine();
-	writeString(STRING["stats.attributes.luc"]);
-	writeNumber(re._luck);
-	_textPos.x = 8;
-	writeString(STRING["stats.attributes.ac"]);
-	writeNumber(re._ac);
-	_textPos.x = 26;
-	writeString(STRING["stats.attributes.food"]);
-	writeNumber(re._food);
-
-	newLine();
+	writeLine(4, STRING["stats.attributes.int"], ALIGN_RIGHT, COL1_X);
+	writeLine(4, Common::String::format("%u", c._intelligence._base), ALIGN_LEFT, COL1_X);
+	writeLine(5, STRING["stats.attributes.mgt"], ALIGN_RIGHT, COL1_X);
+	writeLine(5, Common::String::format("%u", c._might._base), ALIGN_LEFT, COL1_X);
+	writeLine(6, STRING["stats.attributes.per"], ALIGN_RIGHT, COL1_X);
+	writeLine(6, Common::String::format("%u", c._personality._base), ALIGN_LEFT, COL1_X);
+	writeLine(7, STRING["stats.attributes.end"], ALIGN_RIGHT, COL1_X);
+	writeLine(7, Common::String::format("%u", c._endurance._base), ALIGN_LEFT, COL1_X);
+	writeLine(8, STRING["stats.attributes.spd"], ALIGN_RIGHT, COL1_X);
+	writeLine(8, Common::String::format("%u", c._speed._base), ALIGN_LEFT, COL1_X);
+	writeLine(9, STRING["stats.attributes.acy"], ALIGN_RIGHT, COL1_X);
+	writeLine(9, Common::String::format("%u", c._accuracy._base), ALIGN_LEFT, COL1_X);
+	writeLine(10, STRING["stats.attributes.luc"], ALIGN_RIGHT, COL1_X);
+	writeLine(10, Common::String::format("%u", c._luck._base), ALIGN_LEFT, COL1_X);
+
+	writeLine(4, STRING["stats.attributes.level"], ALIGN_RIGHT, 90);
+	writeNumber(c._level);
+	writeLine(4, STRING["stats.attributes.age"], ALIGN_LEFT, 120);
+	writeNumber(c._age);
+
+	writeLine(6, STRING["stats.attributes.sp"], ALIGN_RIGHT, 90);
+	writeLine(6, Common::String::format("%u", c._sp._current), ALIGN_LEFT, 90);
+	writeLine(6, Common::String::format("/%u", c._sp._base), ALIGN_LEFT, 120);
+	writeLine(6, Common::String::format("(%u)", c._spellLevel._current), ALIGN_LEFT, 160);
+
+	writeLine(8, STRING["stats.attributes.hp"], ALIGN_RIGHT, 90);
+	writeLine(8, Common::String::format("%u", c._hpCurrent), ALIGN_LEFT, 90);
+	writeLine(8, Common::String::format("/%u", c._hpMax), ALIGN_LEFT, 120);
+
+	writeLine(10, STRING["stats.attributes.ac"], ALIGN_RIGHT, 90);
+	writeLine(10, Common::String::format("%u", c._ac._current), ALIGN_LEFT, 90);
+
+	writeLine(4, STRING["stats.attributes.exp"], ALIGN_RIGHT, COL3_X);
+	writeLine(4, Common::String::format("%u", c._exp), ALIGN_LEFT, COL3_X);
+	writeLine(6, STRING["stats.attributes.gems"], ALIGN_RIGHT, COL3_X);
+	writeLine(6, Common::String::format("%u", c._gems), ALIGN_LEFT, COL3_X);
+	writeLine(8, STRING["stats.attributes.gold"], ALIGN_RIGHT, COL3_X);
+	writeLine(8, Common::String::format("%u", c._gold), ALIGN_LEFT, COL3_X);
+	writeLine(10, STRING["stats.attributes.food"], ALIGN_RIGHT, COL3_X);
+	writeLine(10, Common::String::format("%u", c._food), ALIGN_LEFT, COL3_X);
+
+/*	newLine();
 	newLine();
 	printCondition();
 	printInventory();
+	*/
 }
 
+#define LINE1_Y 5
+
 void CharacterBase::printSummary() {
-	Character &re = *g_globals->_currCharacter;
-	writeString(1, 0, re._name);
+	const Character &c = *g_globals->_currCharacter;
+	writeString(35, LINE1_Y, c._name);
 
-	_textPos.x = 17;
-	writeString(": ");
+	writeString(120, LINE1_Y, ": ");
 
-	writeChar((re._sex == MALE) ? 'M' : (re._sex == FEMALE ? 'F' : 'O'));
+	writeString((c._sex == MALE) ? "M " : (c._sex == FEMALE ? "F " : "O "));
 
-	_textPos.x++;
-	writeString((re._alignment >= GOOD && re._alignment <= EVIL) ?
-		STRING[Common::String::format("stats.alignments.%d", re._alignment)] :
+	writeString((c._alignment >= GOOD && c._alignment <= EVIL) ?
+		STRING[Common::String::format("stats.alignments.%d", c._alignment)] :
 		STRING["stats.none"]
 	);
+	writeChar(' ');
 
-	if (re._race >= HUMAN && re._race <= HALF_ORC)
-		writeString(26, 0, STRING[Common::String::format("stats.races.%d", re._race)]);
+	if (c._race >= HUMAN && c._race <= HALF_ORC)
+		writeString(STRING[Common::String::format("stats.races.%d", c._race)]);
 	else
-		writeString(26, 0, STRING["stats.none"]);
+		writeString(STRING["stats.none"]);
+	writeChar(' ');
 
-	if (re._class >= KNIGHT && re._class <= ROBBER)
-		writeString(32, 0, STRING[Common::String::format("stats.classes.%d", re._class)]);
+	if (c._class >= KNIGHT && c._class <= ROBBER)
+		writeString(STRING[Common::String::format("stats.classes.%d", c._class)]);
 	else
-		writeString(32, 0, STRING["stats.none"]);
+		writeString(STRING["stats.none"]);
 }
 
 void CharacterBase::printCondition() {
@@ -161,7 +144,12 @@ void CharacterBase::printInventory() {
 
 void CharacterBase::draw() {
 	assert(g_globals->_currCharacter);
-	clearSurface();
+	const Character &c = *g_globals->_currCharacter;
+	ScrollView::draw();
+
+	Graphics::ManagedSurface s = getSurface();
+	c._faceSprites.draw(&s, 0, Common::Point(_innerBounds.left, _innerBounds.top));
+
 	printStats();
 }
 
diff --git a/engines/mm/mm1/views_enh/character_manage.cpp b/engines/mm/mm1/views_enh/character_manage.cpp
index 1169ad9aafd..686dd4cbd1f 100644
--- a/engines/mm/mm1/views_enh/character_manage.cpp
+++ b/engines/mm/mm1/views_enh/character_manage.cpp
@@ -30,7 +30,7 @@ namespace ViewsEnh {
 void CharacterManage::draw() {
 	assert(g_globals->_currCharacter);
 	CharacterBase::draw();
-
+/*
 	switch (_state) {
 	case DISPLAY:
 		writeString(6, 21, STRING["dialogs.view_character.rename"]);
@@ -48,6 +48,7 @@ void CharacterManage::draw() {
 		writeString(6, 21, STRING["dialogs.view_character.are_you_sure"]);
 		break;
 	}
+	*/
 }
 
 bool CharacterManage::msgKeypress(const KeypressMessage &msg) {


Commit: 0dca7c38a020806a0752ae62c9c8bc1fbe507583
    https://github.com/scummvm/scummvm/commit/0dca7c38a020806a0752ae62c9c8bc1fbe507583
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-03-03T22:43:02-08:00

Commit Message:
MM: MM1: More character info display

Changed paths:
    engines/mm/mm1/views_enh/character_base.cpp


diff --git a/engines/mm/mm1/views_enh/character_base.cpp b/engines/mm/mm1/views_enh/character_base.cpp
index 43ca60ad895..ef42995b64c 100644
--- a/engines/mm/mm1/views_enh/character_base.cpp
+++ b/engines/mm/mm1/views_enh/character_base.cpp
@@ -27,6 +27,7 @@ namespace MM {
 namespace MM1 {
 namespace ViewsEnh {
 
+#define LINE1_Y 5
 #define COL1_X 30
 #define COL3_X 220
 
@@ -75,15 +76,10 @@ void CharacterBase::printStats() {
 	writeLine(10, STRING["stats.attributes.food"], ALIGN_RIGHT, COL3_X);
 	writeLine(10, Common::String::format("%u", c._food), ALIGN_LEFT, COL3_X);
 
-/*	newLine();
-	newLine();
 	printCondition();
 	printInventory();
-	*/
 }
 
-#define LINE1_Y 5
-
 void CharacterBase::printSummary() {
 	const Character &c = *g_globals->_currCharacter;
 	writeString(35, LINE1_Y, c._name);
@@ -111,34 +107,32 @@ void CharacterBase::printSummary() {
 }
 
 void CharacterBase::printCondition() {
-	Character &c = *g_globals->_currCharacter;
-	writeString(STRING["stats.attributes.cond"]);
-	_textPos.x++;
+	const Character &c = *g_globals->_currCharacter;
 
-	writeString(c.getConditionString());
+	writeLine(2, STRING["stats.attributes.cond"], ALIGN_RIGHT, 90);
+	writeLine(2, c.getConditionString(), ALIGN_LEFT, 90);
 }
 
 void CharacterBase::printInventory() {
-	Character &re = *g_globals->_currCharacter;
-	writeString(0, 12, STRING["stats.inventory"]);
+	const Character &c = *g_globals->_currCharacter;
+	writeLine(12, STRING["stats.inventory"]);
+	for (int i = 0; i < 5; ++i)
+		writeChar('-');
 
 	// Print the equipped and backpack items
 	for (int i = 0; i < INVENTORY_COUNT; ++i) {
 		// Equippied item
-		writeChar(0, 13 + i, '1' + i);
-		writeChar(')');
-		_textPos.x++;
-		if (re._equipped[i])
+		writeLine(13 + i, Common::String::format("%c) ", '1' + i));
+		if (c._equipped[i])
 			writeString(STRING[Common::String::format("stats.items.%d",
-				(int)re._equipped[i]._id)]);
+				(int)c._equipped[i]._id)]);
 
 		// Backpack item
-		writeChar(20, 13 + i, 'A' + i);
-		writeChar(')');
-		_textPos.x++;
-		if (re._backpack[i])
+		writeLine(13 + i, Common::String::format("%c) ", 'A' + i), ALIGN_LEFT,
+			160 - _innerBounds.left);
+		if (c._backpack[i])
 			writeString(STRING[Common::String::format("stats.items.%d",
-			(int)re._backpack[i]._id)]);
+			(int)c._backpack[i]._id)]);
 	}
 }
 




More information about the Scummvm-git-logs mailing list