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.
- batFramework/__init__.py +2 -0
- batFramework/action.py +280 -279
- batFramework/actionContainer.py +105 -82
- batFramework/animatedSprite.py +80 -58
- batFramework/animation.py +91 -77
- batFramework/audioManager.py +156 -131
- batFramework/baseScene.py +249 -240
- batFramework/camera.py +245 -317
- batFramework/constants.py +57 -51
- batFramework/cutscene.py +239 -253
- batFramework/cutsceneManager.py +34 -34
- batFramework/drawable.py +107 -77
- batFramework/dynamicEntity.py +30 -30
- batFramework/easingController.py +58 -58
- batFramework/entity.py +130 -130
- batFramework/enums.py +171 -135
- batFramework/fontManager.py +65 -65
- batFramework/gui/__init__.py +28 -25
- batFramework/gui/animatedLabel.py +90 -89
- batFramework/gui/button.py +17 -17
- batFramework/gui/clickableWidget.py +244 -244
- batFramework/gui/collapseContainer.py +98 -0
- batFramework/gui/constraints/__init__.py +1 -1
- batFramework/gui/constraints/constraints.py +1066 -980
- batFramework/gui/container.py +220 -206
- batFramework/gui/debugger.py +140 -130
- batFramework/gui/draggableWidget.py +63 -44
- batFramework/gui/image.py +61 -58
- batFramework/gui/indicator.py +116 -113
- batFramework/gui/interactiveWidget.py +243 -239
- batFramework/gui/label.py +147 -344
- batFramework/gui/layout.py +442 -429
- batFramework/gui/meter.py +155 -96
- batFramework/gui/radioButton.py +43 -35
- batFramework/gui/root.py +228 -228
- batFramework/gui/scrollingContainer.py +282 -0
- batFramework/gui/selector.py +232 -250
- batFramework/gui/shape.py +286 -276
- batFramework/gui/slider.py +353 -397
- batFramework/gui/style.py +10 -10
- batFramework/gui/styleManager.py +49 -54
- batFramework/gui/syncedVar.py +43 -49
- batFramework/gui/textInput.py +331 -306
- batFramework/gui/textWidget.py +308 -0
- batFramework/gui/toggle.py +140 -128
- batFramework/gui/tooltip.py +35 -30
- batFramework/gui/widget.py +546 -521
- batFramework/manager.py +131 -134
- batFramework/particle.py +118 -118
- batFramework/propertyEaser.py +79 -79
- batFramework/renderGroup.py +34 -34
- batFramework/resourceManager.py +130 -130
- batFramework/scene.py +31 -31
- batFramework/sceneLayer.py +134 -138
- batFramework/sceneManager.py +200 -197
- batFramework/scrollingSprite.py +115 -115
- batFramework/sprite.py +46 -51
- batFramework/stateMachine.py +49 -54
- batFramework/templates/__init__.py +2 -1
- batFramework/templates/character.py +15 -0
- batFramework/templates/controller.py +158 -97
- batFramework/templates/stateMachine.py +39 -0
- batFramework/tileset.py +46 -46
- batFramework/timeManager.py +213 -213
- batFramework/transition.py +162 -162
- batFramework/triggerZone.py +22 -22
- batFramework/utils.py +306 -306
- {batframework-1.0.9a11.dist-info → batframework-1.0.9a12.dist-info}/LICENSE +20 -20
- {batframework-1.0.9a11.dist-info → batframework-1.0.9a12.dist-info}/METADATA +24 -17
- batframework-1.0.9a12.dist-info/RECORD +72 -0
- batframework-1.0.9a11.dist-info/RECORD +0 -67
- {batframework-1.0.9a11.dist-info → batframework-1.0.9a12.dist-info}/WHEEL +0 -0
- {batframework-1.0.9a11.dist-info → batframework-1.0.9a12.dist-info}/top_level.txt +0 -0
batFramework/gui/meter.py
CHANGED
@@ -1,96 +1,155 @@
|
|
1
|
-
import math
|
2
|
-
import batFramework as bf
|
3
|
-
from .shape import Shape
|
4
|
-
from typing import Self
|
5
|
-
|
6
|
-
|
7
|
-
def custom_top_at(self, x, y):
|
8
|
-
if Shape.top_at(self, x, y) == self:
|
9
|
-
return self.parent
|
10
|
-
return None
|
11
|
-
|
12
|
-
class Meter(Shape):
|
13
|
-
def __init__(self, min_value: float = 0, max_value: float =
|
14
|
-
super().__init__()
|
15
|
-
self.min_value, self.max_value = min_value, max_value
|
16
|
-
self.step = step
|
17
|
-
self.snap: bool = False
|
18
|
-
self.
|
19
|
-
self.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
self.
|
34
|
-
self.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
self.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
self.
|
60
|
-
|
61
|
-
|
62
|
-
self.
|
63
|
-
|
64
|
-
|
65
|
-
self.
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
def
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
self.
|
96
|
-
|
1
|
+
import math
|
2
|
+
import batFramework as bf
|
3
|
+
from .shape import Shape
|
4
|
+
from typing import Self
|
5
|
+
from .syncedVar import SyncedVar
|
6
|
+
|
7
|
+
def custom_top_at(self, x, y):
|
8
|
+
if Shape.top_at(self, x, y) == self:
|
9
|
+
return self.parent
|
10
|
+
return None
|
11
|
+
|
12
|
+
class Meter(Shape):
|
13
|
+
def __init__(self, min_value: float = 0, max_value: float = None, step: float = 0.1, synced_var: SyncedVar = None):
|
14
|
+
super().__init__()
|
15
|
+
self.min_value, self.max_value = min_value, max_value
|
16
|
+
self.step = step
|
17
|
+
self.snap: bool = False
|
18
|
+
self.synced_var = synced_var or SyncedVar(min_value)
|
19
|
+
if self.max_value is None:
|
20
|
+
self.max_value = self.synced_var.value
|
21
|
+
self.synced_var.bind(self, self._on_synced_var_update)
|
22
|
+
self.set_debug_color("pink")
|
23
|
+
|
24
|
+
def __str__(self) -> str:
|
25
|
+
return "Meter"
|
26
|
+
|
27
|
+
def set_snap(self,snap:bool)->Self:
|
28
|
+
self.snap = snap
|
29
|
+
self.set_value(self.get_value())
|
30
|
+
return self
|
31
|
+
|
32
|
+
def set_step(self, step: float) -> Self:
|
33
|
+
self.step = step
|
34
|
+
self.set_value(self.get_value())
|
35
|
+
return self
|
36
|
+
|
37
|
+
def set_range(self, range_min: float, range_max: float) -> Self:
|
38
|
+
if range_min >= range_max:
|
39
|
+
return self
|
40
|
+
self.min_value = range_min
|
41
|
+
self.max_value = range_max
|
42
|
+
self.dirty_shape = True
|
43
|
+
return self
|
44
|
+
|
45
|
+
def set_value(self, value: float) -> Self:
|
46
|
+
"""
|
47
|
+
Sets the value of the meter and updates the synced variable.
|
48
|
+
"""
|
49
|
+
value = max(self.min_value, min(self.max_value, value))
|
50
|
+
value = round(value / self.step) * self.step
|
51
|
+
value = round(value, 10)
|
52
|
+
self.synced_var.value = value # Update the synced variable
|
53
|
+
return self
|
54
|
+
|
55
|
+
def get_value(self) -> float:
|
56
|
+
"""
|
57
|
+
Gets the current value from the synced variable.
|
58
|
+
"""
|
59
|
+
return self.synced_var.value
|
60
|
+
|
61
|
+
def get_range(self) -> float:
|
62
|
+
return self.max_value - self.min_value
|
63
|
+
|
64
|
+
def get_ratio(self) -> float:
|
65
|
+
if self.max_value <= self.min_value:
|
66
|
+
return 0
|
67
|
+
return (self.get_value() - self.min_value) / (self.max_value - self.min_value)
|
68
|
+
|
69
|
+
def _on_synced_var_update(self, value: float) -> None:
|
70
|
+
"""
|
71
|
+
Updates the meter's internal state when the synced variable changes.
|
72
|
+
"""
|
73
|
+
self.dirty_shape = True
|
74
|
+
|
75
|
+
def set_synced_var(self, synced_var: SyncedVar) -> Self:
|
76
|
+
"""
|
77
|
+
Rebinds the meter to a new SyncedVar.
|
78
|
+
"""
|
79
|
+
if self.synced_var:
|
80
|
+
self.synced_var.unbind(self)
|
81
|
+
self.synced_var = synced_var
|
82
|
+
self.synced_var.bind(self, self._on_synced_var_update)
|
83
|
+
return self
|
84
|
+
|
85
|
+
class BarMeter(Meter):
|
86
|
+
def __init__(self, min_value = 0, max_value = None, step = 0.1, synced_var = None):
|
87
|
+
super().__init__(min_value, max_value, step, synced_var)
|
88
|
+
self.axis: bf.axis = bf.axis.HORIZONTAL
|
89
|
+
self.direction = bf.direction.RIGHT # Direction determines which side is the max range
|
90
|
+
self.content = Shape((4, 4)).set_color(bf.color.BLUE)
|
91
|
+
self.content.set_debug_color("cyan")
|
92
|
+
self.content.top_at = lambda x, y: custom_top_at(self.content, x, y)
|
93
|
+
self.add(self.content)
|
94
|
+
self.set_padding(4)
|
95
|
+
self.set_color("gray20")
|
96
|
+
self.set_outline_width(1)
|
97
|
+
self.set_outline_color(bf.color.BLACK)
|
98
|
+
self.set_debug_color("pink")
|
99
|
+
|
100
|
+
def __str__(self) -> str:
|
101
|
+
return "BarMeter"
|
102
|
+
|
103
|
+
def set_direction(self, direction: bf.direction) -> Self:
|
104
|
+
"""
|
105
|
+
Sets the direction of the BarMeter.
|
106
|
+
"""
|
107
|
+
self.direction = direction
|
108
|
+
if self.axis == bf.axis.HORIZONTAL and self.direction in [bf.direction.UP, bf.direction.DOWN]:
|
109
|
+
self.set_axis(bf.axis.VERTICAL)
|
110
|
+
elif self.axis == bf.axis.VERTICAL and self.direction in [bf.direction.LEFT, bf.direction.RIGHT]:
|
111
|
+
self.set_axis(bf.axis.HORIZONTAL)
|
112
|
+
self.dirty_shape = True
|
113
|
+
return self
|
114
|
+
|
115
|
+
def set_axis(self,axis:bf.axis)->Self:
|
116
|
+
self.axis = axis
|
117
|
+
if axis==bf.axis.HORIZONTAL and self.direction not in [bf.direction.LEFT,bf.direction.RIGHT]:
|
118
|
+
self.direction = bf.direction.RIGHT
|
119
|
+
elif axis == bf.axis.VERTICAL and self.direction not in [bf.direction.UP, bf.direction.DOWN]:
|
120
|
+
self.direction = bf.direction.UP
|
121
|
+
|
122
|
+
self.dirty_shape = True
|
123
|
+
return self
|
124
|
+
|
125
|
+
def _build_content(self) -> None:
|
126
|
+
padded = self.get_inner_rect()
|
127
|
+
ratio = self.get_ratio()
|
128
|
+
|
129
|
+
self.content.set_border_radius(*[round(b / 2) for b in self.border_radius])
|
130
|
+
|
131
|
+
if self.axis == bf.axis.HORIZONTAL:
|
132
|
+
width = (padded.width - self.outline_width * 2) * ratio
|
133
|
+
width = max(width,0)
|
134
|
+
self.content.set_size((width, padded.height - self.outline_width * 2))
|
135
|
+
if self.direction == bf.direction.RIGHT:
|
136
|
+
self.content.rect.topleft = padded.move(self.outline_width, self.outline_width).topleft
|
137
|
+
else: # bf.direction.LEFT
|
138
|
+
self.content.rect.topright = padded.move(-self.outline_width, self.outline_width).topright
|
139
|
+
|
140
|
+
else: # vertical
|
141
|
+
height = (padded.height - self.outline_width * 2) * ratio
|
142
|
+
height = round(height)
|
143
|
+
height = max(height,0)
|
144
|
+
|
145
|
+
self.content.set_size((padded.width - self.outline_width * 2, height))
|
146
|
+
if self.direction == bf.direction.UP:
|
147
|
+
|
148
|
+
|
149
|
+
self.content.rect.bottomleft = (padded.left + self.outline_width, padded.bottom - self.outline_width)
|
150
|
+
else: # bf.direction.DOWN
|
151
|
+
self.content.rect.topleft = padded.move(self.outline_width, self.outline_width).topleft
|
152
|
+
|
153
|
+
def build(self) -> None:
|
154
|
+
self._build_content()
|
155
|
+
super().build()
|
batFramework/gui/radioButton.py
CHANGED
@@ -1,35 +1,43 @@
|
|
1
|
-
import batFramework as bf
|
2
|
-
from typing import Self, Any, Callable
|
3
|
-
from .toggle import Toggle
|
4
|
-
from .syncedVar import SyncedVar
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
if
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
return
|
22
|
-
|
23
|
-
def
|
24
|
-
self.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
1
|
+
import batFramework as bf
|
2
|
+
from typing import Self, Any, Callable
|
3
|
+
from .toggle import Toggle
|
4
|
+
from .syncedVar import SyncedVar
|
5
|
+
|
6
|
+
|
7
|
+
# TODO : RadioButton with no synced var ? click crashes
|
8
|
+
|
9
|
+
class RadioButton(Toggle):
|
10
|
+
def __init__(self, text: str, synced_var: SyncedVar, radio_value: Any = None) -> None:
|
11
|
+
super().__init__(text, None, False)
|
12
|
+
self.radio_value: Any = radio_value if radio_value is not None else text if text else None
|
13
|
+
self.synced_var : SyncedVar = synced_var
|
14
|
+
self.synced_var.bind(self,self._update_state)
|
15
|
+
|
16
|
+
def __str__(self) -> str:
|
17
|
+
return f"RadioButton({self.radio_value}|{'Active' if self.value else 'Inactive'})"
|
18
|
+
|
19
|
+
def set_radio_value(self, value: Any) -> Self:
|
20
|
+
self.radio_value = value
|
21
|
+
return self
|
22
|
+
|
23
|
+
def set_value(self, value : bool, do_callback=False):
|
24
|
+
if self.value == value:
|
25
|
+
return self # No change
|
26
|
+
self.value = value
|
27
|
+
self.indicator.set_value(value)
|
28
|
+
self.dirty_surface = True
|
29
|
+
|
30
|
+
# Update SyncedVar only if different (avoid recursion)
|
31
|
+
if value and self.synced_var.value != self.radio_value:
|
32
|
+
self.synced_var.value = self.radio_value
|
33
|
+
|
34
|
+
if do_callback and self.callback:
|
35
|
+
self.callback(self.value)
|
36
|
+
return self
|
37
|
+
# if value : self.synced_var.value = self.radio_value
|
38
|
+
|
39
|
+
def _update_state(self, synced_value: Any) -> None:
|
40
|
+
"""
|
41
|
+
Updates the state of the RadioButton based on the synced variable's value.
|
42
|
+
"""
|
43
|
+
self.set_value(self.radio_value == synced_value, False)
|