Display full inventory
This commit is contained in:
parent
fbfcd5dae0
commit
a68b3a6d08
|
@ -21,8 +21,6 @@ class MenuDisplay(Display):
|
||||||
|
|
||||||
# Menu values are printed in pad
|
# Menu values are printed in pad
|
||||||
self.pad = self.newpad(self.trueheight, self.truewidth + 2)
|
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:
|
def update_pad(self) -> None:
|
||||||
for i in range(self.trueheight):
|
for i in range(self.trueheight):
|
||||||
|
@ -107,3 +105,16 @@ class InventoryDisplay(MenuDisplay):
|
||||||
message = _("== INVENTORY ==")
|
message = _("== INVENTORY ==")
|
||||||
self.addstr(self.pad, 0, (self.width - len(message)) // 2, message,
|
self.addstr(self.pad, 0, (self.width - len(message)) // 2, message,
|
||||||
curses.A_BOLD | curses.A_ITALIC)
|
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
|
||||||
|
|
|
@ -55,6 +55,7 @@ class Game:
|
||||||
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)
|
||||||
self.map.spawn_random_entities(randint(3, 10))
|
self.map.spawn_random_entities(randint(3, 10))
|
||||||
|
self.inventory_menu.update_player(self.player)
|
||||||
|
|
||||||
def run(self, screen: Any) -> None:
|
def run(self, screen: Any) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -5,6 +5,7 @@ from enum import Enum
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from .display.texturepack import TexturePack
|
from .display.texturepack import TexturePack
|
||||||
|
from .entities.player import Player
|
||||||
from .enums import GameMode, KeyValues, DisplayActions
|
from .enums import GameMode, KeyValues, DisplayActions
|
||||||
from .settings import Settings
|
from .settings import Settings
|
||||||
from .translations import gettext as _, Translator
|
from .translations import gettext as _, Translator
|
||||||
|
@ -118,5 +119,11 @@ class SettingsMenu(Menu):
|
||||||
|
|
||||||
|
|
||||||
class InventoryMenu(Menu):
|
class InventoryMenu(Menu):
|
||||||
# FIXME Use real menu
|
player: Player
|
||||||
values = ["bomb"]
|
|
||||||
|
def update_player(self, player: Player) -> None:
|
||||||
|
self.player = player
|
||||||
|
|
||||||
|
@property
|
||||||
|
def values(self) -> list:
|
||||||
|
return self.player.inventory
|
||||||
|
|
Loading…
Reference in New Issue