diff --git a/squirrelbattle/display/menudisplay.py b/squirrelbattle/display/menudisplay.py index 61ac155..285b6db 100644 --- a/squirrelbattle/display/menudisplay.py +++ b/squirrelbattle/display/menudisplay.py @@ -21,8 +21,6 @@ class MenuDisplay(Display): # Menu values are printed in pad self.pad = self.newpad(self.trueheight, self.truewidth + 2) - for i in range(self.trueheight): - self.addstr(self.pad, i, 0, " " + self.values[i]) def update_pad(self) -> None: for i in range(self.trueheight): @@ -107,3 +105,16 @@ class InventoryDisplay(MenuDisplay): message = _("== INVENTORY ==") self.addstr(self.pad, 0, (self.width - len(message)) // 2, message, curses.A_BOLD | curses.A_ITALIC) + for i, item in enumerate(self.menu.values): + rep = self.pack[item.name.upper()] + selection = f"[{rep}]" if i == self.menu.position else f" {rep} " + self.addstr(self.pad, 2 + i, 0, selection + + " " + _(item.name).capitalize()) + + @property + def truewidth(self) -> int: + return max(1, self.height if hasattr(self, "height") else 10) + + @property + def trueheight(self) -> int: + return 2 + super().trueheight diff --git a/squirrelbattle/game.py b/squirrelbattle/game.py index b4b3147..f1171fa 100644 --- a/squirrelbattle/game.py +++ b/squirrelbattle/game.py @@ -55,6 +55,7 @@ class Game: self.map.add_entity(self.player) self.player.move(self.map.start_y, self.map.start_x) self.map.spawn_random_entities(randint(3, 10)) + self.inventory_menu.update_player(self.player) def run(self, screen: Any) -> None: """ diff --git a/squirrelbattle/menus.py b/squirrelbattle/menus.py index 68c8c3e..d6946d0 100644 --- a/squirrelbattle/menus.py +++ b/squirrelbattle/menus.py @@ -5,6 +5,7 @@ from enum import Enum from typing import Any, Optional from .display.texturepack import TexturePack +from .entities.player import Player from .enums import GameMode, KeyValues, DisplayActions from .settings import Settings from .translations import gettext as _, Translator @@ -118,5 +119,11 @@ class SettingsMenu(Menu): class InventoryMenu(Menu): - # FIXME Use real menu - values = ["bomb"] + player: Player + + def update_player(self, player: Player) -> None: + self.player = player + + @property + def values(self) -> list: + return self.player.inventory