batframework 1.0.9a11__py3-none-any.whl → 1.0.9a12__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.
Files changed (73) hide show
  1. batFramework/__init__.py +2 -0
  2. batFramework/action.py +280 -279
  3. batFramework/actionContainer.py +105 -82
  4. batFramework/animatedSprite.py +80 -58
  5. batFramework/animation.py +91 -77
  6. batFramework/audioManager.py +156 -131
  7. batFramework/baseScene.py +249 -240
  8. batFramework/camera.py +245 -317
  9. batFramework/constants.py +57 -51
  10. batFramework/cutscene.py +239 -253
  11. batFramework/cutsceneManager.py +34 -34
  12. batFramework/drawable.py +107 -77
  13. batFramework/dynamicEntity.py +30 -30
  14. batFramework/easingController.py +58 -58
  15. batFramework/entity.py +130 -130
  16. batFramework/enums.py +171 -135
  17. batFramework/fontManager.py +65 -65
  18. batFramework/gui/__init__.py +28 -25
  19. batFramework/gui/animatedLabel.py +90 -89
  20. batFramework/gui/button.py +17 -17
  21. batFramework/gui/clickableWidget.py +244 -244
  22. batFramework/gui/collapseContainer.py +98 -0
  23. batFramework/gui/constraints/__init__.py +1 -1
  24. batFramework/gui/constraints/constraints.py +1066 -980
  25. batFramework/gui/container.py +220 -206
  26. batFramework/gui/debugger.py +140 -130
  27. batFramework/gui/draggableWidget.py +63 -44
  28. batFramework/gui/image.py +61 -58
  29. batFramework/gui/indicator.py +116 -113
  30. batFramework/gui/interactiveWidget.py +243 -239
  31. batFramework/gui/label.py +147 -344
  32. batFramework/gui/layout.py +442 -429
  33. batFramework/gui/meter.py +155 -96
  34. batFramework/gui/radioButton.py +43 -35
  35. batFramework/gui/root.py +228 -228
  36. batFramework/gui/scrollingContainer.py +282 -0
  37. batFramework/gui/selector.py +232 -250
  38. batFramework/gui/shape.py +286 -276
  39. batFramework/gui/slider.py +353 -397
  40. batFramework/gui/style.py +10 -10
  41. batFramework/gui/styleManager.py +49 -54
  42. batFramework/gui/syncedVar.py +43 -49
  43. batFramework/gui/textInput.py +331 -306
  44. batFramework/gui/textWidget.py +308 -0
  45. batFramework/gui/toggle.py +140 -128
  46. batFramework/gui/tooltip.py +35 -30
  47. batFramework/gui/widget.py +546 -521
  48. batFramework/manager.py +131 -134
  49. batFramework/particle.py +118 -118
  50. batFramework/propertyEaser.py +79 -79
  51. batFramework/renderGroup.py +34 -34
  52. batFramework/resourceManager.py +130 -130
  53. batFramework/scene.py +31 -31
  54. batFramework/sceneLayer.py +134 -138
  55. batFramework/sceneManager.py +200 -197
  56. batFramework/scrollingSprite.py +115 -115
  57. batFramework/sprite.py +46 -51
  58. batFramework/stateMachine.py +49 -54
  59. batFramework/templates/__init__.py +2 -1
  60. batFramework/templates/character.py +15 -0
  61. batFramework/templates/controller.py +158 -97
  62. batFramework/templates/stateMachine.py +39 -0
  63. batFramework/tileset.py +46 -46
  64. batFramework/timeManager.py +213 -213
  65. batFramework/transition.py +162 -162
  66. batFramework/triggerZone.py +22 -22
  67. batFramework/utils.py +306 -306
  68. {batframework-1.0.9a11.dist-info → batframework-1.0.9a12.dist-info}/LICENSE +20 -20
  69. {batframework-1.0.9a11.dist-info → batframework-1.0.9a12.dist-info}/METADATA +24 -17
  70. batframework-1.0.9a12.dist-info/RECORD +72 -0
  71. batframework-1.0.9a11.dist-info/RECORD +0 -67
  72. {batframework-1.0.9a11.dist-info → batframework-1.0.9a12.dist-info}/WHEEL +0 -0
  73. {batframework-1.0.9a11.dist-info → batframework-1.0.9a12.dist-info}/top_level.txt +0 -0
batFramework/__init__.py CHANGED
@@ -1,3 +1,5 @@
1
+ __version__="1.0.9a12"
2
+
1
3
  import os
2
4
  import pygame
3
5
  import json
