ui/curses: implement game view widget focusing

This commit is contained in:
rr-
2019-01-04 00:22:29 +01:00
parent 4230c57e73
commit 9db61f7191
11 changed files with 204 additions and 67 deletions
@@ -4,16 +4,18 @@ from pqcli.lingo import act_name
from pqcli.mechanic import Player
from pqcli.ui.curses.widgets import ListBox, WindowWrapper
from .focusable import Focusable
from .progress_bar_window import ListBoxProgressBarWindow
class PlotWindow(ListBoxProgressBarWindow):
class PlotWindow(Focusable, ListBoxProgressBarWindow):
cutoff = 100
def __init__(
self, player: Player, parent: T.Any, h: int, w: int, y: int, x: int
) -> None:
super().__init__(parent, h, w, y, x, " Plot Development ")
self._on_focus_change += self._render
self._player = player
self._player.quest_book.connect("start_act", self._sync_act_add)
@@ -51,8 +53,6 @@ class PlotWindow(ListBoxProgressBarWindow):
self._list_box.add("[ ] " + act_name(act_number))
def _sync_position(self) -> None:
self._render_progress_bar(
self._player.quest_book.plot_bar.position,
self._player.quest_book.plot_bar.max_,
"",
)
self._cur_pos = self._player.quest_book.plot_bar.position
self._max_pos = self._player.quest_book.plot_bar.max_
self._render_progress_bar()