ui/curses: estimate time in progress bars

This commit is contained in:
rr-
2019-01-04 16:40:30 +01:00
parent b20c4b4b34
commit 0133802570
9 changed files with 107 additions and 35 deletions
@@ -11,7 +11,14 @@ class CharacterSheetWindow(Focusable, DataTableProgressBarWindow):
self, player: Player, parent: T.Any, h: int, w: int, y: int, x: int
) -> None:
super().__init__(
parent, h, w, y, x, " Character Sheet ", align_right=False
parent,
h,
w,
y,
x,
" Character Sheet ",
align_right=False,
show_time=True,
)
self._on_focus_change += self._render
@@ -13,7 +13,16 @@ class InventoryWindow(Focusable, DataTableProgressBarWindow):
def __init__(
self, player: Player, parent: T.Any, h: int, w: int, y: int, x: int
) -> None:
super().__init__(parent, h, w, y, x, " Inventory ", align_right=True)
super().__init__(
parent,
h,
w,
y,
x,
" Inventory ",
align_right=True,
show_time=False,
)
self._on_focus_change += self._render
self._player = player
@@ -14,7 +14,9 @@ class PlotWindow(Focusable, ListBoxProgressBarWindow):
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 ")
super().__init__(
parent, h, w, y, x, " Plot Development ", show_time=True
)
self._on_focus_change += self._render
self._player = player
@@ -13,7 +13,14 @@ from .focusable import Focusable
class ProgressBarWindow(WindowWrapper):
def __init__(
self, parent: T.Any, h: int, w: int, y: int, x: int, title: str
self,
parent: T.Any,
h: int,
w: int,
y: int,
x: int,
title: str,
show_time: bool,
) -> None:
super().__init__(parent, h, w, y, x)
@@ -29,7 +36,7 @@ class ProgressBarWindow(WindowWrapper):
except curses.error:
self._progress_bar_win = None
self._progress_bar = ProgressBar(
self._progress_bar_win, 1, w - 2, 1, 1
self._progress_bar_win, 1, w - 2, 1, 1, show_time=show_time
)
def stop(self) -> None:
@@ -87,8 +94,9 @@ class DataTableProgressBarWindow(ProgressBarWindow):
x: int,
title: str,
align_right: bool,
show_time: bool,
) -> None:
super().__init__(parent, h, w, y, x, title)
super().__init__(parent, h, w, y, x, title, show_time)
self._data_table = DataTable(
self._win, h - 4, w - 2, 1, 1, align_right
@@ -119,9 +127,16 @@ class DataTableProgressBarWindow(ProgressBarWindow):
class ListBoxProgressBarWindow(ProgressBarWindow):
def __init__(
self, parent: T.Any, h: int, w: int, y: int, x: int, title: str
self,
parent: T.Any,
h: int,
w: int,
y: int,
x: int,
title: str,
show_time: bool,
) -> None:
super().__init__(parent, h, w, y, x, title)
super().__init__(parent, h, w, y, x, title, show_time)
self._list_box = ListBox(self._win, h - 4, w - 2, 1, 1)
@@ -13,7 +13,7 @@ class QuestBookWindow(Focusable, ListBoxProgressBarWindow):
def __init__(
self, player: Player, parent: T.Any, h: int, w: int, y: int, x: int
) -> None:
super().__init__(parent, h, w, y, x, " Quests ")
super().__init__(parent, h, w, y, x, " Quests ", show_time=True)
self._on_focus_change += self._render
self._player = player
@@ -13,7 +13,9 @@ class TaskProgressWindow(Focusable, WindowWrapper):
super().__init__(parent, h, w, y, x)
self._desc_win = Label(self._win, 1, w, 0, 0)
self._progress_bar = ProgressBar(self._win, 1, w, 1, 0)
self._progress_bar = ProgressBar(
self._win, 1, w, 1, 0, show_time=False
)
self._player = player
self._player.connect("new_task", self._sync_task_name)