MM: MM1: Go Back button for combat options

This commit is contained in:
Paul Gilbert 2023-03-27 19:40:13 -07:00
parent e7168e34c0
commit 692b6e265a
4 changed files with 44 additions and 34 deletions

View File

@ -383,7 +383,7 @@ dialogs:
monster_wanders: "wanders aimlessly"
attacks: "attacks"
shoots: "shoots"
weapon_no_effect: "weapon has no effect!"
weapon_no_effect: "Weapon has no effect!"
once: "once"
times: "times"
and: "and"
@ -394,9 +394,9 @@ dialogs:
point: "point"
points: "points"
of_damage: "of damage!"
fight_which: "fight which 'a'-'%c'?"
shoot_which: "shoot which 'a'-'%c'?"
set_delay: "set delay (0-9):"
fight_which: "Fight which 'A'-'%c'?"
shoot_which: "Shoot which 'A'-'%c'?"
set_delay: "Set delay (0-9):"
delay_currently: "(currently= %d)"
infiltration: "infiltrates the ranks!"
exchange_places: "exchange places with (1-%c)?"

View File

@ -273,8 +273,15 @@ bool Combat::msgAction(const ActionMessage &msg) {
if (endDelay())
return true;
if (_mode == SELECT_OPTION && _option != OPTION_NONE &&
msg._action == KEYBIND_ESCAPE) {
_option = OPTION_NONE;
combatLoop();
return true;
}
if (_mode != SELECT_OPTION || (_option != OPTION_NONE &&
_option != OPTION_EXCHANGE))
_option != OPTION_EXCHANGE))
return false;
switch (msg._action) {
@ -331,12 +338,6 @@ bool Combat::msgAction(const ActionMessage &msg) {
case KEYBIND_COMBAT_USE:
use();
break;
case KEYBIND_ESCAPE:
if (_mode == SELECT_OPTION) {
_option = OPTION_NONE;
combatLoop();
}
break;
default:
break;
}

View File

@ -39,6 +39,7 @@ Combat::Combat() : ScrollView("Combat") {
void Combat::setMode(Mode newMode) {
_mode = newMode;
clearButtons();
if (newMode == SELECT_OPTION) {
_option = OPTION_NONE;
@ -277,6 +278,13 @@ bool Combat::msgAction(const ActionMessage &msg) {
if (endDelay())
return true;
if (_mode == SELECT_OPTION && _option != OPTION_NONE &&
msg._action == KEYBIND_ESCAPE) {
_option = OPTION_NONE;
combatLoop();
return true;
}
if (_mode != SELECT_OPTION || (_option != OPTION_NONE &&
_option != OPTION_EXCHANGE))
return false;
@ -335,12 +343,6 @@ bool Combat::msgAction(const ActionMessage &msg) {
case KEYBIND_COMBAT_USE:
use();
break;
case KEYBIND_ESCAPE:
if (_mode == SELECT_OPTION) {
_option = OPTION_NONE;
combatLoop();
}
break;
default:
break;
}
@ -372,7 +374,8 @@ bool Combat::msgMouseUp(const MouseUpMessage &msg) {
}
void Combat::writeOptions() {
resetBottom();
if (_option != OPTION_NONE)
writeString(30, 170, STRING["enhdialogs.misc.go_back"]);
switch (_option) {
case OPTION_NONE:
@ -435,36 +438,34 @@ void Combat::writeAllOptions() {
}
void Combat::writeDelaySelect() {
resetBottom();
error("TODO: delay select");
writeString(0, 20, STRING["dialogs.combat.set_delay"]);
writeString(0, 23, Common::String::format(
STRING["dialogs.combat.delay_currently"].c_str(),
g_globals->_delay));
escToGoBack(0, 23);
}
void Combat::writeExchangeSelect() {
resetBottom();
writeString(7, 20, Common::String::format(
writeBottomText(0, 1, Common::String::format(
STRING["dialogs.combat.exchange_places"].c_str(),
'0' + g_globals->_combatParty.size()));
escToGoBack(12, 23);
'0' + g_globals->_combatParty.size()),
ALIGN_MIDDLE);
}
void Combat::writeFightSelect() {
_attackableCount = MIN(_attackersCount, (int)_remainingMonsters.size());
writeString(10, 20, Common::String::format(
STRING["dialogs.combat.fight_which"].c_str(), 'A' + _attackableCount - 1));
escToGoBack(12, 23);
writeBottomText(0, 1, Common::String::format(
STRING["dialogs.combat.fight_which"].c_str(), 'A' + _attackableCount - 1),
ALIGN_MIDDLE);
}
void Combat::writeShootSelect() {
_attackableCount = MIN(_attackersCount, (int)_remainingMonsters.size());
writeString(10, 20, Common::String::format(
STRING["dialogs.combat.shoot_which"].c_str(), 'A' + _attackableCount - 1));
escToGoBack(12, 23);
writeBottomText(0, 1, Common::String::format(
STRING["dialogs.combat.shoot_which"].c_str(), 'A' + _attackableCount - 1),
ALIGN_MIDDLE);
}
void Combat::writeAttackOptions() {
@ -514,8 +515,9 @@ void Combat::resetBottom() {
_allowCast = _allowAttack = false;
}
void Combat::writeBottomText(int x, int line, const Common::String &msg) {
writeString(x, (line + 19) * LINE_H, msg);
void Combat::writeBottomText(int x, int line, const Common::String &msg,
TextAlign align) {
writeString(x, (line + 19) * LINE_H, msg, align);
}
#define BTN_SIZE 10
@ -919,6 +921,13 @@ void Combat::setOption(SelectedOption option) {
KeybindingMode::KBMODE_PARTY_MENUS :
KeybindingMode::KBMODE_MENUS);
_option = option;
clearButtons();
if (option != OPTION_NONE) {
addButton(&g_globals->_escSprites, Common::Point(0, 164),
0, KEYBIND_ESCAPE);
}
redraw();
}

View File

@ -34,7 +34,6 @@ private:
// TODO: Stuff to refactor
void writeSpaces(int count) { error("TODO"); }
void clearLines(int y1, int y2) { error("TODO"); }
void escToGoBack(int x, int y) { error("TODO"); }
private:
LineArray _monsterSpellLines;
@ -62,7 +61,8 @@ private:
void clearBottom();
void clearArea(const Common::Rect &r);
void resetBottom();
void writeBottomText(int x, int line, const Common::String &msg);
void writeBottomText(int x, int line, const Common::String &msg,
TextAlign align = ALIGN_LEFT);
Common::Rect getOptionButtonRect(uint col, uint row);
void writeOption(uint col, uint row, char c, const Common::String &msg);