batframework 1.0.9a11__py3-none-any.whl → 1.1.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.
Files changed (76) hide show
  1. batFramework/__init__.py +52 -76
  2. batFramework/action.py +99 -126
  3. batFramework/actionContainer.py +9 -53
  4. batFramework/animatedSprite.py +114 -56
  5. batFramework/audioManager.py +36 -82
  6. batFramework/camera.py +69 -263
  7. batFramework/constants.py +53 -29
  8. batFramework/cutscene.py +109 -243
  9. batFramework/cutsceneBlocks.py +176 -0
  10. batFramework/debugger.py +48 -0
  11. batFramework/dynamicEntity.py +9 -16
  12. batFramework/easing.py +71 -0
  13. batFramework/entity.py +85 -92
  14. batFramework/gui/__init__.py +3 -14
  15. batFramework/gui/button.py +78 -12
  16. batFramework/gui/constraints.py +204 -0
  17. batFramework/gui/container.py +31 -188
  18. batFramework/gui/debugger.py +43 -126
  19. batFramework/gui/frame.py +19 -0
  20. batFramework/gui/image.py +20 -55
  21. batFramework/gui/indicator.py +22 -95
  22. batFramework/gui/interactiveWidget.py +12 -229
  23. batFramework/gui/label.py +77 -311
  24. batFramework/gui/layout.py +66 -414
  25. batFramework/gui/root.py +35 -203
  26. batFramework/gui/shape.py +57 -247
  27. batFramework/gui/toggle.py +48 -114
  28. batFramework/gui/widget.py +243 -457
  29. batFramework/manager.py +29 -113
  30. batFramework/particles.py +77 -0
  31. batFramework/scene.py +217 -22
  32. batFramework/sceneManager.py +129 -161
  33. batFramework/stateMachine.py +8 -11
  34. batFramework/time.py +75 -0
  35. batFramework/transition.py +124 -129
  36. batFramework/transitionManager.py +0 -0
  37. batFramework/triggerZone.py +4 -4
  38. batFramework/utils.py +144 -266
  39. {batframework-1.0.9a11.dist-info → batframework-1.1.0.dist-info}/METADATA +24 -22
  40. batframework-1.1.0.dist-info/RECORD +43 -0
  41. batFramework/animation.py +0 -77
  42. batFramework/baseScene.py +0 -240
  43. batFramework/cutsceneManager.py +0 -34
  44. batFramework/drawable.py +0 -77
  45. batFramework/easingController.py +0 -58
  46. batFramework/enums.py +0 -135
  47. batFramework/fontManager.py +0 -65
  48. batFramework/gui/animatedLabel.py +0 -89
  49. batFramework/gui/clickableWidget.py +0 -244
  50. batFramework/gui/constraints/__init__.py +0 -1
  51. batFramework/gui/constraints/constraints.py +0 -980
  52. batFramework/gui/draggableWidget.py +0 -44
  53. batFramework/gui/meter.py +0 -96
  54. batFramework/gui/radioButton.py +0 -35
  55. batFramework/gui/selector.py +0 -250
  56. batFramework/gui/slider.py +0 -397
  57. batFramework/gui/style.py +0 -10
  58. batFramework/gui/styleManager.py +0 -54
  59. batFramework/gui/syncedVar.py +0 -49
  60. batFramework/gui/textInput.py +0 -306
  61. batFramework/gui/tooltip.py +0 -30
  62. batFramework/particle.py +0 -118
  63. batFramework/propertyEaser.py +0 -79
  64. batFramework/renderGroup.py +0 -34
  65. batFramework/resourceManager.py +0 -130
  66. batFramework/sceneLayer.py +0 -138
  67. batFramework/scrollingSprite.py +0 -115
  68. batFramework/sprite.py +0 -51
  69. batFramework/templates/__init__.py +0 -1
  70. batFramework/templates/controller.py +0 -97
  71. batFramework/tileset.py +0 -46
  72. batFramework/timeManager.py +0 -213
  73. batframework-1.0.9a11.dist-info/RECORD +0 -67
  74. {batframework-1.0.9a11.dist-info → batframework-1.1.0.dist-info}/LICENSE +0 -0
  75. {batframework-1.0.9a11.dist-info → batframework-1.1.0.dist-info}/WHEEL +0 -0
  76. {batframework-1.0.9a11.dist-info → batframework-1.1.0.dist-info}/top_level.txt +0 -0
