batframework 0.1.13__py3-none-any.whl → 1.0.1__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 (47) hide show
  1. batFramework/__init__.py +41 -46
  2. batFramework/action.py +42 -20
  3. batFramework/actionContainer.py +43 -4
  4. batFramework/animatedSprite.py +26 -20
  5. batFramework/camera.py +177 -47
  6. batFramework/constants.py +26 -51
  7. batFramework/cutscene.py +15 -15
  8. batFramework/cutsceneBlocks.py +11 -9
  9. batFramework/dynamicEntity.py +7 -6
  10. batFramework/easing.py +28 -23
  11. batFramework/entity.py +87 -49
  12. batFramework/enums.py +14 -0
  13. batFramework/fontManager.py +57 -0
  14. batFramework/gui/__init__.py +2 -2
  15. batFramework/gui/button.py +82 -31
  16. batFramework/gui/constraints.py +137 -104
  17. batFramework/gui/container.py +27 -28
  18. batFramework/gui/debugger.py +92 -42
  19. batFramework/gui/frame.py +15 -15
  20. batFramework/gui/image.py +37 -17
  21. batFramework/gui/indicator.py +18 -14
  22. batFramework/gui/interactiveWidget.py +11 -10
  23. batFramework/gui/label.py +60 -56
  24. batFramework/gui/layout.py +50 -47
  25. batFramework/gui/root.py +43 -30
  26. batFramework/gui/shape.py +34 -41
  27. batFramework/gui/slider.py +5 -0
  28. batFramework/gui/toggle.py +31 -27
  29. batFramework/gui/widget.py +148 -128
  30. batFramework/manager.py +18 -13
  31. batFramework/particles.py +16 -13
  32. batFramework/resourceManager.py +55 -0
  33. batFramework/scene.py +141 -83
  34. batFramework/sceneManager.py +21 -16
  35. batFramework/sprite.py +31 -0
  36. batFramework/stateMachine.py +1 -0
  37. batFramework/tileset.py +7 -9
  38. batFramework/time.py +61 -50
  39. batFramework/transition.py +20 -12
  40. batFramework/utils.py +2 -65
  41. batframework-1.0.1.dist-info/LICENCE +21 -0
  42. {batframework-0.1.13.dist-info → batframework-1.0.1.dist-info}/METADATA +3 -2
  43. batframework-1.0.1.dist-info/RECORD +48 -0
  44. {batframework-0.1.13.dist-info → batframework-1.0.1.dist-info}/WHEEL +1 -1
  45. batFramework/debugger.py +0 -48
  46. batframework-0.1.13.dist-info/RECORD +0 -43
  47. {batframework-0.1.13.dist-info → batframework-1.0.1.dist-info}/top_level.txt +0 -0
batFramework/gui/shape.py CHANGED
@@ -4,83 +4,76 @@ import pygame
4
4
 
5
5
 
6
6
  class Shape(Widget):
7
- def __init__(self,width:float,height:float):
8
- self._color = (0,0,0,0)
9
- self._border_radius:list[int] = [0]
10
- self._outline : int = 0
11
- self._outline_color : tuple[int,int,int] | str = (0,0,0,0)
12
- super().__init__(convert_alpha = True)
13
- self.set_size(width,height)
7
+ def __init__(self, width: float, height: float):
8
+ self._color = (0, 0, 0, 0)
9
+ self._border_radius: list[int] = [0]
10
+ self._outline: int = 0
11
+ self._outline_color: tuple[int, int, int] | str = (0, 0, 0, 0)
12
+ super().__init__(convert_alpha=True)
13
+ self.set_size(width, height)
14
14
 
15
-
16
- def to_string_id(self)->str:
15
+ def to_string_id(self) -> str:
17
16
  return "Shape"
18
17
 
19
- def set_color(self,color:tuple[int,int,int]|str) -> "Frame":
18
+ def set_color(self, color: tuple[int, int, int] | str) -> "Frame":
20
19
  self._color = color
21
20
  self.build()
22
21
  return self
23
22
 
24
- def set_outline_color(self,color:tuple[int,int,int]|str) -> "Frame":
23
+ def set_outline_color(self, color: tuple[int, int, int] | str) -> "Frame":
25
24
  self._outline_color = color
26
25
  self.build()
27
26
  return self
28
27
 
29
- def set_border_radius(self,value:int|list[int]) -> "Frame":
30
- if isinstance(value,int):
28
+ def set_border_radius(self, value: int | list[int]) -> "Frame":
29
+ if isinstance(value, int):
31
30
  self._border_radius = [value]
32
31
  else:
33
32
  self._border_radius = value
34
33
  self.build()
35
34
  return self
36
-
37
- def set_outline_width(self,value:int) -> "Frame":
35
+
36
+ def set_outline_width(self, value: int) -> "Frame":
38
37
  self._outline = value
39
38
  self.build()
40
39
  return self
41
-
42
- def build(self)->None:
40
+
41
+ def build(self) -> None:
43
42
  if self.surface.get_size() != self.get_size_int():
44
43
  self.surface = pygame.Surface(self.get_size_int())
45
- if self.convert_alpha :
44
+ if self.convert_alpha:
46
45
  self.surface = self.surface.convert_alpha()
47
- self.surface.fill((0,0,0,0))
48
- if self.parent :
46
+ self.surface.fill((0, 0, 0, 0))
47
+ if self.parent:
49
48
  self.parent.children_modified()
50
49
  if self._border_radius == [0]:
