improving

This commit is contained in:
Yonokid
2025-06-24 11:48:21 -04:00
parent c1081d255b
commit 9c8a51118e
12 changed files with 373 additions and 194 deletions

View File

@@ -728,6 +728,11 @@ class Judgement:
index = int(self.texture_animation.attribute)
hit_color = ray.fade(ray.WHITE, self.fade_animation_1.attribute)
color = ray.fade(ray.WHITE, self.fade_animation_2.attribute)
if self.curr_hit_ms is not None:
if float(self.curr_hit_ms) < -(global_data.config['general']['hard_judge']):
color = ray.fade(ray.BLUE, self.fade_animation_2.attribute)
elif float(self.curr_hit_ms) > (global_data.config['general']['hard_judge']):
color = ray.fade(ray.RED, self.fade_animation_2.attribute)
if self.type == 'GOOD':
if self.big:
ray.draw_texture(textures_1[21], 342, 184, color)
@@ -736,9 +741,6 @@ class Judgement:
ray.draw_texture(textures_1[19], 342, 184, color)
ray.draw_texture(textures_2[index+5], 304, 143, hit_color)
ray.draw_texture(textures_2[9], 370, int(y), color)
if self.curr_hit_ms is not None:
pass
#ray.draw_text(self.curr_hit_ms, 370, int(y)-20, 40, ray.fade(ray.YELLOW, self.fade_animation_1.attribute))
elif self.type == 'OK':
if self.big:
ray.draw_texture(textures_1[20], 342, 184, color)
@@ -747,12 +749,8 @@ class Judgement:
ray.draw_texture(textures_1[18], 342, 184, color)
ray.draw_texture(textures_2[index], 304, 143, hit_color)
ray.draw_texture(textures_2[4], 370, int(y), color)
if self.curr_hit_ms is not None:
ray.draw_text(self.curr_hit_ms, 370, int(y)-20, 40, ray.fade(ray.WHITE, self.fade_animation_1.attribute))
elif self.type == 'BAD':
ray.draw_texture(textures_2[10], 370, int(y), color)
if self.curr_hit_ms is not None:
ray.draw_text(self.curr_hit_ms, 370, int(y)-20, 40, ray.fade(ray.BLUE, self.fade_animation_1.attribute))
class LaneHitEffect:
def __init__(self, type: str):

View File

@@ -223,9 +223,7 @@ class SongSelectScreen:
if not isinstance(song, Directory) and song.box.is_open:
if self.demo_song is None and get_current_ms() >= song.box.wait + (83.33*3):
song.box.get_scores()
self.demo_song = audio.load_music_stream(song.tja.metadata.wave)
audio.normalize_music_stream(self.demo_song, 0.1935)
audio.seek_music_stream(self.demo_song, song.tja.metadata.demostart)
self.demo_song = audio.load_music_stream(song.tja.metadata.wave, preview=song.tja.metadata.demostart, normalize=0.1935)
audio.play_music_stream(self.demo_song)
audio.stop_sound(self.sound_bgm)
if song.box.is_open:
@@ -450,7 +448,7 @@ class SongBox:
direction = -1
if abs(self.target_position - self.position) > 250:
direction *= -1
self.move = Animation.create_move(66.67, start_position=0, total_distance=100 * direction)
self.move = Animation.create_move(83.3, start_position=0, total_distance=100 * direction, ease_out='cubic')
if self.is_open or self.target_position == SongSelectScreen.BOX_CENTER + 150:
self.move.total_distance = 250 * direction
self.start_position = self.position
@@ -929,6 +927,7 @@ class FileNavigator:
self.items: list[Directory | SongFile] = []
self.selected_index = 0
self.history = []
self.box_open = False
# Generate all objects upfront
self._generate_all_objects()
@@ -1257,16 +1256,23 @@ class FileNavigator:
self.selected_index = 0 if self.items else -1
self.calculate_box_positions()
def load_current_directory(self):
def load_current_directory(self, selected_item=None):
"""Load pre-generated items for the current directory"""
self.items = []
has_children = any(item.is_dir() and (item / "box.def").exists() for item in self.current_dir.iterdir())
if has_children:
self.items = []
else:
if selected_item in self.items:
self.items.remove(selected_item)
self.box_open = True
dir_key = str(self.current_dir)
# Add back/to_root navigation items
if self.current_dir != self.current_root_dir:
back_dir = Directory(self.current_dir.parent, "", 552, back=True)
self.items.append(back_dir)
if has_children:
self.items.append(back_dir)
elif not self.in_root_selection:
to_root_dir = Directory(Path(), "", 552, to_root=True)
self.items.append(to_root_dir)
@@ -1275,7 +1281,6 @@ class FileNavigator:
if dir_key in self.directory_contents:
content_items = self.directory_contents[dir_key]
# Handle the every-10-songs navigation logic
song_count = 0
for item in content_items:
if isinstance(item, SongFile):
@@ -1283,13 +1288,20 @@ class FileNavigator:
# Add navigation item
if self.current_dir != self.current_root_dir:
back_dir = Directory(self.current_dir.parent, "", 552, back=True)
self.items.append(back_dir)
if not has_children:
self.items.insert(self.selected_index+song_count, back_dir)
else:
self.items.append(back_dir)
elif not self.in_root_selection:
to_root_dir = Directory(Path(), "", 552, to_root=True)
self.items.append(to_root_dir)
if has_children:
self.items.append(to_root_dir)
song_count += 1
self.items.append(item)
if not has_children:
self.items.insert(self.selected_index+song_count, item)
else:
self.items.append(item)
# OPTIMIZED: Use cached crowns (calculated on-demand)
for item in self.items:
@@ -1361,7 +1373,7 @@ class FileNavigator:
self.current_root_dir = selected_item.path
self.in_root_selection = False
self.selected_index = 0
self.load_current_directory()
self.load_current_directory(selected_item=selected_item)
elif isinstance(selected_item, SongFile):
return selected_item
@@ -1378,6 +1390,7 @@ class FileNavigator:
self.load_root_directories()
else:
self.load_current_directory()
self.box_open = False
def get_current_item(self):
"""Get the currently selected item"""

