diff --git a/PyTaiko.py b/PyTaiko.py index 687a8c9..4e38915 100644 --- a/PyTaiko.py +++ b/PyTaiko.py @@ -13,7 +13,6 @@ from libs import song_hash from libs.audio import audio from libs.utils import ( get_config, - get_current_ms, global_data, load_all_textures_from_zip, ) diff --git a/libs/song_hash.py b/libs/song_hash.py index ebe7fc1..fd0a238 100644 --- a/libs/song_hash.py +++ b/libs/song_hash.py @@ -4,7 +4,6 @@ import sys import time from collections import deque from pathlib import Path -from typing import Optional from git import Repo @@ -12,17 +11,17 @@ from libs.tja import TJAParser from libs.utils import get_config, global_data +def diff_hashes_object_hook(obj): + if "diff_hashes" in obj: + obj["diff_hashes"] = { + int(key): value + for key, value in obj["diff_hashes"].items() + } + return obj + class DiffHashesDecoder(json.JSONDecoder): def __init__(self, *args, **kwargs): - super().__init__(object_hook=self.object_hook, *args, **kwargs) - - def object_hook(self, obj): - if "diff_hashes" in obj: - obj["diff_hashes"] = { - int(key): value - for key, value in obj["diff_hashes"].items() - } - return obj + super().__init__(object_hook=diff_hashes_object_hook, *args, **kwargs) def build_song_hashes(output_dir=Path("cache")): song_hashes: dict[str, list[dict]] = dict() diff --git a/scenes/game.py b/scenes/game.py index 94a7bc2..23c73d6 100644 --- a/scenes/game.py +++ b/scenes/game.py @@ -136,7 +136,8 @@ class GameScreen: for zip in self.textures: for texture in self.textures[zip]: ray.unload_texture(texture) - audio.unload_sound(self.song_music) + if self.song_music is not None: + audio.unload_sound(self.song_music) del self.song_music self.song_started = False self.end_ms = 0 diff --git a/scenes/song_select.py b/scenes/song_select.py index 49f4d74..bd0e667 100644 --- a/scenes/song_select.py +++ b/scenes/song_select.py @@ -1396,11 +1396,11 @@ class FileNavigator: self.items.append(item) i += 1 - if not has_children: - self.box_open = True - end_box = content_items[-1].box - if selected_item in self.items: - self.items.remove(selected_item) + if not has_children: + self.box_open = True + end_box = content_items[-1].box + if selected_item in self.items: + self.items.remove(selected_item) # OPTIMIZED: Use cached crowns (calculated on-demand) for item in self.items: if isinstance(item, Directory):