-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
globalstorage.py
117 lines (89 loc) · 3.31 KB
/
globalstorage.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from typing import List, Any
from SimConnect import AircraftEvents, AircraftRequests
from MSFSPythonSimConnectMobiFlightExtension.src.mobiflight_variable_requests import MobiFlightVariableRequests
from singleton import Singleton
from rotaryencoder import RotaryEncoder
from pushbutton import PushButton
from trigger import Trigger
from fader import Fader
from activelayerchanger import ActiveLayerChanger
from aircraftstaterequest import SystemStateRequest
class GlobalStorage(metaclass=Singleton):
def __init__(self):
self._buttons = [] # type: List[PushButton]
self._encoders = [] # type: List[RotaryEncoder]
self._faders = [] # type: List[Fader]
self._triggers = [] # type: List[Trigger]
self._ae = None
self._aq = None
self._vr = None
self._global_variables = {}
self._active_layer_changer = None # type: ActiveLayerChanger
self._sq = None
self._base_matching = None
def clear(self):
self._buttons = []
self._encoders = []
self._faders = []
self._triggers = []
self._active_layer_changer = None
def add_encoder(self, encoder: RotaryEncoder):
self._encoders.append(encoder)
def add_button(self, button: PushButton):
self._buttons.append(button)
def add_fader(self, fader: Fader):
self._faders.append(fader)
def add_trigger(self, trigger: Trigger):
self._triggers.append(trigger)
def set_aircraft_events(self, ae: AircraftEvents):
self._ae = ae
def set_aircraft_requests(self, aq: AircraftRequests):
self._aq = aq
#Add MobiFlight
def get_mobiflight_variable(self, key: str):
return self._vr.get(key)
def set_mobiflight_variable_requests(self, vr: MobiFlightVariableRequests):
self._vr = vr
def set_global_variable(self, key: str, value):
self._global_variables[key] = value
def get_global_variable(self, key: str):
return self._global_variables.get(key, None)
def set_active_layer_changer(self, ac: ActiveLayerChanger):
self._active_layer_changer = ac
def set_system_request(self, sq: SystemStateRequest):
self._sq = sq
def set_base_matching(self, base_matching: bool):
self._base_matching = base_matching
@property
def encoders(self) -> List[RotaryEncoder]:
return self._encoders
@property
def buttons(self) -> List[PushButton]:
return self._buttons
@property
def faders(self) -> List[Fader]:
return self._faders
@property
def triggers(self) -> List[Trigger]:
return self._triggers
@property
def all_elements(self) -> List[Any]:
return self._encoders + self._buttons + self._triggers
@property
def aircraft_events(self) -> AircraftEvents:
return self._ae
@property
def aircraft_requests(self) -> AircraftRequests:
return self._aq
@property
def mobiflight_variable_requests(self) -> MobiFlightVariableRequests:
return self._vr
@property
def active_layer_changer(self) -> ActiveLayerChanger:
return self._active_layer_changer
@property
def system_requests(self) -> SystemStateRequest:
return self._sq
@property
def base_matching(self) -> bool:
return self._base_matching