fix restarting/exiting bugs in dan mode

This commit is contained in:
Anthony Samms
2025-10-31 15:29:35 -04:00
parent deb4e84e58
commit 157b79440f
5 changed files with 45 additions and 24 deletions

View File

@@ -424,19 +424,19 @@ class TJAParser:
elif item.startswith('BALLOONNOR'): elif item.startswith('BALLOONNOR'):
balloon_data = item.split(':')[1] balloon_data = item.split(':')[1]
if balloon_data == '': if balloon_data == '':
logger.warning(f"Invalid BALLOONNOR value: {balloon_data} in TJA file {self.file_path}") logger.debug(f"Invalid BALLOONNOR value: {balloon_data} in TJA file {self.file_path}")
continue continue
self.metadata.course_data[current_diff].balloon.extend([int(x) for x in balloon_data.split(',') if x != '']) self.metadata.course_data[current_diff].balloon.extend([int(x) for x in balloon_data.split(',') if x != ''])
elif item.startswith('BALLOONEXP'): elif item.startswith('BALLOONEXP'):
balloon_data = item.split(':')[1] balloon_data = item.split(':')[1]
if balloon_data == '': if balloon_data == '':
logger.warning(f"Invalid BALLOONEXP value: {balloon_data} in TJA file {self.file_path}") logger.debug(f"Invalid BALLOONEXP value: {balloon_data} in TJA file {self.file_path}")
continue continue
self.metadata.course_data[current_diff].balloon.extend([int(x) for x in balloon_data.split(',') if x != '']) self.metadata.course_data[current_diff].balloon.extend([int(x) for x in balloon_data.split(',') if x != ''])
elif item.startswith('BALLOONMAS'): elif item.startswith('BALLOONMAS'):
balloon_data = item.split(':')[1] balloon_data = item.split(':')[1]
if balloon_data == '': if balloon_data == '':
logger.warning(f"Invalid BALLOONMAS value: {balloon_data} in TJA file {self.file_path}") logger.debug(f"Invalid BALLOONMAS value: {balloon_data} in TJA file {self.file_path}")
continue continue
self.metadata.course_data[current_diff].balloon = [int(x) for x in balloon_data.split(',') if x != ''] self.metadata.course_data[current_diff].balloon = [int(x) for x in balloon_data.split(',') if x != '']
elif item.startswith('BALLOON'): elif item.startswith('BALLOON'):
@@ -445,13 +445,13 @@ class TJAParser:
continue continue
balloon_data = item.split(':')[1] balloon_data = item.split(':')[1]
if balloon_data == '': if balloon_data == '':
logger.warning(f"Invalid BALLOON value: {balloon_data} in TJA file {self.file_path}") logger.debug(f"Invalid BALLOON value: {balloon_data} in TJA file {self.file_path}")
continue continue
self.metadata.course_data[current_diff].balloon = [int(x) for x in balloon_data.split(',') if x != ''] self.metadata.course_data[current_diff].balloon = [int(x) for x in balloon_data.split(',') if x != '']
elif item.startswith('SCOREINIT'): elif item.startswith('SCOREINIT'):
score_init = item.split(':')[1] score_init = item.split(':')[1]
if score_init == '': if score_init == '':
logger.warning(f"Invalid SCOREINIT value: {score_init} in TJA file {self.file_path}") logger.debug(f"Invalid SCOREINIT value: {score_init} in TJA file {self.file_path}")
continue continue
try: try:
self.metadata.course_data[current_diff].scoreinit = [int(x) for x in score_init.split(',') if x != ''] self.metadata.course_data[current_diff].scoreinit = [int(x) for x in score_init.split(',') if x != '']
@@ -461,7 +461,7 @@ class TJAParser:
elif item.startswith('SCOREDIFF'): elif item.startswith('SCOREDIFF'):
score_diff = item.split(':')[1] score_diff = item.split(':')[1]
if score_diff == '': if score_diff == '':
logger.error(f"Invalid SCOREDIFF value: {score_diff} in TJA file {self.file_path}") logger.debug(f"Invalid SCOREDIFF value: {score_diff} in TJA file {self.file_path}")
continue continue
self.metadata.course_data[current_diff].scorediff = int(float(score_diff)) self.metadata.course_data[current_diff].scorediff = int(float(score_diff))
for region_code in self.metadata.title: for region_code in self.metadata.title:

View File

@@ -11,11 +11,11 @@ class Transition:
subtitle: str - The subtitle of the chart. subtitle: str - The subtitle of the chart.
is_second: bool - Whether this is the second half of the transition.""" is_second: bool - Whether this is the second half of the transition."""
self.is_finished = False self.is_finished = False
self.rainbow_up = global_tex.get_animation(0) self.rainbow_up = global_tex.get_animation(0, is_copy=True)
self.mini_up = global_tex.get_animation(1) self.mini_up = global_tex.get_animation(1, is_copy=True)
self.chara_down = global_tex.get_animation(2) self.chara_down = global_tex.get_animation(2, is_copy=True)
self.song_info_fade = global_tex.get_animation(3) self.song_info_fade = global_tex.get_animation(3, is_copy=True)
self.song_info_fade_out = global_tex.get_animation(4) self.song_info_fade_out = global_tex.get_animation(4, is_copy=True)
if title == '' and subtitle == '': if title == '' and subtitle == '':
self.title = '' self.title = ''
self.subtitle = '' self.subtitle = ''

View File

