batframework 1.0.9a11__py3-none-any.whl → 1.0.10__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 +53 -76
- batFramework/action.py +99 -126
- batFramework/actionContainer.py +9 -53
- batFramework/animatedSprite.py +114 -56
- batFramework/audioManager.py +36 -82
- batFramework/camera.py +69 -263
- batFramework/constants.py +53 -29
- batFramework/cutscene.py +109 -243
- batFramework/cutsceneBlocks.py +176 -0
- batFramework/debugger.py +48 -0
- batFramework/dynamicEntity.py +9 -16
- batFramework/easing.py +71 -0
- batFramework/entity.py +85 -92
- batFramework/gui/__init__.py +3 -14
- batFramework/gui/button.py +78 -12
- batFramework/gui/constraints.py +204 -0
- batFramework/gui/container.py +31 -188
- batFramework/gui/debugger.py +43 -126
- batFramework/gui/frame.py +19 -0
- batFramework/gui/image.py +20 -55
- batFramework/gui/indicator.py +22 -95
- batFramework/gui/interactiveWidget.py +12 -229
- batFramework/gui/label.py +77 -311
- batFramework/gui/layout.py +66 -414
- batFramework/gui/root.py +35 -203
- batFramework/gui/shape.py +57 -247
- batFramework/gui/toggle.py +48 -114
- batFramework/gui/widget.py +243 -457
- batFramework/manager.py +29 -113
- batFramework/particles.py +77 -0
- batFramework/scene.py +217 -22
- batFramework/sceneManager.py +129 -161
- batFramework/stateMachine.py +8 -11
- batFramework/time.py +75 -0
- batFramework/transition.py +124 -129
- batFramework/transitionManager.py +0 -0
- batFramework/triggerZone.py +4 -4
- batFramework/utils.py +144 -266
- {batframework-1.0.9a11.dist-info → batframework-1.0.10.dist-info}/METADATA +24 -17
- batframework-1.0.10.dist-info/RECORD +43 -0
- batFramework/animation.py +0 -77
- batFramework/baseScene.py +0 -240
- batFramework/cutsceneManager.py +0 -34
- batFramework/drawable.py +0 -77
- batFramework/easingController.py +0 -58
- batFramework/enums.py +0 -135
- batFramework/fontManager.py +0 -65
- batFramework/gui/animatedLabel.py +0 -89
- batFramework/gui/clickableWidget.py +0 -244
- batFramework/gui/constraints/__init__.py +0 -1
- batFramework/gui/constraints/constraints.py +0 -980
- batFramework/gui/draggableWidget.py +0 -44
- batFramework/gui/meter.py +0 -96
- batFramework/gui/radioButton.py +0 -35
- batFramework/gui/selector.py +0 -250
- batFramework/gui/slider.py +0 -397
- batFramework/gui/style.py +0 -10
- batFramework/gui/styleManager.py +0 -54
- batFramework/gui/syncedVar.py +0 -49
- batFramework/gui/textInput.py +0 -306
- batFramework/gui/tooltip.py +0 -30
- batFramework/particle.py +0 -118
- batFramework/propertyEaser.py +0 -79
- batFramework/renderGroup.py +0 -34
- batFramework/resourceManager.py +0 -130
- batFramework/sceneLayer.py +0 -138
- batFramework/scrollingSprite.py +0 -115
- batFramework/sprite.py +0 -51
- batFramework/templates/__init__.py +0 -1
- batFramework/templates/controller.py +0 -97
- batFramework/tileset.py +0 -46
- batFramework/timeManager.py +0 -213
- batframework-1.0.9a11.dist-info/RECORD +0 -67
- {batframework-1.0.9a11.dist-info → batframework-1.0.10.dist-info}/LICENSE +0 -0
- {batframework-1.0.9a11.dist-info → batframework-1.0.10.dist-info}/WHEEL +0 -0
- {batframework-1.0.9a11.dist-info → batframework-1.0.10.dist-info}/top_level.txt +0 -0
batFramework/gui/toggle.py
CHANGED
@@ -1,128 +1,62 @@
|
|
1
1
|
from .button import Button
|
2
|
-
from .indicator import Indicator,
|
3
|
-
|
2
|
+
from .indicator import Indicator,ToggleIndicator
|
3
|
+
import pygame
|
4
4
|
import batFramework as bf
|
5
|
-
from typing import Self
|
5
|
+
from typing import Self
|
6
6
|
|
7
7
|
class Toggle(Button):
|
8
|
-
def __init__(self,
|
9
|
-
self.value:
|
10
|
-
self.
|
11
|
-
self.
|
12
|
-
self.
|
13
|
-
super().__init__(text,
|
14
|
-
self.
|
15
|
-
self.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def set_value(self, value: bool, do_callback=False) -> Self:
|
22
|
-
self.value = value
|
23
|
-
self.indicator.set_value(value)
|
24
|
-
self.dirty_surface = True
|
25
|
-
if do_callback and self.callback:
|
26
|
-
self.callback(self.value)
|
27
|
-
return self
|
28
|
-
|
29
|
-
def set_spacing(self, spacing: bf.spacing) -> Self:
|
30
|
-
if spacing == self.spacing:
|
31
|
-
return self
|
32
|
-
self.spacing = spacing
|
33
|
-
self.dirty_shape = True
|
34
|
-
return self
|
35
|
-
|
36
|
-
def click(self) -> None:
|
37
|
-
self.set_value(not self.value, True)
|
38
|
-
|
39
|
-
def set_gap(self, value: int | float) -> Self:
|
40
|
-
value = max(0, value)
|
41
|
-
if value == self.gap:
|
42
|
-
return self
|
8
|
+
def __init__(self,text:str,default_value : bool = False)->None:
|
9
|
+
self.value :bool= default_value
|
10
|
+
self.on_toggle = None
|
11
|
+
self.indicator : Indicator=ToggleIndicator(default_value)
|
12
|
+
self.gap :float|int = 0
|
13
|
+
super().__init__(text,self.toggle)
|
14
|
+
self.add_child(self.indicator)
|
15
|
+
self.set_gap(int(max(4,self.get_content_width()/3)))
|
16
|
+
# self.set_gap()
|
17
|
+
# self.set_gap(20)
|
18
|
+
|
19
|
+
def set_gap(self,value:int|float)->Self:
|
20
|
+
if value < 0 : return self
|
43
21
|
self.gap = value
|
44
|
-
self.
|
22
|
+
self.build()
|
23
|
+
if self.parent : self.parent.children_modified()
|
45
24
|
return self
|
46
|
-
|
47
|
-
def __str__(self) -> str:
|
25
|
+
def to_string_id(self)->str:
|
48
26
|
return f"Toggle({self.value})"
|
27
|
+
|
28
|
+
def toggle(self)->None:
|
29
|
+
self.value = not self.value
|
30
|
+
self.build()
|
31
|
+
if self.on_toggle : self.on_toggle(self.value)
|
49
32
|
|
50
|
-
def
|
51
|
-
self.
|
52
|
-
|
53
|
-
def get_min_required_size(self) -> tuple[float, float]:
|
54
|
-
if not self.text_rect:
|
55
|
-
self.text_rect.size = self._get_text_rect_required_size()
|
56
|
-
|
57
|
-
text_width, text_height = self.text_rect.size
|
58
|
-
indicator_size = self.indicator.get_min_required_size()[1]
|
59
|
-
gap = self.gap if self.text else 0
|
60
|
-
|
61
|
-
total_width = text_width + gap + indicator_size
|
62
|
-
total_height = text_height + self.unpressed_relief
|
63
|
-
|
64
|
-
return self.expand_rect_with_padding((0, 0, total_width, total_height)).size
|
65
|
-
|
66
|
-
def _build_composed_layout(self,other:Shape):
|
67
|
-
size_changed = False
|
68
|
-
self.text_rect.size = self._get_text_rect_required_size()
|
69
|
-
|
70
|
-
gap = self.gap if self.text else 0
|
71
|
-
full_rect = self.text_rect.copy()
|
33
|
+
def set_toggle_callback(self,callback)->Self:
|
34
|
+
self.on_toggle = callback
|
35
|
+
return self
|
72
36
|
|
73
|
-
|
74
|
-
|
37
|
+
def _build_layout(self)->None:
|
38
|
+
self.indicator.set_value(self.value)
|
75
39
|
|
76
|
-
|
77
|
-
|
40
|
+
size = (
|
41
|
+
0,
|
42
|
+
0,
|
43
|
+
self._text_rect.w + self.indicator.rect.w + self.gap,
|
44
|
+
max(self._text_rect.h, self.indicator.rect.h)
|
45
|
+
)
|
78
46
|
|
79
|
-
|
80
|
-
# take into account the relief when calculating target size
|
81
|
-
inflated = self.expand_rect_with_padding((0, 0, *full_rect.size)).size
|
82
|
-
target_size = self.resolve_size(inflated)
|
83
|
-
if self.rect.size != target_size:
|
84
|
-
self.set_size(target_size)
|
85
|
-
size_changed = True
|
86
|
-
|
87
|
-
self._align_composed(other)
|
88
|
-
return size_changed
|
89
|
-
|
90
|
-
def _align_composed(self,other:Shape):
|
47
|
+
required_rect = self.inflate_rect_by_padding(size)
|
91
48
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
gap = {
|
96
|
-
bf.spacing.MIN: 0,
|
97
|
-
bf.spacing.HALF: (full_rect.width - left_rect.width - right_rect.width) // 2,
|
98
|
-
bf.spacing.MAX: full_rect.width - left_rect.width - right_rect.width,
|
99
|
-
bf.spacing.MANUAL: self.gap
|
100
|
-
}.get(self.spacing, 0)
|
101
|
-
|
102
|
-
gap = max(0, gap)
|
103
|
-
combined_width = left_rect.width + right_rect.width + gap
|
104
|
-
|
105
|
-
group_x = {
|
106
|
-
bf.alignment.LEFT: full_rect.left,
|
107
|
-
bf.alignment.MIDLEFT: full_rect.left,
|
108
|
-
bf.alignment.RIGHT: full_rect.right - combined_width,
|
109
|
-
bf.alignment.MIDRIGHT: full_rect.right - combined_width,
|
110
|
-
bf.alignment.CENTER: full_rect.centerx - combined_width // 2
|
111
|
-
}.get(self.alignment, full_rect.left)
|
112
|
-
|
113
|
-
left_rect.x, right_rect.x = group_x, group_x + left_rect.width + gap
|
114
|
-
|
115
|
-
if self.alignment in {bf.alignment.TOP, bf.alignment.TOPLEFT, bf.alignment.TOPRIGHT}:
|
116
|
-
left_rect.top = right_rect.top = full_rect.top
|
117
|
-
elif self.alignment in {bf.alignment.BOTTOM, bf.alignment.BOTTOMLEFT, bf.alignment.BOTTOMRIGHT}:
|
118
|
-
left_rect.bottom = right_rect.bottom = full_rect.bottom
|
119
|
-
else:
|
120
|
-
left_rect.centery = right_rect.centery = full_rect.centery
|
121
|
-
|
122
|
-
right_rect.move_ip(*self.rect.topleft)
|
123
|
-
|
124
|
-
def _build_layout(self) -> None:
|
125
|
-
return self._build_composed_layout(self.indicator)
|
126
|
-
|
49
|
+
if self.autoresize and (self.rect.size != required_rect.size) :
|
50
|
+
self.set_size(*required_rect.size)
|
51
|
+
return
|
127
52
|
|
53
|
+
required_rect = self.get_content_rect()
|
54
|
+
required_rect_rel = self.get_content_rect_rel()
|
128
55
|
|
56
|
+
self._text_rect.midleft = required_rect_rel.midleft
|
57
|
+
r = self.indicator.rect.copy()
|
58
|
+
r.midleft = required_rect.move(self._text_rect.w+self.gap,0).midleft
|
59
|
+
self.indicator.set_position(*r.topleft)
|
60
|
+
|
61
|
+
self.surface.blit(self._text_surface,self._text_rect)
|
62
|
+
|