From 7e636078363d2b105cd137dc0501122092809e29 Mon Sep 17 00:00:00 2001 From: Nicolas Margulies Date: Fri, 20 Nov 2020 16:52:04 +0100 Subject: [PATCH] Added vertical and horizontal lines as display elements --- squirrelbattle/display/display.py | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/squirrelbattle/display/display.py b/squirrelbattle/display/display.py index 1e47189..eba86b9 100644 --- a/squirrelbattle/display/display.py +++ b/squirrelbattle/display/display.py @@ -50,3 +50,43 @@ class Display: @property def cols(self) -> int: return curses.COLS if self.screen else 42 + + +class VerticalSplit(Display): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.pad = self.newpad(self.rows, 1) + + @property + def width(self) -> int: + return 1 + + @width.setter + def width(self, val: Any) -> None: + pass + + def display(self) -> None: + for i in range(self.height): + self.pad.addstr(i, 0, "┃") + self.pad.refresh(0, 0, self.y, self.x, self.y + self.height, self.x) + + +class HorizontalSplit(Display): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.pad = self.newpad(1, self.cols) + + @property + def height(self) -> int: + return 1 + + @height.setter + def height(self, val: Any) -> None: + pass + + def display(self) -> None: + for i in range(self.width): + self.pad.addstr(0, i, "━") + self.pad.refresh(0, 0, self.y, self.x, self.y, self.x + self.width)