batframework 1.0.9a10__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 -245
- 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 -201
- 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 -426
- 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.9a10.dist-info → batframework-1.0.9a12.dist-info}/LICENSE +20 -20
- {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/METADATA +24 -17
- batframework-1.0.9a12.dist-info/RECORD +72 -0
- batframework-1.0.9a10.dist-info/RECORD +0 -67
- {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/WHEEL +0 -0
- {batframework-1.0.9a10.dist-info → batframework-1.0.9a12.dist-info}/top_level.txt +0 -0
batFramework/gui/indicator.py
CHANGED
@@ -1,113 +1,116 @@
|
|
1
|
-
from .shape import Shape
|
2
|
-
from typing import Any, Self, Callable
|
3
|
-
import pygame
|
4
|
-
from .widget import Widget
|
5
|
-
from .interactiveWidget import InteractiveWidget
|
6
|
-
from .draggableWidget import DraggableWidget
|
7
|
-
import batFramework as bf
|
8
|
-
|
9
|
-
|
10
|
-
class Indicator(Shape):
|
11
|
-
"""
|
12
|
-
Shape intended to be used as icons/indicators
|
13
|
-
due to its nature, it overrides the top_at function (it can not be 'seen' by the mouse)
|
14
|
-
|
15
|
-
"""
|
16
|
-
|
17
|
-
def __init__(self, size: tuple[int | float] = (10, 10)) -> None:
|
18
|
-
super().__init__(size)
|
19
|
-
self.debug_color = "magenta"
|
20
|
-
self.set_outline_width(1)
|
21
|
-
self.set_outline_color("black")
|
22
|
-
|
23
|
-
def to_string_id(self) -> str:
|
24
|
-
return "Indicator"
|
25
|
-
|
26
|
-
def set_value(self, value: Any) -> None:
|
27
|
-
pass
|
28
|
-
|
29
|
-
def get_value(self) -> Any:
|
30
|
-
pass
|
31
|
-
|
32
|
-
def top_at(self, x, y):
|
33
|
-
return None
|
34
|
-
|
35
|
-
|
36
|
-
class ToggleIndicator(Indicator):
|
37
|
-
def __init__(self, default_value: bool) -> None:
|
38
|
-
super().__init__((20, 20))
|
39
|
-
self.value: bool = default_value
|
40
|
-
self.callback = lambda val: self.set_color("green" if val else "red")
|
41
|
-
self.set_value(default_value)
|
42
|
-
self.callback(default_value)
|
43
|
-
# TODO aspect ratio would be good right about here
|
44
|
-
self.add_constraints(bf.gui.AspectRatio(1,reference_axis=bf.axis.VERTICAL))
|
45
|
-
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
self
|
52
|
-
|
53
|
-
|
54
|
-
self.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
self.
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
self
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
self
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
r.width
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
1
|
+
from .shape import Shape
|
2
|
+
from typing import Any, Self, Callable
|
3
|
+
import pygame
|
4
|
+
from .widget import Widget
|
5
|
+
from .interactiveWidget import InteractiveWidget
|
6
|
+
from .draggableWidget import DraggableWidget
|
7
|
+
import batFramework as bf
|
8
|
+
|
9
|
+
|
10
|
+
class Indicator(Shape):
|
11
|
+
"""
|
12
|
+
Shape intended to be used as icons/indicators
|
13
|
+
due to its nature, it overrides the top_at function (it can not be 'seen' by the mouse)
|
14
|
+
|
15
|
+
"""
|
16
|
+
|
17
|
+
def __init__(self, size: tuple[int | float] = (10, 10)) -> None:
|
18
|
+
super().__init__(size)
|
19
|
+
self.debug_color = "magenta"
|
20
|
+
self.set_outline_width(1)
|
21
|
+
self.set_outline_color("black")
|
22
|
+
|
23
|
+
def to_string_id(self) -> str:
|
24
|
+
return "Indicator"
|
25
|
+
|
26
|
+
def set_value(self, value: Any) -> None:
|
27
|
+
pass
|
28
|
+
|
29
|
+
def get_value(self) -> Any:
|
30
|
+
pass
|
31
|
+
|
32
|
+
def top_at(self, x, y):
|
33
|
+
return None
|
34
|
+
|
35
|
+
|
36
|
+
class ToggleIndicator(Indicator):
|
37
|
+
def __init__(self, default_value: bool) -> None:
|
38
|
+
super().__init__((20, 20))
|
39
|
+
self.value: bool = default_value
|
40
|
+
self.callback = lambda val: self.set_color("green" if val else "red")
|
41
|
+
self.set_value(default_value)
|
42
|
+
self.callback(default_value)
|
43
|
+
# TODO aspect ratio would be good right about here
|
44
|
+
self.add_constraints(bf.gui.AspectRatio(1,reference_axis=bf.axis.VERTICAL))
|
45
|
+
|
46
|
+
def __str__(self):
|
47
|
+
return "ToggleIndicator"
|
48
|
+
|
49
|
+
def set_callback(self, callback : Callable[[bool],Any]) -> Self:
|
50
|
+
self.callback = callback
|
51
|
+
return self
|
52
|
+
|
53
|
+
def set_value(self, value: bool) -> None:
|
54
|
+
self.value = value
|
55
|
+
if self.callback:
|
56
|
+
self.callback(value)
|
57
|
+
self.dirty_surface = True
|
58
|
+
|
59
|
+
def get_value(self) -> bool:
|
60
|
+
return self.value
|
61
|
+
|
62
|
+
def top_at(self, x: float, y: float) -> "None|Widget":
|
63
|
+
r = super().top_at(x, y)
|
64
|
+
if r is self:
|
65
|
+
return None
|
66
|
+
return r
|
67
|
+
|
68
|
+
class ArrowIndicator(Indicator):
|
69
|
+
def __init__(self,direction:bf.direction):
|
70
|
+
super().__init__()
|
71
|
+
self.direction : bf.direction = direction
|
72
|
+
self.arrow_color = bf.color.WHITE
|
73
|
+
self.line_width : int = 1
|
74
|
+
|
75
|
+
def set_arrow_color(self,color)-> Self:
|
76
|
+
self.arrow_color = color
|
77
|
+
self.dirty_surface = True
|
78
|
+
return self
|
79
|
+
|
80
|
+
def set_arrow_direction(self,direction:bf.direction)->Self:
|
81
|
+
self.direction = direction
|
82
|
+
self.dirty_surface = True
|
83
|
+
return self
|
84
|
+
|
85
|
+
def set_arrow_line_width(self,value:int)->Self:
|
86
|
+
self.line_width = value
|
87
|
+
self.dirty_surface = True
|
88
|
+
return self
|
89
|
+
|
90
|
+
def paint(self):
|
91
|
+
super().paint()
|
92
|
+
r = self.get_local_inner_rect()
|
93
|
+
size = min(r.width, r.height)
|
94
|
+
if size %2 == 0:
|
95
|
+
size -= 1
|
96
|
+
r.width = size
|
97
|
+
r.height = size
|
98
|
+
|
99
|
+
#pixel alignment
|
100
|
+
if (self.padding[1]+self.padding[3] )%2 ==0:
|
101
|
+
r.height-=1
|
102
|
+
if (self.padding[0]+self.padding[2] )%2 ==0:
|
103
|
+
r.width-=1
|
104
|
+
r.center = self.get_local_inner_rect().center
|
105
|
+
|
106
|
+
bf.utils.draw_triangle(
|
107
|
+
surface = self.surface,
|
108
|
+
color = self.arrow_color,
|
109
|
+
rect =r,
|
110
|
+
direction = self.direction,
|
111
|
+
width = self.line_width
|
112
|
+
|
113
|
+
)
|
114
|
+
|
115
|
+
|
116
|
+
|