diff --git a/pqcli/ui/curses/views/choose_character_view.py b/pqcli/ui/curses/views/choose_character_view.py index 42b718f..dfdff70 100644 --- a/pqcli/ui/curses/views/choose_character_view.py +++ b/pqcli/ui/curses/views/choose_character_view.py @@ -1,6 +1,7 @@ import functools import typing as T +from pqcli.lingo import act_name, to_roman from pqcli.roster import Roster from pqcli.ui.curses.event_handler import EventHandler from pqcli.ui.curses.util import Choice @@ -14,10 +15,33 @@ class ChooseCharacterView(MenuView): for y, player in enumerate(roster.players, 1): key: T.Optional[str] = str(y % 10) if y <= 10 else None + + best_equip = player.equipment.best + + best_spell = player.spell_book.best + best_spell_name = ( + (best_spell.name + " " + to_roman(best_spell.level)) + if best_spell + else "-" + ) + + best_stat_name = ( + f"{player.stats.best_prime.value} " + f"{player.stats[player.stats.best_prime]}" + ) + + label = ( + f"[{key or '-'}] " + f"{player.name} the {player.race.name} " + f"({act_name(player.quest_book.act)})\n" + f" Level {player.level} {player.class_.name}\n" + f" {best_equip} / {best_spell_name} / {best_stat_name}" + ) + self._choices.append( Choice( keys=[ord(key)] if key is not None else [], - desc=f"[{key or '-'}] {player.name}", + desc=label, callback=functools.partial(self.on_confirm, player), ) ) diff --git a/pqcli/ui/curses/widgets/menu.py b/pqcli/ui/curses/widgets/menu.py index 9298a16..bf65497 100644 --- a/pqcli/ui/curses/widgets/menu.py +++ b/pqcli/ui/curses/widgets/menu.py @@ -23,8 +23,12 @@ class Menu(Widget): self._scr_width = scr_width self._scr_height = scr_height - w = max(map(len, self._header_lines)) - h = len(self._header_lines) + 1 + len(choices) + all_lines = self._header_lines + sum( + [choice.desc.splitlines() for choice in choices], [] + ) + + w = max(map(len, all_lines)) + 1 + h = len(all_lines) + 1 self._pad: T.Optional[T.Any] = curses.newpad(h, w) for y, line in enumerate(self._header_lines): @@ -72,10 +76,15 @@ class Menu(Widget): if not self._pad: return - for y, choice in enumerate(self._choices): - self._pad.move(len(self._header_lines) + 1 + y, 0) - with focus_standout(y == self._active_choice, self._pad): - self._pad.addstr(choice.desc) + y = len(self._header_lines) + 1 + for i, choice in enumerate(self._choices): + self._pad.move(y, 0) + with focus_standout(i == self._active_choice, self._pad): + lines = choice.desc.splitlines() + max_len = max(map(len, lines)) + lines = [line.ljust(max_len) for line in lines] + self._pad.addstr("\n".join(lines)) + y += len(choice.desc.splitlines()) self._pad.refresh( 0,