mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 19:50:12 +01:00
fix insane config bottleneck
This commit is contained in:
@@ -12,7 +12,6 @@ from libs.backgrounds import Background
|
||||
from libs.tja import Balloon, Drumroll, Note, TJAParser, calculate_base_score
|
||||
from libs.utils import (
|
||||
OutlinedText,
|
||||
get_config,
|
||||
get_current_ms,
|
||||
global_data,
|
||||
is_l_don_pressed,
|
||||
@@ -114,7 +113,7 @@ class GameScreen:
|
||||
self.movie.set_volume(0.0)
|
||||
else:
|
||||
self.movie = None
|
||||
session_data.song_title = self.tja.metadata.title.get(get_config()['general']['language'].lower(), self.tja.metadata.title['en'])
|
||||
session_data.song_title = self.tja.metadata.title.get(global_data.config['general']['language'].lower(), self.tja.metadata.title['en'])
|
||||
|
||||
self.player_1 = Player(self, 1, difficulty)
|
||||
if not hasattr(self, 'song_music'):
|
||||
@@ -144,7 +143,7 @@ class GameScreen:
|
||||
return 'RESULT'
|
||||
|
||||
def write_score(self):
|
||||
if get_config()['general']['autoplay']:
|
||||
if global_data.config['general']['autoplay']:
|
||||
return
|
||||
with sqlite3.connect('scores.db') as con:
|
||||
cursor = con.cursor()
|
||||
@@ -169,7 +168,7 @@ class GameScreen:
|
||||
def update(self):
|
||||
self.on_screen_start()
|
||||
self.current_ms = get_current_ms() - self.start_ms
|
||||
if (self.current_ms >= self.tja.metadata.offset*1000 + self.start_delay - get_config()["general"]["judge_offset"]) and not self.song_started:
|
||||
if (self.current_ms >= self.tja.metadata.offset*1000 + self.start_delay - global_data.config["general"]["judge_offset"]) and not self.song_started:
|
||||
if self.song_music is not None:
|
||||
if not audio.is_sound_playing(self.song_music):
|
||||
audio.play_sound(self.song_music)
|
||||
@@ -227,7 +226,7 @@ class Player:
|
||||
|
||||
self.player_number = player_number
|
||||
self.difficulty = difficulty
|
||||
self.visual_offset = get_config()["general"]["visual_offset"]
|
||||
self.visual_offset = global_data.config["general"]["visual_offset"]
|
||||
|
||||
self.play_notes, self.draw_note_list, self.draw_bar_list = game_screen.tja.notes_to_position(self.difficulty)
|
||||
self.total_notes = len([note for note in self.play_notes if 0 < note.type < 5])
|
||||
@@ -489,14 +488,14 @@ class Player:
|
||||
self.lane_hit_effect = LaneHitEffect(note_type)
|
||||
self.draw_drum_hit_list.append(DrumHitEffect(note_type, side))
|
||||
|
||||
if get_config()["general"]["sfx"]:
|
||||
if global_data.config["general"]["sfx"]:
|
||||
audio.play_sound(sound)
|
||||
|
||||
self.check_note(game_screen, 1 if note_type == 'DON' else 2)
|
||||
self.input_log[game_screen.current_ms] = (note_type, side)
|
||||
|
||||
def autoplay_manager(self, game_screen: GameScreen):
|
||||
if not get_config()["general"]["autoplay"]:
|
||||
if not global_data.config["general"]["autoplay"]:
|
||||
return
|
||||
if len(self.play_notes) == 0:
|
||||
return
|
||||
@@ -674,7 +673,7 @@ class Player:
|
||||
self.draw_notes(game_screen)
|
||||
ray.draw_texture(game_screen.textures['lane_obi'][0], 0, 184, ray.WHITE)
|
||||
ray.draw_texture(game_screen.textures['lane_obi'][14], 211, 206, ray.WHITE)
|
||||
if get_config()["general"]["autoplay"]:
|
||||
if global_data.config["general"]["autoplay"]:
|
||||
ray.draw_texture(game_screen.textures['lane_obi'][58], 0, 290, ray.WHITE)
|
||||
for anim in self.draw_drum_hit_list:
|
||||
anim.draw(game_screen)
|
||||
|
||||
@@ -2,7 +2,7 @@ import pyray as ray
|
||||
import sounddevice as sd
|
||||
|
||||
from libs.utils import (
|
||||
get_config,
|
||||
global_data,
|
||||
is_l_don_pressed,
|
||||
is_l_kat_pressed,
|
||||
is_r_don_pressed,
|
||||
@@ -16,7 +16,7 @@ class SettingsScreen:
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.screen_init = False
|
||||
self.config = get_config()
|
||||
self.config = global_data.config
|
||||
self.headers = list(self.config.keys())
|
||||
self.headers.append('Exit')
|
||||
self.header_index = 0
|
||||
@@ -32,6 +32,7 @@ class SettingsScreen:
|
||||
def on_screen_end(self):
|
||||
self.screen_init = False
|
||||
save_config(self.config)
|
||||
global_data.config = self.config
|
||||
return "ENTRY"
|
||||
|
||||
def get_current_settings(self):
|
||||
@@ -68,7 +69,7 @@ class SettingsScreen:
|
||||
elif key == 'buffer_size':
|
||||
new_value = max(1, min(32, new_value))
|
||||
elif key == 'sample_rate':
|
||||
valid_rates = [22050, 44100, 48000, 88200, 96000]
|
||||
valid_rates = [-1, 22050, 44100, 48000, 88200, 96000]
|
||||
current_idx = valid_rates.index(current_value) if current_value in valid_rates else 2
|
||||
new_idx = max(0, min(len(valid_rates) - 1, current_idx + increment))
|
||||
new_value = valid_rates[new_idx]
|
||||
|
||||
@@ -11,7 +11,6 @@ from libs.audio import audio
|
||||
from libs.tja import TJAParser
|
||||
from libs.utils import (
|
||||
OutlinedText,
|
||||
get_config,
|
||||
get_current_ms,
|
||||
global_data,
|
||||
is_l_don_pressed,
|
||||
@@ -27,7 +26,7 @@ class SongSelectScreen:
|
||||
BOX_CENTER = 444
|
||||
def __init__(self, screen_width: int, screen_height: int):
|
||||
self.screen_init = False
|
||||
self.root_dir = get_config()["paths"]["tja_path"]
|
||||
self.root_dir = global_data.config["paths"]["tja_path"]
|
||||
self.screen_width = screen_width
|
||||
self.screen_height = screen_height
|
||||
|
||||
@@ -386,7 +385,7 @@ class SongBox:
|
||||
def reset(self):
|
||||
if self.black_name is not None:
|
||||
if self.tja is not None:
|
||||
subtitle = OutlinedText(self.tja.metadata.subtitle.get(get_config()['general']['language'], ''), 30, ray.Color(255, 255, 255, 255), ray.Color(0, 0, 0, 255), outline_thickness=5, vertical=True)
|
||||
subtitle = OutlinedText(self.tja.metadata.subtitle.get(global_data.config['general']['language'], ''), 30, ray.Color(255, 255, 255, 255), ray.Color(0, 0, 0, 255), outline_thickness=5, vertical=True)
|
||||
else:
|
||||
subtitle = None
|
||||
self.yellow_box = YellowBox(self.black_name, self.texture_index == 552, tja=self.tja, subtitle=subtitle)
|
||||
@@ -457,7 +456,7 @@ class SongBox:
|
||||
#print(f"loaded black name {self.text_name}")
|
||||
if self.tja is not None or self.texture_index == 552:
|
||||
if self.tja is not None:
|
||||
subtitle = OutlinedText(self.tja.metadata.subtitle.get(get_config()['general']['language'], ''), 30, ray.Color(255, 255, 255, 255), ray.Color(0, 0, 0, 255), outline_thickness=5, vertical=True)
|
||||
subtitle = OutlinedText(self.tja.metadata.subtitle.get(global_data.config['general']['language'], ''), 30, ray.Color(255, 255, 255, 255), ray.Color(0, 0, 0, 255), outline_thickness=5, vertical=True)
|
||||
else:
|
||||
subtitle = None
|
||||
self.yellow_box = YellowBox(self.black_name, self.texture_index == 552, tja=self.tja, subtitle=subtitle)
|
||||
@@ -889,7 +888,7 @@ class SongFile(FileSystemItem):
|
||||
def __init__(self, path: Path, name: str, texture_index: int, tja=None):
|
||||
super().__init__(path, name)
|
||||
self.tja = tja or TJAParser(path)
|
||||
title = self.tja.metadata.title.get(get_config()['general']['language'].lower(), self.tja.metadata.title['en'])
|
||||
title = self.tja.metadata.title.get(global_data.config['general']['language'].lower(), self.tja.metadata.title['en'])
|
||||
self.box = SongBox(title, texture_index, False, tja=self.tja)
|
||||
self.box.get_scores()
|
||||
|
||||
@@ -1153,7 +1152,7 @@ class FileNavigator:
|
||||
elif line.startswith("#TITLE:"):
|
||||
name = line.split(":", 1)[1].strip()
|
||||
elif line.startswith("#TITLEJA:"):
|
||||
if get_config()['general']['language'] == 'ja':
|
||||
if global_data.config['general']['language'] == 'ja':
|
||||
name = line.split(":", 1)[1].strip()
|
||||
except Exception as e:
|
||||
print(f"Error parsing box.def in {path}: {e}")
|
||||
|
||||
@@ -6,8 +6,8 @@ import pyray as ray
|
||||
from libs.animation import Animation
|
||||
from libs.audio import audio
|
||||
from libs.utils import (
|
||||
get_config,
|
||||
get_current_ms,
|
||||
global_data,
|
||||
is_l_don_pressed,
|
||||
is_r_don_pressed,
|
||||
load_all_textures_from_zip,
|
||||
@@ -20,9 +20,9 @@ class TitleScreen:
|
||||
def __init__(self, width: int, height: int):
|
||||
self.width = width
|
||||
self.height = height
|
||||
video_dir = Path(get_config()["paths"]["video_path"]) / "op_videos"
|
||||
video_dir = Path(global_data.config["paths"]["video_path"]) / "op_videos"
|
||||
self.op_video_list = [file for file in video_dir.glob("**/*.mp4")]
|
||||
video_dir = Path(get_config()["paths"]["video_path"]) / "attract_videos"
|
||||
video_dir = Path(global_data.config["paths"]["video_path"]) / "attract_videos"
|
||||
self.attract_video_list = [file for file in video_dir.glob("**/*.mp4")]
|
||||
self.load_sounds()
|
||||
self.screen_init = False
|
||||
|
||||
Reference in New Issue
Block a user