Cleanup of the hotkey code

The only actual changes are:
- 0 (non-numpad) now opens the jobs panel
- f in combat now ends combat, and no longer cancels shooting or throwing
This commit is contained in:
2017-01-27 16:25:59 -05:00
parent 93ded95bc8
commit 3400a13c8d

View File

@@ -1732,7 +1732,7 @@ bool handle_keystroke(sf::Event& event){
are_done = handle_action(pass_event);
break;
case '9':
case '9': // Special items
pass_point.x = item_screen_button_rects[6].left + ITEM_WIN_UL_X + ul.x;
pass_point.y = item_screen_button_rects[6].top + ITEM_WIN_UL_Y + ul.y;
pass_event.mouseButton.x = pass_point.x;
@@ -1740,6 +1740,14 @@ bool handle_keystroke(sf::Event& event){
are_done = handle_action(pass_event);
break;
case '0': // Jobs/quests
pass_point.x = item_screen_button_rects[7].left + ITEM_WIN_UL_X + ul.x;
pass_point.y = item_screen_button_rects[7].top + ITEM_WIN_UL_Y + ul.y;
pass_event.mouseButton.x = pass_point.x;
pass_event.mouseButton.y = pass_point.y;
are_done = handle_action(pass_event);
break;
case ' ':
if(overall_mode == MODE_FANCY_TARGET) { // cast multi-target spell, set # targets to 0 so that
// space clicked doesn't matter
@@ -1749,8 +1757,10 @@ bool handle_keystroke(sf::Event& event){
pass_event.mouseButton.y = pass_point.y + ul.y;
are_done = handle_action(pass_event);
} else if(overall_mode == MODE_SPELL_TARGET)
// Rotate a force wall
spell_cast_hit_return();
else if(overall_mode == MODE_TOWN || overall_mode == MODE_COMBAT || overall_mode == MODE_OUTDOORS) {
// Pause (skip turn)
pass_point.x = terrain_click[5].x + ul.x;
pass_point.y = terrain_click[5].y + ul.y;
pass_event.mouseButton.x = pass_point.x;
@@ -1770,11 +1780,12 @@ bool handle_keystroke(sf::Event& event){
}
print_buf();
break;
case 'z':
case 'z': // Show active PC's inventory
if(((overall_mode >= MODE_COMBAT) && (overall_mode < MODE_TALKING)) || (overall_mode == MODE_LOOK_COMBAT)) {
set_stat_window(univ.cur_pc);
put_item_screen(stat_window);
} else {
// ... or first PC's inventory... why?
set_stat_window(0);
put_item_screen(stat_window);
}
@@ -2017,7 +2028,7 @@ bool handle_keystroke(sf::Event& event){
if(!univ.debug_mode) break;
cChoiceDlog("help-debug").show();
break;
case 'a':
case 'a': // Show automap
if(overall_mode < MODE_TALK_TOWN) {
pass_point.x = (overall_mode == MODE_OUTDOORS) ? 180 : 221;
pass_point.y = 405;
@@ -2027,7 +2038,7 @@ bool handle_keystroke(sf::Event& event){
}
break;
case 'u':
case 'u': // Use space
if(overall_mode == MODE_TOWN || overall_mode == MODE_USE_TOWN) {
pass_point.x = 220;
pass_point.y = 388;
@@ -2037,7 +2048,7 @@ bool handle_keystroke(sf::Event& event){
}
break;
case 'b': case 'L':
case 'b': case 'L': // Bash door, pick lock
if(overall_mode == MODE_TOWN || overall_mode == MODE_BASH_TOWN) {
pass_point.x = chr == 'b' ? 1002 : 1003;
pass_point.y = 0;
@@ -2046,58 +2057,45 @@ bool handle_keystroke(sf::Event& event){
are_done = handle_action(pass_event);
}
case 's': case 'x': case 'e':
if((overall_mode == MODE_COMBAT) ||
((overall_mode == MODE_FIRING) && (chr == 's')) ||
((overall_mode == MODE_THROWING) && (chr == 's')) ) {
pass_point.x = (chr == 's') ? 215 : 250;
pass_point.y = (chr == 'e') ? 390 : 406;
pass_event.mouseButton.x = pass_point.x + ul.x;
pass_event.mouseButton.y = pass_point.y + ul.y;
case 'A': // Alchemy
if(overall_mode == MODE_TOWN) {
pass_point.x = 1000 + ul.x;
pass_event.mouseButton.x = pass_point.x;
pass_event.mouseButton.y = pass_point.y;
are_done = handle_action(pass_event);
} else {
add_string_to_buf("Alchemy: In town only.");
print_buf();
return false;
}
break;
case 's': case 'x': case 'e':
case 'm': case 'p': case 'l': case 'r': case 'w': case 't': case 'd': case 'g': case 'f':
case 'M': case 'P': case 'A':
case 'M': case 'P':
int btn = 50;
if(overall_mode == MODE_SPELL_TARGET || overall_mode == MODE_FANCY_TARGET || overall_mode == MODE_TOWN_TARGET) { // cancel spell
if(chr == 'm') btn = 0;
else if(chr == 'p') btn = 1;
}
// TODO: There's several weird things about this conditional. Why 'f' when the key to initiate this is 's'? Why is it checking for 't' (though that can never be true)?
if(chr == 'f' && (overall_mode == MODE_FIRING || overall_mode == MODE_THROWING || chr == 't')) // cancel missile
btn = 6;
if((overall_mode == MODE_OUTDOORS) || (overall_mode == MODE_TOWN) || (overall_mode == MODE_COMBAT)) {
switch(chr) {
// Spells
case 'M': spell_forced = true; btn = 0; break;
case 'm': btn = 0; break;
case 'P': spell_forced = true; btn = 1; break;
case 'p': btn = 1; break;
// Look
case 'l': btn = 2; break;
case 'r':
case 'r': // Rest
if(overall_mode != MODE_OUTDOORS) return false;
btn = 3;
break;
case 't':
if(overall_mode == MODE_TOWN)
btn = 3;
else return false;
case 't': // Talk
if(overall_mode != MODE_TOWN) return false;
btn = 3;
break;
case 'A':
if(overall_mode == MODE_TOWN) {
pass_point.x = 1000 + ul.x;
pass_event.mouseButton.x = pass_point.x;
pass_event.mouseButton.y = pass_point.y;
are_done = handle_action(pass_event);
} else {
add_string_to_buf("Alchemy: In town only.");
print_buf();
return false;
}
break;
case 'w':
case 'w': // Wait (town), delay action (combat)
if(overall_mode == MODE_COMBAT)
btn = 5;
else if(overall_mode == MODE_TOWN) {
@@ -2112,20 +2110,33 @@ bool handle_keystroke(sf::Event& event){
return false;
}
break;
case 'd':
case 'd': // Parry
if(overall_mode != MODE_COMBAT) return false;
btn = 3;
break;
case 'g':
case 'g': // Get
if(overall_mode == MODE_OUTDOORS) return false;
btn = 4;
break;
case 'f':
if(overall_mode != MODE_TOWN) return false;
case 's': // Shoot
if(overall_mode != MODE_COMBAT) return false;
btn = 6;
break;
case 'x': // Toggle active
if(overall_mode != MODE_COMBAT) return false;
btn = 8;
break;
case 'e': // End combat
if(overall_mode != MODE_COMBAT) return false;
btn = 7;
break;
case 'f': // Fight (toggle combat)
if(overall_mode != MODE_TOWN && overall_mode != MODE_COMBAT) return false;
btn = 7;
break;
}
}
} else if(chr == 's' && (overall_mode == MODE_FIRING || overall_mode == MODE_THROWING))
btn = 6;
if(btn < 50) {
pass_point.x = bottom_buttons[btn].left + 5;
pass_point.y = bottom_buttons[btn].top + 5;