mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 03:30:13 +01:00
Update file_navigator.py
This commit is contained in:
@@ -1280,8 +1280,36 @@ class FileNavigator:
|
|||||||
for tja_path in sorted(tja_files):
|
for tja_path in sorted(tja_files):
|
||||||
song_key = str(tja_path)
|
song_key = str(tja_path)
|
||||||
if song_key not in self.all_song_files and tja_path.name == "dan.json":
|
if song_key not in self.all_song_files and tja_path.name == "dan.json":
|
||||||
song_obj = DanCourse(tja_path, tja_path.name)
|
valid_dan = True
|
||||||
self.all_song_files[song_key] = song_obj
|
with open(tja_path, 'r', encoding='utf-8') as f:
|
||||||
|
data = json.load(f)
|
||||||
|
for chart in data["charts"]:
|
||||||
|
hash = chart["hash"]
|
||||||
|
chart_title = chart["title"]
|
||||||
|
chart_subtitle = chart["subtitle"]
|
||||||
|
path = None
|
||||||
|
|
||||||
|
if hash in global_data.song_hashes:
|
||||||
|
path = Path(global_data.song_hashes[hash][0]["file_path"])
|
||||||
|
else:
|
||||||
|
# Fallback: search by title and subtitle
|
||||||
|
found = False
|
||||||
|
for key, value in global_data.song_hashes.items():
|
||||||
|
for i, song in enumerate(value):
|
||||||
|
if (song["title"]["en"].strip() == chart_title and
|
||||||
|
song["subtitle"]["en"].strip() == chart_subtitle.removeprefix('--') and
|
||||||
|
Path(song["file_path"]).exists()):
|
||||||
|
path = Path(song["file_path"])
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
if found:
|
||||||
|
break
|
||||||
|
if path is None or not path.exists():
|
||||||
|
valid_dan = False
|
||||||
|
break
|
||||||
|
if valid_dan:
|
||||||
|
song_obj = DanCourse(tja_path, tja_path.name)
|
||||||
|
self.all_song_files[song_key] = song_obj
|
||||||
elif song_key not in self.all_song_files and tja_path in global_data.song_paths:
|
elif song_key not in self.all_song_files and tja_path in global_data.song_paths:
|
||||||
song_obj = SongFile(tja_path, tja_path.name, back_color, fore_color, texture_index)
|
song_obj = SongFile(tja_path, tja_path.name, back_color, fore_color, texture_index)
|
||||||
song_obj.box.get_scores()
|
song_obj.box.get_scores()
|
||||||
|
|||||||
Reference in New Issue
Block a user