[Scummvm-git-logs] scummvm master -> 2474727b3482e069fced6256aa13a406639d333c
dreammaster
noreply at scummvm.org
Fri Feb 17 05:39:51 UTC 2023
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ad0d9a4935 MM: MM1: Cost and btn text in Cast Spell is reduced font
6e575b8da8 MM: MM1: Display proper SP/Gem requirements for spells
7aa079a5eb MM: MM1: Cast Spell keypress handler
2474727b34 MM: MM1: Skeleton spellbook view
Commit: ad0d9a49351fed43e847b633f81b097fdb9b8536
https://github.com/scummvm/scummvm/commit/ad0d9a49351fed43e847b633f81b097fdb9b8536
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-16T21:06:33-08:00
Commit Message:
MM: MM1: Cost and btn text in Cast Spell is reduced font
Changed paths:
engines/mm/mm1/views_enh/spells/cast_spell.cpp
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
index 6df6eb7963f..71f607a3522 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
@@ -28,8 +28,8 @@ namespace ViewsEnh {
CastSpell::CastSpell() : ScrollView("CastSpell") {
_bounds = Common::Rect(225, 0, 320, 146);
- _icons.load("cast.icn");
+ _icons.load("cast.icn");
addButton(&_icons, Common::Point(0, 100), 0,
Common::KeyState(Common::KEYCODE_c, 'c'));
addButton(&_icons, Common::Point(28, 100), 2,
@@ -57,12 +57,18 @@ bool CastSpell::msgUnfocus(const UnfocusMessage &msg) {
void CastSpell::draw() {
ScrollView::draw();
+ _fontReduced = false;
const Character &c = *g_globals->_currCharacter;
writeString(0, 0, STRING["enhdialogs.cast_spell.title"], ALIGN_MIDDLE);
writeString(0, 20, c._name, ALIGN_MIDDLE);
writeString(0, 40, STRING["enhdialogs.cast_spell.spell_ready"]);
+ setTextColor(37);
+ writeString(0, 60, STRING["enhdialogs.cast_spell.none"], ALIGN_MIDDLE);
+ setTextColor(0);
+
+ _fontReduced = true;
writeString(0, 80, STRING["enhdialogs.cast_spell.cost"]);
writeString(0, 90, STRING["enhdialogs.cast_spell.cur_sp"]);
writeString(0, 80, Common::String::format("%d/%d", 6, 9), ALIGN_RIGHT);
@@ -70,10 +76,9 @@ void CastSpell::draw() {
writeString(0, 122, STRING["enhdialogs.cast_spell.cast"]);
writeString(30, 122, STRING["enhdialogs.cast_spell.new"]);
- writeString(58, 122, STRING["enhdialogs.cast_spell.esc"]);
+ writeString(60, 122, STRING["enhdialogs.cast_spell.esc"]);
- setTextColor(37);
- writeString(0, 60, STRING["enhdialogs.cast_spell.none"], ALIGN_MIDDLE);
+ _fontReduced = false;
}
bool CastSpell::msgKeypress(const KeypressMessage &msg) {
Commit: 6e575b8da80ed7ed4ca851cfd23f2f7fcb6cb09a
https://github.com/scummvm/scummvm/commit/6e575b8da80ed7ed4ca851cfd23f2f7fcb6cb09a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-16T21:06:33-08:00
Commit Message:
MM: MM1: Display proper SP/Gem requirements for spells
Changed paths:
engines/mm/mm1/game/spell_casting.cpp
engines/mm/mm1/game/spell_casting.h
engines/mm/mm1/views_enh/spells/cast_spell.cpp
engines/mm/mm1/views_enh/spells/cast_spell.h
diff --git a/engines/mm/mm1/game/spell_casting.cpp b/engines/mm/mm1/game/spell_casting.cpp
index 2aeb3bce7bc..78d428662d8 100644
--- a/engines/mm/mm1/game/spell_casting.cpp
+++ b/engines/mm/mm1/game/spell_casting.cpp
@@ -71,7 +71,7 @@ enum SpellFlag {
SF_OUTDOORS_ONLY = 0x10
};
-int SpellCasting::getSpellIndex(Character *chr, int lvl, int num) {
+int SpellCasting::getSpellIndex(const Character *chr, int lvl, int num) {
int lvlNum;
int setNum = chr->_class == ARCHER || chr->_class == SORCERER ? 1 : 0;
int spellNum = num - 1;
@@ -84,7 +84,24 @@ int SpellCasting::getSpellIndex(Character *chr, int lvl, int num) {
return spellIndex;
}
-void SpellCasting::setSpell(Character *chr, int lvl, int num) {
+void SpellCasting::getSpellLevelNum(int spellIndex, int &lvl, int &num) {
+ int idx = spellIndex % 47;
+ int numSpells;
+
+ for (lvl = 1; lvl < 8; ++lvl) {
+ int numSpells = (lvl >= 5) ? 5 : 8;
+ if (idx < numSpells) {
+ num = idx + 1;
+ return;
+ }
+ idx -= numSpells;
+ }
+
+ num = -1;
+}
+
+
+void SpellCasting::setSpell(const Character *chr, int lvl, int num) {
_spellState = SS_OK;
// Figure the offset in the spell list
diff --git a/engines/mm/mm1/game/spell_casting.h b/engines/mm/mm1/game/spell_casting.h
index ce903fc4836..d4a53e8bae0 100644
--- a/engines/mm/mm1/game/spell_casting.h
+++ b/engines/mm/mm1/game/spell_casting.h
@@ -52,12 +52,17 @@ public:
/**
* Sets the current spell
*/
- void setSpell(Character *chr, int lvl, int num);
+ void setSpell(const Character *chr, int lvl, int num);
/**
* Get the index in the spell array for a given spell
*/
- static int getSpellIndex(Character *chr, int lvl, int num);
+ static int getSpellIndex(const Character *chr, int lvl, int num);
+
+ /**
+ * Get the spell level and number from spell index
+ */
+ static void getSpellLevelNum(int spellIndex, int &lvl, int &num);
/**
* Sets a spell directly by index
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
index 71f607a3522..d32f88b820f 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
@@ -41,8 +41,9 @@ bool CastSpell::msgFocus(const FocusMessage &msg) {
// Turn on highlight for selected character
if (!g_globals->_currCharacter)
g_globals->_currCharacter = &g_globals->_party[0];
- g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)true));
+ updateSelectedSpell();
+ g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)true));
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_PARTY_MENUS);
return true;
}
@@ -65,13 +66,21 @@ void CastSpell::draw() {
writeString(0, 40, STRING["enhdialogs.cast_spell.spell_ready"]);
setTextColor(37);
- writeString(0, 60, STRING["enhdialogs.cast_spell.none"], ALIGN_MIDDLE);
- setTextColor(0);
+
+ 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)];
+ }
+ writeString(0, 60, spellName, ALIGN_MIDDLE);
_fontReduced = true;
+ setTextColor(0);
writeString(0, 80, STRING["enhdialogs.cast_spell.cost"]);
writeString(0, 90, STRING["enhdialogs.cast_spell.cur_sp"]);
- writeString(0, 80, Common::String::format("%d/%d", 6, 9), ALIGN_RIGHT);
+ writeString(0, 80, Common::String::format("%d/%d",
+ _requiredSp, _requiredGems), ALIGN_RIGHT);
writeString(0, 90, Common::String::format("%d", c._sp._current), ALIGN_RIGHT);
writeString(0, 122, STRING["enhdialogs.cast_spell.cast"]);
@@ -96,6 +105,7 @@ bool CastSpell::msgAction(const ActionMessage &msg) {
if (charNum < g_globals->_party.size()) {
g_globals->_currCharacter = &g_globals->_party[
msg._action - KEYBIND_VIEW_PARTY1];
+ updateSelectedSpell();
g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)true));
redraw();
return true;
@@ -105,6 +115,21 @@ bool CastSpell::msgAction(const ActionMessage &msg) {
return false;
}
+void CastSpell::updateSelectedSpell() {
+ const Character &c = *g_globals->_currCharacter;
+
+ if (c._nonCombatSpell == -1) {
+ _requiredSp = _requiredGems = 0;
+
+ } else {
+ int lvl, num;
+ getSpellLevelNum(c._nonCombatSpell, lvl, num);
+ assert(getSpellIndex(&c, lvl, num) == c._nonCombatSpell);
+
+ setSpell(&c, lvl, num);
+ }
+}
+
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.h b/engines/mm/mm1/views_enh/spells/cast_spell.h
index 636b30bf2db..c7e7352c34c 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.h
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.h
@@ -23,6 +23,7 @@
#define MM1_VIEWS_ENH_CAST_SPELL_H
#include "mm/mm1/messages.h"
+#include "mm/mm1/game/spell_casting.h"
#include "mm/mm1/views_enh/scroll_view.h"
namespace MM {
@@ -32,9 +33,15 @@ namespace ViewsEnh {
/**
* Dialog for casting a spell
*/
-class CastSpell : public ScrollView {
+class CastSpell : public ScrollView, public MM1::Game::SpellCasting {
private:
Shared::Xeen::SpriteResource _icons;
+
+ /**
+ * Updates the data for the displayed spell
+ */
+ void updateSelectedSpell();
+
public:
CastSpell();
virtual ~CastSpell() {}
Commit: 7aa079a5eb8bd4432125e0f3eb989697e2a6b21d
https://github.com/scummvm/scummvm/commit/7aa079a5eb8bd4432125e0f3eb989697e2a6b21d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-16T21:16:45-08:00
Commit Message:
MM: MM1: Cast Spell keypress handler
Changed paths:
engines/mm/mm1/game/spell_casting.cpp
engines/mm/mm1/views_enh/spells/cast_spell.cpp
diff --git a/engines/mm/mm1/game/spell_casting.cpp b/engines/mm/mm1/game/spell_casting.cpp
index 78d428662d8..457212037bc 100644
--- a/engines/mm/mm1/game/spell_casting.cpp
+++ b/engines/mm/mm1/game/spell_casting.cpp
@@ -86,7 +86,6 @@ int SpellCasting::getSpellIndex(const Character *chr, int lvl, int num) {
void SpellCasting::getSpellLevelNum(int spellIndex, int &lvl, int &num) {
int idx = spellIndex % 47;
- int numSpells;
for (lvl = 1; lvl < 8; ++lvl) {
int numSpells = (lvl >= 5) ? 5 : 8;
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
index d32f88b820f..26706f5e35a 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
@@ -91,7 +91,21 @@ void CastSpell::draw() {
}
bool CastSpell::msgKeypress(const KeypressMessage &msg) {
- return true;
+ if (msg.keycode == Common::KEYCODE_c) {
+ close();
+
+ const Character &c = *g_globals->_currCharacter;
+ if (c._nonCombatSpell != -1) {
+ // TODO: Cast spell here
+ }
+ return true;
+ } else if (msg.keycode == Common::KEYCODE_n) {
+ // Select a new spell
+ addView("Spellbook");
+ return true;
+ }
+
+ return false;
}
bool CastSpell::msgAction(const ActionMessage &msg) {
Commit: 2474727b3482e069fced6256aa13a406639d333c
https://github.com/scummvm/scummvm/commit/2474727b3482e069fced6256aa13a406639d333c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-16T21:39:34-08:00
Commit Message:
MM: MM1: Skeleton spellbook view
Changed paths:
A engines/mm/mm1/views_enh/spells/spellbook.cpp
A engines/mm/mm1/views_enh/spells/spellbook.h
engines/mm/mm1/views_enh/dialogs.h
engines/mm/mm1/views_enh/spells/cast_spell.cpp
engines/mm/mm1/views_enh/spells/cast_spell.h
engines/mm/module.mk
diff --git a/engines/mm/mm1/views_enh/dialogs.h b/engines/mm/mm1/views_enh/dialogs.h
index 548d268a3bd..60e2c249560 100644
--- a/engines/mm/mm1/views_enh/dialogs.h
+++ b/engines/mm/mm1/views_enh/dialogs.h
@@ -35,6 +35,7 @@
#include "mm/mm1/views_enh/locations/market.h"
#include "mm/mm1/views_enh/locations/temple.h"
#include "mm/mm1/views_enh/spells/cast_spell.h"
+#include "mm/mm1/views_enh/spells/spellbook.h"
namespace MM {
namespace MM1 {
@@ -52,7 +53,8 @@ private:
Views::Protect _protect;
Views::Title _title;
// Views::ViewCharacter _viewCharacter;
- ViewsEnh::CastSpell _castSpell;
+ ViewsEnh::Spells::CastSpell _castSpell;
+ ViewsEnh::Spells::Spellbook _spellbook;
ViewsEnh::MainMenu _mainMenu;
ViewsEnh::MapPopup _mapPopup;
ViewsEnh::QuickRef _quickRef;
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
index 26706f5e35a..e77b1a01ae9 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
@@ -25,6 +25,7 @@
namespace MM {
namespace MM1 {
namespace ViewsEnh {
+namespace Spells {
CastSpell::CastSpell() : ScrollView("CastSpell") {
_bounds = Common::Rect(225, 0, 320, 146);
@@ -114,7 +115,7 @@ bool CastSpell::msgAction(const ActionMessage &msg) {
return true;
} else if (msg._action >= KEYBIND_VIEW_PARTY1 &&
- msg._action <= KEYBIND_VIEW_PARTY6) {
+ msg._action <= KEYBIND_VIEW_PARTY6) {
uint charNum = msg._action - KEYBIND_VIEW_PARTY1;
if (charNum < g_globals->_party.size()) {
g_globals->_currCharacter = &g_globals->_party[
@@ -129,6 +130,16 @@ bool CastSpell::msgAction(const ActionMessage &msg) {
return false;
}
+bool CastSpell::msgGame(const GameMessage &msg) {
+ if (msg._name == "UPDATE") {
+ updateSelectedSpell();
+ draw();
+ return true;
+ }
+
+ return true;
+}
+
void CastSpell::updateSelectedSpell() {
const Character &c = *g_globals->_currCharacter;
@@ -144,6 +155,7 @@ void CastSpell::updateSelectedSpell() {
}
}
+} // namespace Spells
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.h b/engines/mm/mm1/views_enh/spells/cast_spell.h
index c7e7352c34c..5bc9411024d 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.h
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.h
@@ -29,6 +29,7 @@
namespace MM {
namespace MM1 {
namespace ViewsEnh {
+namespace Spells {
/**
* Dialog for casting a spell
@@ -51,8 +52,10 @@ public:
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
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.cpp b/engines/mm/mm1/views_enh/spells/spellbook.cpp
new file mode 100644
index 00000000000..e0aaeab3ebf
--- /dev/null
+++ b/engines/mm/mm1/views_enh/spells/spellbook.cpp
@@ -0,0 +1,119 @@
+/* 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/spells/spellbook.h"
+#include "mm/mm1/globals.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+namespace Spells {
+
+Spellbook::Spellbook() : ScrollView("Spellbook") {
+ _bounds = Common::Rect(27, 6, 195, 142);
+}
+
+bool Spellbook::msgFocus(const FocusMessage &msg) {
+ g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)true));
+ MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_PARTY_MENUS);
+ return true;
+}
+
+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;
+}
+
+void Spellbook::draw() {
+ ScrollView::draw();
+ const Character &c = *g_globals->_currCharacter;
+
+ _fontReduced = true;
+ Common::String title = Common::String::format("%s %s",
+ STRING["enhdialogs.spellbook.title"].c_str(),
+ c._name
+ );
+ writeString(0, 0, title, ALIGN_MIDDLE);
+}
+
+bool Spellbook::msgKeypress(const KeypressMessage &msg) {
+ return false;
+}
+
+bool Spellbook::msgAction(const ActionMessage &msg) {
+ if (msg._action == KEYBIND_ESCAPE) {
+ close();
+ return true;
+
+ } else if (msg._action >= KEYBIND_VIEW_PARTY1 &&
+ msg._action <= KEYBIND_VIEW_PARTY6 && !g_events->isInCombat()) {
+ uint charNum = msg._action - KEYBIND_VIEW_PARTY1;
+
+ if (charNum < g_globals->_party.size())
+ selectChar(charNum);
+ return true;
+ }
+
+ return false;
+}
+
+void Spellbook::selectChar(uint charNum) {
+ assert(!g_events->isInCombat());
+ g_globals->_currCharacter = &g_globals->_party[charNum];
+
+ // Refresh the cast spell side dialog for new character
+ send("CastSpell", GameMessage("UPDATE"));
+
+ // 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() {
+ /*
+ const Character &c = *g_globals->_currCharacter;
+
+ if (c._nonCombatSpell == -1) {
+ _requiredSp = _requiredGems = 0;
+
+ } else {
+ int lvl, num;
+ getSpellLevelNum(c._nonCombatSpell, lvl, num);
+ assert(getSpellIndex(&c, lvl, num) == c._nonCombatSpell);
+
+ setSpell(&c, lvl, num);
+ }
+ */
+}
+
+} // namespace Spells
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views_enh/spells/spellbook.h b/engines/mm/mm1/views_enh/spells/spellbook.h
new file mode 100644
index 00000000000..62a8ef4750f
--- /dev/null
+++ b/engines/mm/mm1/views_enh/spells/spellbook.h
@@ -0,0 +1,66 @@
+/* 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_SPELLBOOK_H
+#define MM1_VIEWS_ENH_SPELLBOOK_H
+
+#include "mm/mm1/messages.h"
+#include "mm/mm1/game/spell_casting.h"
+#include "mm/mm1/views_enh/scroll_view.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+namespace Spells {
+
+/**
+ * Dialog for selecting a spell to cast
+ */
+class Spellbook : public ScrollView, public MM1::Game::SpellCasting {
+private:
+ /**
+ * Called when character is changed
+ */
+ void selectChar(uint charNum);
+
+ /**
+ * Updates the data for the displayed spell
+ */
+ void updateSelectedSpell();
+
+public:
+ Spellbook();
+ virtual ~Spellbook() {
+ }
+
+ 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;
+};
+
+} // namespace Spells
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/module.mk b/engines/mm/module.mk
index 4206018a131..0120fabebcd 100644
--- a/engines/mm/module.mk
+++ b/engines/mm/module.mk
@@ -120,6 +120,7 @@ MODULE_OBJS += \
mm1/views/trap.o \
mm1/views/unlock.o \
mm1/views_enh/spells/cast_spell.o \
+ mm1/views_enh/spells/spellbook.o \
mm1/views_enh/button_container.o \
mm1/views_enh/character_info.o \
mm1/views_enh/dialogs.o \
More information about the Scummvm-git-logs
mailing list