update workflow, fix huge memory leak

This commit is contained in:
Yonokid
2025-05-02 15:56:00 -04:00
parent 08394cf97a
commit 6bf264a555
13 changed files with 369 additions and 115 deletions

View File

@@ -18,6 +18,7 @@ from libs.utils import (
load_texture_from_zip,
session_data,
)
from libs.video import VideoPlayer
class GameScreen:
@@ -80,6 +81,7 @@ class GameScreen:
self.sound_kat = audio.load_sound(str(sounds_dir / "inst_00_katsu.wav"))
self.sound_balloon_pop = audio.load_sound(str(sounds_dir / "balloon_pop.wav"))
self.sound_result_transition = audio.load_sound(str(sounds_dir / "result" / "VO_RESULT [1].ogg"))
self.sounds = [self.sound_don, self.sound_kat, self.sound_balloon_pop, self.sound_result_transition]
def init_tja(self, song: str, difficulty: int):
self.load_textures()
@@ -98,6 +100,11 @@ class GameScreen:
self.tja = TJAParser(song)
metadata = self.tja.get_metadata()
if hasattr(self.tja, 'bg_movie'):
self.movie = VideoPlayer(str(Path(self.tja.bg_movie)))
self.movie.set_volume(0.0)
else:
self.movie = None
self.tja.distance = self.width - self.judge_x
self.start_delay = 0
session_data.song_title = self.tja.title
@@ -115,6 +122,8 @@ class GameScreen:
self.current_ms = get_current_ms() - self.start_ms
self.song_info = SongInfo(self.current_ms, self.tja.title, 'TEST')
self.result_transition = None
if self.movie is not None:
self.movie.start(get_current_ms())
def on_screen_end(self):
self.screen_init = False
@@ -125,6 +134,8 @@ class GameScreen:
def update(self):
self.on_screen_start()
if self.movie is not None:
self.movie.update()
self.current_ms = get_current_ms() - self.start_ms
@@ -143,6 +154,8 @@ class GameScreen:
audio.play_sound(self.sound_result_transition)
def draw(self):
if self.movie is not None:
self.movie.draw()
self.player_1.draw(self)
if self.song_info is not None:
self.song_info.draw(self)
@@ -530,7 +543,7 @@ class Player:
ray.draw_texture(game_screen.note_type_list[note.type][current_eighth % 2], position, 192, ray.WHITE)
moji_texture = game_screen.texture_se_moji[note.moji]
ray.draw_texture(moji_texture, position - (moji_texture.width//2) + 64, 323, ray.WHITE)
#ray.draw_text(str(i), position+64, 192, 25, ray.GREEN)
#ray.draw_text(str(note.index), position+64, 192, 25, ray.GREEN)
def draw(self, game_screen: GameScreen):
ray.draw_texture(game_screen.textures['lane'][0], 332, 184, ray.WHITE)

View File

@@ -21,7 +21,6 @@ class ResultScreen:
self.width = width
self.height = height
self.screen_init = False
self.load_sounds()
def load_textures(self):
zip_file = Path('Graphics/lumendata/enso_result.zip')
@@ -37,6 +36,7 @@ class ResultScreen:
def on_screen_start(self):
if not self.screen_init:
self.load_textures()
self.load_sounds()
self.screen_init = True
self.song_info = FontText(session_data.song_title, 40).texture
audio.play_sound(self.bgm)

View File

@@ -16,9 +16,6 @@ class SongSelectScreen:
self.selected_song = 0
self.selected_difficulty = 0
self.selected_index = 0
sounds_dir = Path("Sounds")
self.sound_don = audio.load_sound(str(sounds_dir / "inst_00_don.wav"))
self.sound_kat = audio.load_sound(str(sounds_dir / "inst_00_katsu.wav"))
for dirpath, dirnames, filenames in os.walk(f'{get_config()["paths"]["tja_path"]}'):
for filename in filenames:
if filename.endswith(".tja"):
@@ -26,8 +23,14 @@ class SongSelectScreen:
self.screen_init = False
def load_sounds(self):
sounds_dir = Path("Sounds")
self.sound_don = audio.load_sound(str(sounds_dir / "inst_00_don.wav"))
self.sound_kat = audio.load_sound(str(sounds_dir / "inst_00_katsu.wav"))
def on_screen_start(self):
if not self.screen_init:
self.load_sounds()
self.screen_init = True
self.is_song_select = True
self.is_difficulty_select = False

View File

@@ -48,9 +48,8 @@ class TitleScreen:
self.load_textures()
self.scene = 'Opening Video'
self.op_video = VideoPlayer(random.choice(self.op_video_list))
self.op_video._convert_frames()
self.warning_board = WarningScreen(get_current_ms(), self)
self.attract_video = VideoPlayer(random.choice(self.attract_video_list))
self.warning_board = None
def on_screen_end(self) -> str:
self.op_video.stop()
@@ -66,32 +65,28 @@ class TitleScreen:
def scene_manager(self):
if self.scene == 'Opening Video':
if not self.op_video.is_started():
self.op_video.start(get_current_ms())
self.op_video.update()
self.attract_video.convert_frames_background()
if self.op_video.is_finished():
self.op_video.stop()
self.op_video = VideoPlayer(random.choice(self.op_video_list))
self.scene = 'Warning Board'
self.warning_board = WarningScreen(get_current_ms(), self)
elif self.scene == 'Warning Board':
elif self.scene == 'Warning Board' and self.warning_board is not None:
self.warning_board.update(get_current_ms(), self)
self.op_video.convert_frames_background()
self.attract_video.convert_frames_background()
if self.warning_board.is_finished:
self.scene = 'Attract Video'
self.attract_video.start_ms = get_current_ms()
self.attract_video.start(get_current_ms())
elif self.scene == 'Attract Video':
while not self.attract_video.all_frames_converted:
self.attract_video.convert_frames_background()
if self.attract_video.all_frames_converted:
self.attract_video.start_ms = get_current_ms()
self.attract_video.update()
self.op_video.convert_frames_background()
if self.attract_video.is_finished():
self.attract_video.stop()
self.attract_video = VideoPlayer(random.choice(self.attract_video_list))
self.scene = 'Opening Video'
self.op_video.start_ms = get_current_ms()
self.op_video.start(get_current_ms())
def update(self):
@@ -104,7 +99,7 @@ class TitleScreen:
def draw(self):
if self.scene == 'Opening Video':
self.op_video.draw()
elif self.scene == 'Warning Board':
elif self.scene == 'Warning Board' and self.warning_board is not None:
bg_source = ray.Rectangle(0, 0, self.textures['keikoku'][0].width, self.textures['keikoku'][0].height)
bg_dest = ray.Rectangle(0, 0, self.width, self.height)
ray.draw_texture_pro(self.textures['keikoku'][0], bg_source, bg_dest, ray.Vector2(0,0), 0, ray.WHITE)