MM: MM1: Added which character view for combat exchanges

This commit is contained in:
Paul Gilbert 2023-03-27 20:43:00 -07:00
parent 1c9db43757
commit 07754db1aa
4 changed files with 48 additions and 10 deletions

View File

@ -399,7 +399,7 @@ dialogs:
set_delay: "Set delay (0-9):"
delay_currently: "(currently= %d)"
infiltration: "infiltrates the ranks!"
exchange_places: "exchange places with (1-%c)?"
exchange_places: "Exchange places with (1-%c)?"
status:
0: "(paralyze)"
1: "(webbed) "
@ -595,6 +595,7 @@ enhdialogs:
exit: "Exit"
go_back: "Go back"
no_items: "Inventory empty"
exchange: "Exchange with whom?"
quickref:
title: "Quick Reference Chart"
headers:

View File

@ -99,6 +99,12 @@ bool Combat::msgGame(const GameMessage &msg) {
setMode(SPELL_RESULT);
return true;
} else if (msg._name == "EXCHANGE" && msg._value != -1) {
int charNum = msg._value;
if (g_globals->_combatParty[charNum] != g_globals->_currCharacter)
exchangeWith(charNum);
return true;
}
return false;
@ -942,13 +948,20 @@ void Combat::setOption(SelectedOption option) {
KeybindingMode::KBMODE_MENUS);
_option = option;
clearButtons();
if (option != OPTION_NONE) {
addButton(&g_globals->_escSprites, Common::Point(0, 164),
0, KEYBIND_ESCAPE);
}
if (option == OPTION_EXCHANGE) {
// Show the view to select which character
_option = OPTION_NONE;
addView("WhichCharacter");
redraw();
} else {
clearButtons();
if (option != OPTION_NONE) {
addButton(&g_globals->_escSprites, Common::Point(0, 164),
0, KEYBIND_ESCAPE);
}
redraw();
}
}
void Combat::displaySpellResult(const InfoMessage &msg) {

View File

@ -20,6 +20,7 @@
*/
#include "mm/mm1/views_enh/which_character.h"
#include "mm/mm1/views_enh/combat.h"
#include "mm/mm1/globals.h"
namespace MM {
@ -32,15 +33,27 @@ WhichCharacter::WhichCharacter() : PartyView("WhichCharacter") {
}
void WhichCharacter::draw() {
if (dynamic_cast<Combat *>(g_events->priorView()) != nullptr) {
// For combat view, draw a frame that the party view will be inside
const Common::Rect old = _bounds;
_bounds = Common::Rect(0, 144, 320, 200);
frame();
fill();
_bounds = old;
g_events->send("GameParty", GameMessage("CHAR_HIGHLIGHT", (int)true));
}
PartyView::draw();
writeString(10, 5, STRING["enhdialogs.trade.dest"]);
writeString(10, 5, STRING[g_events->isInCombat() ?
"enhdialogs.misc.exchange" : "enhdialogs.trade.dest"]);
}
bool WhichCharacter::msgAction(const ActionMessage &msg) {
switch (msg._action) {
case KEYBIND_ESCAPE:
close();
send("CharacterInventory", GameMessage("TRADE_DEST", -1));
selectCharacter(-1);
return true;
case KEYBIND_VIEW_PARTY1:
@ -52,7 +65,7 @@ bool WhichCharacter::msgAction(const ActionMessage &msg) {
uint charNum = msg._action - KEYBIND_VIEW_PARTY1;
if (charNum < g_globals->_party.size()) {
close();
send("CharacterInventory", GameMessage("TRADE_DEST", charNum));
selectCharacter(charNum);
}
return true;
}
@ -62,6 +75,14 @@ bool WhichCharacter::msgAction(const ActionMessage &msg) {
}
}
void WhichCharacter::selectCharacter(int charNum) {
if (dynamic_cast<Combat *>(g_events->focusedView()) != nullptr) {
send("Combat", GameMessage("EXCHANGE", charNum));
} else {
send("CharacterInventory", GameMessage("TRADE_DEST", charNum));
}
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@ -30,6 +30,9 @@ namespace MM1 {
namespace ViewsEnh {
class WhichCharacter : public PartyView {
private:
void selectCharacter(int charNum);
public:
WhichCharacter();
virtual ~WhichCharacter() {}