From 0e668f991e5dd1284a8ce69d2760311f56b3083a Mon Sep 17 00:00:00 2001 From: Anthony Samms Date: Mon, 13 Oct 2025 21:16:58 -0400 Subject: [PATCH] minor bug fixes --- PyTaiko.py | 1 + libs/animation.py | 13 ++++++++----- libs/global_data.py | 2 +- scenes/game.py | 14 +++++++++----- scenes/song_select.py | 8 ++++---- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/PyTaiko.py b/PyTaiko.py index a695ec2..b72c2bd 100644 --- a/PyTaiko.py +++ b/PyTaiko.py @@ -138,6 +138,7 @@ def main(): if next_screen is not None: current_screen = next_screen + global_data.input_locked = 0 if global_data.config["general"]["fps_counter"]: ray.draw_fps(20, 20) diff --git a/libs/animation.py b/libs/animation.py index 96ae6bd..5eab2c2 100644 --- a/libs/animation.py +++ b/libs/animation.py @@ -33,6 +33,7 @@ class BaseAnimation(): self.is_finished = False self.attribute = 0 self.is_started = False + self.unlocked = False self.loop = loop self.lock_input = lock_input @@ -46,15 +47,17 @@ class BaseAnimation(): """Update the animation based on the current time.""" if self.loop and self.is_finished: self.restart() - if self.lock_input and self.is_finished: - global_data.input_locked = False + if self.lock_input and self.is_finished and not self.unlocked: + self.unlocked = True + global_data.input_locked -= 1 def restart(self) -> None: self.start_ms = get_current_ms() self.is_finished = False self.delay = self.delay_saved + self.unlocked = False if self.lock_input: - global_data.input_locked = True + global_data.input_locked += 1 def start(self) -> None: self.is_started = True @@ -63,12 +66,12 @@ class BaseAnimation(): def pause(self): self.is_started = False if self.lock_input: - global_data.input_locked = False + global_data.input_locked -= 1 def unpause(self): self.is_started = True if self.lock_input: - global_data.input_locked = True + global_data.input_locked += 1 def reset(self): self.restart() diff --git a/libs/global_data.py b/libs/global_data.py index 61900fc..088d3aa 100644 --- a/libs/global_data.py +++ b/libs/global_data.py @@ -20,7 +20,7 @@ class GlobalData: total_songs: int = 0 hit_sound: int = 0 player_num: int = 1 - input_locked: bool = False + input_locked: int = 0 modifiers: Modifiers = field(default_factory=lambda: Modifiers()) global_data = GlobalData() diff --git a/scenes/game.py b/scenes/game.py index 40d0990..0d8a1a9 100644 --- a/scenes/game.py +++ b/scenes/game.py @@ -816,12 +816,16 @@ class Player: # Get the next note from any of the three lists for BPM and gogo time updates next_note = None + candidates = [] if self.don_notes: - next_note = self.don_notes[0] - elif self.kat_notes: - next_note = self.kat_notes[0] - elif self.other_notes: - next_note = self.other_notes[0] + candidates.append(self.don_notes[0]) + if self.kat_notes: + candidates.append(self.kat_notes[0]) + if self.other_notes: + candidates.append(self.other_notes[0]) + + if candidates: + next_note = min(candidates, key=lambda note: note.load_ms) if next_note: self.bpm = next_note.bpm diff --git a/scenes/song_select.py b/scenes/song_select.py index df9a823..13f4c5e 100644 --- a/scenes/song_select.py +++ b/scenes/song_select.py @@ -495,14 +495,14 @@ class SongSelectScreen: if (self.selected_song and self.state == State.SONG_SELECTED and self.selected_difficulty >= 0): if global_data.player_num == 2: tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, fade=min(0.5, self.selected_diff_fadein.attribute), x=1025, y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute) - tex.draw_texture('global', 'background_diff_highlight', frame=max(3, self.selected_difficulty), fade=self.selected_diff_highlight_fade.attribute, x=1025) + tex.draw_texture('global', 'background_diff_highlight', frame=min(3, self.selected_difficulty), fade=self.selected_diff_highlight_fade.attribute, x=1025) tex.draw_texture('global', 'bg_diff_text_bg', x=1025, fade=min(0.5, self.selected_diff_text_fadein.attribute), scale=self.selected_diff_text_resize.attribute, center=True) - tex.draw_texture('global', 'bg_diff_text', frame=self.selected_difficulty, x=1025, fade=self.selected_diff_text_fadein.attribute, scale=self.selected_diff_text_resize.attribute, center=True) + tex.draw_texture('global', 'bg_diff_text', frame=min(3, self.selected_difficulty), x=1025, fade=self.selected_diff_text_fadein.attribute, scale=self.selected_diff_text_resize.attribute, center=True) else: tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, fade=min(0.5, self.selected_diff_fadein.attribute), y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute) - tex.draw_texture('global', 'background_diff_highlight', frame=max(3, self.selected_difficulty), fade=self.selected_diff_highlight_fade.attribute) + tex.draw_texture('global', 'background_diff_highlight', frame=min(3, self.selected_difficulty), fade=self.selected_diff_highlight_fade.attribute) tex.draw_texture('global', 'bg_diff_text_bg', fade=min(0.5, self.selected_diff_text_fadein.attribute), scale=self.selected_diff_text_resize.attribute, center=True) - tex.draw_texture('global', 'bg_diff_text', frame=self.selected_difficulty, fade=self.selected_diff_text_fadein.attribute, scale=self.selected_diff_text_resize.attribute, center=True) + tex.draw_texture('global', 'bg_diff_text', frame=min(3, self.selected_difficulty), fade=self.selected_diff_text_fadein.attribute, scale=self.selected_diff_text_resize.attribute, center=True) for item in self.navigator.items: box = item.box