batFramework/action.py CHANGED
@@ -1,279 +1,280 @@
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 set_consume_event(self, val: bool) -> Self:
28
- """
29
- Set whether this action is unique (exclusive).
30
- When in an action Container, unique actions -when active - break the propagation of their event to other actions.
31
-
32
- Args:
33
- val (bool): True if the action is unique, False otherwise.
34
- """
35
- self.consume_event = val
36
- return self
37
-
38
- def set_active(self, value: bool) -> None:
39
- """
40
- Set the action's active state.
41
-
42
- Args:
43
- value (bool): True to activate the action, False to deactivate it.
44
- """
45
- self.active = value
46
-
47
-
48
- def add_event_control(self, *events) -> Self:
49
- self._event_control.update(events)
50
- return self
51
-
52
- def remove_event_control(self, *events) -> Self:
53
- self._event_control = self._event_control - events
54
- return self
55
-
56
- def add_key_control(self, *keys) -> Self:
57
- """
58
- Add key controls to the action.
59
-
60
- Args:
61
- *keys (int): Key codes to control this action.
62
-
63
- Returns:
64
- Action: The updated Action object for method chaining.
65
- """
66
- self._key_control.update(keys)
67
- return self
68
-
69
- def remove_key_control(self, *keys: int) -> Self:
70
- """
71
- Remove key controls to the action.
72
-
73
- Args:
74
- *keys (int): Key codes to control this action.
75
-
76
- Returns:
77
- Action: The updated Action object for method chaining.
78
- """
79
- self._key_control = self._key_control - set(keys)
80
- return self
81
-
82
- def replace_key_control(self, key, new_key) -> Self:
83
- if not key in self._key_control:
84
- return self
85
- self.remove_key_control(key)
86
- self.add_key_control(new_key)
87
- return self
88
-
89
- def add_mouse_control(self, *mouse: int) -> Self:
90
- """
91
- Add mouse control to the action.
92
-
93
- Args:
94
- *mouse_buttons (int): Mouse button codes to control this action.
95
-
96
- Returns:
97
- Action: The updated Action object for method chaining.
98
- """
99
- self._mouse_control.update(mouse)
100
- return self
101
-
102
- def remove_mouse_control(self, *mouse: int) -> Self:
103
- self._mouse_control = self._mouse_control - set(mouse)
104
- return self
105
-
106
- def replace_mouse_control(self, mouse, new_mouse) -> Self:
107
- if not mouse in self._mouse_control:
108
- return self
109
- self.remove_mouse_control(mouse)
110
- self.add_mouse_control(new_mouse)
111
- return self
112
-
113
- def set_continuous(self) -> Self:
114
- """
115
- Set the action type to continuous.
116
-
117
- Returns:
118
- Action: The updated Action object for method chaining.
119
- """
120
- self._holding = set()
121
- self._type = actionType.CONTINUOUS
122
- return self
123
-
124
- def is_continuous(self) -> bool:
125
- """
126
- Check if the action type is continuous.
127
-
128
- Returns:
129
- bool: True if the action type is continuous, False otherwise.
130
- """
131
- return self._type == actionType.CONTINUOUS
132
-
133
- def set_instantaneous(self) -> Self:
134
- """
135
- Set the action type to instantaneous.
136
-
137
- Returns:
138
- Action: The updated Action object for method chaining.
139
- """
140
- self._type = actionType.INSTANTANEOUS
141
- self._holding = set()
142
- return self
143
-
144
- def is_instantaneous(self) -> bool:
145
- """
146
- Check if the action type is instantaneous.
147
-
148
- Returns:
149
- bool: True if the action type is instantaneous, False otherwise.
150
- """
151
- return self._type == actionType.INSTANTANEOUS
152
-
153
- def set_holding(self) -> Self:
154
- """
155
- Set the action type to holding.
156
-
157
- Returns:
158
- Action: The updated Action object for method chaining.
159
- """
160
- self._type = actionType.HOLDING
161
- return self
162
-
163
- def is_holding_type(self) -> bool:
164
- """
165
- Check if the action type is holding.
166
-
167
- Returns:
168
- bool: True if the action type is holding, False otherwise.
169
- """
170
- return self._type == actionType.HOLDING
171
-
172
- def process_update(self, event: pygame.Event) -> None:
173
- if (
174
- event.type == pygame.MOUSEMOTION
175
- and self._type == actionType.HOLDING
176
- and pygame.MOUSEMOTION in self._mouse_control
177
- ) or self._event_control:
178
- self.data = event.dict
179
-
180
- def process_activate(self, event: pygame.event.Event):
181
- """
182
- Process activation of the action based on a pygame event.
183
-
184
- Args:
185
- event (pygame.event.Event): The pygame event to process.
186
-
187
- Returns:
188
- bool: True if the action was activated by the event, False otherwise.
189
- """
190
-
191
- if event.type == pygame.KEYDOWN and event.key in self._key_control:
192
- self._activate_action(event.key)
193
-
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 == pygame.MOUSEMOTION and event.type in self._mouse_control:
200
- self._activate_action(event.type)
201
-
202
- elif event.type in self._event_control:
203
- self._activate_action(event.type)
204
- self.data = event.dict
205
- else:
206
- return
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 == pygame.MOUSEMOTION and event.type in self._mouse_control:
232
- self._deactivate_action(event.type)
233
- elif event.type in self._event_control:
234
- self._deactivate_action(event.type)
235
- else:
236
- event.consumed = False
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()
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 = {}