This commit is contained in:
Nicolas Margulies 2020-11-13 19:08:40 +01:00
parent aa81d455f6
commit 04d2bc1789
3 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -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