@@ -1,244 +0,0 @@
1
- import batFramework as bf
2
- from typing import Self, Callable, Any
3
- from .interactiveWidget import InteractiveWidget
4
- from .shape import Shape
5
- import pygame
6
-
7
-
8
- class ClickableWidget(Shape, InteractiveWidget):
9
- _cache: dict = {}
10
-
11
- def __init__(self, callback: Callable[[],Any] = None, *args, **kwargs) -> None:
12
- super().__init__(*args, **kwargs)
13
- self.callback = callback
14
- self.is_pressed: bool = False # the state where the button is being held down (releasing will trigger callback)
15
- self.is_enabled: bool = True #
16
- self.hover_cursor = bf.const.DEFAULT_HOVER_CURSOR
17
- self.click_cursor = bf.const.DEFAULT_CLICK_CURSOR
18
-
19
- self.click_down_sound = None
20
- self.click_up_sound = None
21
- self.get_focus_sound = None
22
- self.lose_focus_sound = None
23
-
24
- self.pressed_relief: int = 1 # Depth effect height when pressed
25
- self.unpressed_relief: int = 2 # Depth effect height when released (default)
26
- self.silent_focus: bool = False
27
- self.set_debug_color("cyan")
28
- self.set_relief(self.unpressed_relief)
29
-
30
-
31
- def get_min_required_size(self) -> tuple[float, float]:
32
- res = super().get_min_required_size()
33
- res = res[0],res[1]+self.unpressed_relief
34
- return res
35
-
36
- def set_unpressed_relief(self, relief: int) -> Self:
37
- if relief == self.unpressed_relief:
38
- return self
39
- self.unpressed_relief = relief
40
- self.dirty_shape = True
41
- if not self.is_pressed:
42
- self.set_relief(relief)
43
- return self
44
-
45
- def set_pressed_relief(self, relief: int) -> Self:
46
- if relief == self.pressed_relief:
47
- return self
48
- self.pressed_relief = relief
49
- self.dirty_shape = True
50
- if self.is_pressed:
51
- self.set_relief(relief)
52
- return self
53
-
54
- def set_silent_focus(self, value: bool) -> Self:
55
- self.silent_focus = value
56
- return self
57
-
58
- def set_click_down_sound(self, sound_name: str) -> Self:
59
- self.click_down_sound = sound_name
60
- return self
61
-
62
- def set_click_up_sound(self, sound_name: str) -> Self:
63
- self.click_up_sound = sound_name
64
- return self
65
-
66
- def set_get_focus_sound(self, sound_name: str) -> Self:
67
- self.get_focus_sound = sound_name
68
- return self
69
-
70
- def set_lose_focus_sound(self, sound_name: str) -> Self:
71
- self.lose_focus_sound = sound_name
72
- return self
73
-
74
- def set_hover_cursor(self, cursor: pygame.Cursor) -> Self:
75
- self.hover_cursor = cursor
76
- return self
77
-
78
- def set_click_cursor(self, cursor: pygame.Cursor) -> Self:
79
- self.click_cursor = cursor
80
- return self
81
-
82
- def get_surface_filter(self) -> pygame.Surface | None:
83
- size = int(self.rect.w), int(self.rect.h)
84
- surface_filter = ClickableWidget._cache.get((size, *self.border_radius), None)
85
- if surface_filter is None:
86
- # Create a mask from the original surface
87
- mask = pygame.mask.from_surface(self.surface, threshold=0)
88
-
89
- silhouette_surface = mask.to_surface(
90
- setcolor=(30, 30, 30), unsetcolor=(0, 0, 0)
91
- )
92
-
93
- ClickableWidget._cache[(size, *self.border_radius)] = silhouette_surface
94
-
95
- surface_filter = silhouette_surface
96
-
97
- return surface_filter
98
-
99
- def allow_focus_to_self(self) -> bool:
100
- return True
101
-
102
- def enable(self) -> Self:
103
- self.is_enabled = True
104
- self.dirty_surface = True
105
- return self
106
-
107
- def disable(self) -> Self:
108
- self.is_enabled = False
109
- self.dirty_surface = True
110
- return self
111
-
112
- def set_callback(self, callback: Callable[[],Any]) -> Self:
113
- self.callback = callback
114
- return self
115
-
116
- def on_get_focus(self):
117
- super().on_get_focus()
118
- if self.get_focus_sound and not self.silent_focus:
119
- if self.parent_scene and self.parent_scene.visible:
120
- bf.AudioManager().play_sound(self.get_focus_sound)
121
- if self.silent_focus:
122
- self.silent_focus = False
123
-
124
- def on_lose_focus(self):
125
- super().on_lose_focus()
126
- if self.lose_focus_sound and not self.silent_focus:
127
- if self.parent_scene and self.parent_scene.visible:
128
- bf.AudioManager().play_sound(self.lose_focus_sound)
129
- if self.silent_focus:
130
- self.silent_focus = False
131
-
132
- def __str__(self) -> str:
133
- return f"ClickableWidget"
134
-
135
- def click(self, force=False) -> None:
136
- if not self.is_enabled and not force:
137
- return False
138
- if self.callback is not None:
139
- self.callback()
140
- return True
141
- return False
142
-
143
- def on_key_down(self, key):
144
- if key == pygame.K_SPACE:
145
- self.on_click_down(1)
146
- return True
147
- return self.do_on_key_down(key)
148
-
149
- def on_key_up(self, key):
150
- if key == pygame.K_SPACE:
151
- self.on_click_up(1)
152
- return True
153
- return self.do_on_key_down(key)
154
-
155
-
156
- def on_click_down(self, button) -> bool:
157
- if button < 1 or button > 5 : return False
158
- self.is_clicked_down[button-1] = True
159
- if self.is_enabled and button == 1:
160
- if self.get_focus():
161
- self.is_pressed = True
162
- if self.click_down_sound:
163
- bf.AudioManager().play_sound(self.click_down_sound)
164
- pygame.mouse.set_cursor(self.click_cursor)
165
- self.set_relief(self.pressed_relief)
166
- self.do_on_click_down(button)
167
- return True
168
- return True
169
-
170
- def on_click_up(self, button):
171
- if button < 1 or button > 5 : return False
172
- self.is_clicked_down[button-1] = False
173
- if self.is_enabled and button == 1 and self.is_pressed:
174
- self.is_pressed = False
175
- if self.click_up_sound:
176
- bf.AudioManager().play_sound(self.click_up_sound)
177
- self.set_relief(self.unpressed_relief)
178
- self.click()
179
- self.do_on_click_up(button)
180
- return True
181
- return True
182
-
183
-
184
- def on_enter(self) -> None:
185
- if not self.is_enabled:
186
- return
187
- super().on_enter()
188
- self.dirty_surface = True
189
- pygame.mouse.set_cursor(self.hover_cursor)
190
-
191
- def on_exit(self) -> None:
192
- super().on_exit()
193
- if self.is_pressed:
194
- self.set_relief(self.unpressed_relief)
195
- self.is_pressed = False
196
- self.dirty_surface = True
197
- pygame.mouse.set_cursor(bf.const.DEFAULT_CURSOR)
198
-
199
- def on_lose_focus(self):
200
- super().on_lose_focus()
201
- self.on_exit()
202
-
203
- def _paint_disabled(self) -> None:
204
- self.surface.blit(
205
- self.get_surface_filter(), (0, 0), special_flags=pygame.BLEND_RGB_SUB
206
- )
207
-
208
- def _paint_hovered(self) -> None:
209
- self.surface.blit(
210
- self.get_surface_filter(), (0, 0), special_flags=pygame.BLEND_RGB_ADD
211
- )
212
-
213
- def get_inner_rect(self) -> pygame.FRect:
214
- return pygame.FRect(
215
- self.rect.x + self.padding[0],
216
- self.rect.y + self.padding[1] + (self.unpressed_relief - self.pressed_relief if self.is_pressed else 0),
217
- self.rect.w - self.padding[2] - self.padding[0],
218
- self.rect.h - self.unpressed_relief - self.padding[1] - self.padding[3],
219
- )
220
-
221
- def get_local_inner_rect(self) -> pygame.FRect:
222
- return pygame.FRect(
223
- self.padding[0],
224
- self.padding[1] + (self.unpressed_relief - self.pressed_relief if self.is_pressed else 0),
225
- self.rect.w - self.padding[2] - self.padding[0],
226
- self.rect.h - self.unpressed_relief - self.padding[1] - self.padding[3],
227
- )
228
-
229
-
230
- def _get_elevated_rect(self) -> pygame.FRect:
231
- return pygame.FRect(
232
- 0,
233
- self.unpressed_relief - self.pressed_relief if self.is_pressed else 0,
234
- self.rect.w,
235
- self.rect.h - self.unpressed_relief,
236
- )
237
-
238
- def paint(self) -> None:
239
- super().paint()
240
- if not self.is_enabled:
241
- self._paint_disabled()
242
- elif self.is_hovered:
243
- self._paint_hovered()
244
-
@@ -1 +0,0 @@
1
- from . import constraints