View File

@@ -33,9 +33,6 @@ class TitleScreen:
self.screen_init = False
self.fade_out = None
def get_videos(self):
return self.op_video, self.attract_video
def load_sounds(self):
sounds_dir = Path("Sounds")
title_dir = sounds_dir / "title"
@@ -55,13 +52,15 @@ class TitleScreen:
self.screen_init = True
self.load_textures()
self.state = State.OP_VIDEO
self.op_video = VideoPlayer(random.choice(self.op_video_list))
self.attract_video = VideoPlayer(random.choice(self.attract_video_list))
self.op_video = None
self.attract_video = None
self.warning_board = None
def on_screen_end(self) -> str:
self.op_video.stop()
self.attract_video.stop()
if self.op_video is not None:
self.op_video.stop()
if self.attract_video is not None:
self.attract_video.stop()
for sound in self.sounds:
if audio.is_sound_playing(sound):
audio.stop_sound(sound)
@@ -73,28 +72,30 @@ class TitleScreen:
def scene_manager(self):
if self.state == State.OP_VIDEO:
if not self.op_video.is_started():
if self.op_video is None:
self.op_video = VideoPlayer(random.choice(self.op_video_list))
self.op_video.start(get_current_ms())
self.op_video.update()
if self.op_video.is_finished():
self.op_video.stop()
self.op_video = VideoPlayer(random.choice(self.op_video_list))
self.op_video = None
self.state = State.WARNING
elif self.state == State.WARNING:
if self.warning_board is None:
self.warning_board = WarningScreen(get_current_ms(), self)
elif self.state == State.WARNING and self.warning_board is not None:
self.warning_board.update(get_current_ms(), self)
if self.warning_board.is_finished:
self.state = State.ATTRACT_VIDEO
self.attract_video.start(get_current_ms())
self.warning_board = None
elif self.state == State.ATTRACT_VIDEO:
if self.attract_video is None:
self.attract_video = VideoPlayer(random.choice(self.attract_video_list))
self.attract_video.start(get_current_ms())
self.attract_video.update()
if self.attract_video.is_finished():
self.attract_video.stop()
self.attract_video = VideoPlayer(random.choice(self.attract_video_list))
self.attract_video = None
self.state = State.OP_VIDEO
self.op_video.start(get_current_ms())
def update(self):
@@ -111,14 +112,14 @@ class TitleScreen:
audio.play_sound(self.sound_don)
def draw(self):
if self.state == State.OP_VIDEO:
if self.state == State.OP_VIDEO and self.op_video is not None:
self.op_video.draw()
elif self.state == State.WARNING and self.warning_board is not None:
bg_source = ray.Rectangle(0, 0, self.textures['keikoku'][0].width, self.textures['keikoku'][0].height)
bg_dest = ray.Rectangle(0, 0, self.width, self.height)
ray.draw_texture_pro(self.textures['keikoku'][0], bg_source, bg_dest, ray.Vector2(0,0), 0, ray.WHITE)
self.warning_board.draw(self)
elif self.state == State.ATTRACT_VIDEO:
elif self.state == State.ATTRACT_VIDEO and self.attract_video is not None:
self.attract_video.draw()
if self.fade_out is not None: