mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-29 14:54:00 -06:00
ui/curses: add colors
This commit is contained in:
@@ -8,11 +8,10 @@ from pqcli.roster import Roster
|
||||
from pqcli.ui.curses.event_handler import EventHandler
|
||||
from pqcli.ui.curses.util import KEYS_DOWN, KEYS_LEFT, KEYS_RIGHT, KEYS_UP
|
||||
from pqcli.ui.curses.views.base_view import BaseView
|
||||
from pqcli.ui.curses.widgets import Scrollable, Widget
|
||||
from pqcli.ui.curses.widgets import Focusable, Scrollable, Widget
|
||||
|
||||
from .character_sheet_window import CharacterSheetWindow
|
||||
from .equipment_window import EquipmentWindow
|
||||
from .focusable import Focusable
|
||||
from .inventory_window import InventoryWindow
|
||||
from .plot_window import PlotWindow
|
||||
from .quest_book_window import QuestBookWindow
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import typing as T
|
||||
|
||||
from pqcli.mechanic import Player, StatType
|
||||
from pqcli.ui.curses.widgets import Focusable
|
||||
|
||||
from .focusable import Focusable
|
||||
from .progress_bar_window import DataTableProgressBarWindow
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import typing as T
|
||||
|
||||
from pqcli.mechanic import EquipmentType, Player
|
||||
from pqcli.ui.curses.widgets import DataTable, WindowWrapper
|
||||
|
||||
from .focusable import Focusable
|
||||
from pqcli.ui.curses.widgets import DataTable, Focusable, WindowWrapper
|
||||
|
||||
|
||||
class EquipmentWindow(Focusable, WindowWrapper):
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import contextlib
|
||||
import typing as T
|
||||
|
||||
from pqcli.ui.curses.event_handler import EventHandler
|
||||
|
||||
|
||||
class Focusable:
|
||||
def __init__(self, *args: T.Any, **kwargs: T.Any) -> None:
|
||||
self._focused = False
|
||||
self._on_focus_change = EventHandler()
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def focused(self) -> bool:
|
||||
return self._focused
|
||||
|
||||
@focused.setter
|
||||
def focused(self, focused: bool) -> None:
|
||||
self._focused = focused
|
||||
self._on_focus_change()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def focus_standout(self, win: T.Any) -> T.Generator:
|
||||
if self._focused:
|
||||
win.standout()
|
||||
yield
|
||||
if self._focused:
|
||||
win.standend()
|
||||
@@ -3,9 +3,13 @@ import typing as T
|
||||
|
||||
from pqcli.lingo import to_roman
|
||||
from pqcli.mechanic import InventoryItem, Player
|
||||
from pqcli.ui.curses.widgets import DataTable, ProgressBar, WindowWrapper
|
||||
from pqcli.ui.curses.widgets import (
|
||||
DataTable,
|
||||
Focusable,
|
||||
ProgressBar,
|
||||
WindowWrapper,
|
||||
)
|
||||
|
||||
from .focusable import Focusable
|
||||
from .progress_bar_window import DataTableProgressBarWindow
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@ import typing as T
|
||||
|
||||
from pqcli.lingo import act_name
|
||||
from pqcli.mechanic import Player
|
||||
from pqcli.ui.curses.widgets import ListBox, WindowWrapper
|
||||
from pqcli.ui.curses.widgets import Focusable, ListBox, WindowWrapper
|
||||
|
||||
from .focusable import Focusable
|
||||
from .progress_bar_window import ListBoxProgressBarWindow
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import curses
|
||||
import typing as T
|
||||
|
||||
from pqcli.ui.curses.views.game_view.focusable import Focusable
|
||||
from pqcli.ui.curses.widgets import (
|
||||
DataTable,
|
||||
Focusable,
|
||||
ListBox,
|
||||
ProgressBar,
|
||||
WindowWrapper,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import typing as T
|
||||
|
||||
from pqcli.mechanic import Player
|
||||
from pqcli.ui.curses.widgets import ListBox, WindowWrapper
|
||||
from pqcli.ui.curses.widgets import Focusable, ListBox, WindowWrapper
|
||||
|
||||
from .focusable import Focusable
|
||||
from .progress_bar_window import ListBoxProgressBarWindow
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@ import typing as T
|
||||
|
||||
from pqcli.lingo import to_roman
|
||||
from pqcli.mechanic import Player, Spell
|
||||
from pqcli.ui.curses.widgets import DataTable, WindowWrapper
|
||||
|
||||
from .focusable import Focusable
|
||||
from pqcli.ui.curses.widgets import DataTable, Focusable, WindowWrapper
|
||||
|
||||
|
||||
class SpellBookWindow(Focusable, WindowWrapper):
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import typing as T
|
||||
|
||||
from pqcli.mechanic import Player
|
||||
from pqcli.ui.curses.widgets import Label, ProgressBar, WindowWrapper
|
||||
|
||||
from .focusable import Focusable
|
||||
from pqcli.ui.curses.widgets import (
|
||||
Focusable,
|
||||
Label,
|
||||
ProgressBar,
|
||||
WindowWrapper,
|
||||
)
|
||||
|
||||
|
||||
class TaskProgressWindow(Focusable, WindowWrapper):
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import curses
|
||||
import typing as T
|
||||
|
||||
from ..event_handler import EventHandler
|
||||
from ..util import Choice
|
||||
from ..widgets import Menu
|
||||
from pqcli.ui.curses.colors import COLOR_LOGO, has_colors
|
||||
from pqcli.ui.curses.event_handler import EventHandler
|
||||
from pqcli.ui.curses.util import Choice
|
||||
from pqcli.ui.curses.widgets import Menu
|
||||
|
||||
from .base_view import BaseView
|
||||
|
||||
LOGO = """
|
||||
@@ -13,6 +16,22 @@ LOGO = """
|
||||
""".strip()
|
||||
|
||||
|
||||
class MainMenu(Menu):
|
||||
def __init__(
|
||||
self, choices: T.List[Choice], scr_height: int, scr_width: int
|
||||
) -> None:
|
||||
super().__init__(
|
||||
header=LOGO,
|
||||
choices=choices,
|
||||
active_choice=0,
|
||||
scr_height=scr_height,
|
||||
scr_width=scr_width,
|
||||
)
|
||||
if has_colors():
|
||||
for y in range(len(self._header_lines)):
|
||||
self._pad.chgat(y, 0, curses.color_pair(COLOR_LOGO))
|
||||
|
||||
|
||||
class RosterView(BaseView):
|
||||
def __init__(self, screen: T.Any) -> None:
|
||||
super().__init__(screen)
|
||||
@@ -50,12 +69,8 @@ class RosterView(BaseView):
|
||||
self.screen.erase()
|
||||
self.screen.noutrefresh()
|
||||
|
||||
self.main_menu = Menu(
|
||||
header=LOGO,
|
||||
choices=self.choices,
|
||||
active_choice=0,
|
||||
scr_height=scr_height,
|
||||
scr_width=scr_width,
|
||||
self.main_menu = MainMenu(
|
||||
choices=self.choices, scr_height=scr_height, scr_width=scr_width
|
||||
)
|
||||
self.main_menu.render()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user