Added documentation on a lot of classes and functions (and removed some files I commited by mistake)
This commit is contained in:
@@ -8,22 +8,37 @@ from .settings import Settings
|
||||
|
||||
|
||||
class Menu:
|
||||
"""
|
||||
A Menu object is the logical representation of a menu in the game
|
||||
"""
|
||||
values: list
|
||||
|
||||
def __init__(self):
|
||||
self.position = 0
|
||||
|
||||
def go_up(self) -> None:
|
||||
"""
|
||||
Moves the pointer of the menu on the previous value
|
||||
"""
|
||||
self.position = max(0, self.position - 1)
|
||||
|
||||
def go_down(self) -> None:
|
||||
"""
|
||||
Moves the pointer of the menu on the next value
|
||||
"""
|
||||
self.position = min(len(self.values) - 1, self.position + 1)
|
||||
|
||||
def validate(self) -> Any:
|
||||
"""
|
||||
Selects the value that is pointed by the menu pointer
|
||||
"""
|
||||
return self.values[self.position]
|
||||
|
||||
|
||||
class MainMenuValues(Enum):
|
||||
"""
|
||||
Values of the main menu
|
||||
"""
|
||||
START = 'Jouer'
|
||||
SAVE = 'Sauvegarder'
|
||||
LOAD = 'Charger'
|
||||
@@ -35,13 +50,22 @@ class MainMenuValues(Enum):
|
||||
|
||||
|
||||
class MainMenu(Menu):
|
||||
"""
|
||||
A special instance of a menu : the main menu
|
||||
"""
|
||||
values = [e for e in MainMenuValues]
|
||||
|
||||
|
||||
class SettingsMenu(Menu):
|
||||
"""
|
||||
A special instance of a menu : the settings menu
|
||||
"""
|
||||
waiting_for_key: bool = False
|
||||
|
||||
def update_values(self, settings: Settings) -> None:
|
||||
"""
|
||||
The settings can change, so they are updated
|
||||
"""
|
||||
self.values = []
|
||||
for i, key in enumerate(settings.settings_keys):
|
||||
s = settings.get_comment(key)
|
||||
@@ -61,7 +85,7 @@ class SettingsMenu(Menu):
|
||||
def handle_key_pressed(self, key: Optional[KeyValues], raw_key: str,
|
||||
game: Any) -> None:
|
||||
"""
|
||||
Update settings
|
||||
In the setting menu, we van select a setting and change it
|
||||
"""
|
||||
if not self.waiting_for_key:
|
||||
# Navigate normally through the menu.
|
||||
|
Reference in New Issue
Block a user