batframework 1.0.9a10__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.
Files changed (76) hide show
  1. batFramework/__init__.py +53 -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 -183
  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 -411
  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.9a10.dist-info → batframework-1.0.10.dist-info}/METADATA +24 -17
  40. batframework-1.0.10.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 -245
  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.9a10.dist-info/RECORD +0 -67
  74. {batframework-1.0.9a10.dist-info → batframework-1.0.10.dist-info}/LICENSE +0 -0
  75. {batframework-1.0.9a10.dist-info → batframework-1.0.10.dist-info}/WHEEL +0 -0
  76. {batframework-1.0.9a10.dist-info → batframework-1.0.10.dist-info}/top_level.txt +0 -0
@@ -1,128 +1,62 @@
1
1
  from .button import Button
2
- from .indicator import Indicator, ToggleIndicator
3
- from .shape import Shape
2
+ from .indicator import Indicator,ToggleIndicator
3
+ import pygame
4
4
  import batFramework as bf
5
- from typing import Self,Callable,Any
5
+ from typing import Self
6
6
 
7
7
  class Toggle(Button):
8
- def __init__(self, text: str = "", callback : Callable[[bool],Any]=None, default_value: bool = False) -> None:
9
- self.value: bool = default_value
10
- self.indicator: ToggleIndicator = ToggleIndicator(default_value)
11
- self.gap: float | int = 0
12
- self.spacing: bf.spacing = bf.spacing.MANUAL
13
- super().__init__(text, callback)
14
- self.add(self.indicator)
15
- self.set_clip_children(False)
16
-
17
- def set_visible(self, value: bool) -> Self:
18
- self.indicator.set_visible(value)
19
- return super().set_visible(value)
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.dirty_shape = True
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 toggle(self) -> None:
51
- self.set_value(not self.value, do_callback=True)
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
- other_height = min(self.text_rect.h, self.font_object.get_height()+1)
74
- other.set_size(other.resolve_size((other_height,other_height)))
37
+ def _build_layout(self)->None:
38
+ self.indicator.set_value(self.value)
75
39
 
76
- full_rect.w += other.rect.w + gap
77
- full_rect.h += self.unpressed_relief
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
- full_rect = self.get_local_inner_rect()
93
- left_rect = self.text_rect
94
- right_rect = other.rect
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
+