Merging master into village, conflicts were solved
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# Copyright (C) 2020 by ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import curses
|
||||
from typing import List
|
||||
|
||||
from squirrelbattle.menus import Menu, MainMenu
|
||||
@ -24,8 +24,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):
|
||||
@ -110,12 +108,22 @@ class MainMenuDisplay(Display):
|
||||
menuy, menux, min(self.menudisplay.preferred_height,
|
||||
self.height - menuy), menuwidth)
|
||||
|
||||
class VariableMenuDisplay(MenuDisplay):
|
||||
"""
|
||||
A class to display a menu in which each value is associated to a parameter
|
||||
"""
|
||||
|
||||
class InventoryDisplay(MenuDisplay):
|
||||
def update_pad(self) -> None:
|
||||
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.translated_name.capitalize())
|
||||
|
||||
@property
|
||||
def values(self) -> List[str]:
|
||||
return [a[1][1] + (" : "
|
||||
+ (a[1][0])
|
||||
if a[1][0] else "") for a in self.menu.values]
|
||||
def truewidth(self) -> int:
|
||||
return max(1, self.height if hasattr(self, "height") else 10)
|
||||
|
||||
@property
|
||||
def trueheight(self) -> int:
|
||||
return 2 + super().trueheight
|
||||
|
Reference in New Issue
Block a user