linting
This commit is contained in:
parent
aa81d455f6
commit
04d2bc1789
@ -1,7 +1,8 @@
|
||||
import curses
|
||||
from dungeonbattle.display.mapdisplay import MapDisplay
|
||||
from dungeonbattle.display.statsdisplay import StatsDisplay
|
||||
from dungeonbattle.display.menudisplay import SettingsMenuDisplay, MainMenuDisplay
|
||||
from dungeonbattle.display.menudisplay import SettingsMenuDisplay, \
|
||||
MainMenuDisplay
|
||||
from dungeonbattle.display.texturepack import TexturePack
|
||||
from typing import Any
|
||||
from dungeonbattle.game import Game, GameMode
|
||||
|
@ -59,27 +59,33 @@ class MenuDisplay(Display):
|
||||
def values(self) -> List[str]:
|
||||
return [str(a) for a in self.menu.values]
|
||||
|
||||
|
||||
class SettingsMenuDisplay(MenuDisplay):
|
||||
@property
|
||||
def values(self) -> List[str]:
|
||||
return [ a[1][1] + (" : " + ("?" if self.menu.waiting_for_key else a[1][0]) if a[1][0] else "") for a in self.menu.values ]
|
||||
return [a[1][1] + (" : "
|
||||
+ ("?" if self.menu.waiting_for_key else a[1][0])
|
||||
if a[1][0] else "") for a in self.menu.values]
|
||||
|
||||
|
||||
class MainMenuDisplay(Display):
|
||||
def __init__(self, menu: MainMenu, *args):
|
||||
super().__init__(*args)
|
||||
self.menu = menu
|
||||
self.pad = self.newpad(self.rows, self.cols)
|
||||
|
||||
with open("resources/ascii_art.txt", "r") as file:
|
||||
self.title = file.read().split("\n")
|
||||
|
||||
self.pad = self.newpad(max(self.rows, len(self.title) + 30),
|
||||
max(len(self.title[0]) + 5, self.cols))
|
||||
|
||||
self.menudisplay = MenuDisplay(self.screen, self.pack)
|
||||
self.menudisplay.update_menu(self.menu)
|
||||
|
||||
def display(self) -> None:
|
||||
for i in range(len(self.title)):
|
||||
self.pad.addstr(4 + i, self.width // 2
|
||||
- len(self.title[0]) // 2 - 1, self.title[i])
|
||||
self.pad.addstr(4 + i, max(self.width // 2
|
||||
- len(self.title[0]) // 2 - 1, 0), self.title[i])
|
||||
self.pad.refresh(0, 0, self.y, self.x, self.height, self.width)
|
||||
menuwidth = min(self.menudisplay.preferred_width, self.width)
|
||||
menuy, menux = len(self.title) + 8, self.width // 2 - menuwidth // 2 - 1
|
||||
|
@ -58,7 +58,7 @@ class SettingsMenu(Menu):
|
||||
|
||||
def update_values(self, settings: Settings) -> None:
|
||||
self.values = list(settings.__dict__.items())
|
||||
self.values.append(("RETURN",["","Retour"]))
|
||||
self.values.append(("RETURN", ["", "Retour"]))
|
||||
|
||||
def handle_key_pressed(self, key: Optional[KeyValues], raw_key: str,
|
||||
game: Any) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user