Fixed grammar, unified the docstring's format and added documentation to some classes that did not have any. Closes #32.
This commit is contained in:
@ -41,6 +41,9 @@ class DisplayManager:
|
||||
self.update_game_components()
|
||||
|
||||
def handle_display_action(self, action: DisplayActions, *params) -> None:
|
||||
"""
|
||||
Handles the differents values of display action.
|
||||
"""
|
||||
if action == DisplayActions.REFRESH:
|
||||
self.refresh()
|
||||
elif action == DisplayActions.UPDATE:
|
||||
@ -49,6 +52,9 @@ class DisplayManager:
|
||||
self.handle_mouse_click(*params)
|
||||
|
||||
def update_game_components(self) -> None:
|
||||
"""
|
||||
Updates the game components, for example when loading a game.
|
||||
"""
|
||||
for d in self.displays:
|
||||
d.pack = TexturePack.get_pack(self.game.settings.TEXTURE_PACK)
|
||||
self.mapdisplay.update_map(self.game.map)
|
||||
@ -62,6 +68,9 @@ class DisplayManager:
|
||||
self.messagedisplay.update_message(self.game.message)
|
||||
|
||||
def handle_mouse_click(self, y: int, x: int) -> None:
|
||||
"""
|
||||
Handles the mouse clicks.
|
||||
"""
|
||||
displays = self.refresh()
|
||||
display = None
|
||||
for d in displays:
|
||||
@ -74,6 +83,9 @@ class DisplayManager:
|
||||
display.handle_click(y - display.y, x - display.x, self.game)
|
||||
|
||||
def refresh(self) -> List[Display]:
|
||||
"""
|
||||
Refreshes all components on the screen.
|
||||
"""
|
||||
displays = []
|
||||
|
||||
if self.game.state == GameMode.PLAY \
|
||||
@ -127,7 +139,7 @@ class DisplayManager:
|
||||
|
||||
def resize_window(self) -> bool:
|
||||
"""
|
||||
If the window got resized, ensure that the screen size got updated.
|
||||
When the window is resized, ensures that the screen size is updated.
|
||||
"""
|
||||
y, x = self.screen.getmaxyx() if self.screen else (0, 0)
|
||||
if self.screen and curses.is_term_resized(self.rows,
|
||||
@ -138,8 +150,16 @@ class DisplayManager:
|
||||
|
||||
@property
|
||||
def rows(self) -> int:
|
||||
"""
|
||||
Overwrites the native curses attribute of the same name,
|
||||
for testing purposes.
|
||||
"""
|
||||
return curses.LINES if self.screen else 42
|
||||
|
||||
@property
|
||||
def cols(self) -> int:
|
||||
"""
|
||||
Overwrites the native curses attribute of the same name,
|
||||
for testing purposes.
|
||||
"""
|
||||
return curses.COLS if self.screen else 42
|
||||
|
Reference in New Issue
Block a user