[Scummvm-git-logs] scummvm master -> ce66d264631b8e71b7aa8cc764ca91cb6c64cb7f
dreammaster
noreply at scummvm.org
Tue May 30 03:08:02 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:
31a2814353 MM: MM1: Fix for closing Gypsy interaction
ce66d26463 MM: MM1: Fix Cast Spell, Spellbook display in combat
Commit: 31a28143533f22c11ba586768ef3a202c0a5f534
https://github.com/scummvm/scummvm/commit/31a28143533f22c11ba586768ef3a202c0a5f534
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-05-29T20:07:46-07:00
Commit Message:
MM: MM1: Fix for closing Gypsy interaction
Changed paths:
engines/mm/mm1/views_enh/interactions/gypsy.cpp
diff --git a/engines/mm/mm1/views_enh/interactions/gypsy.cpp b/engines/mm/mm1/views_enh/interactions/gypsy.cpp
index 1dac4aa31a2..7ad16fa2b85 100644
--- a/engines/mm/mm1/views_enh/interactions/gypsy.cpp
+++ b/engines/mm/mm1/views_enh/interactions/gypsy.cpp
@@ -42,7 +42,7 @@ bool Gypsy::msgFocus(const FocusMessage &msg) {
void Gypsy::viewAction() {
// When already showing Gypsy, any click/key will close view
- if (_lines.empty())
+ if (_charSelected)
close();
}
@@ -62,6 +62,7 @@ void Gypsy::charSwitched(Character *priorChar) {
);
addText(line);
+ _charSelected = true;
redraw();
}
Commit: ce66d264631b8e71b7aa8cc764ca91cb6c64cb7f
https://github.com/scummvm/scummvm/commit/ce66d264631b8e71b7aa8cc764ca91cb6c64cb7f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-05-29T20:07:46-07:00
Commit Message:
MM: MM1: Fix Cast Spell, Spellbook display in combat
Changed paths:
engines/mm/mm1/data/character.cpp
engines/mm/mm1/data/character.h
engines/mm/mm1/views_enh/spells/cast_spell.cpp
engines/mm/mm1/views_enh/spells/cast_spell.h
engines/mm/mm1/views_enh/spells/spellbook.cpp
engines/mm/mm1/views_enh/spells/spellbook.h
diff --git a/engines/mm/mm1/data/character.cpp b/engines/mm/mm1/data/character.cpp
index b59037f3d01..c1bbf096b57 100644
--- a/engines/mm/mm1/data/character.cpp
+++ b/engines/mm/mm1/data/character.cpp
@@ -737,5 +737,16 @@ Common::String Character::getConditionString(ConditionEnum cond) {
}
}
+int Character::spellNumber() const {
+ return g_events->isInCombat() ? _combatSpell : _nonCombatSpell;
+}
+
+void Character::setSpellNumber(int spellNum) {
+ if (g_events->isInCombat())
+ _combatSpell = spellNum;
+ else
+ _nonCombatSpell = spellNum;
+}
+
} // namespace MM1
} // namespace MM
diff --git a/engines/mm/mm1/data/character.h b/engines/mm/mm1/data/character.h
index e9c7ef3c8d1..768201a1de1 100644
--- a/engines/mm/mm1/data/character.h
+++ b/engines/mm/mm1/data/character.h
@@ -470,6 +470,16 @@ struct Character : public PrimaryAttributes {
int _nonCombatSpell = -1;
int _combatSpell = -1;
+ /**
+ * Get the selected combat/noncombat spell number
+ */
+ int spellNumber() const;
+
+ /**
+ * Sets the selected spell
+ */
+ void setSpellNumber(int spellNum);
+
Character();
/**
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
index 94971842922..b46fb79be4c 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
@@ -40,13 +40,26 @@ CastSpell::CastSpell() : PartyView("CastSpell") {
}
bool CastSpell::msgFocus(const FocusMessage &msg) {
- (void)PartyView::msgFocus(msg);
+ if (!isInCombat())
+ (void)PartyView::msgFocus(msg);
+
updateSelectedSpell();
return true;
}
+bool CastSpell::msgUnfocus(const UnfocusMessage &msg) {
+ if (!isInCombat())
+ (void)PartyView::msgUnfocus(msg);
+
+ return true;
+}
+
void CastSpell::draw() {
- PartyView::draw();
+ if (!isInCombat()) {
+ PartyView::draw();
+ } else {
+ ScrollView::draw();
+ }
_fontReduced = false;
const Character &c = *g_globals->_currCharacter;
@@ -56,11 +69,12 @@ void CastSpell::draw() {
setTextColor(37);
+ int spellNum = c.spellNumber();
Common::String spellName = STRING["enhdialogs.cast_spell.none"];
- if (c._nonCombatSpell >= 0 && c._nonCombatSpell < 47) {
- spellName = STRING[Common::String::format("spells.cleric.%d", c._nonCombatSpell)];
- } else if (c._nonCombatSpell >= 47) {
- spellName = STRING[Common::String::format("spells.wizard.%d", c._nonCombatSpell - 47)];
+ if (spellNum >= 0 && spellNum < 47) {
+ spellName = STRING[Common::String::format("spells.cleric.%d", spellNum)];
+ } else if (spellNum >= 47) {
+ spellName = STRING[Common::String::format("spells.wizard.%d", spellNum - 47)];
}
writeString(0, 60, spellName, ALIGN_MIDDLE);
@@ -82,8 +96,7 @@ void CastSpell::draw() {
bool CastSpell::msgKeypress(const KeypressMessage &msg) {
if (msg.keycode == Common::KEYCODE_c) {
// Cast a spell
- const Character &c = *g_globals->_currCharacter;
- if (c._nonCombatSpell != -1) {
+ if (_spellIndex != -1) {
if (!canCast()) {
close();
spellError();
@@ -101,8 +114,10 @@ bool CastSpell::msgKeypress(const KeypressMessage &msg) {
// Select a new spell
addView("Spellbook");
return true;
- } else {
+ } else if (!isInCombat()) {
return PartyView::msgKeypress(msg);
+ } else {
+ return false;
}
}
@@ -111,8 +126,10 @@ bool CastSpell::msgAction(const ActionMessage &msg) {
close();
return true;
- } else {
+ } else if (!isInCombat()) {
return PartyView::msgAction(msg);
+ } else {
+ return false;
}
}
@@ -132,13 +149,15 @@ bool CastSpell::msgGame(const GameMessage &msg) {
void CastSpell::updateSelectedSpell() {
const Character &c = *g_globals->_currCharacter;
- if (c._nonCombatSpell == -1) {
+ int spellNum = c.spellNumber();
+ if (spellNum == -1) {
_requiredSp = _requiredGems = 0;
+ _spellIndex = -1;
} else {
int lvl, num;
- getSpellLevelNum(c._nonCombatSpell, lvl, num);
- assert(getSpellIndex(&c, lvl, num) == c._nonCombatSpell);
+ getSpellLevelNum(spellNum, lvl, num);
+ assert(getSpellIndex(&c, lvl, num) == spellNum);
setSpell(&c, lvl, num);
}
@@ -150,6 +169,9 @@ void CastSpell::charSwitched(Character *priorChar) {
}
void CastSpell::castSpell(Character *target) {
+ if (_spellIndex == -1)
+ return;
+
if (!isMagicAllowed()) {
g_events->send(InfoMessage(STRING["spells.magic_doesnt_work"]));
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.h b/engines/mm/mm1/views_enh/spells/cast_spell.h
index db29dbbeaee..44aea1fd025 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.h
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.h
@@ -54,6 +54,13 @@ private:
void spellError();
protected:
+ /**
+ * Return true if the selected character can be switched
+ */
+ bool canSwitchChar() override {
+ return !isInCombat();
+ }
+
/**
* Called when the selected character has been switched
*/
@@ -65,6 +72,7 @@ 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;
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.cpp b/engines/mm/mm1/views_enh/spells/spellbook.cpp
index 803aab13b2a..6ec28a75ea9 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.cpp
+++ b/engines/mm/mm1/views_enh/spells/spellbook.cpp
@@ -57,7 +57,8 @@ void Spellbook::addButtons() {
}
bool Spellbook::msgFocus(const FocusMessage &msg) {
- PartyView::msgFocus(msg);
+ if (!isInCombat())
+ PartyView::msgFocus(msg);
// In this view we don't want 1 to 6 mapping to char selection
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
@@ -65,12 +66,22 @@ bool Spellbook::msgFocus(const FocusMessage &msg) {
return true;
}
+bool Spellbook::msgUnfocus(const UnfocusMessage &msg) {
+ if (!isInCombat())
+ PartyView::msgUnfocus(msg);
+ return true;
+}
+
bool Spellbook::canSwitchChar() {
return !g_events->isInCombat();
}
void Spellbook::draw() {
- PartyView::draw();
+ if (isInCombat()) {
+ ScrollView::draw();
+ } else {
+ PartyView::draw();
+ }
Graphics::ManagedSurface s = getSurface();
const Character &c = *g_globals->_currCharacter;
@@ -162,7 +173,7 @@ bool Spellbook::msgKeypress(const KeypressMessage &msg) {
// Alternate alias for Select button
msgAction(ActionMessage(KEYBIND_SELECT));
- } else {
+ } else if (!isInCombat()) {
return PartyView::msgKeypress(msg);
}
@@ -191,8 +202,10 @@ bool Spellbook::msgGame(const GameMessage &msg) {
if (msg._name == "UPDATE") {
updateChar();
return true;
- } else {
+ } else if (!isInCombat()) {
return PartyView::msgGame(msg);
+ } else {
+ return true;
}
}
@@ -228,10 +241,7 @@ void Spellbook::spellSelected() {
int spellIndex = (_isWizard ? CATEGORY_SPELLS_COUNT : 0) + _selectedIndex;
// Set the selected spell for the character
- if (g_events->isInCombat())
- c._combatSpell = spellIndex;
- else
- c._nonCombatSpell = spellIndex;
+ c.setSpellNumber(spellIndex);
}
} // namespace Spells
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.h b/engines/mm/mm1/views_enh/spells/spellbook.h
index db5fe731851..3bdbd54b74b 100644
--- a/engines/mm/mm1/views_enh/spells/spellbook.h
+++ b/engines/mm/mm1/views_enh/spells/spellbook.h
@@ -66,6 +66,7 @@ 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;
More information about the Scummvm-git-logs
mailing list