squirrel-battle/dungeonbattle/menus.py

33 lines
624 B
Python

from enum import Enum, auto
class Menu:
values:list
def __init__(self):
self.position = 0
def go_up(self):
self.position = max(0, self.position -1)
def go_down(self):
self.position = min(len(self.values)-1, self.position +1)
def validate(self):
return self.values[self.position]
class MainMenuValues(Enum):
START = auto()
SETTINGS = auto()
EXIT = auto()
class MainMenu(Menu):
values = [ e for e in MainMenuValues ]
class ArbitraryMenu:
def __init__(self, values:list):
super().__init__(self)
self.values = values