mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
fix some game crashes
This commit is contained in:
@@ -787,31 +787,6 @@ class ScoreHistory:
|
|||||||
for i in range(len(counter)):
|
for i in range(len(counter)):
|
||||||
tex.draw_texture('leaderboard', 'counter', frame=int(counter[i]), x=-(total_width // 2) + (i * 14), y=50, color=ray.WHITE)
|
tex.draw_texture('leaderboard', 'counter', frame=int(counter[i]), x=-(total_width // 2) + (i * 14), y=50, color=ray.WHITE)
|
||||||
|
|
||||||
class FileSystemItem:
|
|
||||||
GENRE_MAP = {
|
|
||||||
'J-POP': 1,
|
|
||||||
'アニメ': 2,
|
|
||||||
'VOCALOID': 3,
|
|
||||||
'どうよう': 4,
|
|
||||||
'バラエティー': 5,
|
|
||||||
'クラシック': 6,
|
|
||||||
'ゲームミュージック': 7,
|
|
||||||
'ナムコオリジナル': 8,
|
|
||||||
'RECOMMENDED': 10,
|
|
||||||
'FAVORITE': 11,
|
|
||||||
'RECENT': 12,
|
|
||||||
'段位道場': 13,
|
|
||||||
'DIFFICULTY': 14
|
|
||||||
}
|
|
||||||
GENRE_MAP_2 = {
|
|
||||||
'ボーカロイド': 3,
|
|
||||||
'バラエティ': 5
|
|
||||||
}
|
|
||||||
"""Base class for files and directories in the navigation system"""
|
|
||||||
def __init__(self, path: Path, name: str):
|
|
||||||
self.path = path
|
|
||||||
self.name = name
|
|
||||||
|
|
||||||
def parse_box_def(path: Path):
|
def parse_box_def(path: Path):
|
||||||
"""Parse box.def file for directory metadata"""
|
"""Parse box.def file for directory metadata"""
|
||||||
texture_index = SongBox.DEFAULT_INDEX
|
texture_index = SongBox.DEFAULT_INDEX
|
||||||
@@ -840,6 +815,31 @@ def parse_box_def(path: Path):
|
|||||||
|
|
||||||
return name, texture_index, collection
|
return name, texture_index, collection
|
||||||
|
|
||||||
|
class FileSystemItem:
|
||||||
|
GENRE_MAP = {
|
||||||
|
'J-POP': 1,
|
||||||
|
'アニメ': 2,
|
||||||
|
'VOCALOID': 3,
|
||||||
|
'どうよう': 4,
|
||||||
|
'バラエティー': 5,
|
||||||
|
'クラシック': 6,
|
||||||
|
'ゲームミュージック': 7,
|
||||||
|
'ナムコオリジナル': 8,
|
||||||
|
'RECOMMENDED': 10,
|
||||||
|
'FAVORITE': 11,
|
||||||
|
'RECENT': 12,
|
||||||
|
'段位道場': 13,
|
||||||
|
'DIFFICULTY': 14
|
||||||
|
}
|
||||||
|
GENRE_MAP_2 = {
|
||||||
|
'ボーカロイド': 3,
|
||||||
|
'バラエティ': 5
|
||||||
|
}
|
||||||
|
"""Base class for files and directories in the navigation system"""
|
||||||
|
def __init__(self, path: Path, name: str):
|
||||||
|
self.path = path
|
||||||
|
self.name = name
|
||||||
|
|
||||||
class Directory(FileSystemItem):
|
class Directory(FileSystemItem):
|
||||||
"""Represents a directory in the navigation system"""
|
"""Represents a directory in the navigation system"""
|
||||||
COLLECTIONS = [
|
COLLECTIONS = [
|
||||||
@@ -1081,8 +1081,16 @@ 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 file:
|
||||||
|
dan_data = json.load(file)
|
||||||
|
for chart in dan_data["charts"]:
|
||||||
|
hash = chart["hash"]
|
||||||
|
if hash not in global_data.song_hashes:
|
||||||
|
valid_dan = False
|
||||||
|
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, texture_index)
|
song_obj = SongFile(tja_path, tja_path.name, texture_index)
|
||||||
song_obj.box.get_scores()
|
song_obj.box.get_scores()
|
||||||
|
|||||||
@@ -90,14 +90,14 @@ class TwoPlayerGameScreen(GameScreen):
|
|||||||
logger.info(f"TJA initialized for two-player song: {song}")
|
logger.info(f"TJA initialized for two-player song: {song}")
|
||||||
|
|
||||||
def spawn_ending_anims(self):
|
def spawn_ending_anims(self):
|
||||||
if global_data.session_data[0].result_bad == 0:
|
if global_data.session_data[0].result_data.bad == 0:
|
||||||
self.player_1.ending_anim = FCAnimation(self.player_1.is_2p)
|
self.player_1.ending_anim = FCAnimation(self.player_1.is_2p)
|
||||||
elif self.player_1.gauge.is_clear:
|
elif self.player_1.gauge.is_clear:
|
||||||
self.player_1.ending_anim = ClearAnimation(self.player_1.is_2p)
|
self.player_1.ending_anim = ClearAnimation(self.player_1.is_2p)
|
||||||
elif not self.player_1.gauge.is_clear:
|
elif not self.player_1.gauge.is_clear:
|
||||||
self.player_1.ending_anim = FailAnimation(self.player_1.is_2p)
|
self.player_1.ending_anim = FailAnimation(self.player_1.is_2p)
|
||||||
|
|
||||||
if global_data.session_data[1].result_bad == 0:
|
if global_data.session_data[1].result_data.bad == 0:
|
||||||
self.player_2.ending_anim = FCAnimation(self.player_2.is_2p)
|
self.player_2.ending_anim = FCAnimation(self.player_2.is_2p)
|
||||||
elif self.player_2.gauge.is_clear:
|
elif self.player_2.gauge.is_clear:
|
||||||
self.player_2.ending_anim = ClearAnimation(self.player_2.is_2p)
|
self.player_2.ending_anim = ClearAnimation(self.player_2.is_2p)
|
||||||
@@ -123,11 +123,11 @@ class TwoPlayerGameScreen(GameScreen):
|
|||||||
return self.on_screen_end('RESULT_2P')
|
return self.on_screen_end('RESULT_2P')
|
||||||
elif self.current_ms >= self.player_1.end_time:
|
elif self.current_ms >= self.player_1.end_time:
|
||||||
session_data = global_data.session_data[0]
|
session_data = global_data.session_data[0]
|
||||||
session_data.result_score, session_data.result_good, session_data.result_ok, session_data.result_bad, session_data.result_max_combo, session_data.result_total_drumroll = self.player_1.get_result_score()
|
session_data.result_data.score, session_data.result_data.good, session_data.result_data.ok, session_data.result_data.bad, session_data.result_data.max_combo, session_data.result_data.total_drumroll = self.player_1.get_result_score()
|
||||||
session_data.result_gauge_length = int(self.player_1.gauge.gauge_length)
|
session_data.result_data.gauge_length = int(self.player_1.gauge.gauge_length)
|
||||||
session_data = global_data.session_data[1]
|
session_data = global_data.session_data[1]
|
||||||
session_data.result_score, session_data.result_good, session_data.result_ok, session_data.result_bad, session_data.result_max_combo, session_data.result_total_drumroll = self.player_2.get_result_score()
|
session_data.result_data.score, session_data.result_data.good, session_data.result_data.ok, session_data.result_data.bad, session_data.result_data.max_combo, session_data.result_data.total_drumroll = self.player_2.get_result_score()
|
||||||
session_data.result_gauge_length = int(self.player_2.gauge.gauge_length)
|
session_data.result_data.gauge_length = int(self.player_2.gauge.gauge_length)
|
||||||
if self.end_ms != 0:
|
if self.end_ms != 0:
|
||||||
if current_time >= self.end_ms + 1000:
|
if current_time >= self.end_ms + 1000:
|
||||||
if self.player_1.ending_anim is None:
|
if self.player_1.ending_anim is None:
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ class TwoPlayerSongSelectScreen(SongSelectScreen):
|
|||||||
global_data.session_data[0].genre_index = self.navigator.get_current_item().box.name_texture_index
|
global_data.session_data[0].genre_index = self.navigator.get_current_item().box.name_texture_index
|
||||||
logger.info(f"Finalized song selection: {global_data.session_data[0].selected_song}")
|
logger.info(f"Finalized song selection: {global_data.session_data[0].selected_song}")
|
||||||
|
|
||||||
|
def handle_input(self):
|
||||||
|
if self.player_1.is_ready:
|
||||||
|
self.player_2.handle_input(self.state, self)
|
||||||
|
else:
|
||||||
|
self.player_1.handle_input(self.state, self)
|
||||||
|
|
||||||
def handle_input_browsing(self):
|
def handle_input_browsing(self):
|
||||||
"""Handle input for browsing songs."""
|
"""Handle input for browsing songs."""
|
||||||
action = self.player_1.handle_input_browsing(self.last_moved, self.navigator.items[self.navigator.selected_index] if self.navigator.items else None)
|
action = self.player_1.handle_input_browsing(self.last_moved, self.navigator.items[self.navigator.selected_index] if self.navigator.items else None)
|
||||||
|
|||||||
Reference in New Issue
Block a user