This commit is contained in:
Yohann D'ANELLO 2020-11-08 22:48:50 +01:00
parent e0366b4719
commit 933385e79d
2 changed files with 37 additions and 34 deletions

View File

@ -2,8 +2,10 @@ from dungeonbattle.menus import Menu
from typing import Any from typing import Any
import curses import curses
class MenuDisplay: class MenuDisplay:
def __init__(self, menu : Menu, screen: Any, height : int, width : int, topleftx: int, toplefty: int) : def __init__(self, menu: Menu, screen: Any, height: int, width: int,
topleftx: int, toplefty: int):
self.screen = screen self.screen = screen
self.position = menu.position self.position = menu.position
self.values = menu.values self.values = menu.values
@ -24,12 +26,14 @@ class MenuDisplay:
self.menubox.addstr(0, 0, "" + "" * (self.width - 2) + "") self.menubox.addstr(0, 0, "" + "" * (self.width - 2) + "")
for i in range(1, self.height - 2): for i in range(1, self.height - 2):
self.menubox.addstr(i, 0, "" + " " * (self.width - 2) + "") self.menubox.addstr(i, 0, "" + " " * (self.width - 2) + "")
self.menubox.addstr(self.height-2, 0, ""+""*(self.width-2)+"") self.menubox.addstr(self.height - 2, 0,
"" + "" * (self.width - 2) + "")
def update_pad(self, position: int) -> None: def update_pad(self, position: int) -> None:
for i in range(self.trueheight): for i in range(self.trueheight):
self.pad.addstr(i, 0, " ") self.pad.addstr(i, 0, " ")
self.pad.addstr(position,0,">") #set a marker in front of the selected line # set a marker in front of the selected line
self.pad.addstr(position, 0, ">")
def refresh(self, position: int) -> None: def refresh(self, position: int) -> None:
if self.height - 2 >= position - 1: if self.height - 2 >= position - 1:
@ -44,4 +48,3 @@ class MenuDisplay:
self.pad.refresh(cornery, 0, self.toplefty + 1, self.topleftx + 1, self.pad.refresh(cornery, 0, self.toplefty + 1, self.topleftx + 1,
self.height - 2 + self.toplefty, self.height - 2 + self.toplefty,
self.width - 2 + self.topleftx) self.width - 2 + self.topleftx)