From 1b4db994a531a48e7922bdae060f53ac4ddf1a20 Mon Sep 17 00:00:00 2001 From: Anthony Samms Date: Thu, 20 Nov 2025 23:50:12 -0500 Subject: [PATCH] more bug fixes --- PyTaiko.py | 39 +++++++++++++++++++++++++++++++-------- config.toml | 1 + libs/config.py | 1 + libs/file_navigator.py | 2 +- scenes/practice/game.py | 8 ++++---- 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/PyTaiko.py b/PyTaiko.py index 1d3f9e7..dde0711 100644 --- a/PyTaiko.py +++ b/PyTaiko.py @@ -2,6 +2,7 @@ import logging import os from pathlib import Path import sys +import argparse import sqlite3 @@ -146,14 +147,36 @@ def main(): logger.info("Fullscreen enabled") current_screen = Screens.LOADING - if len(sys.argv) > 1 and Path(sys.argv[1]).exists(): - current_screen = Screens.GAME - path = Path(os.path.abspath(sys.argv[1])) - tja = TJAParser(path) - max_difficulty = max(tja.metadata.course_data.keys()) - global_data.session_data[PlayerNum.P1].selected_song = path - global_data.session_data[PlayerNum.P1].selected_difficulty = max_difficulty - global_data.modifiers[PlayerNum.P1].auto = True + + if len(sys.argv) == 1: + pass + else: + parser = argparse.ArgumentParser(description='Launch game with specified song file') + parser.add_argument('song_path', type=str, help='Path to the TJA song file') + parser.add_argument('difficulty', type=int, nargs='?', default=None, + help='Difficulty level (optional, defaults to max difficulty)') + parser.add_argument('--auto', action='store_true', + help='Enable auto mode') + parser.add_argument('--practice', action='store_true', + help='Start in practice mode') + args = parser.parse_args() + path = Path(args.song_path) + if not path.exists(): + parser.error(f"Song file not found: {args.song_path}") + else: + path = Path(os.path.abspath(path)) + tja = TJAParser(path) + if args.difficulty is not None: + if args.difficulty not in tja.metadata.course_data.keys(): + parser.error(f"Invalid difficulty: {args.difficulty}. Available: {list(tja.metadata.course_data.keys())}") + selected_difficulty = args.difficulty + else: + selected_difficulty = max(tja.metadata.course_data.keys()) + current_screen = Screens.GAME_PRACTICE if args.practice else Screens.GAME + global_data.session_data[PlayerNum.P1].selected_song = path + global_data.session_data[PlayerNum.P1].selected_difficulty = selected_difficulty + global_data.modifiers[PlayerNum.P1].auto = args.auto + logger.info(f"Initial screen: {current_screen}") audio.set_log_level((log_level-1)//10) diff --git a/config.toml b/config.toml index 0afd890..238d5df 100644 --- a/config.toml +++ b/config.toml @@ -10,6 +10,7 @@ judge_counter = false nijiiro_notes = false log_level = 30 fake_online = false +practice_mode_bar_delay = 1 [nameplate_1p] name = 'どんちゃん' diff --git a/libs/config.py b/libs/config.py index 28d8b34..eb47ee7 100644 --- a/libs/config.py +++ b/libs/config.py @@ -17,6 +17,7 @@ class GeneralConfig(TypedDict): nijiiro_notes: bool log_level: int fake_online: bool + practice_mode_bar_delay: int class NameplateConfig(TypedDict): name: str diff --git a/libs/file_navigator.py b/libs/file_navigator.py index e49b9c6..712fa62 100644 --- a/libs/file_navigator.py +++ b/libs/file_navigator.py @@ -1280,7 +1280,7 @@ class FileNavigator: if selected_item.collection == Directory.COLLECTIONS[3]: diff_sort = self.diff_sort_level diffs = ['かんたん', 'ふつう', 'むずかしい', 'おに'] - hori_name = OutlinedText(diffs[min(Difficulty.ONI, self.diff_sort_diff)], 40, ray.WHITE, outline_thickness=5) + hori_name = OutlinedText(diffs[min(Difficulty.ONI, self.diff_sort_diff)], tex.skin_config["song_hori_name"].font_size, ray.WHITE, outline_thickness=5) self.genre_bg = GenreBG(start_box, end_box, hori_name, diff_sort) def select_current_item(self): diff --git a/scenes/practice/game.py b/scenes/practice/game.py index 2b75950..a380638 100644 --- a/scenes/practice/game.py +++ b/scenes/practice/game.py @@ -69,7 +69,7 @@ class PracticeGameScreen(GameScreen): else: self.player_1.input_log.clear() resume_bar_index = max(0, self.scrobble_index) - previous_bar_index = max(0, self.scrobble_index - 1) + previous_bar_index = max(0, self.scrobble_index - global_data.config["general"]["practice_mode_bar_delay"]) first_bar_time = self.bars[0].hit_ms resume_time = self.bars[resume_bar_index].hit_ms - first_bar_time + self.start_delay @@ -87,9 +87,9 @@ class PracticeGameScreen(GameScreen): self.player_1.total_notes = len([note for note in self.player_1.play_notes if 0 < note.type < 5]) self.pause_time = start_time - if self.song_music is not None: - audio.play_music_stream(self.song_music, 'music') - audio.seek_music_stream(self.song_music, (self.pause_time - self.start_delay)/1000 - self.tja.metadata.offset) + audio.play_music_stream(self.song_music, 'music') + audio.seek_music_stream(self.song_music, (self.pause_time - self.start_delay)/1000 - self.tja.metadata.offset) + self.song_started = True self.start_ms = get_current_ms() - self.pause_time def global_keys(self):