ULTIMA4: Speed keys to keybinder

This commit is contained in:
Paul Gilbert 2020-04-13 22:08:09 -07:00
parent 4afd52df8f
commit fda93e493b
5 changed files with 45 additions and 61 deletions

View File

@ -890,6 +890,38 @@ bool Debugger::cmdSearch(int argc, const char **argv) {
return isDebuggerActive();
}
bool Debugger::cmdSpeed(int argc, const char **argv) {
Common::String action = argv[1];
int old_cycles = settings._gameCyclesPerSecond;
if (action == "up") {
if (++settings._gameCyclesPerSecond > MAX_CYCLES_PER_SECOND)
settings._gameCyclesPerSecond = MAX_CYCLES_PER_SECOND;
} else if (action == "down") {
if (--settings._gameCyclesPerSecond == 0)
settings._gameCyclesPerSecond = 1;
} else if (action == "normal") {
settings._gameCyclesPerSecond = DEFAULT_CYCLES_PER_SECOND;
}
if (old_cycles != settings._gameCyclesPerSecond) {
settings._eventTimerGranularity = (1000 / settings._gameCyclesPerSecond);
eventHandler->getTimer()->reset(settings._eventTimerGranularity);
if (settings._gameCyclesPerSecond == DEFAULT_CYCLES_PER_SECOND)
print("Speed: Normal");
else if (action == "up")
print("Speed Up (%d)", settings._gameCyclesPerSecond);
else
print("Speed Down (%d)", settings._gameCyclesPerSecond);
} else if (settings._gameCyclesPerSecond == DEFAULT_CYCLES_PER_SECOND) {
print("Speed: Normal");
}
dontEndTurn();
return isDebuggerActive();
}
bool Debugger::cmdStats(int argc, const char **argv) {
int player = -1;
if (argc == 2)

View File

@ -195,6 +195,11 @@ private:
*/
bool cmdSearch(int argc, const char **argv);
/**
* Speed up, down, or normal
*/
bool cmdSpeed(int argc, const char **argv);
/**
* Show character stats
*/

View File

@ -602,63 +602,6 @@ bool GameController::keyPressed(int key) {
screenMessage("%cNot here!%c\n", FG_GREY, FG_WHITE);
else
switch (key) {
case ' ':
screenMessage("Pass\n");
break;
case '+':
case '-':
case U4_KEYPAD_ENTER: {
int old_cycles = settings._gameCyclesPerSecond;
if (key == '+' && ++settings._gameCyclesPerSecond > MAX_CYCLES_PER_SECOND)
settings._gameCyclesPerSecond = MAX_CYCLES_PER_SECOND;
else if (key == '-' && --settings._gameCyclesPerSecond == 0)
settings._gameCyclesPerSecond = 1;
else if (key == U4_KEYPAD_ENTER)
settings._gameCyclesPerSecond = DEFAULT_CYCLES_PER_SECOND;
if (old_cycles != settings._gameCyclesPerSecond) {
settings._eventTimerGranularity = (1000 / settings._gameCyclesPerSecond);
eventHandler->getTimer()->reset(settings._eventTimerGranularity);
if (settings._gameCyclesPerSecond == DEFAULT_CYCLES_PER_SECOND)
screenMessage("Speed: Normal\n");
else if (key == '+')
screenMessage("Speed Up (%d)\n", settings._gameCyclesPerSecond);
else screenMessage("Speed Down (%d)\n", settings._gameCyclesPerSecond);
} else if (settings._gameCyclesPerSecond == DEFAULT_CYCLES_PER_SECOND)
screenMessage("Speed: Normal\n");
}
endTurn = false;
break;
/* handle music volume adjustments */
case ',':
// decrease the volume if possible
screenMessage("Music: %d%s\n", g_music->decreaseMusicVolume(), "%");
endTurn = false;
break;
case '.':
// increase the volume if possible
screenMessage("Music: %d%s\n", g_music->increaseMusicVolume(), "%");
endTurn = false;
break;
/* handle sound volume adjustments */
case '<':
// decrease the volume if possible
screenMessage("Sound: %d%s\n", g_music->decreaseSoundVolume(), "%");
soundPlay(SOUND_FLEE);
endTurn = false;
break;
case '>':
// increase the volume if possible
screenMessage("Sound: %d%s\n", g_music->increaseSoundVolume(), "%");
soundPlay(SOUND_FLEE);
endTurn = false;
break;
case 'c' + U4_ALT:
if (settings._debug && g_context->_location->_map->isWorldMap()) {
/* first teleport to the abyss */

View File

@ -62,8 +62,11 @@ static const KeybindingRecord KEYS[] = {
{ KEYBIND_PASS, "PASS", "Pass", "pass", "SPACE", nullptr },
{ KEYBIND_PEER, "PEER", "Peer", "peer", "p", nullptr },
{ KEYBIND_QUIT_SAVE, "QUIT-SAVE", "Quit and Save", "quitAndSave", "q", nullptr },
{ KEYBIND_READY_WEAPON, "READY-WEAPON", "Ready Weapon", "ready", nullptr },
{ KEYBIND_READY_WEAPON, "READY-WEAPON", "Ready Weapon", "ready", "r", nullptr },
{ KEYBIND_SEARCH, "SEARCH", "Search", "search", "s", nullptr },
{ KEYBIND_SPEED_UP, "SPEED-UP", "Speed Up", "speed up", "PLUS", nullptr },
{ KEYBIND_SPEED_DOWN, "SPEED-DOWN", "Speed Down", "speed down", "MINUS", nullptr },
{ KEYBIND_SPEED_NORMAL, "SPEED-NORMAL", "Speed Normal", "speed normal", "KP_ENTER", nullptr },
{ KEYBIND_STATS, "STATS", "Stats", "stats", "z", nullptr },
{ KEYBIND_TALK, "TALK", "Talk", "talk", "t", nullptr },
{ KEYBIND_TOGGLE_MUSIC, "TOGGLE-MUSIC", "Toggle Music", "musicToggle", "v", nullptr },

View File

@ -35,9 +35,10 @@ enum KeybindingAction {
KEYBIND_GET, KEYBIND_HOLE_UP, KEYBIND_IGNITE, KEYBIND_JIMMY,
KEYBIND_LOCATE, KEYBIND_MIX, KEYBIND_NEW_ORDER,
KEYBIND_OPEN_DOOR, KEYBIND_PASS, KEYBIND_PEER,
KEYBIND_QUIT_SAVE, KEYBIND_READY_WEAPON, KEYBIND_SEARCH,
KEYBIND_STATS, KEYBIND_TALK, KEYBIND_TOGGLE_MUSIC,
KEYBIND_USE, KEYBIND_WEAR, KEYBIND_YELL,
KEYBIND_QUIT_SAVE, KEYBIND_SPEED_UP, KEYBIND_SPEED_DOWN,
KEYBIND_SPEED_NORMAL, KEYBIND_READY_WEAPON, KEYBIND_SEARCH,
KEYBIND_STATS, KEYBIND_TALK, KEYBIND_TOGGLE_MUSIC, KEYBIND_USE,
KEYBIND_WEAR, KEYBIND_YELL,
KEYBIND_NONE
};