batframework 1.0.10__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- batFramework/__init__.py +84 -52
- batFramework/action.py +280 -252
- batFramework/actionContainer.py +105 -38
- batFramework/animatedSprite.py +81 -117
- batFramework/animation.py +91 -0
- batFramework/audioManager.py +156 -85
- batFramework/baseScene.py +249 -0
- batFramework/camera.py +245 -123
- batFramework/constants.py +57 -75
- batFramework/cutscene.py +239 -119
- batFramework/cutsceneManager.py +34 -0
- batFramework/drawable.py +107 -0
- batFramework/dynamicEntity.py +30 -23
- batFramework/easingController.py +58 -0
- batFramework/entity.py +130 -123
- batFramework/enums.py +171 -0
- batFramework/fontManager.py +65 -0
- batFramework/gui/__init__.py +28 -14
- batFramework/gui/animatedLabel.py +90 -0
- batFramework/gui/button.py +18 -84
- batFramework/gui/clickableWidget.py +244 -0
- batFramework/gui/collapseContainer.py +98 -0
- batFramework/gui/constraints/__init__.py +1 -0
- batFramework/gui/constraints/constraints.py +1066 -0
- batFramework/gui/container.py +220 -49
- batFramework/gui/debugger.py +140 -47
- batFramework/gui/draggableWidget.py +63 -0
- batFramework/gui/image.py +61 -23
- batFramework/gui/indicator.py +116 -40
- batFramework/gui/interactiveWidget.py +243 -22
- batFramework/gui/label.py +147 -110
- batFramework/gui/layout.py +442 -81
- batFramework/gui/meter.py +155 -0
- batFramework/gui/radioButton.py +43 -0
- batFramework/gui/root.py +228 -60
- batFramework/gui/scrollingContainer.py +282 -0
- batFramework/gui/selector.py +232 -0
- batFramework/gui/shape.py +286 -86
- batFramework/gui/slider.py +353 -0
- batFramework/gui/style.py +10 -0
- batFramework/gui/styleManager.py +49 -0
- batFramework/gui/syncedVar.py +43 -0
- batFramework/gui/textInput.py +331 -0
- batFramework/gui/textWidget.py +308 -0
- batFramework/gui/toggle.py +140 -62
- batFramework/gui/tooltip.py +35 -0
- batFramework/gui/widget.py +546 -307
- batFramework/manager.py +131 -50
- batFramework/particle.py +118 -0
- batFramework/propertyEaser.py +79 -0
- batFramework/renderGroup.py +34 -0
- batFramework/resourceManager.py +130 -0
- batFramework/scene.py +31 -226
- batFramework/sceneLayer.py +134 -0
- batFramework/sceneManager.py +200 -165
- batFramework/scrollingSprite.py +115 -0
- batFramework/sprite.py +46 -0
- batFramework/stateMachine.py +49 -51
- batFramework/templates/__init__.py +2 -0
- batFramework/templates/character.py +15 -0
- batFramework/templates/controller.py +158 -0
- batFramework/templates/stateMachine.py +39 -0
- batFramework/tileset.py +46 -0
- batFramework/timeManager.py +213 -0
- batFramework/transition.py +162 -157
- batFramework/triggerZone.py +22 -22
- batFramework/utils.py +306 -184
- {batframework-1.0.10.dist-info → batframework-2.0.0.dist-info}/LICENSE +1 -1
- {batframework-1.0.10.dist-info → batframework-2.0.0.dist-info}/METADATA +3 -4
- batframework-2.0.0.dist-info/RECORD +72 -0
- batFramework/cutsceneBlocks.py +0 -176
- batFramework/debugger.py +0 -48
- batFramework/easing.py +0 -71
- batFramework/gui/constraints.py +0 -204
- batFramework/gui/frame.py +0 -19
- batFramework/particles.py +0 -77
- batFramework/time.py +0 -75
- batFramework/transitionManager.py +0 -0
- batframework-1.0.10.dist-info/RECORD +0 -43
- {batframework-1.0.10.dist-info → batframework-2.0.0.dist-info}/WHEEL +0 -0
- {batframework-1.0.10.dist-info → batframework-2.0.0.dist-info}/top_level.txt +0 -0
batFramework/action.py
CHANGED
@@ -1,252 +1,280 @@
|
|
1
|
-
from typing import Any
|
2
|
-
from enum import Enum
|
3
|
-
import pygame
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
class Action:
|
8
|
-
def __init__(self, name: str) -> None:
|
9
|
-
"""
|
10
|
-
Create a new action with the given name.
|
11
|
-
|
12
|
-
Args:
|
13
|
-
name (str): The name of the action.
|
14
|
-
"""
|
15
|
-
self.
|
16
|
-
self.
|
17
|
-
self.
|
18
|
-
self.
|
19
|
-
self.
|
20
|
-
self.
|
21
|
-
self.
|
22
|
-
self.
|
23
|
-
self.
|
24
|
-
self.
|
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
|
-
self.
|
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
|
-
return self
|
108
|
-
|
109
|
-
def
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
if
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
"""
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
if
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
if
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
"""
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
if
|
243
|
-
|
244
|
-
|
245
|
-
self.
|
246
|
-
|
247
|
-
def
|
248
|
-
"""
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
1
|
+
from typing import Any, Self
|
2
|
+
from enum import Enum
|
3
|
+
import pygame
|
4
|
+
from .enums import actionType
|
5
|
+
|
6
|
+
|
7
|
+
class Action:
|
8
|
+
def __init__(self, name: str) -> None:
|
9
|
+
"""
|
10
|
+
Create a new action with the given name.
|
11
|
+
|
12
|
+
Args:
|
13
|
+
name (str): The name of the action.
|
14
|
+
"""
|
15
|
+
self.name: str = name
|
16
|
+
self.active: bool = False
|
17
|
+
self.data: dict = {}
|
18
|
+
self.consume_event: bool = False
|
19
|
+
self._type: actionType = actionType.INSTANTANEOUS
|
20
|
+
self._key_control: set = set()
|
21
|
+
self._mouse_control: set = set()
|
22
|
+
self._event_control: set = set()
|
23
|
+
self._gamepad_button_control: set = set()
|
24
|
+
self._gamepad_axis_control: set = set()
|
25
|
+
self._holding = set()
|
26
|
+
|
27
|
+
def __bool__(self) -> bool :
|
28
|
+
return self.active
|
29
|
+
|
30
|
+
def set_consume_event(self, val: bool) -> Self:
|
31
|
+
"""
|
32
|
+
Set whether this action is unique (exclusive).
|
33
|
+
When in an action Container, unique actions -when active - break the propagation of their event to other actions.
|
34
|
+
|
35
|
+
Args:
|
36
|
+
val (bool): True if the action is unique, False otherwise.
|
37
|
+
"""
|
38
|
+
self.consume_event = val
|
39
|
+
return self
|
40
|
+
|
41
|
+
def set_active(self, value: bool) -> None:
|
42
|
+
"""
|
43
|
+
Set the action's active state.
|
44
|
+
|
45
|
+
Args:
|
46
|
+
value (bool): True to activate the action, False to deactivate it.
|
47
|
+
"""
|
48
|
+
self.active = value
|
49
|
+
|
50
|
+
|
51
|
+
def add_event_control(self, *events) -> Self:
|
52
|
+
self._event_control.update(events)
|
53
|
+
return self
|
54
|
+
|
55
|
+
def remove_event_control(self, *events) -> Self:
|
56
|
+
self._event_control = self._event_control - events
|
57
|
+
return self
|
58
|
+
|
59
|
+
def add_key_control(self, *keys) -> Self:
|
60
|
+
"""
|
61
|
+
Add key controls to the action.
|
62
|
+
|
63
|
+
Args:
|
64
|
+
*keys (int): Key codes to control this action.
|
65
|
+
|
66
|
+
Returns:
|
67
|
+
Action: The updated Action object for method chaining.
|
68
|
+
"""
|
69
|
+
self._key_control.update(keys)
|
70
|
+
return self
|
71
|
+
|
72
|
+
def remove_key_control(self, *keys: int) -> Self:
|
73
|
+
"""
|
74
|
+
Remove key controls to the action.
|
75
|
+
|
76
|
+
Args:
|
77
|
+
*keys (int): Key codes to control this action.
|
78
|
+
|
79
|
+
Returns:
|
80
|
+
Action: The updated Action object for method chaining.
|
81
|
+
"""
|
82
|
+
self._key_control = self._key_control - set(keys)
|
83
|
+
return self
|
84
|
+
|
85
|
+
def replace_key_control(self, key, new_key) -> Self:
|
86
|
+
if not key in self._key_control:
|
87
|
+
return self
|
88
|
+
self.remove_key_control(key)
|
89
|
+
self.add_key_control(new_key)
|
90
|
+
return self
|
91
|
+
|
92
|
+
def add_mouse_control(self, *mouse: int) -> Self:
|
93
|
+
"""
|
94
|
+
Add mouse control to the action.
|
95
|
+
|
96
|
+
Args:
|
97
|
+
*mouse_buttons (int): Mouse button codes to control this action.
|
98
|
+
|
99
|
+
Returns:
|
100
|
+
Action: The updated Action object for method chaining.
|
101
|
+
"""
|
102
|
+
self._mouse_control.update(mouse)
|
103
|
+
return self
|
104
|
+
|
105
|
+
def remove_mouse_control(self, *mouse: int) -> Self:
|
106
|
+
self._mouse_control = self._mouse_control - set(mouse)
|
107
|
+
return self
|
108
|
+
|
109
|
+
def replace_mouse_control(self, mouse, new_mouse) -> Self:
|
110
|
+
if not mouse in self._mouse_control:
|
111
|
+
return self
|
112
|
+
self.remove_mouse_control(mouse)
|
113
|
+
self.add_mouse_control(new_mouse)
|
114
|
+
return self
|
115
|
+
|
116
|
+
def set_continuous(self) -> Self:
|
117
|
+
"""
|
118
|
+
Set the action type to continuous.
|
119
|
+
|
120
|
+
Returns:
|
121
|
+
Action: The updated Action object for method chaining.
|
122
|
+
"""
|
123
|
+
self._holding = set()
|
124
|
+
self._type = actionType.CONTINUOUS
|
125
|
+
return self
|
126
|
+
|
127
|
+
def is_continuous(self) -> bool:
|
128
|
+
"""
|
129
|
+
Check if the action type is continuous.
|
130
|
+
|
131
|
+
Returns:
|
132
|
+
bool: True if the action type is continuous, False otherwise.
|
133
|
+
"""
|
134
|
+
return self._type == actionType.CONTINUOUS
|
135
|
+
|
136
|
+
def set_instantaneous(self) -> Self:
|
137
|
+
"""
|
138
|
+
Set the action type to instantaneous.
|
139
|
+
|
140
|
+
Returns:
|
141
|
+
Action: The updated Action object for method chaining.
|
142
|
+
"""
|
143
|
+
self._type = actionType.INSTANTANEOUS
|
144
|
+
self._holding = set()
|
145
|
+
return self
|
146
|
+
|
147
|
+
def is_instantaneous(self) -> bool:
|
148
|
+
"""
|
149
|
+
Check if the action type is instantaneous.
|
150
|
+
|
151
|
+
Returns:
|
152
|
+
bool: True if the action type is instantaneous, False otherwise.
|
153
|
+
"""
|
154
|
+
return self._type == actionType.INSTANTANEOUS
|
155
|
+
|
156
|
+
def set_holding(self) -> Self:
|
157
|
+
"""
|
158
|
+
Set the action type to holding.
|
159
|
+
|
160
|
+
Returns:
|
161
|
+
Action: The updated Action object for method chaining.
|
162
|
+
"""
|
163
|
+
self._type = actionType.HOLDING
|
164
|
+
return self
|
165
|
+
|
166
|
+
def is_holding_type(self) -> bool:
|
167
|
+
"""
|
168
|
+
Check if the action type is holding.
|
169
|
+
|
170
|
+
Returns:
|
171
|
+
bool: True if the action type is holding, False otherwise.
|
172
|
+
"""
|
173
|
+
return self._type == actionType.HOLDING
|
174
|
+
|
175
|
+
def process_update(self, event: pygame.Event) -> None:
|
176
|
+
if event.type in self._event_control:
|
177
|
+
self.data = event.dict
|
178
|
+
self.data.update({"type":event.type})
|
179
|
+
|
180
|
+
|
181
|
+
def process_activate(self, event: pygame.event.Event):
|
182
|
+
"""
|
183
|
+
Process activation of the action based on a pygame event.
|
184
|
+
|
185
|
+
Args:
|
186
|
+
event (pygame.event.Event): The pygame event to process.
|
187
|
+
|
188
|
+
Returns:
|
189
|
+
bool: True if the action was activated by the event, False otherwise.
|
190
|
+
"""
|
191
|
+
|
192
|
+
if event.type == pygame.KEYDOWN and event.key in self._key_control:
|
193
|
+
self._activate_action(event.key)
|
194
|
+
elif (
|
195
|
+
event.type == pygame.MOUSEBUTTONDOWN and event.button in self._mouse_control
|
196
|
+
):
|
197
|
+
self._activate_action(event.button)
|
198
|
+
|
199
|
+
elif event.type in self._event_control:
|
200
|
+
self._activate_action(event.type)
|
201
|
+
else:
|
202
|
+
return
|
203
|
+
|
204
|
+
self.data = event.dict
|
205
|
+
self.data.update({"type":event.type})
|
206
|
+
|
207
|
+
if self.consume_event:
|
208
|
+
event.consumed = True
|
209
|
+
|
210
|
+
def _activate_action(self, control):
|
211
|
+
self.active = True
|
212
|
+
if self._type == actionType.HOLDING:
|
213
|
+
self._holding.add(control)
|
214
|
+
|
215
|
+
def process_deactivate(self, event: pygame.event.Event):
|
216
|
+
"""
|
217
|
+
Process deactivation of the action based on a pygame event.
|
218
|
+
|
219
|
+
Args:
|
220
|
+
event (pygame.event.Event): The pygame event to process.
|
221
|
+
|
222
|
+
"""
|
223
|
+
if self._type == actionType.HOLDING:
|
224
|
+
if event.type == pygame.KEYUP and event.key in self._key_control:
|
225
|
+
self._deactivate_action(event.key)
|
226
|
+
elif (
|
227
|
+
event.type == pygame.MOUSEBUTTONUP
|
228
|
+
and event.button in self._mouse_control
|
229
|
+
):
|
230
|
+
self._deactivate_action(event.button)
|
231
|
+
elif event.type in self._event_control:
|
232
|
+
self._deactivate_action(event.type)
|
233
|
+
|
234
|
+
else:
|
235
|
+
event.consumed = False
|
236
|
+
return
|
237
|
+
|
238
|
+
if self.consume_event:
|
239
|
+
event.consumed = True
|
240
|
+
|
241
|
+
def _deactivate_action(self, control) -> bool:
|
242
|
+
if control in self._holding:
|
243
|
+
self._holding.remove(control)
|
244
|
+
if not self._holding:
|
245
|
+
self.active = False
|
246
|
+
|
247
|
+
def process_event(self, event: pygame.event.Event):
|
248
|
+
"""
|
249
|
+
Process a pygame event and update the action's state.
|
250
|
+
|
251
|
+
Args:
|
252
|
+
event (pygame.event.Event): The pygame event to process.
|
253
|
+
"""
|
254
|
+
|
255
|
+
if event.consumed:
|
256
|
+
return
|
257
|
+
if not self.active:
|
258
|
+
self.process_activate(event)
|
259
|
+
else:
|
260
|
+
self.process_deactivate(event)
|
261
|
+
if self.active:
|
262
|
+
self.process_update(event)
|
263
|
+
return
|
264
|
+
|
265
|
+
def reset(self) -> None:
|
266
|
+
"""
|
267
|
+
Reset the action's state to the default state.
|
268
|
+
"""
|
269
|
+
if self._type in {actionType.CONTINUOUS, actionType.HOLDING}:
|
270
|
+
return
|
271
|
+
elif self._type == actionType.INSTANTANEOUS:
|
272
|
+
self.active = False
|
273
|
+
|
274
|
+
def hard_reset(self) -> None:
|
275
|
+
"""
|
276
|
+
Hard reset the action, deactivating it and clearing any holding controls.
|
277
|
+
"""
|
278
|
+
self.active = False
|
279
|
+
self._holding = set()
|
280
|
+
self.data = {}
|