batframework 1.0.9a7__py3-none-any.whl → 1.0.9a9__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 (62) hide show
  1. batFramework/__init__.py +20 -11
  2. batFramework/action.py +1 -1
  3. batFramework/animatedSprite.py +47 -116
  4. batFramework/animation.py +30 -5
  5. batFramework/audioManager.py +8 -5
  6. batFramework/baseScene.py +240 -0
  7. batFramework/camera.py +4 -0
  8. batFramework/constants.py +6 -2
  9. batFramework/cutscene.py +221 -21
  10. batFramework/cutsceneManager.py +5 -2
  11. batFramework/drawable.py +7 -5
  12. batFramework/easingController.py +10 -11
  13. batFramework/entity.py +21 -2
  14. batFramework/enums.py +48 -33
  15. batFramework/gui/__init__.py +6 -3
  16. batFramework/gui/animatedLabel.py +10 -2
  17. batFramework/gui/button.py +4 -31
  18. batFramework/gui/clickableWidget.py +63 -50
  19. batFramework/gui/constraints/constraints.py +212 -136
  20. batFramework/gui/container.py +77 -58
  21. batFramework/gui/debugger.py +12 -17
  22. batFramework/gui/draggableWidget.py +21 -17
  23. batFramework/gui/image.py +3 -10
  24. batFramework/gui/indicator.py +56 -1
  25. batFramework/gui/interactiveWidget.py +127 -108
  26. batFramework/gui/label.py +73 -64
  27. batFramework/gui/layout.py +286 -445
  28. batFramework/gui/meter.py +42 -20
  29. batFramework/gui/radioButton.py +20 -69
  30. batFramework/gui/root.py +99 -29
  31. batFramework/gui/selector.py +250 -0
  32. batFramework/gui/shape.py +13 -5
  33. batFramework/gui/slider.py +262 -107
  34. batFramework/gui/syncedVar.py +49 -0
  35. batFramework/gui/textInput.py +46 -22
  36. batFramework/gui/toggle.py +70 -52
  37. batFramework/gui/tooltip.py +30 -0
  38. batFramework/gui/widget.py +222 -135
  39. batFramework/manager.py +7 -8
  40. batFramework/particle.py +4 -1
  41. batFramework/propertyEaser.py +79 -0
  42. batFramework/renderGroup.py +17 -50
  43. batFramework/resourceManager.py +43 -13
  44. batFramework/scene.py +15 -335
  45. batFramework/sceneLayer.py +138 -0
  46. batFramework/sceneManager.py +31 -36
  47. batFramework/scrollingSprite.py +8 -3
  48. batFramework/sprite.py +1 -1
  49. batFramework/templates/__init__.py +1 -2
  50. batFramework/templates/controller.py +97 -0
  51. batFramework/timeManager.py +76 -22
  52. batFramework/transition.py +37 -103
  53. batFramework/utils.py +125 -66
  54. {batframework-1.0.9a7.dist-info → batframework-1.0.9a9.dist-info}/METADATA +24 -3
  55. batframework-1.0.9a9.dist-info/RECORD +67 -0
  56. {batframework-1.0.9a7.dist-info → batframework-1.0.9a9.dist-info}/WHEEL +1 -1
  57. batFramework/character.py +0 -27
  58. batFramework/templates/character.py +0 -43
  59. batFramework/templates/states.py +0 -166
  60. batframework-1.0.9a7.dist-info/RECORD +0 -63
  61. /batframework-1.0.9a7.dist-info/LICENCE → /batframework-1.0.9a9.dist-info/LICENSE +0 -0
  62. {batframework-1.0.9a7.dist-info → batframework-1.0.9a9.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,8 @@
1
1
  from .button import Button
2
2
  from .indicator import Indicator, ToggleIndicator
3
+ from .shape import Shape
3
4
  import batFramework as bf
4
5
  from typing import Self,Callable,Any
5
- import pygame
6
-
7
6
 
8
7
  class Toggle(Button):
9
8
  def __init__(self, text: str = "", callback : Callable[[bool],Any]=None, default_value: bool = False) -> None:
@@ -54,57 +53,76 @@ class Toggle(Button):
54
53
  def get_min_required_size(self) -> tuple[float, float]:
55
54
  if not self.text_rect:
56
55
  self.text_rect.size = self._get_text_rect_required_size()
57
- size = (
58
- max(
59
- self.indicator.get_min_required_size()[0],
60
- self.text_rect.w + self.font_object.point_size + (self.gap if self.text else 0),
61
- ),
62
- self.text_rect.h+self.unpressed_relief,
63
- )
64
- return self.inflate_rect_by_padding((0, 0, *size)).size
65
56
 
66
- def _build_layout(self) -> None:
57
+ text_width, text_height = self.text_rect.size
58
+ indicator_size = self.indicator.get_min_required_size()[1]
67
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
68
  self.text_rect.size = self._get_text_rect_required_size()
69
69
 
70
- #right part size
71
- right_part_height = min(self.text_rect.h, self.font_object.point_size)
72
- self.indicator.set_size_if_autoresize((right_part_height,right_part_height))
73
-
74
- #join left and right
75
- joined_rect = pygame.FRect(
76
- 0, 0, self.text_rect.w + gap + self.indicator.rect.w, self.text_rect.h
77
- )
78
-
79
- if self.autoresize_h or self.autoresize_w:
80
- target_rect = self.inflate_rect_by_padding(joined_rect)
81
- target_rect.h += self.unpressed_relief
82
- if not self.autoresize_w:
83
- target_rect.w = self.rect.w
84
- if not self.autoresize_h:
85
- target_rect.h = self.rect.h
86
- if self.rect.size != target_rect.size:
87
- self.set_size(target_rect.size)
88
- self.apply_updates()
89
-
90
- # ------------------------------------ size is ok
91
-
92
- offset = self._get_outline_offset() if self.show_text_outline else (0,0)
93
- padded_rect = self.get_padded_rect()
94
- padded_relative = padded_rect.move(-self.rect.x, -self.rect.y)
95
-
96
- self.align_text(joined_rect, padded_relative.move( offset), self.alignment)
97
- self.text_rect.midleft = joined_rect.midleft
98
-
99
- if self.text:
100
- match self.spacing:
101
- case bf.spacing.MAX:
102
- gap = padded_relative.right - self.text_rect.right - self.indicator.rect.w
103
- case bf.spacing.MIN:
104
- gap = 0
105
-
106
- pos = self.text_rect.move(
107
- self.rect.x + gap -offset[0],
108
- self.rect.y + (self.text_rect.h / 2) - (right_part_height/ 2) -offset[1],
109
- ).topright
110
- self.indicator.rect.topleft = pos
70
+ gap = self.gap if self.text else 0
71
+ full_rect = self.text_rect.copy()
72
+
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)))
75
+
76
+ full_rect.w += other.rect.w + gap
77
+ full_rect.h += self.unpressed_relief
78
+
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):
91
+
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
+
127
+
128
+
@@ -0,0 +1,30 @@
1
+ from .label import Label
2
+ import batFramework as bf
3
+ import sys
4
+
5
+ class ToolTip(Label):
6
+ def __init__(self, text = ""):
7
+ super().__init__(text)
8
+ self.fade_in_duration : float = 0.1
9
+ self.fade_out_duration : float = 0.1
10
+ self.set_render_order(sys.maxsize)
11
+
12
+ def __str__(self):
13
+ return f"ToolTip('{self.text}')"
14
+
15
+ def top_at(self, x, y):
16
+ return None
17
+
18
+ def fade_in(self):
19
+ self.set_visible(True)
20
+ bf.PropertyEaser(
21
+ self.fade_in_duration,bf.easing.EASE_OUT,
22
+ 0,self.parent_scene.name
23
+ ).add_custom(self.get_alpha,self.set_alpha,255).start()
24
+
25
+ def fade_out(self):
26
+ bf.PropertyEaser(
27
+ self.fade_out_duration,bf.easing.EASE_IN,
28
+ 0,self.parent_scene.name,
29
+ lambda : self.set_visible(False)
30
+ ).add_custom(self.get_alpha,self.set_alpha,0).start()