squirrel-battle/dungeonbattle/menus.py

33 lines
624 B
Python
Raw Normal View History

2020-11-06 15:40:43 +00:00
from enum import Enum, auto
2020-11-06 15:20:07 +00:00
class Menu:
2020-11-06 15:40:43 +00:00
values:list
def __init__(self):
2020-11-06 15:20:07 +00:00
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):
2020-11-06 15:40:43 +00:00
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