batframework 1.0.9a11__py3-none-any.whl → 1.0.9a13__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 (73) hide show
  1. batFramework/__init__.py +3 -11
  2. batFramework/action.py +280 -279
  3. batFramework/actionContainer.py +105 -82
  4. batFramework/animatedSprite.py +80 -58
  5. batFramework/animation.py +91 -77
  6. batFramework/audioManager.py +156 -131
  7. batFramework/baseScene.py +249 -240
  8. batFramework/camera.py +245 -317
  9. batFramework/constants.py +57 -51
  10. batFramework/cutscene.py +239 -253
  11. batFramework/cutsceneManager.py +34 -34
  12. batFramework/drawable.py +107 -77
  13. batFramework/dynamicEntity.py +30 -30
  14. batFramework/easingController.py +58 -58
  15. batFramework/entity.py +130 -130
  16. batFramework/enums.py +171 -135
  17. batFramework/fontManager.py +65 -65
  18. batFramework/gui/__init__.py +28 -25
  19. batFramework/gui/animatedLabel.py +90 -89
  20. batFramework/gui/button.py +17 -17
  21. batFramework/gui/clickableWidget.py +244 -244
  22. batFramework/gui/collapseContainer.py +98 -0
  23. batFramework/gui/constraints/__init__.py +1 -1
  24. batFramework/gui/constraints/constraints.py +1066 -980
  25. batFramework/gui/container.py +220 -206
  26. batFramework/gui/debugger.py +140 -130
  27. batFramework/gui/draggableWidget.py +63 -44
  28. batFramework/gui/image.py +61 -58
  29. batFramework/gui/indicator.py +116 -113
  30. batFramework/gui/interactiveWidget.py +243 -239
  31. batFramework/gui/label.py +147 -344
  32. batFramework/gui/layout.py +442 -429
  33. batFramework/gui/meter.py +155 -96
  34. batFramework/gui/radioButton.py +43 -35
  35. batFramework/gui/root.py +228 -228
  36. batFramework/gui/scrollingContainer.py +282 -0
  37. batFramework/gui/selector.py +232 -250
  38. batFramework/gui/shape.py +286 -276
  39. batFramework/gui/slider.py +353 -397
  40. batFramework/gui/style.py +10 -10
  41. batFramework/gui/styleManager.py +49 -54
  42. batFramework/gui/syncedVar.py +43 -49
  43. batFramework/gui/textInput.py +331 -306
  44. batFramework/gui/textWidget.py +308 -0
  45. batFramework/gui/toggle.py +140 -128
  46. batFramework/gui/tooltip.py +35 -30
  47. batFramework/gui/widget.py +546 -521
  48. batFramework/manager.py +131 -134
  49. batFramework/particle.py +118 -118
  50. batFramework/propertyEaser.py +79 -79
  51. batFramework/renderGroup.py +34 -34
  52. batFramework/resourceManager.py +130 -130
  53. batFramework/scene.py +31 -31
  54. batFramework/sceneLayer.py +134 -138
  55. batFramework/sceneManager.py +200 -197
  56. batFramework/scrollingSprite.py +115 -115
  57. batFramework/sprite.py +46 -51
  58. batFramework/stateMachine.py +49 -54
  59. batFramework/templates/__init__.py +2 -1
  60. batFramework/templates/character.py +15 -0
  61. batFramework/templates/controller.py +158 -97
  62. batFramework/templates/stateMachine.py +39 -0
  63. batFramework/tileset.py +46 -46
  64. batFramework/timeManager.py +213 -213
  65. batFramework/transition.py +162 -162
  66. batFramework/triggerZone.py +22 -22
  67. batFramework/utils.py +306 -306
  68. {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/LICENSE +20 -20
  69. {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/METADATA +24 -17
  70. batframework-1.0.9a13.dist-info/RECORD +72 -0
  71. batframework-1.0.9a11.dist-info/RECORD +0 -67
  72. {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/WHEEL +0 -0
  73. {batframework-1.0.9a11.dist-info → batframework-1.0.9a13.dist-info}/top_level.txt +0 -0
@@ -1,65 +1,65 @@
1
- from .utils import Singleton
2
-
3
- # put font stuff here later
4
- import pygame
5
- import os
6
- import batFramework as bf
7
-
8
-
9
- class FontManager(metaclass=Singleton):
10
- def __init__(self):
11
- pygame.font.init()
12
- self.DEFAULT_FONT_SIZE = 16
13
- self.MIN_FONT_SIZE = 8
14
- self.MAX_FONT_SIZE = 64
15
- self.DEFAULT_ANTIALIAS = False
16
- self.FONTS = {}
17
-
18
- def set_default_antialias(self, value: bool):
19
- self.DEFAULT_ANTIALIAS = value
20
-
21
- def set_default_text_size(self, size: int):
22
- self.DEFAULT_FONT_SIZE = size
23
-
24
- def init_font(self, raw_path: str | None):
25
- try:
26
- if raw_path is not None:
27
- self.load_font(raw_path if raw_path else None, None)
28
- self.load_font(raw_path)
29
- except FileNotFoundError:
30
- self.load_sysfont(raw_path)
31
- self.load_sysfont(raw_path, None)
32
-
33
- def load_font(self, path: str | None, name: str | None = ""):
34
- if path is not None:
35
- path = bf.ResourceManager().get_path(path) # convert path if given
36
- filename = None
37
- if path is not None:
38
- filename = os.path.basename(path).split(".")[0]
39
-
40
- # get filename if path is given, else None
41
- if name != "":
42
- filename = name # if name is not given, name is the filename
43
- self.FONTS[filename] = {}
44
- # fill the dict
45
- for size in range(self.MIN_FONT_SIZE, self.MAX_FONT_SIZE+1, 2):
46
- self.FONTS[filename][size] = pygame.font.Font(path, size=size)
47
-
48
- def load_sysfont(self, font_name: str | None, key: str | None = ""):
49
- if key == "":
50
- key = font_name
51
- if font_name is None or pygame.font.match_font(font_name) is None:
52
- raise FileNotFoundError(f"Requested font '{font_name}' was not found")
53
- self.FONTS[font_name] = {}
54
-
55
- for size in range(self.MIN_FONT_SIZE, self.MAX_FONT_SIZE+1, 2):
56
- self.FONTS[key][size] = pygame.font.SysFont(font_name, size=size)
57
-
58
- def get_font(
59
- self, name: str | None = None, text_size: int = 12
60
- ) -> pygame.Font | None:
61
- if not name in self.FONTS:
62
- return None
63
- if not text_size in self.FONTS[name]:
64
- return None
65
- return self.FONTS[name][text_size]
1
+ from .utils import Singleton
2
+
3
+ # put font stuff here later
4
+ import pygame
5
+ import os
6
+ import batFramework as bf
7
+
8
+
9
+ class FontManager(metaclass=Singleton):
10
+ def __init__(self):
11
+ pygame.font.init()
12
+ self.DEFAULT_FONT_SIZE = 16
13
+ self.MIN_FONT_SIZE = 8
14
+ self.MAX_FONT_SIZE = 64
15
+ self.DEFAULT_ANTIALIAS = False
16
+ self.FONTS = {}
17
+
18
+ def set_default_antialias(self, value: bool):
19
+ self.DEFAULT_ANTIALIAS = value
20
+
21
+ def set_default_text_size(self, size: int):
22
+ self.DEFAULT_FONT_SIZE = size
23
+
24
+ def init_font(self, raw_path: str | None):
25
+ try:
26
+ if raw_path is not None:
27
+ self.load_font(raw_path if raw_path else None, None)
28
+ self.load_font(raw_path)
29
+ except FileNotFoundError:
30
+ self.load_sysfont(raw_path)
31
+ self.load_sysfont(raw_path, None)
32
+
33
+ def load_font(self, path: str | None, name: str | None = ""):
34
+ if path is not None:
35
+ path = bf.ResourceManager().get_path(path) # convert path if given
36
+ filename = None
37
+ if path is not None:
38
+ filename = os.path.basename(path).split(".")[0]
39
+
40
+ # get filename if path is given, else None
41
+ if name != "":
42
+ filename = name # if name is not given, name is the filename
43
+ self.FONTS[filename] = {}
44
+ # fill the dict
45
+ for size in range(self.MIN_FONT_SIZE, self.MAX_FONT_SIZE+1, 2):
46
+ self.FONTS[filename][size] = pygame.font.Font(path, size=size)
47
+
48
+ def load_sysfont(self, font_name: str | None, key: str | None = ""):
49
+ if key == "":
50
+ key = font_name
51
+ if font_name is None or pygame.font.match_font(font_name) is None:
52
+ raise FileNotFoundError(f"Requested font '{font_name}' was not found")
53
+ self.FONTS[font_name] = {}
54
+
55
+ for size in range(self.MIN_FONT_SIZE, self.MAX_FONT_SIZE+1, 2):
56
+ self.FONTS[key][size] = pygame.font.SysFont(font_name, size=size)
57
+
58
+ def get_font(
59
+ self, name: str | None = None, text_size: int = 12
60
+ ) -> pygame.Font | None:
61
+ if not name in self.FONTS:
62
+ return None
63
+ if not text_size in self.FONTS[name]:
64
+ return None
65
+ return self.FONTS[name][text_size]
@@ -1,25 +1,28 @@
1
- from .widget import Widget
2
- from .styleManager import StyleManager
3
- from .style import Style
4
- from .image import Image
5
- from .interactiveWidget import InteractiveWidget
6
- from .draggableWidget import DraggableWidget
7
- from .clickableWidget import ClickableWidget
8
- from .root import Root
9
- from .shape import Shape
10
- from .meter import BarMeter
11
- from .label import Label
12
- from .tooltip import ToolTip
13
- from .animatedLabel import AnimatedLabel
14
- from .textInput import TextInput
15
- from .button import Button
16
- from .debugger import *
17
- from .layout import *
18
- from .container import Container
19
- from .indicator import *
20
- from .toggle import Toggle
21
- from .syncedVar import SyncedVar
22
- from .radioButton import RadioButton
23
- from .slider import Slider
24
- from .selector import Selector
25
- import batFramework.gui.constraints as constraints
1
+ from .widget import Widget
2
+ from .styleManager import StyleManager
3
+ from .style import Style
4
+ from .image import Image
5
+ from .interactiveWidget import InteractiveWidget
6
+ from .draggableWidget import DraggableWidget
7
+ from .clickableWidget import ClickableWidget
8
+ from .root import Root
9
+ from .shape import Shape
10
+ from .meter import BarMeter
11
+ from .textWidget import TextWidget
12
+ from .label import Label
13
+ from .tooltip import ToolTip
14
+ from .animatedLabel import AnimatedLabel
15
+ from .textInput import TextInput
16
+ from .button import Button
17
+ from .debugger import *
18
+ from .layout import *
19
+ from .container import Container
20
+ from .indicator import *
21
+ from .toggle import Toggle
22
+ from .syncedVar import SyncedVar
23
+ from .radioButton import RadioButton
24
+ from .slider import Slider
25
+ from .selector import Selector
26
+ from .scrollingContainer import ScrollingContainer
27
+ from .collapseContainer import CollapseContainer
28
+ import batFramework.gui.constraints as constraints
@@ -1,89 +1,90 @@
1
- from .label import Label
2
- import batFramework as bf
3
- from typing import Self,Callable,Any
4
-
5
-
6
- class AnimatedLabel(Label):
7
- def __init__(self,text="") -> None:
8
- self.cursor_position: float = 0.0
9
- self.text_speed: float = 20.0
10
- self.is_over: bool = True
11
- self.is_paused: bool = False
12
- self.original_text = ""
13
- self.end_callback : Callable[[],Any]= None
14
- self.set_autoresize(False)
15
- self.set_alignment(bf.alignment.LEFT)
16
- super().__init__("")
17
- self.set_text(text)
18
-
19
- def __str__(self) -> str:
20
- return "AnimatedLabel"
21
-
22
- def set_end_callback(self,callback:Callable[[],Any]):
23
- self.end_callback = callback
24
-
25
- def pause(self) -> Self:
26
- self.is_paused = True
27
- return self
28
-
29
- def resume(self) -> Self:
30
- self.is_paused = False
31
- return self
32
-
33
- def set_text_speed(self, speed: float) -> Self:
34
- self.text_speed = speed
35
- return self
36
-
37
- def cut_text_to_width(self, text: str) -> list[str]:
38
- w = self.get_inner_width()
39
- if text == "" or not self.font_object or w < self.font_object.point_size:
40
- return [text]
41
- left = 0
42
- for index in range(len(text)):
43
- width = self.font_object.size(text[left:index])[0]
44
-
45
- if width > w:
46
- cut_point_start = index - 1
47
- cut_point_end = index - 1
48
- last_space = text.rfind(" ", 0, cut_point_start)
49
- last_nline = text.rfind("\n", 0, cut_point_start)
50
-
51
- if last_space != -1 or last_nline != -1: # space was found !:
52
- cut_point_start = max(last_space, last_nline)
53
- cut_point_end = cut_point_start + 1
54
- res = [text[:cut_point_start].strip()]
55
- res.extend(self.cut_text_to_width(text[cut_point_end:].strip()))
56
- return res
57
- elif text[index] == "\n":
58
- left = index
59
- return [text]
60
-
61
-
62
- def _set_text_internal(self,text:str)->Self:
63
- super().set_text(text)
64
- return self
65
-
66
- def set_text(self,text:str)->Self:
67
- self.original_text = text
68
- self.is_over = False
69
- self.cursor_position = 0
70
-
71
- def set_size(self, size):
72
- super().set_size(size)
73
- self._set_text_internal('\n'.join(self.cut_text_to_width(self.original_text[: int(self.cursor_position)])))
74
-
75
- def do_update(self, dt):
76
- if self.is_over:
77
- return
78
- if not self.is_over and self.cursor_position == len(self.original_text):
79
- if len(self.original_text) == 0:
80
- self._set_text_internal("")
81
- self.is_over = True
82
- if self.end_callback is not None:
83
- self.end_callback()
84
- return
85
- self.cursor_position = min(
86
- self.cursor_position + self.text_speed * dt, len(self.original_text)
87
- )
88
- # self.set_text(self.original_text[: int(self.cursor_position)])
89
- self._set_text_internal('\n'.join(self.cut_text_to_width(self.original_text[: int(self.cursor_position)])))
1
+ from .label import Label
2
+ import batFramework as bf
3
+ from typing import Self,Callable,Any
4
+
5
+
6
+ class AnimatedLabel(Label):
7
+ def __init__(self,text="") -> None:
8
+ self.cursor_position: float = 0.0
9
+ self.text_speed: float = 20.0
10
+ self.is_over: bool = True
11
+ self.is_paused: bool = False
12
+ self.original_text = ""
13
+ self.end_callback : Callable[[],Any]= None
14
+ self.set_autoresize(False)
15
+ self.set_alignment(bf.alignment.LEFT)
16
+ super().__init__("")
17
+ self.set_text(text)
18
+
19
+ def __str__(self) -> str:
20
+ return "AnimatedLabel"
21
+
22
+ def set_end_callback(self,callback:Callable[[],Any]):
23
+ self.end_callback = callback
24
+
25
+ def pause(self) -> Self:
26
+ self.is_paused = True
27
+ return self
28
+
29
+ def resume(self) -> Self:
30
+ self.is_paused = False
31
+ return self
32
+
33
+ def set_text_speed(self, speed: float) -> Self:
34
+ self.text_speed = speed
35
+ return self
36
+
37
+ def cut_text_to_width(self, text: str) -> list[str]:
38
+ w = self.get_inner_width()
39
+ if text == "" or not self.text_widget.font_object or w < self.text_widget.font_object.point_size:
40
+ return [text]
41
+ left = 0
42
+ font_object = self.text_widget.font_object
43
+ for index in range(len(text)):
44
+ width = font_object.size(text[left:index])[0]
45
+
46
+ if width > w:
47
+ cut_point_start = index - 1
48
+ cut_point_end = index - 1
49
+ last_space = text.rfind(" ", 0, cut_point_start)
50
+ last_nline = text.rfind("\n", 0, cut_point_start)
51
+
52
+ if last_space != -1 or last_nline != -1: # space was found !:
53
+ cut_point_start = max(last_space, last_nline)
54
+ cut_point_end = cut_point_start + 1
55
+ res = [text[:cut_point_start].strip()]
56
+ res.extend(self.cut_text_to_width(text[cut_point_end:].strip()))
57
+ return res
58
+ elif text[index] == "\n":
59
+ left = index
60
+ return [text]
61
+
62
+
63
+ def _set_text_internal(self,text:str)->Self:
64
+ super().set_text(text)
65
+ return self
66
+
67
+ def set_text(self,text:str)->Self:
68
+ self.original_text = text
69
+ self.is_over = False
70
+ self.cursor_position = 0
71
+
72
+ def set_size(self, size):
73
+ super().set_size(size)
74
+ self._set_text_internal('\n'.join(self.cut_text_to_width(self.original_text[: int(self.cursor_position)])))
75
+
76
+ def do_update(self, dt):
77
+ if self.is_over:
78
+ return
79
+ if not self.is_over and self.cursor_position == len(self.original_text):
80
+ if len(self.original_text) == 0:
81
+ self._set_text_internal("")
82
+ self.is_over = True
83
+ if self.end_callback is not None:
84
+ self.end_callback()
85
+ return
86
+ self.cursor_position = min(
87
+ self.cursor_position + self.text_speed * dt, len(self.original_text)
88
+ )
89
+ # self.set_text(self.original_text[: int(self.cursor_position)])
90
+ self._set_text_internal('\n'.join(self.cut_text_to_width(self.original_text[: int(self.cursor_position)])))
@@ -1,18 +1,18 @@
1
- from .label import Label
2
- import batFramework as bf
3
- from typing import Self, Callable,Any
4
- from .clickableWidget import ClickableWidget
5
-
6
-
7
- class Button(Label, ClickableWidget):
8
- def __init__(self, text: str = "", callback: Callable[[],Any] = None) -> None:
9
- super().__init__(text=text)
10
- self.set_callback(callback)
11
-
12
- def __str__(self) -> str:
13
- return f"Button('{self.text}')"
14
-
15
- def get_min_required_size(self):
16
- res = super().get_min_required_size()
17
- res = res[0],res[1]+self.unpressed_relief
1
+ from .label import Label
2
+ import batFramework as bf
3
+ from typing import Self, Callable,Any
4
+ from .clickableWidget import ClickableWidget
5
+
6
+
7
+ class Button(Label, ClickableWidget):
8
+ def __init__(self, text: str = "", callback: Callable[[],Any] = None) -> None:
9
+ super().__init__(text=text)
10
+ self.set_callback(callback)
11
+
12
+ def __str__(self) -> str:
13
+ return f"Button('{self.text_widget.text}')"
14
+
15
+ def get_min_required_size(self):
16
+ res = super().get_min_required_size()
17
+ res = res[0],res[1]+self.unpressed_relief
18
18
  return res