-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEventDispatchers.py
61 lines (49 loc) · 1.38 KB
/
EventDispatchers.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
"""
EventDispatchers
"""
from kivy.event import EventDispatcher
class LevelEventDispatcher(EventDispatcher):
"""
Dispatch Level Event (Level completed).
"""
def __init__(self, **kwargs):
"""
Instantiate the level event dispatcher with its custom property.
:param kwargs:
:rtype: void
"""
self.register_event_type('on_level_completed')
super(LevelEventDispatcher, self).__init__(**kwargs)
@staticmethod
def on_level_completed(*args):
"""
Required method.
"""
pass
class MenusEventDispatcher(EventDispatcher):
"""
Dispatch Menu Event (Change screen).
"""
def __init__(self, **kwargs):
"""
Instantiate the Menu event dispatcher with its custom property.
:param kwargs:
:rtype: void
"""
self.register_event_type('on_change_screen')
super(MenusEventDispatcher, self).__init__(**kwargs)
@staticmethod
def on_change_screen(*args):
"""
Required method
"""
pass
def propagate_event(value, current_class, set_id=None):
"""
Propagate change screen event.
:param value: screen's name.
:param current_class: Current active class.
:param set_id: current ID set.
:rtype: void
"""
current_class.event_dispatcher.dispatch('on_change_screen', value, set_id)