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,34 +1,34 @@
1
- import batFramework as bf
2
- import pygame
3
- from typing import Callable, Iterator
4
-
5
-
6
- class RenderGroup(bf.Drawable):
7
- def __init__(
8
- self, entity_iterator: Callable[[], Iterator[bf.Drawable]], blit_flags: int = 0
9
- ) -> None:
10
- super().__init__()
11
- self.entity_iterator = entity_iterator
12
- self.blit_flags = blit_flags
13
- self.set_debug_color("white")
14
-
15
- def draw(self, camera: bf.Camera) -> None:
16
- if not self.visible:
17
- return
18
-
19
- fblits_data = []
20
- for e in self.entity_iterator():
21
- if not getattr(e, "drawn_by_group", False):
22
- # Set flag to skip their individual draw call
23
- e.drawn_by_group = True
24
-
25
- if e.visible and camera.rect.colliderect(e.rect):
26
- fblits_data.append(
27
- (e.surface, (e.rect.x - camera.rect.x, e.rect.y - camera.rect.y))
28
- )
29
-
30
- camera.surface.fblits(fblits_data, self.blit_flags)
31
-
32
- def get_debug_outlines(self):
33
- for e in self.entity_iterator():
34
- yield from e.get_debug_outlines()
1
+ import batFramework as bf
2
+ import pygame
3
+ from typing import Callable, Iterator
4
+
5
+
6
+ class RenderGroup(bf.Drawable):
7
+ def __init__(
8
+ self, entity_iterator: Callable[[], Iterator[bf.Drawable]], blit_flags: int = 0
9
+ ) -> None:
10
+ super().__init__()
11
+ self.entity_iterator = entity_iterator
12
+ self.blit_flags = blit_flags
13
+ self.set_debug_color("white")
14
+
15
+ def draw(self, camera: bf.Camera) -> None:
16
+ if not self.visible:
17
+ return
18
+
19
+ fblits_data = []
20
+ for e in self.entity_iterator():
21
+ if not getattr(e, "drawn_by_group", False):
22
+ # Set flag to skip their individual draw call
23
+ e.drawn_by_group = True
24
+
25
+ if e.visible and camera.rect.colliderect(e.rect):
26
+ fblits_data.append(
27
+ (e.surface, (e.rect.x - camera.rect.x, e.rect.y - camera.rect.y))
28
+ )
29
+
30
+ camera.surface.fblits(fblits_data, self.blit_flags)
31
+
32
+ def get_debug_outlines(self):
33
+ for e in self.entity_iterator():
34
+ yield from e.get_debug_outlines()
@@ -1,130 +1,130 @@
1
- import batFramework as bf
2
- import os
3
- import pygame
4
- import sys
5
- import json
6
- from typing import Any, Callable
7
- from .utils import Singleton
8
- import asyncio
9
-
10
-
11
- if getattr(sys, "frozen", False):
12
- # If the application is run as a bundle, the PyInstaller bootloader
13
- # extends the sys module by a flag frozen=True and sets the app
14
- # path into variable _MEIPASS'.
15
- application_path = sys._MEIPASS
16
- else:
17
- application_path = os.getcwd()
18
-
19
-
20
- class ResourceManager(metaclass=Singleton):
21
- def __init__(self):
22
- self.shared_variables: dict[str, Any] = {}
23
- self.convert_image_cache = {}
24
- self.convert_alpha_image_cache = {}
25
- self.sound_cache = {}
26
- self.RESOURCE_PATH = "."
27
- self.loading_thread = None
28
-
29
- def load_resources(self, path: str, progress_callback: Callable[[float], Any] = None):
30
- """
31
- loads resources from a directory.
32
- Progress is reported through the callback.
33
- Supposed to be asynchronous but don't use it as such yet
34
- """
35
- self.progress_callback = progress_callback
36
-
37
- total_files = sum(
38
- len(files) for _, _, files in os.walk(path) if not any(f.startswith(".") for f in files)
39
- )
40
-
41
- loaded_files = 0
42
-
43
- for root, dirs, files in os.walk(path):
44
- files = [f for f in files if not f.startswith(".")]
45
- dirs[:] = [d for d in dirs if not (d.startswith(".") or d.startswith("__"))]
46
- for file in files:
47
- file_path = os.path.join(root, file)
48
-
49
- # Simulate resource loading
50
- # await asyncio.sleep(0) # Yield control to the event loop
51
-
52
- if file.lower().endswith((".png", ".jpg", ".jpeg", ".gif")):
53
- self.load_image(file_path)
54
- elif file.lower().endswith((".mp3", ".wav", ".ogg")):
55
- bf.AudioManager().load_sound(file.split(".")[0], file_path)
56
- elif file.lower().endswith((".ttf", ".otf")):
57
- bf.FontManager().load_font(file_path, file.split(".")[0])
58
-
59
- loaded_files += 1
60
- # Report progress
61
- # if self.progress_callback:
62
- # self.progress_callback(loaded_files / total_files)
63
-
64
- print(f"Loaded resources in directory: '{path}'")
65
-
66
-
67
- def set_resource_path(self, path: str):
68
- self.RESOURCE_PATH = os.path.join(application_path, path)
69
- print(f"Resource path : '{self.RESOURCE_PATH}'")
70
-
71
- def get_path(self, path: str) -> str:
72
- # Normalize path separators
73
- normalized_path = path.replace("/", os.sep).replace("\\", os.sep)
74
- return os.path.join(self.RESOURCE_PATH, normalized_path)
75
-
76
- def load_image(self, path) -> None:
77
- key = self.get_path(path)
78
- if key in self.convert_image_cache:
79
- return
80
- self.convert_image_cache[key] = pygame.image.load(path).convert()
81
- self.convert_alpha_image_cache[key] = pygame.image.load(path).convert_alpha()
82
-
83
-
84
- def get_image(self, path, convert_alpha: bool = False) -> pygame.Surface | None:
85
- key = self.get_path(path)
86
- return (
87
- self.convert_alpha_image_cache.get(key, None)
88
- if convert_alpha
89
- else self.convert_image_cache.get(key, None)
90
- )
91
-
92
- def load_json_from_file(self, path: str) -> dict | None:
93
- try:
94
- with open(self.get_path(path), "r") as file:
95
- data = json.load(file)
96
- return data
97
- except FileNotFoundError:
98
- print(f"File '{path}' not found")
99
- return None
100
-
101
- def save_json_to_file(self, path: str, data) -> bool:
102
- try:
103
- with open(self.get_path(path), "w") as file:
104
- json.dump(data, file, indent=2)
105
- return True
106
- except FileNotFoundError:
107
- return False
108
-
109
-
110
- def set_sharedVar(self, name, value) -> bool:
111
- """
112
- Set a shared variable of any type. This will be accessible (read/write) from any scene
113
- """
114
- self.shared_variables[name] = value
115
- return True
116
-
117
- def set_sharedVars(self, variables: dict) -> bool:
118
- """
119
- Set multiple shared variables at once. This will be accessible (read/write) from any scene.
120
- """
121
- if not isinstance(variables, dict):
122
- raise ValueError("Input must be a dictionary")
123
- self.shared_variables.update(variables)
124
- return True
125
-
126
- def get_sharedVar(self, name, error_value=None):
127
- """
128
- Get a shared variable
129
- """
130
- return self.shared_variables.get(name, error_value)
1
+ import batFramework as bf
2
+ import os
3
+ import pygame
4
+ import sys
5
+ import json
6
+ from typing import Any, Callable
7
+ from .utils import Singleton
8
+ import asyncio
9
+
10
+
11
+ if getattr(sys, "frozen", False):
12
+ # If the application is run as a bundle, the PyInstaller bootloader
13
+ # extends the sys module by a flag frozen=True and sets the app
14
+ # path into variable _MEIPASS'.
15
+ application_path = sys._MEIPASS
16
+ else:
17
+ application_path = os.getcwd()
18
+
19
+
20
+ class ResourceManager(metaclass=Singleton):
21
+ def __init__(self):
22
+ self.shared_variables: dict[str, Any] = {}
23
+ self.convert_image_cache = {}
24
+ self.convert_alpha_image_cache = {}
25
+ self.sound_cache = {}
26
+ self.RESOURCE_PATH = "."
27
+ self.loading_thread = None
28
+
29
+ def load_resources(self, path: str, progress_callback: Callable[[float], Any] = None):
30
+ """
31
+ loads resources from a directory.
32
+ Progress is reported through the callback.
33
+ Supposed to be asynchronous but don't use it as such yet
34
+ """
35
+ self.progress_callback = progress_callback
36
+
37
+ total_files = sum(
38
+ len(files) for _, _, files in os.walk(path) if not any(f.startswith(".") for f in files)
39
+ )
40
+
41
+ loaded_files = 0
42
+
43
+ for root, dirs, files in os.walk(path):
44
+ files = [f for f in files if not f.startswith(".")]
45
+ dirs[:] = [d for d in dirs if not (d.startswith(".") or d.startswith("__"))]
46
+ for file in files:
47
+ file_path = os.path.join(root, file)
48
+
49
+ # Simulate resource loading
50
+ # await asyncio.sleep(0) # Yield control to the event loop
51
+
52
+ if file.lower().endswith((".png", ".jpg", ".jpeg", ".gif")):
53
+ self.load_image(file_path)
54
+ elif file.lower().endswith((".mp3", ".wav", ".ogg")):
55
+ bf.AudioManager().load_sound(file.split(".")[0], file_path)
56
+ elif file.lower().endswith((".ttf", ".otf")):
57
+ bf.FontManager().load_font(file_path, file.split(".")[0])
58
+
59
+ loaded_files += 1
60
+ # Report progress
61
+ # if self.progress_callback:
62
+ # self.progress_callback(loaded_files / total_files)
63
+
64
+ print(f"Loaded resources in directory: '{path}'")
65
+
66
+
67
+ def set_resource_path(self, path: str):
68
+ self.RESOURCE_PATH = os.path.join(application_path, path)
69
+ print(f"Resource path : '{self.RESOURCE_PATH}'")
70
+
71
+ def get_path(self, path: str) -> str:
72
+ # Normalize path separators
73
+ normalized_path = path.replace("/", os.sep).replace("\\", os.sep)
74
+ return os.path.join(self.RESOURCE_PATH, normalized_path)
75
+
76
+ def load_image(self, path) -> None:
77
+ key = self.get_path(path)
78
+ if key in self.convert_image_cache:
79
+ return
80
+ self.convert_image_cache[key] = pygame.image.load(path).convert()
81
+ self.convert_alpha_image_cache[key] = pygame.image.load(path).convert_alpha()
82
+
83
+
84
+ def get_image(self, path, convert_alpha: bool = False) -> pygame.Surface | None:
85
+ key = self.get_path(path)
86
+ return (
87
+ self.convert_alpha_image_cache.get(key, None)
88
+ if convert_alpha
89
+ else self.convert_image_cache.get(key, None)
90
+ )
91
+
92
+ def load_json_from_file(self, path: str) -> dict | None:
93
+ try:
94
+ with open(self.get_path(path), "r") as file:
95
+ data = json.load(file)
96
+ return data
97
+ except FileNotFoundError:
98
+ print(f"File '{path}' not found")
99
+ return None
100
+
101
+ def save_json_to_file(self, path: str, data) -> bool:
102
+ try:
103
+ with open(self.get_path(path), "w") as file:
104
+ json.dump(data, file, indent=2)
105
+ return True
106
+ except FileNotFoundError:
107
+ return False
108
+
109
+
110
+ def set_sharedVar(self, name, value) -> bool:
111
+ """
112
+ Set a shared variable of any type. This will be accessible (read/write) from any scene
113
+ """
114
+ self.shared_variables[name] = value
115
+ return True
116
+
117
+ def set_sharedVars(self, variables: dict) -> bool:
118
+ """
119
+ Set multiple shared variables at once. This will be accessible (read/write) from any scene.
120
+ """
121
+ if not isinstance(variables, dict):
122
+ raise ValueError("Input must be a dictionary")
123
+ self.shared_variables.update(variables)
124
+ return True
125
+
126
+ def get_sharedVar(self, name, error_value=None):
127
+ """
128
+ Get a shared variable
129
+ """
130
+ return self.shared_variables.get(name, error_value)
batFramework/scene.py CHANGED
@@ -1,31 +1,31 @@
1
- from .baseScene import BaseScene
2
- import batFramework as bf
3
-
4
-
5
- class Scene(BaseScene):
6
- def __init__(self,name: str) -> None:
7
- """
8
- Default Scene object.
9
- Has 2 layers (world and hud) by default
10
- Contains an exposed root gui object on the hud layer
11
- Args:
12
- name: Name of the scene.
13
- """
14
- super().__init__(name)
15
- self.add_layer(bf.SceneLayer("world",True))
16
- hud_layer = bf.SceneLayer("hud",True)
17
- self.add_layer(hud_layer)
18
- self.root: bf.gui.Root = bf.gui.Root(hud_layer.camera)
19
- self.root.rect.center = hud_layer.camera.get_center()
20
- self.add("hud",self.root)
21
- self.entities_to_remove = []
22
- self.entities_to_add = []
23
-
24
- def on_enter(self):
25
- self.root.clear_hovered()
26
- self.root.build()
27
- super().on_enter()
28
-
29
- def on_exit(self):
30
- self.root.clear_hovered()
31
- super().on_exit()
1
+ from .baseScene import BaseScene
2
+ import batFramework as bf
3
+
4
+
5
+ class Scene(BaseScene):
6
+ def __init__(self,name: str) -> None:
7
+ """
8
+ Default Scene object.
9
+ Has 2 layers (world and hud) by default
10
+ Contains an exposed root gui object on the hud layer
11
+ Args:
12
+ name: Name of the scene.
13
+ """
14
+ super().__init__(name)
15
+ self.add_layer(bf.SceneLayer("world",True))
16
+ hud_layer = bf.SceneLayer("hud",True)
17
+ self.add_layer(hud_layer)
18
+ self.root: bf.gui.Root = bf.gui.Root(hud_layer.camera)
19
+ self.root.rect.center = hud_layer.camera.get_center()
20
+ self.add("hud",self.root)
21
+ self.entities_to_remove = []
22
+ self.entities_to_add = []
23
+
24
+ def on_enter(self):
25
+ self.root.clear_hovered()
26
+ self.root.build()
27
+ super().on_enter()
28
+
29
+ def on_exit(self):
30
+ self.root.clear_hovered()
31
+ super().on_exit()