Added settings diplay and ability to change the keys (there is a refreshing problem though)

This commit is contained in:
eichhornchen 2020-11-11 14:46:25 +01:00
parent 56ba9d186e
commit d9b7db742a
2 changed files with 7 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import curses import curses
from dungeonbattle.display.mapdisplay import MapDisplay from dungeonbattle.display.mapdisplay import MapDisplay
from dungeonbattle.display.statsdisplay import StatsDisplay from dungeonbattle.display.statsdisplay import StatsDisplay
from dungeonbattle.display.menudisplay import MainMenuDisplay from dungeonbattle.display.menudisplay import MenuDisplay, MainMenuDisplay
from dungeonbattle.display.texturepack import TexturePack from dungeonbattle.display.texturepack import TexturePack
from typing import Any from typing import Any
from dungeonbattle.game import Game, GameMode from dungeonbattle.game import Game, GameMode
@ -17,9 +17,11 @@ class DisplayManager:
self.statsdisplay = StatsDisplay(screen, pack) self.statsdisplay = StatsDisplay(screen, pack)
self.mainmenudisplay = MainMenuDisplay(self.game.main_menu, self.mainmenudisplay = MainMenuDisplay(self.game.main_menu,
screen, pack) screen, pack)
self.settingsmenudisplay = MenuDisplay(screen, pack)
self.displays = [self.statsdisplay, self.mapdisplay, self.displays = [self.statsdisplay, self.mapdisplay,
self.mainmenudisplay] self.mainmenudisplay, self.settingsmenudisplay]
self.update_game_components() self.update_game_components()
self.settingsmenudisplay.update_menu(self.game.settings_menu)
def update_game_components(self) -> None: def update_game_components(self) -> None:
for d in self.displays: for d in self.displays:
@ -34,6 +36,8 @@ class DisplayManager:
self.rows // 5, self.cols) self.rows // 5, self.cols)
if self.game.state == GameMode.MAINMENU: if self.game.state == GameMode.MAINMENU:
self.mainmenudisplay.refresh(0, 0, self.rows, self.cols) 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.resize_window() self.resize_window()
def resize_window(self) -> bool: def resize_window(self) -> bool:

View File

@ -22,7 +22,7 @@ class MenuDisplay(Display):
def update_pad(self) -> None: def update_pad(self) -> None:
for i in range(self.trueheight): for i in range(self.trueheight):
self.pad.addstr(i, 0, " ") self.pad.addstr(i, 0, " " + self.values[i])
# set a marker on the selected line # set a marker on the selected line
self.pad.addstr(self.menu.position, 0, ">") self.pad.addstr(self.menu.position, 0, ">")