[Scummvm-git-logs] scummvm master -> d4d189f37493e50c1bde2cf265b4f8b7a597419f
dreammaster
noreply at scummvm.org
Wed Feb 22 05:41:41 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:
aee70c07c6 MM: MM1: Improvements for selecting select/exit buttons in Spellbook
698522ae41 MM: MM1: Handle redraw after closing 3rd level view
d4d189f374 MM: MM1: Switch spellbook to use PartyView base class
Commit: aee70c07c6b9d25ec9e9da247637fc11b906213f
https://github.com/scummvm/scummvm/commit/aee70c07c6b9d25ec9e9da247637fc11b906213f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-21T21:16:40-08:00
Commit Message:
MM: MM1: Improvements for selecting select/exit buttons in Spellbook
Changed paths:
engines/mm/mm1/views_enh/spells/spellbook.cpp
engines/mm/mm1/views_enh/spells/spellbook.h
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.cpp b/engines/mm/mm1/views_enh/spells/spellbook.cpp
index ef6c41ed0be..28dfab385be 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.cpp
+++ b/engines/mm/mm1/views_enh/spells/spellbook.cpp
@@ -49,10 +49,10 @@ void Spellbook::addButtons() {
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(174, 123, 198, 133), KEYBIND_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);
+ addButton(Common::Rect(132, 123, 168, 133), KEYBIND_SELECT);
}
bool Spellbook::msgFocus(const FocusMessage &msg) {
@@ -132,37 +132,37 @@ bool Spellbook::msgKeypress(const KeypressMessage &msg) {
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;
}
+ } else if (msg.keycode == Common::KEYCODE_s) {
+ // Alternate alias for Select button
+ msgAction(ActionMessage(KEYBIND_SELECT));
+
+ } else {
+ return ScrollView::msgKeypress(msg);
}
- return false;
+ return true;
}
bool Spellbook::msgAction(const ActionMessage &msg) {
@@ -173,7 +173,7 @@ bool Spellbook::msgAction(const ActionMessage &msg) {
case KEYBIND_SELECT:
close();
- castSpell();
+ spellSelected();
return true;
case KEYBIND_VIEW_PARTY1:
@@ -216,6 +216,8 @@ void Spellbook::updateChar() {
// Update fields
const Character &c = *g_globals->_currCharacter;
+ _isWizard = c._class == SORCERER || c._class == ARCHER;
+
_selectedIndex = (g_events->isInCombat() ? c._combatSpell : c._nonCombatSpell) % CATEGORY_SPELLS_COUNT;
if (_selectedIndex == -1)
_selectedIndex = 0;
@@ -232,7 +234,7 @@ void Spellbook::updateChar() {
redraw();
}
-void Spellbook::castSpell() {
+void Spellbook::spellSelected() {
Character &c = *g_globals->_currCharacter;
int spellIndex = (_isWizard ? CATEGORY_SPELLS_COUNT : 0) + _selectedIndex;
@@ -242,23 +244,8 @@ void Spellbook::castSpell() {
else
c._nonCombatSpell = spellIndex;
- // Set the spell
- int lvl, num;
- getSpellLevelNum(spellIndex, lvl, num);
- setSpell(&c, lvl, num);
- assert(getSpellIndex(&c, lvl, num) == spellIndex);
-
- if (!canCast()) {
- Common::String msg = getSpellError();
- warning("TODO: Show error - %s", msg.c_str());
-
- } else {
- if (hasCharTarget()) {
- // TODO: select a character target
- } else {
- // TODO: Cast spell
- }
- }
+ // Update the cast spell dialog with the new spell
+ send("CastSpell", GameMessage("UPDATE"));
}
} // namespace Spells
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.h b/engines/mm/mm1/views_enh/spells/spellbook.h
index fe3594de27e..373ff4d807b 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.h
+++ b/engines/mm/mm1/views_enh/spells/spellbook.h
@@ -37,7 +37,7 @@ namespace Spells {
class Spellbook : public ScrollView, public MM1::Game::SpellCasting {
private:
Shared::Xeen::SpriteResource _scrollSprites;
- bool _isWizard;
+ bool _isWizard = false;
int _topIndex = 0, _count = 0;
int _selectedIndex = -1;
@@ -59,7 +59,7 @@ private:
/**
* Performs the selected spell
*/
- void castSpell();
+ void spellSelected();
public:
Spellbook();
Commit: 698522ae411859593e3f91bddcb563b6fbb3567c
https://github.com/scummvm/scummvm/commit/698522ae411859593e3f91bddcb563b6fbb3567c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-21T21:16:41-08:00
Commit Message:
MM: MM1: Handle redraw after closing 3rd level view
Previously, closing the spellbook to return to the
Cast Spell view wasn't erasing the spellbook, because
the overall game view wasn't being redrawn, just the
spellbook itself. This changed version iterates
through the views drawing them in order from back to front
Changed paths:
engines/mm/mm1/events.cpp
diff --git a/engines/mm/mm1/events.cpp b/engines/mm/mm1/events.cpp
index f3eea9fea0d..2466721ae27 100644
--- a/engines/mm/mm1/events.cpp
+++ b/engines/mm/mm1/events.cpp
@@ -142,10 +142,13 @@ void Events::popView() {
focusedView()->msgUnfocus(UnfocusMessage());
_views.pop();
- if (!_views.empty()) {
- focusedView()->redraw();
- focusedView()->msgFocus(FocusMessage());
+ for (int i = 0; i < (int)_views.size() - 1; ++i) {
+ _views[i]->redraw();
+ _views[i]->draw();
}
+
+ if (!_views.empty())
+ focusedView()->msgFocus(FocusMessage());
}
bool Events::isPresent(const Common::String &name) const {
Commit: d4d189f37493e50c1bde2cf265b4f8b7a597419f
https://github.com/scummvm/scummvm/commit/d4d189f37493e50c1bde2cf265b4f8b7a597419f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-21T21:16:41-08:00
Commit Message:
MM: MM1: Switch spellbook to use PartyView base class
Changed paths:
engines/mm/mm1/views_enh/party_view.cpp
engines/mm/mm1/views_enh/party_view.h
engines/mm/mm1/views_enh/spells/spellbook.cpp
engines/mm/mm1/views_enh/spells/spellbook.h
diff --git a/engines/mm/mm1/views_enh/party_view.cpp b/engines/mm/mm1/views_enh/party_view.cpp
index c93e6f6b2f4..2af20caeb86 100644
--- a/engines/mm/mm1/views_enh/party_view.cpp
+++ b/engines/mm/mm1/views_enh/party_view.cpp
@@ -48,7 +48,11 @@ bool PartyView::msgUnfocus(const UnfocusMessage &msg) {
}
bool PartyView::msgMouseDown(const MouseDownMessage &msg) {
- return send("GameParty", msg);
+ if (canSwitchChar()) {
+ return send("GameParty", msg);
+ } else {
+ return ScrollView::msgMouseDown(msg);
+ }
}
bool PartyView::msgGame(const GameMessage &msg) {
@@ -62,7 +66,7 @@ bool PartyView::msgGame(const GameMessage &msg) {
bool PartyView::msgAction(const ActionMessage &msg) {
if (msg._action >= KEYBIND_VIEW_PARTY1 &&
- msg._action <= KEYBIND_VIEW_PARTY6)
+ msg._action <= KEYBIND_VIEW_PARTY6 && canSwitchChar())
return send("GameParty", msg);
return false;
}
diff --git a/engines/mm/mm1/views_enh/party_view.h b/engines/mm/mm1/views_enh/party_view.h
index 487a425a7e1..a45fb940172 100644
--- a/engines/mm/mm1/views_enh/party_view.h
+++ b/engines/mm/mm1/views_enh/party_view.h
@@ -29,6 +29,13 @@ namespace MM1 {
namespace ViewsEnh {
class PartyView : public ScrollView {
+protected:
+ /**
+ * Return true if the selected character can be switched
+ */
+ virtual bool canSwitchChar() const {
+ return true;
+ }
public:
PartyView(const Common::String &name) : ScrollView(name) {}
PartyView(const Common::String &name, UIElement *owner) :
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.cpp b/engines/mm/mm1/views_enh/spells/spellbook.cpp
index 28dfab385be..0ddc2c9cbbf 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.cpp
+++ b/engines/mm/mm1/views_enh/spells/spellbook.cpp
@@ -28,7 +28,7 @@ namespace MM1 {
namespace ViewsEnh {
namespace Spells {
-Spellbook::Spellbook() : ScrollView("Spellbook") {
+Spellbook::Spellbook() : PartyView("Spellbook") {
_bounds = Common::Rect(27, 6, 208, 142);
addButtons();
}
@@ -56,19 +56,20 @@ void Spellbook::addButtons() {
}
bool Spellbook::msgFocus(const FocusMessage &msg) {
+ PartyView::msgFocus(msg);
+
+ // In this view we don't want 1 to 6 mapping to char selection
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
updateChar();
return true;
}
-bool Spellbook::msgUnfocus(const UnfocusMessage &msg) {
- // Turn off highlight for selected character
- g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)false));
- return true;
+bool Spellbook::canSwitchChar() const {
+ return !g_events->isInCombat();
}
void Spellbook::draw() {
- ScrollView::draw();
+ PartyView::draw();
Graphics::ManagedSurface s = getSurface();
const Character &c = *g_globals->_currCharacter;
@@ -159,7 +160,7 @@ bool Spellbook::msgKeypress(const KeypressMessage &msg) {
msgAction(ActionMessage(KEYBIND_SELECT));
} else {
- return ScrollView::msgKeypress(msg);
+ return PartyView::msgKeypress(msg);
}
return true;
@@ -176,24 +177,6 @@ bool Spellbook::msgAction(const ActionMessage &msg) {
spellSelected();
return true;
- case KEYBIND_VIEW_PARTY1:
- case KEYBIND_VIEW_PARTY2:
- case KEYBIND_VIEW_PARTY3:
- case KEYBIND_VIEW_PARTY4:
- case KEYBIND_VIEW_PARTY5:
- case KEYBIND_VIEW_PARTY6:
- // This is unlikely to be triggered. Since normally '1' to '6'
- // changes the selected character, but in this dialog,
- // numeric keys are used to select a spell number
- if (!g_events->isInCombat()) {
- uint charNum = msg._action - KEYBIND_VIEW_PARTY1;
-
- if (charNum < g_globals->_party.size())
- selectChar(charNum);
- return true;
- }
- return true;
-
default:
break;
}
@@ -201,10 +184,13 @@ bool Spellbook::msgAction(const ActionMessage &msg) {
return false;
}
-void Spellbook::selectChar(uint charNum) {
- assert(!g_events->isInCombat());
- g_globals->_currCharacter = &g_globals->_party[charNum];
- updateChar();
+bool Spellbook::msgGame(const GameMessage &msg) {
+ if (msg._name == "UPDATE") {
+ updateChar();
+ return true;
+ } else {
+ return PartyView::msgGame(msg);
+ }
}
void Spellbook::updateChar() {
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.h b/engines/mm/mm1/views_enh/spells/spellbook.h
index 373ff4d807b..6d454d8ef9e 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.h
+++ b/engines/mm/mm1/views_enh/spells/spellbook.h
@@ -24,7 +24,7 @@
#include "mm/mm1/messages.h"
#include "mm/mm1/game/spell_casting.h"
-#include "mm/mm1/views_enh/scroll_view.h"
+#include "mm/mm1/views_enh/party_view.h"
namespace MM {
namespace MM1 {
@@ -34,7 +34,7 @@ namespace Spells {
/**
* Dialog for selecting a spell to cast
*/
-class Spellbook : public ScrollView, public MM1::Game::SpellCasting {
+class Spellbook : public PartyView, public MM1::Game::SpellCasting {
private:
Shared::Xeen::SpriteResource _scrollSprites;
bool _isWizard = false;
@@ -46,11 +46,6 @@ private:
*/
void addButtons();
- /**
- * Selects a new character to show spellbook for
- */
- void selectChar(uint charNum);
-
/**
* Called when character is changed
*/
@@ -61,6 +56,9 @@ private:
*/
void spellSelected();
+protected:
+ bool canSwitchChar() const override;
+
public:
Spellbook();
virtual ~Spellbook() {
@@ -68,9 +66,9 @@ public:
void draw() override;
bool msgFocus(const FocusMessage &msg) override;
- bool msgUnfocus(const UnfocusMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
+ bool msgGame(const GameMessage &msg) override;
};
} // namespace Spells
More information about the Scummvm-git-logs
mailing list