2020-11-06 15:40:43 +00:00
|
|
|
from enum import Enum, auto
|
2020-11-06 17:25:02 +00:00
|
|
|
from typing import Any
|
2020-11-06 15:40:43 +00:00
|
|
|
|
|
|
|
|
2020-11-06 15:20:07 +00:00
|
|
|
class Menu:
|
2020-11-06 17:11:59 +00:00
|
|
|
values: list
|
2020-11-06 15:40:43 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
2020-11-06 15:20:07 +00:00
|
|
|
self.position = 0
|
2020-11-06 17:11:59 +00:00
|
|
|
|
|
|
|
def go_up(self) -> None:
|
|
|
|
self.position = max(0, self.position - 1)
|
|
|
|
|
|
|
|
def go_down(self) -> None:
|
|
|
|
self.position = min(len(self.values) - 1, self.position + 1)
|
|
|
|
|
2020-11-06 17:25:02 +00:00
|
|
|
def validate(self) -> Any:
|
2020-11-06 15:40:43 +00:00
|
|
|
return self.values[self.position]
|
|
|
|
|
2020-11-06 17:11:59 +00:00
|
|
|
|
2020-11-06 15:40:43 +00:00
|
|
|
class MainMenuValues(Enum):
|
|
|
|
START = auto()
|
|
|
|
SETTINGS = auto()
|
|
|
|
EXIT = auto()
|
|
|
|
|
2020-11-06 17:11:59 +00:00
|
|
|
|
2020-11-06 15:40:43 +00:00
|
|
|
class MainMenu(Menu):
|
2020-11-06 17:11:59 +00:00
|
|
|
values = [e for e in MainMenuValues]
|
2020-11-06 15:40:43 +00:00
|
|
|
|
|
|
|
|
2020-11-06 17:32:51 +00:00
|
|
|
class ArbitraryMenu(Menu):
|
2020-11-06 17:11:59 +00:00
|
|
|
def __init__(self, values: list):
|
2020-11-06 17:32:51 +00:00
|
|
|
super().__init__()
|
2020-11-06 17:11:59 +00:00
|
|
|
self.values = values
|