This commit is contained in:
Yohann D'ANELLO 2020-11-11 20:36:43 +01:00
parent f33d8b8170
commit 53077aacb0
4 changed files with 13 additions and 8 deletions

View File

@ -37,7 +37,7 @@ class DisplayManager:
if self.game.state == GameMode.MAINMENU:
self.mainmenudisplay.refresh(0, 0, self.rows, self.cols)
if self.game.state == GameMode.SETTINGS:
self.settingsmenudisplay.refresh(0, 0, self.rows, self.cols-1)
self.settingsmenudisplay.refresh(0, 0, self.rows, self.cols - 1)
self.resize_window()
def resize_window(self) -> bool:

View File

@ -1,3 +1,5 @@
from typing import List
from dungeonbattle.menus import Menu, MainMenu
from .display import Display
@ -54,7 +56,7 @@ class MenuDisplay(Display):
return self.trueheight + 2
@property
def values(self):
def values(self) -> List[str]:
return [str(a) for a in self.menu.values]

View File

@ -93,7 +93,7 @@ class Game:
elif key == ' ':
return KeyValues.SPACE
def handle_key_pressed(self, key: KeyValues, screen) -> None:
def handle_key_pressed(self, key: KeyValues, screen: Any) -> None:
"""
Indicates what should be done when the given key is pressed,
according to the current game state.
@ -103,7 +103,7 @@ class Game:
elif self.state == GameMode.MAINMENU:
self.handle_key_pressed_main_menu(key)
elif self.state == GameMode.SETTINGS:
self.handle_key_pressed_settings(key,screen)
self.handle_key_pressed_settings(key, screen)
self.display_refresh()
def handle_key_pressed_play(self, key: KeyValues) -> None:
@ -142,7 +142,7 @@ class Game:
elif option == menus.MainMenuValues.EXIT:
sys.exit(0)
def handle_key_pressed_settings(self, key: KeyValues, screen : Any) -> None:
def handle_key_pressed_settings(self, key: KeyValues, screen: Any) -> None:
"""
For now, in the settings mode, we can only go backwards.
"""

View File

@ -31,12 +31,15 @@ class MainMenuValues(Enum):
class MainMenu(Menu):
values = [e for e in MainMenuValues]
class SettingsMenu(Menu) :
class SettingsMenu(Menu):
def __init__(self):
super().__init__()
def update_values(self, settings : Settings):
def update_values(self, settings: Settings) -> None:
s = settings.dumps_to_string()
self.values = s[6:-2].replace("\"","").split(",\n ")
self.values = s[6:-2].replace("\"", "").split(",\n ")
class ArbitraryMenu(Menu):
def __init__(self, values: list):