mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
add a loading bar
This commit is contained in:
@@ -28,6 +28,12 @@ class Background:
|
||||
self.footer.draw()
|
||||
self.donbg.draw()
|
||||
|
||||
def unload(self):
|
||||
self.donbg.unload()
|
||||
self.bg_normal.unload()
|
||||
self.bg_fever.unload()
|
||||
self.footer.unload()
|
||||
|
||||
class DonBG:
|
||||
|
||||
@staticmethod
|
||||
@@ -52,6 +58,11 @@ class DonBGBase:
|
||||
if self.move.is_finished:
|
||||
self.move.restart()
|
||||
|
||||
def unload(self):
|
||||
for texture_group in self.textures:
|
||||
for texture in self.textures[texture_group]:
|
||||
ray.unload_texture(texture)
|
||||
|
||||
class DonBG1(DonBGBase):
|
||||
def __init__(self, index: int, screen_width: int, screen_height: int, player_num: int):
|
||||
super().__init__(index, screen_width, screen_height, player_num)
|
||||
@@ -114,6 +125,11 @@ class BGNormalBase:
|
||||
self.name = 'bg_nomal_a_' + str(index).zfill(2)
|
||||
self.textures = (load_all_textures_from_zip(Path(f'Graphics/lumendata/enso_original/{self.name}.zip')))
|
||||
|
||||
def unload(self):
|
||||
for texture_group in self.textures:
|
||||
for texture in self.textures[texture_group]:
|
||||
ray.unload_texture(texture)
|
||||
|
||||
class BGNormal1(BGNormalBase):
|
||||
def __init__(self, index: int, screen_width: int, screen_height: int):
|
||||
super().__init__(index, screen_width, screen_height)
|
||||
@@ -284,6 +300,11 @@ class BGFeverBase:
|
||||
self.vertical_move = Animation.create_move(1300, start_position=0, total_distance=50, reverse_delay=0)
|
||||
self.horizontal_move = Animation.create_move(5000, start_position=0, total_distance=self.textures[self.name][2].width)
|
||||
|
||||
def unload(self):
|
||||
for texture_group in self.textures:
|
||||
for texture in self.textures[texture_group]:
|
||||
ray.unload_texture(texture)
|
||||
|
||||
class BGFever4(BGFeverBase):
|
||||
def __init__(self, index: int, screen_width: int, screen_height: int):
|
||||
super().__init__(index, screen_width, screen_height)
|
||||
@@ -308,5 +329,9 @@ class Footer:
|
||||
self.screen_height = screen_height
|
||||
self.name = 'dodai_a_' + str(index).zfill(2)
|
||||
self.textures = (load_all_textures_from_zip(Path(f'Graphics/lumendata/enso_original/{self.name}.zip')))
|
||||
def unload(self):
|
||||
for texture_group in self.textures:
|
||||
for texture in self.textures[texture_group]:
|
||||
ray.unload_texture(texture)
|
||||
def draw(self):
|
||||
ray.draw_texture(self.textures[self.name][0], 0, self.screen_height - self.textures[self.name][0].height + 20, ray.WHITE)
|
||||
|
||||
@@ -56,6 +56,8 @@ def build_song_hashes(output_dir=Path("cache")):
|
||||
print('Pulled latest from', root_path)
|
||||
all_tja_files.extend(root_path.rglob("*.tja"))
|
||||
|
||||
global_data.total_songs = len(all_tja_files)
|
||||
|
||||
files_to_process = []
|
||||
|
||||
# O(n) pass to identify which files need processing
|
||||
@@ -86,6 +88,10 @@ def build_song_hashes(output_dir=Path("cache")):
|
||||
del path_to_hash[tja_path_str]
|
||||
|
||||
# Process only files that need updating
|
||||
song_count = 0
|
||||
total_songs = len(files_to_process)
|
||||
if total_songs > 0:
|
||||
global_data.total_songs = total_songs
|
||||
for tja_path in files_to_process:
|
||||
tja_path_str = str(tja_path)
|
||||
current_modified = tja_path.stat().st_mtime
|
||||
@@ -120,6 +126,8 @@ def build_song_hashes(output_dir=Path("cache")):
|
||||
# Update both indexes
|
||||
path_to_hash[tja_path_str] = hash_val
|
||||
global_data.song_paths[tja_path] = hash_val
|
||||
song_count += 1
|
||||
global_data.song_progress = song_count / total_songs
|
||||
|
||||
# Save both files
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
|
||||
@@ -234,6 +234,9 @@ class GlobalData:
|
||||
config: dict = field(default_factory=lambda: dict())
|
||||
song_hashes: dict[str, list[dict]] = field(default_factory=lambda: dict()) #Hash to path
|
||||
song_paths: dict[Path, str] = field(default_factory=lambda: dict()) #path to hash
|
||||
song_progress: float = 0.0
|
||||
total_songs: int = 0
|
||||
|
||||
global_data = GlobalData()
|
||||
|
||||
class OutlinedText:
|
||||
|
||||
Reference in New Issue
Block a user