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

dreammaster noreply at scummvm.org
Sat Feb 18 06:33:00 UTC 2023


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

Summary:
83dda58241 MM: MM1: Spellbook frame drawing
f45abfc332 MM: MM1: Listing spell names in spellbook
d5c93b2627 MM: MM1: Spellbook line selection


Commit: 83dda5824180b15688ee10b44c42d65831bad1e2
    https://github.com/scummvm/scummvm/commit/83dda5824180b15688ee10b44c42d65831bad1e2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-17T21:32:20-08:00

Commit Message:
MM: MM1: Spellbook frame drawing

Changed paths:
    devtools/create_mm/files/mm1/strings_en.yml
    engines/mm/mm1/views_enh/scroll_view.cpp
    engines/mm/mm1/views_enh/scroll_view.h
    engines/mm/mm1/views_enh/spells/spellbook.cpp
    engines/mm/mm1/views_enh/spells/spellbook.h


diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index 71bf951316d..92418846283 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -507,7 +507,7 @@ enhdialogs:
 			cond: "Cond"
 	spellbook:
 		title: "Spells for"
-		spell_pts: "Spell Pts - "
+		spell_points: "Spell Pts"
 		select: "Select"
 		exit: "Exit"
 	temple:
diff --git a/engines/mm/mm1/views_enh/scroll_view.cpp b/engines/mm/mm1/views_enh/scroll_view.cpp
index 6d242ca1fb0..64aeb9808d3 100644
--- a/engines/mm/mm1/views_enh/scroll_view.cpp
+++ b/engines/mm/mm1/views_enh/scroll_view.cpp
@@ -52,6 +52,14 @@ void ScrollView::addButton(Shared::Xeen::SpriteResource *sprites,
 	_buttons.push_back(Button(sprites, pos, frame, action));
 }
 
