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