|
@@ -13,17 +13,23 @@ class Manager:
|
13
|
13
|
def __init__(self, g):
|
14
|
14
|
self.gui = g
|
15
|
15
|
self.screens = []
|
16
|
|
- self.index = 0
|
17
|
16
|
self.restart()
|
18
|
17
|
|
19
|
18
|
def restart(self):
|
|
19
|
+ self.index = 0
|
|
20
|
+ self.done = False
|
20
|
21
|
self.lastTime = time.time()
|
|
22
|
+ if len(self.screens) > 0:
|
|
23
|
+ self.screens[0][0].restart()
|
|
24
|
+
|
|
25
|
+ def finished(self):
|
|
26
|
+ return self.done
|
21
|
27
|
|
22
|
28
|
def add(self, s, d = None):
|
23
|
29
|
v = (s, d)
|
24
|
30
|
self.screens.append(v)
|
25
|
31
|
|
26
|
|
- def loop(self):
|
|
32
|
+ def draw(self):
|
27
|
33
|
self.screens[self.index][0].draw()
|
28
|
34
|
|
29
|
35
|
if self.screens[self.index][1] == None:
|
|
@@ -31,12 +37,14 @@ class Manager:
|
31
|
37
|
if self.screens[self.index][0].finished():
|
32
|
38
|
self.lastTime = time.time()
|
33
|
39
|
self.index = (self.index + 1) % len(self.screens)
|
|
40
|
+ self.done = (self.index == 0)
|
34
|
41
|
self.screens[self.index][0].restart()
|
35
|
42
|
else:
|
36
|
43
|
# use given timeout
|
37
|
44
|
if (time.time() - self.lastTime) > self.screens[self.index][1]:
|
38
|
45
|
self.lastTime = time.time()
|
39
|
46
|
self.index = (self.index + 1) % len(self.screens)
|
|
47
|
+ self.done = (self.index == 0)
|
40
|
48
|
self.screens[self.index][0].restart()
|
41
|
49
|
|
42
|
50
|
if __name__ == "__main__":
|
|
@@ -68,5 +76,13 @@ if __name__ == "__main__":
|
68
|
76
|
m.add(GameOfLife(t, 20, (0, 255, 0), (0, 0, 0), 20.0, True))
|
69
|
77
|
m.add(Solid(t, 1.0))
|
70
|
78
|
|
|
79
|
+ sub = Manager(t)
|
|
80
|
+ sub.add(ScrollText(t, "Hello"))
|
|
81
|
+ sub.add(Solid(t, 1.0, (0, 255, 0)))
|
|
82
|
+ sub.add(ScrollText(t, "World"))
|
|
83
|
+ sub.add(Solid(t, 1.0, (0, 0, 255)))
|
|
84
|
+ m.add(sub)
|
|
85
|
+ m.add(Solid(t, 1.0))
|
|
86
|
+
|
71
|
87
|
m.restart()
|
72
|
|
- t.debug_loop(m.loop)
|
|
88
|
+ t.debug_loop(m.draw)
|