-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.py
31 lines (23 loc) · 1.2 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from data_structures import Stack # Import stack object from stack.py
from abc import ABC, abstractmethod # Import abstract base class and abstract method
from application import Application # Import game application
'''
User Interface class, parent class of
both Terminal and UI, stores the current
version of the application.
'''
class UI(ABC): # User Interface class, inherits from abstract base class (must be inherited to use it)
VERSION = "v1.0.2" # Set version
def __init__(self): # Constructor
self._application = Application() # Create game application
self._ui_stack = Stack() # Create new UI stack (for back buttons)
self._push_ui_to_stack("home") # Push "home" to stack, represents the home screen first being rendered
def _push_ui_to_stack(self, ui): # Push ui to stack method
self._ui_stack.push(ui)
def _pop_ui_from_stack(self): # Pop ui from stack method
return self._ui_stack.pop()
def _get_curr_ui(self): # Get current ui at the top of the stack
return self._ui_stack.peek()
@abstractmethod
def run(self): # Run method to start the game, must be implemented by children classes
raise NotImplementedError