moved render stuff

This commit is contained in:
Lukas Nöllemeyer 2024-08-19 21:30:29 +02:00
parent 733c6ec30e
commit 5b2a68ff2c
6 changed files with 109 additions and 100 deletions

View file

@ -45,10 +45,9 @@ class SelectItem(MenuItem):
case _:
return None
def on_draw(self, console: tcod.console.Console, x: int, y: int, highlight: bool) -> None:
def on_draw(self, x: int, y: int, highlight: bool) -> None:
"""Render this items label."""
#g.foreground.print(x, y, self.label, fg=(255, 255, 255), bg=(64, 64, 64) if highlight else (0, 0, 0))
g.background.print(x, y, self.label, fg=(255, 255, 255), bg=(64, 64, 64) if highlight else (0, 0, 0))
g.renderer.background.print(x, y, self.label, fg=(255, 255, 255), bg=(64, 64, 64) if highlight else (0, 0, 0))
@attrs.define()
@ -94,8 +93,8 @@ class ListMenu(Screen):
"""Handle escape or right click being pressed on menus."""
return Pop()
def on_draw(self, console: tcod.console.Console) -> None:
def on_draw(self) -> None:
"""Render the menu."""
draw_previous_screens(self, g.foreground)
draw_previous_screens(self)
for i, item in enumerate(self.items):
item.on_draw(g.foreground, x=self.x, y=self.y + i, highlight=i == self.selected)
item.on_draw(x=self.x, y=self.y + i, highlight=i == self.selected)