2020-11-19 11:03:05 +00:00
|
|
|
from squirrelbattle.display.display import Display
|
|
|
|
from squirrelbattle.interfaces import Logs
|
|
|
|
|
|
|
|
|
|
|
|
class LogsDisplay(Display):
|
|
|
|
|
|
|
|
def __init__(self, *args) -> None:
|
|
|
|
super().__init__(*args)
|
|
|
|
self.pad = self.newpad(self.rows, self.cols)
|
|
|
|
|
|
|
|
def update_logs(self, logs: Logs) -> None:
|
|
|
|
self.logs = logs
|
|
|
|
|
|
|
|
def display(self) -> None:
|
2020-11-19 11:55:06 +00:00
|
|
|
print(type(self.logs.messages), flush=True)
|
|
|
|
messages = self.logs.messages[-self.height:]
|
|
|
|
messages = messages[::-1]
|
2020-11-26 21:20:14 +00:00
|
|
|
self.pad.erase()
|
2020-11-19 11:55:06 +00:00
|
|
|
for i in range(min(self.height, len(messages))):
|
2020-11-26 11:35:52 +00:00
|
|
|
self.addstr(self.pad, self.height - i - 1, self.x,
|
|
|
|
messages[i][:self.width])
|
2020-11-26 19:58:46 +00:00
|
|
|
self.refresh_pad(self.pad, 0, 0, self.y, self.x,
|
|
|
|
self.y + self.height - 1, self.x + self.width - 1)
|