batframework 1.0.9a1__tar.gz → 1.0.9a3__tar.gz
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-1.0.9a1 → batframework-1.0.9a3}/PKG-INFO +1 -1
- {batframework-1.0.9a1 → batframework-1.0.9a3}/pyproject.toml +1 -1
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/__init__.py +2 -1
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/audioManager.py +1 -1
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/easingController.py +3 -2
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/button.py +2 -2
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/clickableWidget.py +12 -5
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/constraints/constraints.py +4 -4
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/container.py +1 -1
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/debugger.py +6 -6
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/image.py +6 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/indicator.py +2 -2
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/layout.py +1 -1
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/radioButton.py +2 -2
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/root.py +9 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/slider.py +4 -2
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/styleManager.py +6 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/textInput.py +3 -5
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/toggle.py +4 -3
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/widget.py +19 -12
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/timeManager.py +2 -3
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/transition.py +8 -8
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/triggerZone.py +3 -3
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/utils.py +0 -1
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batframework.egg-info/PKG-INFO +1 -1
- {batframework-1.0.9a1 → batframework-1.0.9a3}/LICENCE +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/README.md +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/setup.cfg +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/action.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/actionContainer.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/animatedSprite.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/animation.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/camera.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/character.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/constants.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/cutscene.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/cutsceneBlocks.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/drawable.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/dynamicEntity.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/entity.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/enums.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/fontManager.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/__init__.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/animatedLabel.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/constraints/__init__.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/draggableWidget.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/interactiveWidget.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/label.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/meter.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/shape.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/style.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/manager.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/particle.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/renderGroup.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/resourceManager.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/scene.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/sceneManager.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/scrollingSprite.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/sprite.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/stateMachine.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/templates/__init__.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/templates/character.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/templates/states.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/tileset.py +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batframework.egg-info/SOURCES.txt +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batframework.egg-info/dependency_links.txt +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batframework.egg-info/requires.txt +0 -0
- {batframework-1.0.9a1 → batframework-1.0.9a3}/src/batframework.egg-info/top_level.txt +0 -0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "batframework"
|
7
|
-
version = "1.0.
|
7
|
+
version = "1.0.9a3"
|
8
8
|
description = "Pygame framework for making games easier."
|
9
9
|
readme = "README.md"
|
10
10
|
classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent",]
|
@@ -2,6 +2,7 @@ import pygame
|
|
2
2
|
import batFramework as bf
|
3
3
|
from functools import lru_cache
|
4
4
|
from .enums import easing
|
5
|
+
from typing import Callable,Any
|
5
6
|
|
6
7
|
|
7
8
|
@lru_cache(maxsize=None)
|
@@ -22,11 +23,11 @@ class EasingController(bf.Timer):
|
|
22
23
|
easing_function: easing = easing.LINEAR,
|
23
24
|
duration: float = 1,
|
24
25
|
update_callback=None,
|
25
|
-
end_callback=None,
|
26
|
+
end_callback: Callable[[],Any]=None,
|
26
27
|
loop: bool = False,
|
27
28
|
) -> None:
|
28
29
|
self.easing_function = easing_function
|
29
|
-
self.update_callback = update_callback
|
30
|
+
self.update_callback: Callable[[float],Any] = update_callback
|
30
31
|
self.value: float = 0.0
|
31
32
|
super().__init__(duration, end_callback, loop)
|
32
33
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
from .label import Label
|
2
2
|
import batFramework as bf
|
3
|
-
from typing import Self, Callable
|
3
|
+
from typing import Self, Callable,Any
|
4
4
|
from .clickableWidget import ClickableWidget
|
5
5
|
import pygame
|
6
6
|
from math import ceil
|
7
7
|
|
8
8
|
|
9
9
|
class Button(Label, ClickableWidget):
|
10
|
-
def __init__(self, text: str = "", callback:
|
10
|
+
def __init__(self, text: str = "", callback: Callable[[],Any] = None) -> None:
|
11
11
|
super().__init__(text=text)
|
12
12
|
self.set_callback(callback)
|
13
13
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from .label import Label
|
2
2
|
import batFramework as bf
|
3
|
-
from typing import Self, Callable
|
3
|
+
from typing import Self, Callable, Any
|
4
4
|
from .interactiveWidget import InteractiveWidget
|
5
5
|
from .shape import Shape
|
6
6
|
import pygame
|
@@ -10,7 +10,7 @@ from math import ceil
|
|
10
10
|
class ClickableWidget(Shape, InteractiveWidget):
|
11
11
|
_cache: dict = {}
|
12
12
|
|
13
|
-
def __init__(self, callback:
|
13
|
+
def __init__(self, callback: Callable[[],Any] = None, *args, **kwargs) -> None:
|
14
14
|
super().__init__(*args, **kwargs)
|
15
15
|
self.callback = callback
|
16
16
|
self.is_pressed: bool = False
|
@@ -28,8 +28,15 @@ class ClickableWidget(Shape, InteractiveWidget):
|
|
28
28
|
self.set_relief(self.unpressed_relief)
|
29
29
|
|
30
30
|
def get_min_required_size(self) -> tuple[float, float]:
|
31
|
-
|
32
|
-
|
31
|
+
if not (self.autoresize_w or self.autoresize_h):
|
32
|
+
return self.rect.size
|
33
|
+
|
34
|
+
res = super().get_min_required_size()
|
35
|
+
res = res[0],res[1]+self.unpressed_relief
|
36
|
+
print("hey",res)
|
37
|
+
return res[0] if self.autoresize_w else self.rect.w, (
|
38
|
+
res[1] if self.autoresize_h else self.rect.h
|
39
|
+
)
|
33
40
|
|
34
41
|
|
35
42
|
def set_unpressed_relief(self, relief: int) -> Self:
|
@@ -111,7 +118,7 @@ class ClickableWidget(Shape, InteractiveWidget):
|
|
111
118
|
def is_enabled(self) -> bool:
|
112
119
|
return self.enabled
|
113
120
|
|
114
|
-
def set_callback(self, callback: Callable) -> Self:
|
121
|
+
def set_callback(self, callback: Callable[[],Any]) -> Self:
|
115
122
|
self.callback = callback
|
116
123
|
return self
|
117
124
|
|
{batframework-1.0.9a1 → batframework-1.0.9a3}/src/batFramework/gui/constraints/constraints.py
RENAMED
@@ -41,16 +41,16 @@ class MinWidth(Constraint):
|
|
41
41
|
self.min_width = width
|
42
42
|
|
43
43
|
def on_removal(self, child_widget: Widget) -> None:
|
44
|
-
|
44
|
+
return
|
45
|
+
# child_widget.set_autoresize_w(False)
|
45
46
|
|
46
47
|
def evaluate(self, parent_widget, child_widget):
|
47
48
|
res = child_widget.rect.width >= self.min_width
|
48
|
-
if not res:
|
49
|
-
child_widget.set_autoresize_w(False)
|
49
|
+
# if not res:
|
50
|
+
# child_widget.set_autoresize_w(False)
|
50
51
|
return res
|
51
52
|
|
52
53
|
def apply_constraint(self, parent_widget, child_widget):
|
53
|
-
child_widget.set_autoresize_w(True)
|
54
54
|
child_widget.set_size((self.min_width, None))
|
55
55
|
|
56
56
|
def __eq__(self,other:"Constraint")->bool:
|
@@ -106,7 +106,7 @@ class Container(Shape, InteractiveWidget):
|
|
106
106
|
return self
|
107
107
|
|
108
108
|
def top_at(self, x: float | int, y: float | int) -> "None|Widget":
|
109
|
-
if self.
|
109
|
+
if self.rect.collidepoint(x, y):
|
110
110
|
for child in reversed(self.children):
|
111
111
|
result = child.top_at(x, y)
|
112
112
|
if result is not None:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from .label import Label
|
2
|
-
from typing import Self
|
2
|
+
from typing import Self,Callable,Any
|
3
3
|
import batFramework as bf
|
4
4
|
import pygame
|
5
5
|
|
@@ -11,8 +11,8 @@ def convert_to_int(*args):
|
|
11
11
|
class Debugger(Label):
|
12
12
|
def __init__(self) -> None:
|
13
13
|
super().__init__("")
|
14
|
-
self.static_data: dict = {}
|
15
|
-
self.dynamic_data: dict = {}
|
14
|
+
self.static_data: dict[str,Any] = {}
|
15
|
+
self.dynamic_data: dict[str,Callable[[],str]] = {}
|
16
16
|
self.refresh_rate = 10
|
17
17
|
self.refresh_counter: float = 0
|
18
18
|
self.add_tags("debugger")
|
@@ -26,18 +26,18 @@ class Debugger(Label):
|
|
26
26
|
self.static_data[key] = str(data)
|
27
27
|
self.update_text()
|
28
28
|
|
29
|
-
def add_dynamic(self, key: str, func) -> None:
|
29
|
+
def add_dynamic(self, key: str, func:Callable[[],str]) -> None:
|
30
30
|
self.dynamic_data[key] = func
|
31
31
|
self.update_text()
|
32
32
|
|
33
|
-
def remove_static(self, key) -> bool:
|
33
|
+
def remove_static(self, key:str) -> bool:
|
34
34
|
try:
|
35
35
|
self.static_data.pop(key)
|
36
36
|
return True
|
37
37
|
except KeyError:
|
38
38
|
return False
|
39
39
|
|
40
|
-
def remove_dynamic(self, key) -> bool:
|
40
|
+
def remove_dynamic(self, key:str) -> bool:
|
41
41
|
try:
|
42
42
|
self.dynamic_data.pop(key)
|
43
43
|
return True
|
@@ -37,6 +37,12 @@ class Image(Shape):
|
|
37
37
|
)
|
38
38
|
super().build()
|
39
39
|
|
40
|
+
def get_min_required_size(self) -> tuple[float, float]:
|
41
|
+
res = self.rect.size
|
42
|
+
return self.inflate_rect_by_padding((0, 0, *res)).size
|
43
|
+
|
44
|
+
|
45
|
+
|
40
46
|
|
41
47
|
def from_path(self, path: str) -> Self:
|
42
48
|
tmp = bf.ResourceManager().get_image(path, self.convert_alpha)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from .shape import Shape
|
2
|
-
from typing import Any, Self
|
2
|
+
from typing import Any, Self, Callable
|
3
3
|
import pygame
|
4
4
|
from .widget import Widget
|
5
5
|
from .interactiveWidget import InteractiveWidget
|
@@ -37,7 +37,7 @@ class ToggleIndicator(Indicator):
|
|
37
37
|
# TODO aspect ratio would be good right about here
|
38
38
|
# self.add_constraint(ConstraintAspectRatio(1))
|
39
39
|
|
40
|
-
def set_callback(self, callback) -> Self:
|
40
|
+
def set_callback(self, callback : Callable[[bool],Any]) -> Self:
|
41
41
|
self.callback = callback
|
42
42
|
return self
|
43
43
|
|
@@ -45,9 +45,9 @@ class RadioVariable:
|
|
45
45
|
def __init__(self) -> None:
|
46
46
|
self.buttons: list[RadioButton] = []
|
47
47
|
self.value = None
|
48
|
-
self.modify_callback: Callable[[
|
48
|
+
self.modify_callback: Callable[[bool],Any] = None
|
49
49
|
|
50
|
-
def set_modify_callback(self, callback) -> Self:
|
50
|
+
def set_modify_callback(self, callback:Callable[[bool],Any]) -> Self:
|
51
51
|
self.modify_callback = callback
|
52
52
|
return self
|
53
53
|
|
@@ -138,6 +138,15 @@ class Root(InteractiveWidget):
|
|
138
138
|
if self.hovered and isinstance(self.hovered, InteractiveWidget):
|
139
139
|
self.hovered.on_enter()
|
140
140
|
|
141
|
+
def apply_updates(self):
|
142
|
+
if any(child.dirty_shape for child in self.children):
|
143
|
+
self.dirty_shape = True # Mark layout as dirty if any child changed size
|
144
|
+
|
145
|
+
if self.dirty_shape:
|
146
|
+
for child in self.children:
|
147
|
+
child.apply_updates()
|
148
|
+
self.dirty_shape = False
|
149
|
+
|
141
150
|
def draw(self, camera: bf.Camera) -> None:
|
142
151
|
super().draw(camera)
|
143
152
|
if (
|
@@ -66,7 +66,7 @@ class Slider(Button):
|
|
66
66
|
super().__init__(text, None)
|
67
67
|
self.gap: float | int = 0
|
68
68
|
self.spacing: bf.spacing = bf.spacing.MANUAL
|
69
|
-
self.modified_callback = None
|
69
|
+
self.modified_callback : Callable[[float],Any] = None
|
70
70
|
self.meter: SliderMeter = SliderMeter()
|
71
71
|
self.handle = SliderHandle()
|
72
72
|
self.add(self.meter, self.handle)
|
@@ -102,7 +102,7 @@ class Slider(Button):
|
|
102
102
|
self.dirty_shape = True
|
103
103
|
return self
|
104
104
|
|
105
|
-
def set_modify_callback(self, callback) -> Self:
|
105
|
+
def set_modify_callback(self, callback : Callable[[float],Any]) -> Self:
|
106
106
|
self.modified_callback = callback
|
107
107
|
return self
|
108
108
|
|
@@ -175,6 +175,7 @@ class Slider(Button):
|
|
175
175
|
if not self.text_rect:
|
176
176
|
self.text_rect.size = self._get_text_rect_required_size()
|
177
177
|
w, h = self.text_rect.size
|
178
|
+
h+=self.unpressed_relief
|
178
179
|
return self.inflate_rect_by_padding((0, 0, w + gap + self.meter.get_min_required_size()[1], h)).size
|
179
180
|
|
180
181
|
def _build_layout(self) -> None:
|
@@ -198,6 +199,7 @@ class Slider(Button):
|
|
198
199
|
|
199
200
|
if self.autoresize_h or self.autoresize_w:
|
200
201
|
target_rect = self.inflate_rect_by_padding(joined_rect)
|
202
|
+
target_rect.h += self.unpressed_relief
|
201
203
|
if not self.autoresize_w:
|
202
204
|
target_rect.w = self.rect.w
|
203
205
|
if not self.autoresize_h:
|
@@ -39,6 +39,12 @@ class StyleManager(metaclass=Singleton):
|
|
39
39
|
self.lookup = {key: False for key in self.lookup}
|
40
40
|
self.update()
|
41
41
|
|
42
|
+
def update_forced(self):
|
43
|
+
for widget in self.widgets:
|
44
|
+
for style in self.styles:
|
45
|
+
style.apply(widget)
|
46
|
+
self.lookup[widget] = True
|
47
|
+
|
42
48
|
def update(self):
|
43
49
|
for widget in self.widgets:
|
44
50
|
if self.lookup[widget]:
|
@@ -140,7 +140,7 @@ class TextInput(Label, InteractiveWidget):
|
|
140
140
|
lines = self.text.split('\n')
|
141
141
|
line_x, line_y = self.cursor_position
|
142
142
|
|
143
|
-
height = self.font_object.
|
143
|
+
height = self.font_object.get_linesize()
|
144
144
|
|
145
145
|
cursor_y = self.get_padded_rect().__getattribute__(self.alignment.value)[1] - self.rect.top
|
146
146
|
cursor_y += line_y * height
|
@@ -248,10 +248,8 @@ class TextInput(Label, InteractiveWidget):
|
|
248
248
|
return
|
249
249
|
cursor_rect = self.get_cursor_rect()
|
250
250
|
cursor_rect.move_ip(-self.scroll)
|
251
|
-
|
252
251
|
|
253
252
|
pygame.draw.rect(self.surface, bf.color.CLOUD, cursor_rect.inflate(2,2))
|
254
|
-
|
255
253
|
pygame.draw.rect(self.surface, self.text_color, cursor_rect)
|
256
254
|
|
257
255
|
def paint(self) -> None:
|
@@ -272,9 +270,9 @@ class TextInput(Label, InteractiveWidget):
|
|
272
270
|
|
273
271
|
|
274
272
|
if cursor_rect.right > area.right+self.scroll.x:
|
275
|
-
self.scroll.x=cursor_rect.right - area.right
|
273
|
+
self.scroll.x=cursor_rect.right - area.right - cursor_rect.w*2
|
276
274
|
elif cursor_rect.x < self.scroll.x+area.left:
|
277
|
-
self.scroll.x= cursor_rect.left - area.left
|
275
|
+
self.scroll.x= cursor_rect.left - area.left
|
278
276
|
self.scroll.x = max(self.scroll.x,0)
|
279
277
|
|
280
278
|
if cursor_rect.bottom > area.bottom + self.scroll.y:
|
@@ -1,12 +1,12 @@
|
|
1
1
|
from .button import Button
|
2
2
|
from .indicator import Indicator, ToggleIndicator
|
3
3
|
import batFramework as bf
|
4
|
-
from typing import Self
|
4
|
+
from typing import Self,Callable,Any
|
5
5
|
import pygame
|
6
6
|
|
7
7
|
|
8
8
|
class Toggle(Button):
|
9
|
-
def __init__(self, text: str = "", callback=None, default_value: bool = False) -> None:
|
9
|
+
def __init__(self, text: str = "", callback : Callable[[bool],Any]=None, default_value: bool = False) -> None:
|
10
10
|
self.value: bool = default_value
|
11
11
|
self.indicator: ToggleIndicator = ToggleIndicator(default_value)
|
12
12
|
self.gap: float | int = 0
|
@@ -59,7 +59,7 @@ class Toggle(Button):
|
|
59
59
|
self.indicator.get_min_required_size()[0],
|
60
60
|
self.text_rect.w + self.font_object.point_size + (self.gap if self.text else 0),
|
61
61
|
),
|
62
|
-
self.text_rect.h,
|
62
|
+
self.text_rect.h+self.unpressed_relief,
|
63
63
|
)
|
64
64
|
return self.inflate_rect_by_padding((0, 0, *size)).size
|
65
65
|
|
@@ -78,6 +78,7 @@ class Toggle(Button):
|
|
78
78
|
|
79
79
|
if self.autoresize_h or self.autoresize_w:
|
80
80
|
target_rect = self.inflate_rect_by_padding(joined_rect)
|
81
|
+
target_rect.h += self.unpressed_relief
|
81
82
|
if not self.autoresize_w:
|
82
83
|
target_rect.w = self.rect.w
|
83
84
|
if not self.autoresize_h:
|
@@ -174,11 +174,11 @@ class Widget(bf.Drawable, metaclass=WidgetMeta):
|
|
174
174
|
return self.rect.bottom - self.padding[3]
|
175
175
|
|
176
176
|
def get_debug_outlines(self):
|
177
|
-
if
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
177
|
+
if self.visible:
|
178
|
+
if any(self.padding):
|
179
|
+
yield (self.get_padded_rect(), self.debug_color)
|
180
|
+
else:
|
181
|
+
yield (self.rect, self.debug_color)
|
182
182
|
for child in self.children:
|
183
183
|
yield from child.get_debug_outlines()
|
184
184
|
|
@@ -272,11 +272,11 @@ class Widget(bf.Drawable, metaclass=WidgetMeta):
|
|
272
272
|
def top_at(self, x: float | int, y: float | int) -> "None|Widget":
|
273
273
|
if self.children:
|
274
274
|
for child in reversed(self.children):
|
275
|
-
if child.visible:
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
return self if
|
275
|
+
# if child.visible:
|
276
|
+
r = child.top_at(x, y)
|
277
|
+
if r is not None:
|
278
|
+
return r
|
279
|
+
return self if self.rect.collidepoint(x, y) else None
|
280
280
|
|
281
281
|
def add(self, *children: "Widget") -> Self:
|
282
282
|
self.children.extend(children)
|
@@ -387,20 +387,27 @@ class Widget(bf.Drawable, metaclass=WidgetMeta):
|
|
387
387
|
|
388
388
|
|
389
389
|
def apply_updates(self) -> None:
|
390
|
-
|
390
|
+
|
391
|
+
if self.dirty_constraints:
|
392
|
+
self.resolve_constraints() # Finalize positioning based on final size
|
393
|
+
self.dirty_constraints = False
|
394
|
+
|
395
|
+
# Build shape if needed
|
391
396
|
if self.dirty_shape:
|
392
397
|
self.build() # Finalize widget size
|
393
398
|
self.dirty_shape = False
|
394
399
|
self.dirty_surface = True
|
400
|
+
self.dirty_constraints = True
|
395
401
|
# Propagate dirty_constraints to children in case size affects their position
|
396
402
|
for child in self.children:
|
397
403
|
child.dirty_constraints = True
|
398
404
|
|
399
|
-
#
|
405
|
+
# Resolve constraints now that size is finalized
|
400
406
|
if self.dirty_constraints:
|
401
407
|
self.resolve_constraints() # Finalize positioning based on final size
|
402
408
|
self.dirty_constraints = False
|
403
409
|
|
410
|
+
|
404
411
|
# Step 3: Paint the surface if flagged as dirty
|
405
412
|
if self.dirty_surface:
|
406
413
|
self.paint()
|
@@ -1,13 +1,12 @@
|
|
1
1
|
import batFramework as bf
|
2
|
-
from typing import Self
|
3
|
-
from typing import Callable, Union, Self
|
2
|
+
from typing import Callable, Union, Self,Any
|
4
3
|
|
5
4
|
|
6
5
|
class Timer:
|
7
6
|
_count: int = 0
|
8
7
|
_available_ids: set[int] = set()
|
9
8
|
|
10
|
-
def __init__(self, duration: Union[float, int], end_callback: Callable, loop: bool = False, register: str = "global") -> None:
|
9
|
+
def __init__(self, duration: Union[float, int], end_callback: Callable[[],Any], loop: bool = False, register: str = "global") -> None:
|
11
10
|
if Timer._available_ids:
|
12
11
|
self.uid = Timer._available_ids.pop()
|
13
12
|
else:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import batFramework as bf
|
2
|
-
from typing import Self
|
2
|
+
from typing import Self,Callable,Any
|
3
3
|
import pygame
|
4
4
|
|
5
5
|
"""
|
@@ -23,24 +23,24 @@ class Transition:
|
|
23
23
|
update_callback=self.update,
|
24
24
|
end_callback=self.end,
|
25
25
|
)
|
26
|
-
self.start_callback = None
|
27
|
-
self.update_callback = None
|
28
|
-
self.end_callback = None
|
26
|
+
self.start_callback : Callable[[],Any] = None
|
27
|
+
self.update_callback : Callable[[float],Any]= None
|
28
|
+
self.end_callback : Callable[[],Any]= None
|
29
29
|
self.source: pygame.Surface = None
|
30
30
|
self.dest: pygame.Surface = None
|
31
31
|
|
32
32
|
def __repr__(self) -> str:
|
33
33
|
return f"Transition {self.__class__},{self.duration}"
|
34
34
|
|
35
|
-
def set_start_callback(self, func) -> Self:
|
35
|
+
def set_start_callback(self, func : Callable[[],Any]) -> Self:
|
36
36
|
self.start_callback = func
|
37
37
|
return self
|
38
38
|
|
39
|
-
def set_update_callback(self, func) -> Self:
|
39
|
+
def set_update_callback(self, func : Callable[[float],Any]) -> Self:
|
40
40
|
self.update_callback = func
|
41
41
|
return self
|
42
42
|
|
43
|
-
def set_end_callback(self, func) -> Self:
|
43
|
+
def set_end_callback(self, func : Callable[[],Any]) -> Self:
|
44
44
|
self.end_callback = func
|
45
45
|
return self
|
46
46
|
|
@@ -118,7 +118,7 @@ class FadeColor(Transition):
|
|
118
118
|
def transition_to_end(self):
|
119
119
|
self.next_step(self.end)
|
120
120
|
|
121
|
-
def next_step(self, callback=None) -> None:
|
121
|
+
def next_step(self, callback : Callable[[],Any]=None) -> None:
|
122
122
|
self.index += 1
|
123
123
|
if callback:
|
124
124
|
callback()
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import batFramework as bf
|
2
|
-
|
2
|
+
from typing import Callable,Any
|
3
3
|
|
4
4
|
class TriggerZone(bf.Entity):
|
5
|
-
def __init__(self, size, trigger, callback, active=True) -> None:
|
5
|
+
def __init__(self, size, trigger, callback: Callable[[Any],Any], active=True) -> None:
|
6
6
|
super().__init__(size, True)
|
7
7
|
self.set_debug_color(bf.color.RED)
|
8
8
|
self.active = active
|
@@ -13,7 +13,7 @@ class TriggerZone(bf.Entity):
|
|
13
13
|
self.trigger = trigger
|
14
14
|
return self
|
15
15
|
|
16
|
-
def set_callback(self, callback):
|
16
|
+
def set_callback(self, callback: Callable[[Any],Any]):
|
17
17
|
self.callback = callback
|
18
18
|
return self
|
19
19
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{batframework-1.0.9a1 → batframework-1.0.9a3}/src/batframework.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|