-
Notifications
You must be signed in to change notification settings - Fork 0
/
gloomcontroller.py
63 lines (48 loc) · 1.6 KB
/
gloomcontroller.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from gloombackend import Backend
from gloomview import UserInterfaceMain
def error_exit_gloomlog():
"""
Something really strange happened...
"""
print('Sorry, GloomLog lost controll')
print('GloomLog has to shut down :(')
exit()
class Controller:
def __init__(self):
self.backend = None
self.interface = None
def run(self):
"""
Call this command to boot up GloomLog
"""
self.backend = Backend()
saves_copy = self.backend.check_saves()
self.interface = UserInterfaceMain(list_saves=saves_copy)
self.present_user_interface_main()
def present_user_interface_main(self):
"""
The main control function.
Boots an interface.
Coordinates data flow in the programm based on user input
"""
hold = True
while hold:
hold = self.interface.present_interface()
if type(hold) == tuple:
self.backend.save_to_file(save_file=hold[0], save_info=hold[1])
# slight overkill, but works well enough for a simple app as this
self.interface.list_saves = self.backend.check_saves()
if type(hold) == str:
save_text = self.backend.load_save_file_as_text(save_file=hold)
self.interface.prepare_save_interface(
save_file=hold,
save_text=save_text
)
self.exit_gloomlog()
@staticmethod
def exit_gloomlog():
"""
Gracefully exits GloomLog
"""
print('Bye!')
exit()