Skip to content

Commit 1512614

Browse files
committed
gmenu: return an indication of handled keys from gmenu_presskeys()
This patch updates the function `gmenu_presskeys()` to return `true` if the keys are actually handled. This allows the caller function `PressKey()` to continue processing keys and not silently drop them, even when the game menu is active. Why bother? First of all, there should not be any reasons not to handle keys once the game menu is open. For example, why not handle the "Quick Load" shortcut once the player is dead and the menu is shown on the screen? The other reason is more practical. In headless mode, once the game is controlled by a 3rd party application (training of an AI agent, for example), lost key presses lead to a broken training procedure. Therefore, even if the menu is raised, it is crucial not to lose a keystroke. Signed-off-by: Roman Penyaev <[email protected]>
1 parent 4eb63dd commit 1512614

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Source/gmenu.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,10 @@ bool gmenu_presskeys(SDL_Keycode vkey)
299299
GmenuUpDown(true);
300300
break;
301301
default:
302-
break;
302+
// Key was not handled by the gmenu
303+
return false;
303304
}
305+
// Key was handled
304306
return true;
305307
}
306308

0 commit comments

Comments
 (0)