MM: MM1: Some content in the Cast Spell dialog

This commit is contained in:
Paul Gilbert 2023-02-15 21:15:13 -08:00
parent 705a0ad544
commit 51d843db19
11 changed files with 140 additions and 61 deletions

View File

@ -426,6 +426,7 @@ enhdialogs:
cast_spell:
title: "Cast Spell"
spell_ready: "Spell Ready:"
none: "None Ready"
cost: "Cost"
cur_sp: "Cur SP"
cast: "\x01""37Cast"

View File

@ -466,7 +466,8 @@ struct Character : public PrimaryAttributes {
// Combat fields
bool _checked = false;
bool _canAttack = false;
int _activeSpell = -1;
int _nonCombatSpell = -1;
int _combatSpell = -1;
Character();

View File

@ -1,54 +0,0 @@
/* 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/cast_spell.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
CastSpell::CastSpell() : ScrollView("CastSpell") {
_bounds = Common::Rect(234, 0, 320, 144);
addButton(&g_globals->_confirmIcons,
Common::Point(14, 10), 0,
Common::KeyState(Common::KEYCODE_y, 'y'));
addButton(&g_globals->_confirmIcons,
Common::Point(40, 10), 2,
Common::KeyState(Common::KEYCODE_n, 'n'));
}
void CastSpell::draw() {
ScrollView::draw();
}
bool CastSpell::msgFocus(const FocusMessage &msg) {
return true;
}
bool CastSpell::msgKeypress(const KeypressMessage &msg) {
return true;
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@ -83,7 +83,11 @@ CharacterInfo::CharacterInfo() :
bool CharacterInfo::msgFocus(const FocusMessage &msg) {
_viewIcon.load("view.icn");
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_PARTY_MENUS);
g_events->findView("GameParty")->draw();
// 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));
_cursorCell = 0;
showCursor(true);
@ -94,6 +98,11 @@ bool CharacterInfo::msgFocus(const FocusMessage &msg) {
bool CharacterInfo::msgUnfocus(const UnfocusMessage &msg) {
_viewIcon.clear();
// Turn off highlight for selected character
g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)false));
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
return ScrollView::msgUnfocus(msg);
}

View File

@ -27,7 +27,6 @@
#include "mm/mm1/views/locations/inn.h"
#include "mm/mm1/views/protect.h"
#include "mm/mm1/views/title.h"
#include "mm/mm1/views_enh/cast_spell.h"
#include "mm/mm1/views_enh/character_info.h"
#include "mm/mm1/views_enh/game.h"
#include "mm/mm1/views_enh/main_menu.h"
@ -35,6 +34,7 @@
#include "mm/mm1/views_enh/quick_ref.h"
#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"
namespace MM {
namespace MM1 {

View File

@ -45,8 +45,6 @@ Game::Game() : TextView("Game"),
bool Game::msgFocus(const FocusMessage &msg) {
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_NORMAL);
g_globals->_currCharacter = nullptr;
return TextView::msgFocus(msg);
}

View File

@ -87,7 +87,7 @@ void GameParty::draw() {
_hpSprites.draw(&s, frame, Common::Point(HP_BARS_X[idx], 38));
// Also draw the highlight if character is selected
if (g_globals->_currCharacter == &c)
if (_highlightOn && g_globals->_currCharacter == &c)
g_globals->_globalSprites.draw(&s, 8, Common::Point(CHAR_FACES_X[idx] - 1, 5));
}
@ -96,6 +96,17 @@ void GameParty::draw() {
s.markAllDirty();
}
bool GameParty::msgGame(const GameMessage &msg) {
if (msg._name == "CHAR_HIGHLIGHT") {
_highlightOn = msg._value != 0;
draw();
return true;
}
return false;
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@ -37,6 +37,7 @@ private:
Shared::Xeen::SpriteResource _restoreSprites;
Shared::Xeen::SpriteResource _hpSprites;
Shared::Xeen::SpriteResource _dseFace;
bool _highlightOn = false;
public:
GameParty(UIElement *owner);
@ -46,6 +47,11 @@ public:
* Draw the view
*/
void draw() override;
/**
* Handle game messages
*/
bool msgGame(const GameMessage &msg) override;
};
} // namespace ViewsEnh

View File

@ -0,0 +1,105 @@
/* 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/cast_spell.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
CastSpell::CastSpell() : ScrollView("CastSpell") {
_bounds = Common::Rect(225, 0, 320, 144);
addButton(&g_globals->_confirmIcons,
Common::Point(0, 100), 0,
Common::KeyState(Common::KEYCODE_y, 'y'));
addButton(&g_globals->_confirmIcons,
Common::Point(40, 100), 2,
Common::KeyState(Common::KEYCODE_n, 'n'));
}
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));
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_PARTY_MENUS);
return true;
}
bool CastSpell::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 CastSpell::draw() {
ScrollView::draw();
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"]);
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, 90, Common::String::format("%d", c._sp._current), ALIGN_RIGHT);
writeString(0, 120, STRING["enhdialogs.cast_spell.cast"]);
writeString(30, 120, STRING["enhdialogs.cast_spell.new"]);
writeString(60, 120, STRING["enhdialogs.cast_spell.esc"]);
setTextColor(37);
writeString(0, 60, STRING["enhdialogs.cast_spell.none"], ALIGN_MIDDLE);
}
bool CastSpell::msgKeypress(const KeypressMessage &msg) {
return true;
}
bool CastSpell::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
close();
return true;
} else if (msg._action >= KEYBIND_VIEW_PARTY1 &&
msg._action <= KEYBIND_VIEW_PARTY6) {
uint charNum = msg._action - KEYBIND_VIEW_PARTY1;
if (charNum < g_globals->_party.size()) {
g_globals->_currCharacter = &g_globals->_party[
msg._action - KEYBIND_VIEW_PARTY1];
g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)true));
redraw();
return true;
}
}
return false;
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@ -39,7 +39,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;
};
} // namespace ViewsEnh

View File

@ -119,8 +119,8 @@ MODULE_OBJS += \
mm1/views/text_view.o \
mm1/views/trap.o \
mm1/views/unlock.o \
mm1/views_enh/spells/cast_spell.o \
mm1/views_enh/button_container.o \
mm1/views_enh/cast_spell.o \
mm1/views_enh/character_info.o \
mm1/views_enh/dialogs.o \
mm1/views_enh/game.o \