51
- self._build_shape()
52
- if self._outline : self._build_outline()
50
+ self._build_shape()
51
+ if self._outline:
52
+ self._build_outline()
53
53
  else:
54
54
  self._build_rounded_shape()
55
- if self._outline : self._build_rounded_outline()
56
-
55
+ if self._outline:
56
+ self._build_rounded_outline()
57
57
 
58
- def _build_shape(self)->None:
58
+ def _build_shape(self) -> None:
59
59
  self.surface.fill(self._color)
60
60
 
61
- def _build_rounded_shape(self)->None:
62
- self.surface.fill((0,0,0,0))
61
+ def _build_rounded_shape(self) -> None:
62
+ self.surface.fill((0, 0, 0, 0))
63
63
  pygame.draw.rect(
64
- self.surface,
65
- self._color,
66
- (0,0,*self.rect.size),
67
- 0,
68
- *self._border_radius
64
+ self.surface, self._color, (0, 0, *self.rect.size), 0, *self._border_radius
69
65
  )
70
66
 
71
- def _build_outline(self)->None:
67
+ def _build_outline(self) -> None:
72
68
  pygame.draw.rect(
73
- self.surface,
74
- self._outline_color,
75
- (0,0,*self.rect.size),
76
- self._outline
69
+ self.surface, self._outline_color, (0, 0, *self.rect.size), self._outline
77
70
  )
78
-
79
- def _build_rounded_outline(self)->None:
71
+
72
+ def _build_rounded_outline(self) -> None:
80
73
  pygame.draw.rect(
81
74
  self.surface,
82
75
  self._outline_color,
83
- (0,0,*self.rect.size),
76
+ (0, 0, *self.rect.size),
84
77
  self._outline,
85
- *self._border_radius
78
+ *self._border_radius,
86
79
  )
@@ -0,0 +1,5 @@
1
+ import batFramework as bf
2
+
3
+
4
+ class Slider(bf.Widget):
5
+ pass
@@ -1,52 +1,57 @@
1
1
  from .button import Button
2
- from .indicator import Indicator,ToggleIndicator
2
+ from .indicator import Indicator, ToggleIndicator
3
3
  import pygame
4
4
  import batFramework as bf
5
5
  from typing import Self
6
6
 
7
+
8
+
7
9
  class Toggle(Button):
8
- def __init__(self,text:str,default_value : bool = False)->None:
9
- self.value :bool= default_value
10
+ def __init__(self, text: str, default_value: bool = False,callback=None) -> None:
11
+ self.value: bool = default_value
10
12
  self.on_toggle = None
11
- self.indicator : Indicator=ToggleIndicator(default_value)
12
- self.gap :float|int = 0
13
- super().__init__(text,self.toggle)
13
+ self.indicator: Indicator = ToggleIndicator(default_value)
14
+ self.gap: float | int = 0
15
+ super().__init__(text, self.toggle)
14
16
  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)
17
+ self.set_gap(int(max(4, self.get_content_width() / 3)))
18
+ self.set_toggle_callback(callback)
18
19
 
19
- def set_gap(self,value:int|float)->Self:
20
- if value < 0 : return self
20
+ def set_gap(self, value: int | float) -> Self:
21
+ if value < 0:
22
+ return self
21
23
  self.gap = value
22
24
  self.build()
23
- if self.parent : self.parent.children_modified()
25
+ if self.parent:
26
+ self.parent.children_modified()
24
27
  return self
25
- def to_string_id(self)->str:
28
+
29
+ def to_string_id(self) -> str:
26
30
  return f"Toggle({self.value})"
27
-
28
- def toggle(self)->None:
31
+
32
+ def toggle(self) -> None:
29
33
  self.value = not self.value
30
34
  self.build()
31
- if self.on_toggle : self.on_toggle(self.value)
35
+ if self.on_toggle:
36
+ self.on_toggle(self.value)
32
37
 
33
- def set_toggle_callback(self,callback)->Self:
38
+ def set_toggle_callback(self, callback) -> Self:
34
39
  self.on_toggle = callback
35
40
  return self
36
41
 
37
- def _build_layout(self)->None:
42
+ def _build_layout(self) -> None:
38
43
  self.indicator.set_value(self.value)
39
-
44
+ self.indicator.set_size(self._text_rect.h,self._text_rect.h)
40
45
  size = (
41
46
  0,
42
47
  0,
43
48
  self._text_rect.w + self.indicator.rect.w + self.gap,
44
- max(self._text_rect.h, self.indicator.rect.h)
49
+ max(self._text_rect.h, self.indicator.rect.h),
45
50
  )
46
-
51
+
47
52
  required_rect = self.inflate_rect_by_padding(size)
48
-
49
- if self.autoresize and (self.rect.size != required_rect.size) :
53
+
54
+ if self.autoresize and (self.rect.size != required_rect.size):
50
55
  self.set_size(*required_rect.size)
51
56
  return
52
57
 
@@ -55,8 +60,7 @@ class Toggle(Button):
55
60
 
56
61
  self._text_rect.midleft = required_rect_rel.midleft
57
62
  r = self.indicator.rect.copy()
58
- r.midleft = required_rect.move(self._text_rect.w+self.gap,0).midleft
63
+ r.midleft = required_rect.move(self._text_rect.w + self.gap, 0).midleft
59
64
  self.indicator.set_position(*r.topleft)
60
-
61
- self.surface.blit(self._text_surface,self._text_rect)
62
-
65
+
66
+ self.surface.blit(self._text_surface, self._text_rect)