Key handler does not depend on curses's screen anymore

This commit is contained in:
Yohann D'ANELLO
2020-11-11 22:36:42 +01:00
parent 748561e87d
commit 0c17e74d6a
5 changed files with 68 additions and 45 deletions

View File

@ -53,9 +53,10 @@ class Game:
screen.refresh()
self.display_refresh()
key = screen.getkey()
self.handle_key_pressed(KeyValues.translate_key(key, self.settings))
self.handle_key_pressed(
*KeyValues.translate_key(key, self.settings))
def handle_key_pressed(self, key: KeyValues) -> None:
def handle_key_pressed(self, key: KeyValues, raw_key: str = '') -> None:
"""
Indicates what should be done when the given key is pressed,
according to the current game state.
@ -65,7 +66,7 @@ class Game:
elif self.state == GameMode.MAINMENU:
self.main_menu.handle_key_pressed(key, self)
elif self.state == GameMode.SETTINGS:
self.settings_menu.handle_key_pressed(key, self.settings)
self.settings_menu.handle_key_pressed(key, raw_key, self)
self.display_refresh()
def handle_key_pressed_play(self, key: KeyValues) -> None: