Added logs to the layout, clear logs on new game (tests still aren't fixed)
This commit is contained in:
parent
6e71146aa2
commit
589f825765
|
@ -33,7 +33,7 @@ class Display:
|
||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
if hasattr(self, "pad") and resize_pad:
|
if hasattr(self, "pad") and resize_pad:
|
||||||
self.pad.resize(self.height - 1, self.width - 1)
|
self.pad.resize(self.height, self.width)
|
||||||
|
|
||||||
def refresh(self, *args, resize_pad: bool = True) -> None:
|
def refresh(self, *args, resize_pad: bool = True) -> None:
|
||||||
if len(args) == 4:
|
if len(args) == 4:
|
||||||
|
|
|
@ -47,7 +47,9 @@ class DisplayManager:
|
||||||
self.mapdisplay.refresh(0, 0, self.rows * 4 // 5, self.cols,
|
self.mapdisplay.refresh(0, 0, self.rows * 4 // 5, self.cols,
|
||||||
resize_pad=False)
|
resize_pad=False)
|
||||||
self.statsdisplay.refresh(self.rows * 4 // 5, 0,
|
self.statsdisplay.refresh(self.rows * 4 // 5, 0,
|
||||||
self.rows // 5, self.cols)
|
self.rows // 10, self.cols)
|
||||||
|
self.logsdisplay.refresh(self.rows * 9 // 10, 0,
|
||||||
|
self.rows // 10, 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:
|
if self.game.state == GameMode.SETTINGS:
|
||||||
|
|
|
@ -12,6 +12,11 @@ class LogsDisplay(Display):
|
||||||
self.logs = logs
|
self.logs = logs
|
||||||
|
|
||||||
def display(self) -> None:
|
def display(self) -> None:
|
||||||
messages = self.logs.messages[-self.height:].reverse()
|
print(type(self.logs.messages), flush=True)
|
||||||
for i, y in enumerate(range(self.y + self.height - 1, self.y - 1, - 1)):
|
messages = self.logs.messages[-self.height:]
|
||||||
self.pad.addstr(y, self.x, messages[i][:self.width])
|
messages = messages[::-1]
|
||||||
|
self.pad.clear()
|
||||||
|
for i in range(min(self.height, len(messages))):
|
||||||
|
self.pad.addstr(self.height - i - 1, self.x, messages[i][:self.width])
|
||||||
|
self.pad.refresh(0, 0, self.y, self.x, self.y + self.height,
|
||||||
|
self.x + self.width)
|
||||||
|
|
|
@ -42,6 +42,7 @@ class Game:
|
||||||
# TODO generate a new map procedurally
|
# TODO generate a new map procedurally
|
||||||
self.map = Map.load(ResourceManager.get_asset_path("example_map_2.txt"))
|
self.map = Map.load(ResourceManager.get_asset_path("example_map_2.txt"))
|
||||||
self.map.logs = self.logs
|
self.map.logs = self.logs
|
||||||
|
self.logs.clear()
|
||||||
self.player = Player()
|
self.player = Player()
|
||||||
self.map.add_entity(self.player)
|
self.map.add_entity(self.player)
|
||||||
self.player.move(self.map.start_y, self.map.start_x)
|
self.player.move(self.map.start_y, self.map.start_x)
|
||||||
|
|
Loading…
Reference in New Issue