@@ -20,7 +20,6 @@ class DanSelectScreen(Screen):
super().on_screen_start() super().on_screen_start()
self.navigator = navigator self.navigator = navigator
self.navigator.in_dan_select = True self.navigator.in_dan_select = True
self.navigator.select_current_item()
self.coin_overlay = CoinOverlay() self.coin_overlay = CoinOverlay()
self.allnet_indicator = AllNetIcon() self.allnet_indicator = AllNetIcon()
self.timer = Timer(60, get_current_ms(), self.navigator.select_current_item) self.timer = Timer(60, get_current_ms(), self.navigator.select_current_item)

View File

@@ -1,3 +1,4 @@
import copy
from typing import override from typing import override
import pyray as ray import pyray as ray
import logging import logging
@@ -44,9 +45,21 @@ class DanGameScreen(GameScreen):
logger.info("Loaded nijiiro notes textures") logger.info("Loaded nijiiro notes textures")
ray.set_shader_value_texture(self.mask_shader, ray.get_shader_location(self.mask_shader, "texture0"), tex.textures['balloon']['rainbow_mask'].texture) ray.set_shader_value_texture(self.mask_shader, ray.get_shader_location(self.mask_shader, "texture0"), tex.textures['balloon']['rainbow_mask'].texture)
ray.set_shader_value_texture(self.mask_shader, ray.get_shader_location(self.mask_shader, "texture1"), tex.textures['balloon']['rainbow'].texture) ray.set_shader_value_texture(self.mask_shader, ray.get_shader_location(self.mask_shader, "texture1"), tex.textures['balloon']['rainbow'].texture)
self.hori_name = OutlinedText(global_data.session_data[global_data.player_num-1].song_title, 40, ray.WHITE)
self.init_dan()
self.background = Background(global_data.player_num, self.bpm, scene_preset='DAN')
self.transition = Transition('', '', is_second=True)
self.transition.start()
self.dan_transition = DanTransition()
self.dan_transition.start()
self.allnet_indicator = AllNetIcon()
self.result_transition = ResultTransition(4)
self.load_hitsounds()
def init_dan(self):
session_data = global_data.session_data[global_data.player_num-1] session_data = global_data.session_data[global_data.player_num-1]
songs = session_data.selected_dan songs = copy.deepcopy(session_data.selected_dan)
self.exams = session_data.selected_dan_exam self.exams = copy.deepcopy(session_data.selected_dan_exam)
self.total_notes = 0 self.total_notes = 0
for song, genre_index, difficulty in songs: for song, genre_index, difficulty in songs:
notes, branch_m, branch_e, branch_n = song.notes_to_position(difficulty) notes, branch_m, branch_e, branch_n = song.notes_to_position(difficulty)
@@ -59,22 +72,14 @@ class DanGameScreen(GameScreen):
self.total_notes += sum(1 for note in branch.play_notes if note.type < 5) self.total_notes += sum(1 for note in branch.play_notes if note.type < 5)
song, genre_index, difficulty = songs[self.song_index] song, genre_index, difficulty = songs[self.song_index]
session_data.selected_difficulty = difficulty session_data.selected_difficulty = difficulty
self.hori_name = OutlinedText(session_data.song_title, 40, ray.WHITE)
self.init_tja(song.file_path) self.init_tja(song.file_path)
self.color = session_data.dan_color self.color = session_data.dan_color
self.player_1.is_dan = True self.player_1.is_dan = True
self.player_1.gauge = DanGauge(str(global_data.player_num), self.total_notes) self.player_1.gauge = DanGauge(str(global_data.player_num), self.total_notes)
logger.info(f"TJA initialized for song: {song.file_path}")
self.load_hitsounds()
self.song_info = SongInfo(song.metadata.title.get(global_data.config["general"]["language"], "en"), genre_index) self.song_info = SongInfo(song.metadata.title.get(global_data.config["general"]["language"], "en"), genre_index)
self.result_transition = ResultTransition(4)
self.bpm = self.tja.metadata.bpm self.bpm = self.tja.metadata.bpm
self.background = Background(global_data.player_num, self.bpm, scene_preset='DAN') logger.info(f"TJA initialized for song: {song.file_path}")
self.transition = Transition('', '', is_second=True)
self.transition.start()
self.dan_transition = DanTransition()
self.dan_transition.start()
self.allnet_indicator = AllNetIcon()
self.dan_info_cache = None self.dan_info_cache = None
self.exam_failed = [False] * len(self.exams) self.exam_failed = [False] * len(self.exams)
@@ -150,6 +155,22 @@ class DanGameScreen(GameScreen):
} }
return int(type_mapping.get(exam.type, 0)) return int(type_mapping.get(exam.type, 0))
@override
def global_keys(self):
if ray.is_key_pressed(ray.KeyboardKey.KEY_F1):
if self.song_music is not None:
audio.stop_music_stream(self.song_music)
audio.seek_music_stream(self.song_music, 0)
self.song_started = False
audio.play_sound('restart', 'sound')
self.init_dan()
if ray.is_key_pressed(ray.KeyboardKey.KEY_ESCAPE):
if self.song_music is not None:
audio.stop_music_stream(self.song_music)
return self.on_screen_end('DAN_SELECT')
@override
def update(self): def update(self):
super(GameScreen, self).update() super(GameScreen, self).update()
current_time = get_current_ms() current_time = get_current_ms()

View File

@@ -251,6 +251,7 @@ class SongSelectScreen(Screen):
self.blue_arrow_move.update(current_time) self.blue_arrow_move.update(current_time)
self.dan_transition.update(current_time) self.dan_transition.update(current_time)
if self.dan_transition.is_finished: if self.dan_transition.is_finished:
self.navigator.select_current_item()
return self.on_screen_end('DAN_SELECT') return self.on_screen_end('DAN_SELECT')
next_screen = self.update_players(current_time) next_screen = self.update_players(current_time)