+void ScrollView::addButton(const Common::Rect &r, const Common::KeyState &key) {
+	_buttons.push_back(Button(r, key));
+}
+
+void ScrollView::addButton(const Common::Rect &r, KeybindingAction action) {
+	_buttons.push_back(Button(r, action));
+}
+
 void ScrollView::resetSelectedButton() {
 	_selectedButton = -1;
 	redraw();
@@ -65,10 +73,12 @@ void ScrollView::draw() {
 	Graphics::ManagedSurface s = getSurface();
 	for (uint i = 0; i < _buttons.size(); ++i) {
 		const Button &btn = _buttons[i];
-		btn._sprites->draw(&s,
-			btn._frame + (_selectedButton == (int)i ? 1 : 0),
-			Common::Point(btn._pos.x + _bounds.borderSize(),
-				btn._pos.y + _bounds.borderSize()));
+		if (btn._frame != -1) {
+			btn._sprites->draw(&s,
+				btn._frame + (_selectedButton == (int)i ? 1 : 0),
+				Common::Point(btn._bounds.left + _bounds.borderSize(),
+					btn._bounds.top + _bounds.borderSize()));
+		}
 	}
 }
 
@@ -188,11 +198,8 @@ bool ScrollView::msgMouseUp(const MouseUpMessage &msg) {
 }
 
 int ScrollView::getButtonAt(const Common::Point &pos) {
-	Common::Rect r(16, 16);
 	for (uint i = 0; i < _buttons.size(); ++i) {
-		r.moveTo(_innerBounds.left + _buttons[i]._pos.x,
-			_innerBounds.top + _buttons[i]._pos.y);
-		if (r.contains(pos))
+		if (_buttons[i]._bounds.contains(pos))
 			return i;
 	}
 
diff --git a/engines/mm/mm1/views_enh/scroll_view.h b/engines/mm/mm1/views_enh/scroll_view.h
index 52d6f916a63..f70f0e6f7e7 100644
--- a/engines/mm/mm1/views_enh/scroll_view.h
+++ b/engines/mm/mm1/views_enh/scroll_view.h
@@ -29,24 +29,34 @@ namespace MM1 {
 namespace ViewsEnh {
 
 #define FRAME_BORDER_SIZE 8
+#define GLYPH_W 16
+#define GLYPH_H 16
 
 class ScrollView : public TextView {
 	struct Button {
 		Shared::Xeen::SpriteResource *_sprites;
-		Common::Point _pos;
-		int _frame;
+		Common::Rect _bounds;
+		int _frame = -1;
 		Common::KeyState _key;
 		KeybindingAction _action = KEYBIND_NONE;
 
 		Button(Shared::Xeen::SpriteResource *sprites,
 			const Common::Point &pos, int frame,
 			const Common::KeyState &key) :
-			_sprites(sprites), _pos(pos), _frame(frame), _key(key) {
+			_sprites(sprites), _frame(frame), _key(key),
+			_bounds(Common::Rect(pos.x, pos.y, pos.x + GLYPH_W, pos.y + GLYPH_H)) {
 		}
 		Button(Shared::Xeen::SpriteResource *sprites,
 			const Common::Point &pos, int frame,
 			KeybindingAction action) :
-			_sprites(sprites), _pos(pos), _frame(frame), _action(action) {
+			_sprites(sprites), _frame(frame), _action(action),
+			_bounds(Common::Rect(pos.x, pos.y, pos.x + GLYPH_W, pos.y + GLYPH_H)) {
+		}
+		Button(const Common::Rect &r, const Common::KeyState &key) :
+			_sprites(nullptr), _bounds(r), _key(key) {
+		}
+		Button(const Common::Rect &r, const KeybindingAction action) :
+			_sprites(nullptr), _bounds(r), _action(action) {
 		}
 	};
 private:
@@ -99,6 +109,16 @@ public:
 	void addButton(Shared::Xeen::SpriteResource *sprites,
 		const Common::Point &pos, int frame, KeybindingAction action);
 
+	/**
+	 * Add a button for display
+	 */
+	void addButton(const Common::Rect &r, const Common::KeyState &key);
+
+	/**
+	 * Add a button for display
+	 */
+	void addButton(const Common::Rect &r, KeybindingAction action);
+
 	/**
 	 * Reset selected button
 	 */
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.cpp b/engines/mm/mm1/views_enh/spells/spellbook.cpp
index e0aaeab3ebf..bf056373906 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.cpp
+++ b/engines/mm/mm1/views_enh/spells/spellbook.cpp
@@ -28,12 +28,35 @@ namespace ViewsEnh {
 namespace Spells {
 
 Spellbook::Spellbook() : ScrollView("Spellbook") {
-	_bounds = Common::Rect(27, 6, 195, 142);
+	_bounds = Common::Rect(27, 6, 208, 142);
+	addButtons();
+}
+
+void Spellbook::addButtons() {
+	_scrollSprites.load("scroll.icn");
+	addButton(&g_globals->_mainIcons, Common::Point(187, 26), 0, Common::KEYCODE_UP);
+	addButton(&g_globals->_mainIcons, Common::Point(187, 111), 2, Common::KEYCODE_DOWN);
+	addButton(&_scrollSprites, Common::Point(90, 109), 5, KEYBIND_SELECT);
+
+	addButton(Common::Rect(40, 28, 187, 36), Common::KEYCODE_1);
+	addButton(Common::Rect(40, 37, 187, 45), Common::KEYCODE_2);
+	addButton(Common::Rect(40, 46, 187, 54), Common::KEYCODE_3);
+	addButton(Common::Rect(40, 55, 187, 63), Common::KEYCODE_4);
+	addButton(Common::Rect(40, 64, 187, 72), Common::KEYCODE_5);
+	addButton(Common::Rect(40, 73, 187, 81), Common::KEYCODE_6);
+	addButton(Common::Rect(40, 82, 187, 90), Common::KEYCODE_7);
+	addButton(Common::Rect(40, 91, 187, 99), Common::KEYCODE_8);
+	addButton(Common::Rect(40, 100, 187, 108), Common::KEYCODE_9);
+	addButton(Common::Rect(40, 109, 187, 117), Common::KEYCODE_0);
+	addButton(Common::Rect(174, 123, 198, 133), Common::KEYCODE_ESCAPE);
+	addButton(Common::Rect(187, 35, 198, 73), Common::KEYCODE_PAGEUP);
+	addButton(Common::Rect(187, 74, 198, 112), Common::KEYCODE_PAGEDOWN);
+	addButton(Common::Rect(132, 123, 168, 133), Common::KEYCODE_s);
 }
 
 bool Spellbook::msgFocus(const FocusMessage &msg) {
-	g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)true));
 	MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_PARTY_MENUS);
+	updateChar();
 	return true;
 }
 
@@ -47,14 +70,34 @@ bool Spellbook::msgUnfocus(const UnfocusMessage &msg) {
 
 void Spellbook::draw() {
 	ScrollView::draw();
+
+	Graphics::ManagedSurface s = getSurface();
 	const Character &c = *g_globals->_currCharacter;
 
+	// Draw the scrolling area frame
+	_scrollSprites.draw(&s, 4, Common::Point(14, 20));
+	_scrollSprites.draw(&s, 0, Common::Point(162, 20));
+	_scrollSprites.draw(&s, 2, Common::Point(162, 105));
+
+	// Title line
 	_fontReduced = true;
 	Common::String title = Common::String::format("%s %s",
 		STRING["enhdialogs.spellbook.title"].c_str(),
 		c._name
 	);
 	writeString(0, 0, title, ALIGN_MIDDLE);
+
+	// Write current spell points
+	Common::String sp = Common::String::format("%s - %d",
+		STRING["enhdialogs.spellbook.spell_points"].c_str(), c._sp._current);
+	writeString(7, 111, sp);
+
+	// Write line numbers 1 to 0 on left edge
+	for (int i = 0; i < 10; ++i) {
+		writeString(0, 15 + 9 * i,
+			Common::String::format("%c", (i == 9) ? '0' : '1' + i));
+	}
+
 }
 
 bool Spellbook::msgKeypress(const KeypressMessage &msg) {
@@ -81,7 +124,10 @@ bool Spellbook::msgAction(const ActionMessage &msg) {
 void Spellbook::selectChar(uint charNum) {
 	assert(!g_events->isInCombat());
 	g_globals->_currCharacter = &g_globals->_party[charNum];
+	updateChar();
+}
 
+void Spellbook::updateChar() {
 	// Refresh the cast spell side dialog for new character
 	send("CastSpell", GameMessage("UPDATE"));
 
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.h b/engines/mm/mm1/views_enh/spells/spellbook.h
index 62a8ef4750f..539304df956 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.h
+++ b/engines/mm/mm1/views_enh/spells/spellbook.h
@@ -36,11 +36,23 @@ namespace Spells {
  */
 class Spellbook : public ScrollView, public MM1::Game::SpellCasting {
 private:
+	Shared::Xeen::SpriteResource _scrollSprites;
+
 	/**
-	 * Called when character is changed
+	 * Loads buttons for the dialog
+	 */
+	void addButtons();
+
+	/**
+	 * Selects a new character to show spellbook for
 	 */
 	void selectChar(uint charNum);
 
+	/**
+	 * Called when character is changed
+	 */
+	void updateChar();
+
 	/**
 	 * Updates the data for the displayed spell
 	 */


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

Commit Message:
MM: MM1: Listing spell names in spellbook

Changed paths:
    devtools/create_mm/files/mm1/strings_en.yml
    engines/mm/mm1/views_enh/spells/spellbook.cpp
    engines/mm/mm1/views_enh/spells/spellbook.h


diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index 92418846283..4daa4dff65d 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -510,6 +510,7 @@ enhdialogs:
 		spell_points: "Spell Pts"
 		select: "Select"
 		exit: "Exit"
+		non_caster: "Not a spell caster..."
 	temple:
 		title: "temple"
 		heal: "\x01""37heal"
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.cpp b/engines/mm/mm1/views_enh/spells/spellbook.cpp
index bf056373906..35b782f3326 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.cpp
+++ b/engines/mm/mm1/views_enh/spells/spellbook.cpp
@@ -36,7 +36,7 @@ void Spellbook::addButtons() {
 	_scrollSprites.load("scroll.icn");
 	addButton(&g_globals->_mainIcons, Common::Point(187, 26), 0, Common::KEYCODE_UP);
 	addButton(&g_globals->_mainIcons, Common::Point(187, 111), 2, Common::KEYCODE_DOWN);
-	addButton(&_scrollSprites, Common::Point(90, 109), 5, KEYBIND_SELECT);
+	addButton(&_scrollSprites, Common::Point(100, 109), 5, KEYBIND_SELECT);
 
 	addButton(Common::Rect(40, 28, 187, 36), Common::KEYCODE_1);
 	addButton(Common::Rect(40, 37, 187, 45), Common::KEYCODE_2);
@@ -55,7 +55,7 @@ void Spellbook::addButtons() {
 }
 
 bool Spellbook::msgFocus(const FocusMessage &msg) {
-	MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_PARTY_MENUS);
+	MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
 	updateChar();
 	return true;
 }
@@ -63,8 +63,6 @@ bool Spellbook::msgFocus(const FocusMessage &msg) {
 bool Spellbook::msgUnfocus(const UnfocusMessage &msg) {
 	// Turn off highlight for selected character
 	g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)false));
-
-	MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
 	return true;
 }
 
@@ -92,12 +90,38 @@ void Spellbook::draw() {
 		STRING["enhdialogs.spellbook.spell_points"].c_str(), c._sp._current);
 	writeString(7, 111, sp);
 
-	// Write line numbers 1 to 0 on left edge
+	// Iterate over the lines
 	for (int i = 0; i < 10; ++i) {
-		writeString(0, 15 + 9 * i,
-			Common::String::format("%c", (i == 9) ? '0' : '1' + i));
+		// Left gutter row number
+		setTextColor(0);
+		const int yp = 15 + 9 * i;
+		writeString(0, yp, Common::String::format("%c", (i == 9) ? '0' : '1' + i));
+
+		const int spellIndex = _topIndex + i;
+		setTextColor((spellIndex == _selectedIndex) ? 9 : 37);
+
+		if (_count == 0) {
+			if (i == 0)
+				writeString(12, yp, STRING["enhdialogs.spellbook.non_caster"]);
+
+		} else if (spellIndex < _count) {
+			// Spell name
+			Common::String spellName = STRING[Common::String::format(
+				"spells.%s.%d",
+				_isWizard ? "wizard" : "cleric",
+				spellIndex
+			)];
+			writeString(12, yp, spellName);
+
+			// Spell requirements
+			int lvl, num;
+			getSpellLevelNum(47 * (_isWizard ? 1 : 0) + spellIndex, lvl, num);
+			setSpell(g_globals->_currCharacter, lvl, num);
+
+			writeString(152, yp, Common::String::format("%d/%d",
+				_requiredSp, _requiredGems), ALIGN_RIGHT);
+		}
 	}
-
 }
 
 bool Spellbook::msgKeypress(const KeypressMessage &msg) {
@@ -134,29 +158,22 @@ void Spellbook::updateChar() {
 	// Update the highlighted char in the party display
 	g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)true));
 
-	// And finally, update the display
-	redraw();
-}
-
-void selectedCharChanged() {
-
-}
-
-void Spellbook::updateSelectedSpell() {
-	/*
+	// Update fields
 	const Character &c = *g_globals->_currCharacter;
+	_selectedIndex = (g_events->isInCombat() ? c._combatSpell : c._nonCombatSpell) % 47;
+	if (_selectedIndex == -1)
+		_selectedIndex = 0;
+	_topIndex = (_selectedIndex / 10) * 10;
 
-	if (c._nonCombatSpell == -1) {
-		_requiredSp = _requiredGems = 0;
-
+	if (c._spellLevel._current == 0) {
+		_count = 0;
 	} else {
-		int lvl, num;
-		getSpellLevelNum(c._nonCombatSpell, lvl, num);
-		assert(getSpellIndex(&c, lvl, num) == c._nonCombatSpell);
-
-		setSpell(&c, lvl, num);
+		_count = (c._spellLevel._current < 5) ?
+			c._spellLevel * 8 - 1 : 31 + (c._spellLevel - 4) * 5;
 	}
-	*/
+
+	// And finally, update the display
+	redraw();
 }
 
 } // namespace Spells
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.h b/engines/mm/mm1/views_enh/spells/spellbook.h
index 539304df956..bb2ddeb4b44 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.h
+++ b/engines/mm/mm1/views_enh/spells/spellbook.h
@@ -37,6 +37,9 @@ namespace Spells {
 class Spellbook : public ScrollView, public MM1::Game::SpellCasting {
 private:
 	Shared::Xeen::SpriteResource _scrollSprites;
+	bool _isWizard;
+	int _topIndex = 0, _count = 0;
+	int _selectedIndex = -1;
 
 	/**
 	 * Loads buttons for the dialog
@@ -53,11 +56,6 @@ private:
 	 */
 	void updateChar();
 
-	/**
-	 * Updates the data for the displayed spell
-	 */
-	void updateSelectedSpell();
-
 public:
 	Spellbook();
 	virtual ~Spellbook() {


Commit: d5c93b2627626b176ccd289fd61657169cb19938
    https://github.com/scummvm/scummvm/commit/d5c93b2627626b176ccd289fd61657169cb19938
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-17T22:32:46-08:00

Commit Message:
MM: MM1: Spellbook line selection

Changed paths:
    engines/mm/mm1/views_enh/spells/spellbook.cpp


diff --git a/engines/mm/mm1/views_enh/spells/spellbook.cpp b/engines/mm/mm1/views_enh/spells/spellbook.cpp
index 35b782f3326..eb442711a39 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.cpp
+++ b/engines/mm/mm1/views_enh/spells/spellbook.cpp
@@ -98,7 +98,7 @@ void Spellbook::draw() {
 		writeString(0, yp, Common::String::format("%c", (i == 9) ? '0' : '1' + i));
 
 		const int spellIndex = _topIndex + i;
-		setTextColor((spellIndex == _selectedIndex) ? 9 : 37);
+		setTextColor((spellIndex == _selectedIndex) ? 15 : 37);
 
 		if (_count == 0) {
 			if (i == 0)
@@ -125,6 +125,42 @@ void Spellbook::draw() {
 }
 
 bool Spellbook::msgKeypress(const KeypressMessage &msg) {
+	if (msg.keycode >= Common::KEYCODE_0 && msg.keycode <= Common::KEYCODE_9) {
+		int newIndex = _topIndex + (msg.keycode == Common::KEYCODE_0 ?
+			9 : msg.keycode - Common::KEYCODE_1);
+		if (newIndex < _count) {
+			_selectedIndex = newIndex;
+			redraw();
+			return true;
+		}
+
+	} else if (msg.keycode == Common::KEYCODE_PAGEUP) {
+		if (_topIndex > 0) {
+			_topIndex = MAX(_topIndex - 10, 0);
+			redraw();
+			return true;
+		}
+	} else if (msg.keycode == Common::KEYCODE_PAGEDOWN) {
+		int newTopIndex = _topIndex + 10;
+		if (newTopIndex < _count) {
+			_topIndex = newTopIndex;
+			redraw();
+			return true;
+		}
+	} else if (msg.keycode == Common::KEYCODE_UP) {
+		if (_topIndex > 0) {
+			--_topIndex;
+			redraw();
+			return true;
+		}
+	} else if (msg.keycode == Common::KEYCODE_DOWN) {
+		if ((_topIndex + 10) < _count) {
+			++_topIndex;
+			redraw();
+			return true;
+		}
+	}
+
 	return false;
 }
 




More information about the Scummvm-git-logs mailing list