batframework 1.0.8a1__py3-none-any.whl → 1.0.8a2__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.
- batFramework/__init__.py +50 -53
- batFramework/action.py +105 -116
- batFramework/actionContainer.py +11 -53
- batFramework/animatedSprite.py +65 -115
- batFramework/audioManager.py +26 -70
- batFramework/camera.py +68 -253
- batFramework/constants.py +54 -16
- batFramework/cutscene.py +25 -34
- batFramework/cutsceneBlocks.py +42 -37
- batFramework/debugger.py +48 -0
- batFramework/dynamicEntity.py +7 -9
- batFramework/easing.py +71 -0
- batFramework/entity.py +98 -42
- batFramework/gui/__init__.py +2 -8
- batFramework/gui/button.py +79 -7
- batFramework/gui/constraints.py +204 -0
- batFramework/gui/container.py +31 -155
- batFramework/gui/debugger.py +43 -124
- batFramework/gui/frame.py +19 -0
- batFramework/gui/image.py +17 -41
- batFramework/gui/indicator.py +21 -41
- batFramework/gui/interactiveWidget.py +13 -116
- batFramework/gui/label.py +73 -278
- batFramework/gui/layout.py +61 -148
- batFramework/gui/root.py +37 -102
- batFramework/gui/shape.py +57 -258
- batFramework/gui/toggle.py +46 -97
- batFramework/gui/widget.py +254 -268
- batFramework/manager.py +19 -40
- batFramework/particles.py +77 -0
- batFramework/scene.py +107 -214
- batFramework/sceneManager.py +107 -150
- batFramework/stateMachine.py +0 -1
- batFramework/time.py +57 -117
- batFramework/transition.py +126 -184
- batFramework/transitionManager.py +0 -0
- batFramework/utils.py +161 -34
- batframework-1.0.8a2.dist-info/METADATA +58 -0
- batframework-1.0.8a2.dist-info/RECORD +42 -0
- {batframework-1.0.8a1.dist-info → batframework-1.0.8a2.dist-info}/WHEEL +1 -1
- batFramework/easingController.py +0 -58
- batFramework/enums.py +0 -104
- batFramework/fontManager.py +0 -65
- batFramework/gui/clickableWidget.py +0 -206
- batFramework/gui/constraints/__init__.py +0 -1
- batFramework/gui/constraints/constraints.py +0 -378
- batFramework/gui/dialogueBox.py +0 -96
- batFramework/gui/draggableWidget.py +0 -38
- batFramework/gui/meter.py +0 -76
- batFramework/gui/radioButton.py +0 -62
- batFramework/gui/slider.py +0 -220
- batFramework/gui/textInput.py +0 -134
- batFramework/object.py +0 -115
- batFramework/particle.py +0 -101
- batFramework/renderGroup.py +0 -62
- batFramework/resourceManager.py +0 -84
- batFramework/scrollingSprite.py +0 -113
- batFramework/sprite.py +0 -45
- batFramework/tileset.py +0 -46
- batframework-1.0.8a1.dist-info/LICENCE +0 -21
- batframework-1.0.8a1.dist-info/METADATA +0 -55
- batframework-1.0.8a1.dist-info/RECORD +0 -56
- {batframework-1.0.8a1.dist-info → batframework-1.0.8a2.dist-info}/top_level.txt +0 -0
batFramework/camera.py
CHANGED
@@ -1,308 +1,123 @@
|
|
1
|
+
import batFramework as bf
|
1
2
|
import pygame
|
2
3
|
from pygame.math import Vector2
|
3
|
-
import batFramework as bf
|
4
|
-
from typing import Self
|
5
4
|
|
6
5
|
|
7
6
|
class Camera:
|
8
|
-
def __init__(
|
9
|
-
self
|
10
|
-
|
11
|
-
|
12
|
-
Initialize the Camera object.
|
13
|
-
|
14
|
-
Args:
|
15
|
-
flags (int): Flags for camera initialization.
|
16
|
-
size (tuple): Optional size for camera (defaults to window size)
|
17
|
-
convert_alpha (bool): Convert surface to support alpha values
|
18
|
-
"""
|
19
|
-
self.cached_surfaces: dict[tuple[int, int], pygame.Surface] = {}
|
20
|
-
|
21
|
-
self.target_size = size if size else bf.const.RESOLUTION
|
22
|
-
self.should_convert_alpha: bool = convert_alpha
|
23
|
-
self.rect = pygame.FRect(0, 0, *self.target_size)
|
24
|
-
self.vector_center = Vector2(0, 0)
|
25
|
-
|
26
|
-
self.surface: pygame.Surface = pygame.Surface((0, 0)) # tmp dummy
|
27
|
-
self.flags: int = flags | (pygame.SRCALPHA if convert_alpha else 0)
|
7
|
+
def __init__(self, flags=0) -> None:
|
8
|
+
self.rect = pygame.FRect(0, 0, *bf.const.RESOLUTION)
|
9
|
+
self.flags: int = flags
|
10
|
+
# self.blit_special_flags : int =pygame.BLEND_PREMULTIPLIED if (flags & pygame.SRCALPHA) else 0
|
28
11
|
self.blit_special_flags: int = pygame.BLEND_ALPHA_SDL2
|
29
|
-
|
30
|
-
self._clear_color: pygame.Color = pygame.Color(0, 0, 0, 0)
|
31
|
-
if not convert_alpha:
|
32
|
-
self._clear_color = pygame.Color(0, 0, 0)
|
33
|
-
|
34
|
-
self.follow_point_func = None
|
35
|
-
self.follow_friction: float = 0.5
|
36
|
-
|
12
|
+
self._clear_color : pygame.Color = pygame.Color(0, 0, 0, 0)
|
37
13
|
self.zoom_factor = 1
|
14
|
+
self.cached_surfaces: dict[float, pygame.Surface] = {}
|
15
|
+
self.surface: pygame.Surface = pygame.Surface((0,0))
|
16
|
+
self.follow_point_func = None
|
38
17
|
self.max_zoom = 2
|
39
18
|
self.min_zoom = 0.1
|
40
19
|
self.zoom(1)
|
41
20
|
|
42
|
-
def set_clear_color(self, color: pygame.Color
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
Args:
|
47
|
-
color (pygame.Color | tuple): Color to set as the clear color.
|
48
|
-
|
49
|
-
Returns:
|
50
|
-
Camera: Returns the Camera object.
|
51
|
-
"""
|
21
|
+
def set_clear_color(self, color: pygame.Color|tuple):
|
22
|
+
if not isinstance(color,pygame.Color):
|
23
|
+
color = pygame.Color(color)
|
52
24
|
self._clear_color = color
|
53
|
-
return self
|
54
25
|
|
55
|
-
def set_max_zoom(self,
|
56
|
-
"""
|
57
|
-
Set the maximum zoom value for the camera.
|
58
|
-
|
59
|
-
Args:
|
60
|
-
value (float): Maximum zoom value.
|
61
|
-
|
62
|
-
Returns:
|
63
|
-
Camera: Returns the Camera object.
|
64
|
-
"""
|
26
|
+
def set_max_zoom(self,value:float):
|
65
27
|
self.max_zoom = value
|
66
|
-
return self
|
67
|
-
|
68
|
-
def set_min_zoom(self, value: float) -> Self:
|
69
|
-
"""
|
70
|
-
Set the minimum zoom value for the camera.
|
71
|
-
|
72
|
-
Args:
|
73
|
-
value (float): Minimum zoom value.
|
74
28
|
|
75
|
-
|
76
|
-
Camera: Returns the Camera object.
|
77
|
-
"""
|
29
|
+
def set_min_zoom(self,value:float):
|
78
30
|
self.min_zoom = value
|
79
|
-
return self
|
80
31
|
|
81
|
-
def clear(self)
|
32
|
+
def clear(self):
|
82
33
|
"""
|
83
|
-
Clear the camera surface with the set clear color
|
34
|
+
Clear the camera surface with the set clear color
|
35
|
+
(default is tranparent)
|
84
36
|
"""
|
85
37
|
self.surface.fill(self._clear_color)
|
86
38
|
|
87
|
-
def get_center(self)
|
88
|
-
"""
|
89
|
-
Get the center of the camera's view.
|
90
|
-
|
91
|
-
Returns:
|
92
|
-
tuple[float,float]: Returns the center coordinates.
|
93
|
-
"""
|
39
|
+
def get_center(self):
|
94
40
|
return self.rect.center
|
95
41
|
|
96
|
-
|
97
|
-
"""
|
98
|
-
Get the center of the camera's view.
|
42
|
+
|
99
43
|
|
100
|
-
|
101
|
-
tuple[float,float]: Returns the center coordinates.
|
44
|
+
def move(self, x, y):
|
102
45
|
"""
|
103
|
-
|
104
|
-
|
105
|
-
def move_by(self, x: float | int, y: float | int) -> Self:
|
46
|
+
Moves the camera rect by the given coordinates (+=)
|
106
47
|
"""
|
107
|
-
|
108
|
-
|
109
|
-
Args:
|
110
|
-
x: X-coordinate to move.
|
111
|
-
y: Y-coordinate to move.
|
48
|
+
self.rect.topleft += Vector2(x, y)
|
112
49
|
|
113
|
-
|
114
|
-
Camera: Returns the Camera object.
|
50
|
+
def set_position(self, x, y):
|
115
51
|
"""
|
116
|
-
|
117
|
-
return self
|
118
|
-
|
119
|
-
def set_position(self, x, y) -> Self:
|
120
|
-
"""
|
121
|
-
Set the camera rect top-left position.
|
122
|
-
|
123
|
-
Args:
|
124
|
-
x: X-coordinate to set.
|
125
|
-
y: Y-coordinate to set.
|
126
|
-
|
127
|
-
Returns:
|
128
|
-
Camera: Returns the Camera object.
|
52
|
+
Set the camera rect topleft position
|
129
53
|
"""
|
130
54
|
self.rect.topleft = (x, y)
|
131
55
|
|
132
|
-
|
133
|
-
|
134
|
-
def set_center(self, x, y) -> Self:
|
56
|
+
def set_center(self, x, y):
|
135
57
|
"""
|
136
|
-
Set the camera rect center position
|
137
|
-
|
138
|
-
Args:
|
139
|
-
x: X-coordinate for the center.
|
140
|
-
y: Y-coordinate for the center.
|
141
|
-
|
142
|
-
Returns:
|
143
|
-
Camera: Returns the Camera object.
|
58
|
+
Set the camera rect center position
|
144
59
|
"""
|
145
60
|
self.rect.center = (x, y)
|
146
|
-
return self
|
147
61
|
|
148
|
-
def
|
62
|
+
def set_follow_dynamic_point(self, func):
|
149
63
|
"""
|
150
|
-
Set the following function (returns tuple x y)
|
151
|
-
|
152
|
-
|
153
|
-
Args:
|
154
|
-
func: Function returning coordinates to follow.
|
155
|
-
|
156
|
-
Returns:
|
157
|
-
Camera: Returns the Camera object.
|
64
|
+
Set the following function (returns tuple x y)
|
65
|
+
(camera will center its position to the center of the given coordinates)
|
158
66
|
"""
|
159
67
|
self.follow_point_func = func
|
160
|
-
self.follow_speed = follow_speed if func else 0.1
|
161
|
-
return self
|
162
|
-
|
163
|
-
def set_follow_friction(self,friction:float)->Self:
|
164
|
-
self.follow_friction = friction
|
165
|
-
return self
|
166
|
-
|
167
|
-
def zoom_by(self, amount: float) -> Self:
|
168
|
-
"""
|
169
|
-
Zooms the camera by the given amount.
|
170
68
|
|
171
|
-
|
172
|
-
|
69
|
+
def zoom_by(self, amount:float):
|
70
|
+
self.zoom(self.zoom_factor + amount)
|
173
71
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
def zoom(self, factor: float) -> Self:
|
181
|
-
"""
|
182
|
-
Zooms the camera to the given factor.
|
183
|
-
|
184
|
-
Args:
|
185
|
-
factor: Factor to set for zooming.
|
186
|
-
|
187
|
-
Returns:
|
188
|
-
Camera: Returns the Camera object.
|
189
|
-
"""
|
190
|
-
if factor < self.min_zoom or factor > self.max_zoom:
|
191
|
-
print(
|
192
|
-
f"Zoom value {factor} is outside the zoom range : [{self.min_zoom},{self.max_zoom}]"
|
193
|
-
)
|
194
|
-
return self
|
195
|
-
|
196
|
-
factor = round(factor, 2)
|
72
|
+
def zoom(self, factor):
|
73
|
+
if factor <self.min_zoom:
|
74
|
+
return
|
75
|
+
if factor > self.max_zoom:
|
76
|
+
return
|
77
|
+
factor = round(factor,2)
|
197
78
|
self.zoom_factor = factor
|
198
|
-
|
199
|
-
|
79
|
+
if factor not in self.cached_surfaces:
|
80
|
+
# if factor != 1 : print("creating new surface in cache : ",tuple(i * factor for i in const.RESOLUTION), self.flags)
|
81
|
+
self.cached_surfaces[factor] = pygame.Surface(
|
82
|
+
tuple(i / factor for i in bf.const.RESOLUTION), flags=self.flags
|
83
|
+
).convert_alpha()
|
84
|
+
# c = self.surface.get_colorkey() if self.surface else None
|
85
|
+
# if c : self.cached_surfaces[factor].set_colorkey(c)
|
86
|
+
self.cached_surfaces[factor].fill((0, 0, 0, 0))
|
87
|
+
|
88
|
+
self.surface = self.cached_surfaces[self.zoom_factor]
|
200
89
|
self.rect = self.surface.get_frect(center=self.rect.center)
|
201
|
-
self.
|
202
|
-
return self
|
203
|
-
|
204
|
-
def _free_cache(self):
|
205
|
-
self.cached_surfaces = {}
|
206
|
-
|
207
|
-
def _get_cached_surface(self, new_size: tuple[int, int]):
|
208
|
-
surface = self.cached_surfaces.get(new_size, None)
|
209
|
-
if surface is None:
|
210
|
-
surface = pygame.Surface(new_size, flags=self.flags)
|
211
|
-
if self.flags & pygame.SRCALPHA:
|
212
|
-
surface = surface.convert_alpha()
|
213
|
-
self.cached_surfaces[new_size] = surface
|
214
|
-
|
215
|
-
return surface
|
216
|
-
|
217
|
-
def resize(self, size: tuple[int, int] | None = None) -> Self:
|
218
|
-
if size is None:
|
219
|
-
size = bf.const.RESOLUTION
|
220
|
-
self.target_size = size
|
221
|
-
self.rect.center = (size[0] / 2, size[1] / 2)
|
222
|
-
self.zoom(self.zoom_factor)
|
223
|
-
|
224
|
-
return self
|
90
|
+
# if factor != 1 : print(self.cached_surfaces)
|
225
91
|
|
226
92
|
def intersects(self, rect: pygame.Rect | pygame.FRect) -> bool:
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
Returns:
|
234
|
-
bool: True if intersection occurs, False otherwise.
|
235
|
-
"""
|
236
|
-
return self.rect.colliderect(rect)
|
237
|
-
|
238
|
-
def world_to_screen(
|
239
|
-
self, rect: pygame.Rect | pygame.FRect
|
240
|
-
) -> pygame.Rect | pygame.FRect:
|
241
|
-
"""
|
242
|
-
world_to_screen the given rectangle coordinates relative to the camera.
|
243
|
-
|
244
|
-
Args:
|
245
|
-
rect (pygame.Rect | pygame.FRect): Rectangle to world_to_screen.
|
246
|
-
|
247
|
-
Returns:
|
248
|
-
pygame.FRect: Transposed rectangle.
|
249
|
-
"""
|
250
|
-
return pygame.FRect(rect[0] - self.rect.left, rect[1] - self.rect.top, rect[2],rect[3])
|
251
|
-
|
252
|
-
def world_to_screen_point(
|
253
|
-
self, point: tuple[float, float] | tuple[int, int]
|
254
|
-
) -> tuple[float, float]:
|
255
|
-
"""
|
256
|
-
world_to_screen the given 2D point coordinates relative to the camera.
|
257
|
-
|
258
|
-
Args:
|
259
|
-
point (tuple[float,float] | tuple[int,int]): Point to world_to_screen.
|
93
|
+
return (
|
94
|
+
self.rect.x < rect.right
|
95
|
+
and self.rect.right > rect.x
|
96
|
+
and self.rect.y < rect.bottom
|
97
|
+
and self.rect.bottom > rect.y
|
98
|
+
)
|
260
99
|
|
261
|
-
Returns:
|
262
|
-
tuple[float,float] : Transposed point.
|
263
|
-
"""
|
264
|
-
return point[0] - self.rect.x, point[1] - self.rect.y
|
265
100
|
|
266
|
-
def
|
267
|
-
|
268
|
-
|
269
|
-
"""
|
270
|
-
Convert screen coordinates to world coordinates based on camera settings.
|
101
|
+
def transpose(self, rect: pygame.Rect | pygame.FRect) -> pygame.Rect | pygame.FRect:
|
102
|
+
x, y = round(rect.x - self.rect.left), round(rect.y - self.rect.top)
|
103
|
+
return pygame.Rect(x, y, *rect.size)
|
271
104
|
|
272
|
-
|
273
|
-
|
274
|
-
Returns:
|
275
|
-
tuple: Converted world coordinates.
|
276
|
-
"""
|
277
|
-
return (
|
278
|
-
point[0] / self.zoom_factor + self.rect.x,
|
279
|
-
point[1] / self.zoom_factor + self.rect.y,
|
280
|
-
)
|
105
|
+
def convert_screen_to_world(self, x, y):
|
106
|
+
return x / self.zoom_factor + self.rect.x, y / self.zoom_factor + self.rect.y
|
281
107
|
|
282
108
|
def update(self, dt):
|
283
|
-
"""
|
284
|
-
Update the camera position based on the follow point function.
|
285
|
-
|
286
|
-
Args:
|
287
|
-
dt: Time delta for updating the camera position.
|
288
|
-
"""
|
289
109
|
if self.follow_point_func:
|
290
|
-
self.
|
291
|
-
|
292
|
-
self.set_center(*self.vector_center.lerp(self.follow_point_func(), amount))
|
110
|
+
target = self.follow_point_func()
|
111
|
+
self.rect.center = Vector2(self.rect.center).lerp(target, ((dt * 60) * 0.1))
|
293
112
|
|
294
113
|
def draw(self, surface: pygame.Surface):
|
295
|
-
|
296
|
-
Draw the camera view onto the provided surface with proper scaling.
|
297
|
-
|
298
|
-
Args:
|
299
|
-
surface (pygame.Surface): Surface to draw the camera view onto.
|
300
|
-
"""
|
114
|
+
# pygame.draw.circle(surface,bf.color.ORANGE,self.surface.get_rect().center,4)
|
301
115
|
if self.zoom_factor == 1:
|
302
116
|
surface.blit(self.surface, (0, 0), special_flags=self.blit_special_flags)
|
303
|
-
# surface.blit(self.surface, (0, 0))
|
304
117
|
return
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
118
|
+
# print("From",self.surface,"Target RESOLUTION",const.RESOLUTION,"Destination",surface)
|
119
|
+
surface.blit(
|
120
|
+
pygame.transform.scale(self.surface, bf.const.RESOLUTION),
|
121
|
+
(0, 0),
|
122
|
+
special_flags=self.blit_special_flags,
|
123
|
+
)
|
batFramework/constants.py
CHANGED
@@ -1,37 +1,75 @@
|
|
1
1
|
import pygame
|
2
|
+
from enum import Enum
|
2
3
|
|
3
4
|
|
4
5
|
class Constants:
|
5
|
-
SCREEN
|
6
|
-
RESOLUTION: tuple[int, int] = (1280,
|
6
|
+
SCREEN = None
|
7
|
+
RESOLUTION: tuple[int, int] = (1280,720)
|
7
8
|
VSYNC = 0
|
8
9
|
FLAGS: int = pygame.SCALED | pygame.RESIZABLE
|
9
10
|
FPS: int = 60
|
11
|
+
RESOURCE_PATH = "."
|
12
|
+
|
13
|
+
@staticmethod
|
14
|
+
def init_screen(resolution:tuple[int,int],flags:int= 0, vsync:int= 0):
|
15
|
+
Constants.RESOLUTION = resolution
|
16
|
+
Constants.FLAGS = flags
|
17
|
+
Constants.VSYNC = vsync
|
18
|
+
Constants.SCREEN = pygame.display.set_mode(Constants.RESOLUTION, Constants.FLAGS,vsync=Constants.VSYNC)
|
19
|
+
print(f"Window : {resolution[0]}x{resolution[1]}px | flags:{flags.bit_count()}, vsync:{pygame.display.is_vsync()}")
|
10
20
|
MUSIC_END_EVENT = pygame.event.custom_type()
|
11
21
|
|
12
|
-
|
13
|
-
|
14
|
-
DEFAULT_CLICK_CURSOR = pygame.cursors.Cursor(pygame.SYSTEM_CURSOR_ARROW)
|
22
|
+
# ------------GUI SPECIFIC
|
23
|
+
DEFAULT_TEXT_SIZE: int = 8
|
15
24
|
|
16
|
-
|
25
|
+
GUI_SCALE: int = 1
|
26
|
+
# ---------------------
|
17
27
|
|
18
28
|
@staticmethod
|
19
|
-
def set_resolution(resolution: tuple[int,
|
29
|
+
def set_resolution(resolution : tuple[int,int]):
|
20
30
|
Constants.RESOLUTION = resolution
|
21
31
|
|
22
32
|
@staticmethod
|
23
|
-
def
|
24
|
-
|
33
|
+
def set_resource_path(path: str):
|
34
|
+
print("set resource path :", path)
|
35
|
+
Constants.RESOURCE_PATH = path
|
25
36
|
|
26
37
|
@staticmethod
|
27
|
-
def
|
28
|
-
Constants.
|
38
|
+
def set_fps_limit(value: int):
|
39
|
+
Constants.FPS = value
|
40
|
+
print("FPS limit to : ", value)
|
29
41
|
|
30
42
|
@staticmethod
|
31
|
-
def
|
32
|
-
Constants.
|
43
|
+
def set_gui_scale(value: int):
|
44
|
+
Constants.GUI_SCALE = value
|
45
|
+
print("GUI_SCALE to : ", value)
|
33
46
|
|
34
47
|
@staticmethod
|
35
|
-
def
|
36
|
-
Constants.
|
37
|
-
|
48
|
+
def set_default_text_size(size:int):
|
49
|
+
Constants.DEFAULT_TEXT_SIZE = size
|
50
|
+
|
51
|
+
class Colors:
|
52
|
+
LIGHT_CYAN = (179, 229, 252)
|
53
|
+
WASHED_BLUE = (52, 73, 94)
|
54
|
+
RIVER_BLUE = (52, 152, 219)
|
55
|
+
DARK_INDIGO = (40, 53, 147)
|
56
|
+
LIGHT_BLUE = (3, 169, 244)
|
57
|
+
DEEP_BLUE = (41, 121, 255)
|
58
|
+
DARK_BLUE = (44, 62, 80)
|
59
|
+
GREEN = (67, 160, 71)
|
60
|
+
DARK_GREEN = (39, 174, 96)
|
61
|
+
BROWN = (109, 76, 65)
|
62
|
+
DARK_RED = (192, 57, 43)
|
63
|
+
ORANGE = (251, 140, 0)
|
64
|
+
CLOUD_WHITE = (236, 240, 241)
|
65
|
+
SILVER = (189, 195, 199)
|
66
|
+
DARK_GRAY = (66, 66, 66)
|
67
|
+
|
68
|
+
DARK_GB = (27, 42, 9)
|
69
|
+
SHADE_GB = (14, 69, 11)
|
70
|
+
BASE_GB = (73, 107, 34)
|
71
|
+
LIGHT_GB = (154, 158, 63)
|
72
|
+
|
73
|
+
class Axis(Enum):
|
74
|
+
HORIZONTAL = 1
|
75
|
+
VERTICAL = 2
|
batFramework/cutscene.py
CHANGED
@@ -10,13 +10,10 @@ class Cutscene:
|
|
10
10
|
|
11
11
|
|
12
12
|
class CutsceneManager(metaclass=bf.Singleton):
|
13
|
-
def __init__(self) -> None:
|
13
|
+
def __init__(self, manager) -> None:
|
14
14
|
self.current_cutscene: Cutscene = None
|
15
|
-
self.cutscenes: list[bf.Cutscene] = []
|
16
|
-
self.manager: bf.Manager =
|
17
|
-
|
18
|
-
def set_manager(self, manager):
|
19
|
-
self.manager = manager
|
15
|
+
self.cutscenes : list[bf.Cutscene] = []
|
16
|
+
self.manager: bf.Manager = manager
|
20
17
|
|
21
18
|
def get_flag(self, flag):
|
22
19
|
return None
|
@@ -25,11 +22,11 @@ class CutsceneManager(metaclass=bf.Singleton):
|
|
25
22
|
if self.current_cutscene:
|
26
23
|
self.current_cutscene.process_event(event)
|
27
24
|
|
28
|
-
def queue(self
|
25
|
+
def queue(self,*cutscenes):
|
29
26
|
self.cutscenes.extend(cutscenes)
|
30
27
|
if self.current_cutscene is None:
|
31
28
|
self.play(self.cutscenes.pop(0))
|
32
|
-
|
29
|
+
|
33
30
|
def play(self, cutscene: Cutscene):
|
34
31
|
if self.current_cutscene is None:
|
35
32
|
self.current_cutscene = cutscene
|
@@ -38,33 +35,25 @@ class CutsceneManager(metaclass=bf.Singleton):
|
|
38
35
|
self.current_cutscene.play()
|
39
36
|
self.manager.set_sharedVar("in_cutscene", True)
|
40
37
|
|
41
|
-
def enable_player_control(self) -> None:
|
42
|
-
self.manager.set_sharedVar("player_has_control", True)
|
43
|
-
|
44
|
-
def disable_player_control(self) -> None:
|
45
|
-
self.manager.set_sharedVar("player_has_control", False)
|
46
|
-
|
47
38
|
def update(self, dt):
|
48
39
|
if not self.current_cutscene is None:
|
49
40
|
self.current_cutscene.update(dt)
|
50
41
|
# print("cutscene manager update")
|
51
42
|
if self.current_cutscene.has_ended():
|
52
43
|
self.current_cutscene.on_exit()
|
53
|
-
self.current_cutscene =
|
44
|
+
self.current_cutscene =None
|
54
45
|
if self.cutscenes:
|
55
46
|
self.play(self.cutscenes.pop(0))
|
56
47
|
else:
|
57
48
|
self.current_cutscene = None
|
58
49
|
self.manager.set_sharedVar("in_cutscene", False)
|
59
50
|
|
60
|
-
|
61
51
|
class Cutscene:
|
62
|
-
def __init__(self) -> None:
|
63
|
-
self.cutscene_blocks =
|
52
|
+
def __init__(self,*blocks) -> None:
|
53
|
+
self.cutscene_blocks: list[CutsceneBlock] = list(blocks)
|
64
54
|
self.block_index = 0
|
65
|
-
self.end_blocks: list[CutsceneBlock] = []
|
55
|
+
self.end_blocks : list[CutsceneBlock] = []
|
66
56
|
self.ended = False
|
67
|
-
|
68
57
|
def on_enter(self):
|
69
58
|
pass
|
70
59
|
|
@@ -74,26 +63,23 @@ class Cutscene:
|
|
74
63
|
def init_blocks(self):
|
75
64
|
pass
|
76
65
|
|
77
|
-
def
|
78
|
-
|
66
|
+
def add_end_block(self,block):
|
67
|
+
block.set_parent_cutscene(self)
|
68
|
+
self.end_blocks.append(block)
|
79
69
|
|
80
|
-
def
|
81
|
-
|
82
|
-
self.end_blocks.extend(blocks)
|
83
|
-
|
84
|
-
def get_scene_at(self, index):
|
85
|
-
return bf.CutsceneManager().manager.scenes[index]
|
70
|
+
def get_scene_at(self,index):
|
71
|
+
return bf.CutsceneManager().manager._scenes[index]
|
86
72
|
|
87
73
|
def get_current_scene(self):
|
88
74
|
return bf.CutsceneManager().manager.get_current_scene()
|
75
|
+
|
76
|
+
def set_scene(self,name,index=0):
|
77
|
+
return bf.CutsceneManager().manager.set_scene(name,index)
|
89
78
|
|
90
|
-
def
|
91
|
-
return bf.CutsceneManager().manager.set_scene(name, index)
|
92
|
-
|
93
|
-
def get_scene(self, name):
|
79
|
+
def get_scene(self,name):
|
94
80
|
return bf.CutsceneManager().manager.get_scene(name)
|
95
|
-
|
96
|
-
def add_block(self, *blocks: CutsceneBlock):
|
81
|
+
|
82
|
+
def add_block(self, *blocks: list[CutsceneBlock]):
|
97
83
|
for block in blocks:
|
98
84
|
block.set_parent_cutscene(self)
|
99
85
|
self.cutscene_blocks.append(block)
|
@@ -112,6 +98,7 @@ class Cutscene:
|
|
112
98
|
def update(self, dt):
|
113
99
|
if self.ended:
|
114
100
|
return
|
101
|
+
# print("cutscene update",self.cutscene_blocks[self.block_index])
|
115
102
|
self.cutscene_blocks[self.block_index].update(dt)
|
116
103
|
if self.cutscene_blocks[self.block_index].has_ended():
|
117
104
|
self.block_index += 1
|
@@ -124,5 +111,9 @@ class Cutscene:
|
|
124
111
|
self.end_blocks = []
|
125
112
|
self.cutscene_blocks[self.block_index].start()
|
126
113
|
|
114
|
+
# print("NEXT BLOCK")
|
115
|
+
|
127
116
|
def has_ended(self):
|
128
117
|
return self.ended
|
118
|
+
|
119
|
+
|