ULTIMA4: Remainder of combat keypress code refactored

This commit is contained in:
Paul Gilbert 2020-05-02 16:52:49 -07:00
parent f6646f26cc
commit fccc6e4cc6
3 changed files with 22 additions and 96 deletions

View File

@ -857,92 +857,6 @@ void CombatController::keybinder(KeybindingAction action) {
MetaEngine::executeAction(action);
}
bool CombatController::keyPressed(int key) {
bool valid = true;
bool endTurn = true;
switch (key) {
case 'u':
g_screen->screenMessage("Use which item:\n");
g_context->_stats->setView(STATS_ITEMS);
#ifdef IOS_ULTIMA4
U4IOS::IOSConversationHelper::setIntroString("Use which item?");
#endif
g_items->itemUse(gameGetInput().c_str());
break;
case 'v':
if (g_music->toggle())
g_screen->screenMessage("Volume On!\n");
else
g_screen->screenMessage("Volume Off!\n");
endTurn = false;
break;
case 'z': {
g_context->_stats->setView(StatsView(STATS_CHAR1 + getFocus()));
/* reset the spell mix menu and un-highlight the current item,
and hide reagents that you don't have */
g_context->_stats->resetReagentsMenu();
g_screen->screenMessage("Ztats\n");
ZtatsController ctrl;
eventHandler->pushController(&ctrl);
ctrl.waitFor();
}
break;
case 'b':
case 'e':
case 'd':
case 'f':
case 'h':
case 'i':
case 'j':
case 'k':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 's':
case 'w':
case 'x':
case 'y':
g_screen->screenMessage("Not here!\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (settings._enhancements && settings._enhancementsOptions._activePlayer)
gameSetActivePlayer(key - '1');
else g_screen->screenMessage("Bad command\n");
break;
default:
valid = false;
break;
}
if (valid) {
g_context->_lastCommandTime = g_system->getMillis();
if (endTurn && (eventHandler->getController() == this))
g_context->_location->_turnCompleter->finishTurn();
}
return valid;
}
void CombatController::attack(Direction dir, int distance) {
g_screen->screenMessage("Dir: ");

View File

@ -170,9 +170,7 @@ public:
static void attackFlash(const Coords &coords, const Common::String &tilename, int timeFactor);
static void doScreenAnimationsWhilePausing(int timeFactor);
// Key handlers
void keybinder(KeybindingAction action) override;
bool keyPressed(int key) override;
void finishTurn() override;

View File

@ -165,16 +165,26 @@ bool Debugger::handleCommand(int argc, const char **argv, bool &keepRunning) {
"attack", "board", "enter", "fire", "jimmy", "locate",
"open", "talk", "exit", "yell", nullptr
};
static const char *COMBAT_DISALLOWED[] = {
"board", "climb", "descend", "enter", "exit", "fire", "hole",
"ignite", "jimmy", "mix", "order", "open", "peer", "quitAndSave",
"search", "use", "wear", "yell", nullptr
};
if (g_context && (g_context->_location->_context & CTX_DUNGEON)) {
Common::String method = argv[0];
if (g_context && g_context->_location) {
int ctx = g_context->_location->_context;
if (ctx & (CTX_DUNGEON | CTX_COMBAT)) {
Common::String method = argv[0];
const char *const *mth = (ctx & CTX_COMBAT) ?
COMBAT_DISALLOWED : DUNGEON_DISALLOWED;
for (const char *const *mth = DUNGEON_DISALLOWED; *mth; ++mth) {
if (method.equalsIgnoreCase(*mth)) {
print("%cNot here!%c", FG_GREY, FG_WHITE);
g_game->finishTurn();
keepRunning = false;
return true;
for (; *mth; ++mth) {
if (method.equalsIgnoreCase(*mth)) {
print("%cNot here!%c", FG_GREY, FG_WHITE);
g_game->finishTurn();
keepRunning = false;
return true;
}
}
}
}
@ -1073,6 +1083,8 @@ bool Debugger::cmdStats(int argc, const char **argv) {
int player = -1;
if (argc == 2)
player = strToInt(argv[1]);
else if (isCombat())
player = getCombatFocus();
// get the player if not provided
if (player == -1) {
@ -1080,6 +1092,8 @@ bool Debugger::cmdStats(int argc, const char **argv) {
player = gameGetPlayer(true, false);
if (player == -1)
return isDebuggerActive();
} else {
print("Ztats");
}
// Reset the reagent spell mix menu by removing