minor fixes

This commit is contained in:
Anthony Samms
2025-11-02 18:29:46 -05:00
parent a1bc58b5ea
commit f93accd4a1
16 changed files with 60 additions and 55 deletions

View File

@@ -3,6 +3,7 @@ import platform
import logging
from pathlib import Path
from libs.global_data import VolumeConfig
from libs.utils import get_config
ffi = cffi.FFI()
@@ -118,7 +119,7 @@ except OSError as e:
class AudioEngine:
"""Initialize an audio engine for playing sounds and music."""
def __init__(self, device_type: int, sample_rate: float, buffer_size: int, volume_presets: dict[str, float]):
def __init__(self, device_type: int, sample_rate: float, buffer_size: int, volume_presets: VolumeConfig):
self.device_type = device_type
if sample_rate < 0:
self.target_sample_rate = 44100
@@ -142,7 +143,10 @@ class AudioEngine:
def get_host_api_name(self, api_id: int) -> str:
"""Returns the name of the host API with the given ID"""
result = lib.get_host_api_name(api_id) # type: ignore
return ffi.string(result).decode('utf-8')
result = ffi.string(result)
if isinstance(result, bytes):
result = result.decode('utf-8')
return result
def init_audio_device(self) -> bool:
"""Initialize the audio device"""

View File

@@ -75,10 +75,6 @@ class DonBG(DonBGBase):
self.move = Animation.create_move(10000, total_distance=-1280)
self.move.start()
self.move.loop = True
def draw(self, tex: TextureWrapper):
self._draw_textures(tex, 1.0)
if self.is_clear:
self._draw_textures(tex, self.clear_fade.attribute)
def _draw_textures(self, tex: TextureWrapper, fade: float):
def _draw_textures(self, tex: TextureWrapper, fade: float, y: float):
for i in range(2):
tex.draw_texture(self.name, 'background', frame=self.is_clear, fade=fade, x=(i*1280)+self.move.attribute)

View File

@@ -37,7 +37,5 @@ class DancerGroup(BaseDancerGroup):
class BGFever(BGFeverBase):
def start(self):
self.transitioned = True
def update(self, current_time_ms: float):
pass
def draw(self, tex: TextureWrapper):
tex.draw_texture(self.name, 'background')

View File

@@ -36,8 +36,6 @@ class DancerGroup(BaseDancerGroup):
class BGFever(BGFeverBase):
def start(self):
self.transitioned = True
def update(self, current_time_ms: float):
pass
def draw(self, tex: TextureWrapper):
tex.draw_texture(self.name, 'background')
tex.draw_texture(self.name, 'overlay')

View File

@@ -19,8 +19,8 @@ class Background:
self.chibi = ChibiController(self.tex_wrapper, 2, bpm, path)
class DonBG(DonBG6):
def __init__(self, tex: TextureWrapper, player_num: int, bpm: float, path: str):
super().__init__(tex, player_num, bpm, path)
def __init__(self, tex: TextureWrapper, index: int, player_num: int, path: str):
super().__init__(tex, index, player_num, path)
self.overlay_move_2 = Animation.create_move(8000, total_distance=-760)
self.overlay_move_2.loop = True
self.overlay_move_2.start()

View File

@@ -404,7 +404,7 @@ class YellowBox:
if self.tja.metadata.course_data[diff].is_branching and (get_current_ms() // 1000) % 2 == 0:
tex.draw_texture('yellow_box', 'branch_indicator', x=(diff*60), color=color)
def _draw_tja_data_diff(self, is_ura: bool, song_box):
def _draw_tja_data_diff(self, is_ura: bool, song_box: Optional[SongBox] = None):
if self.tja is None:
return
tex.draw_texture('diff_select', 'back', fade=self.fade_in.attribute)
@@ -412,6 +412,8 @@ class YellowBox:
tex.draw_texture('diff_select', 'neiro', fade=self.fade_in.attribute)
for diff in self.tja.metadata.course_data:
if song_box is None:
continue
if diff >= 4:
continue
elif diff in song_box.scores and song_box.scores[diff] is not None and ((song_box.scores[diff][4] == 2 and song_box.scores[diff][2] == 0) or (song_box.scores[diff][2] == 0 and song_box.scores[diff][3] == 0)):
@@ -472,7 +474,7 @@ class YellowBox:
tex.draw_texture('yellow_box', 'yellow_box_top', x=self.left_x + self.edge_height, y=self.top_y, x2=self.center_width)
tex.draw_texture('yellow_box', 'yellow_box_center', x=self.left_x + self.edge_height, y=self.top_y + self.edge_height, x2=self.center_width, y2=self.center_height)
def draw(self, song_box: SongBox, fade_override: Optional[float], is_ura: bool):
def draw(self, song_box: Optional[SongBox], fade_override: Optional[float], is_ura: bool):
self._draw_yellow_box()
if self.is_dan:
return
@@ -604,7 +606,7 @@ class DanBox:
def _draw_open(self, x: int, y: int, is_ura: bool):
if self.yellow_box is not None:
self.yellow_box.draw(x, y, False)
self.yellow_box.draw(None, None, False)
for i, song in enumerate(self.song_text):
title, subtitle = song
x = i * 140
@@ -895,8 +897,8 @@ class DanCourse(FileSystemItem):
self.charts = []
for chart in data["charts"]:
hash = chart["hash"]
chart_title = chart["title"]
chart_subtitle = chart["subtitle"]
#chart_title = chart["title"]
#chart_subtitle = chart["subtitle"]
difficulty = chart["difficulty"]
if hash in global_data.song_hashes:
path = Path(global_data.song_hashes[hash][0]["file_path"])
@@ -997,10 +999,11 @@ class FileNavigator:
song_list = self._read_song_list(self.favorite_folder.path)
for song_obj in song_list:
if str(song_obj) in self.all_song_files:
if isinstance(self.all_song_files[str(song_obj)].box, DanBox):
box = self.all_song_files[str(song_obj)].box
if isinstance(box, DanBox):
logger.warning(f"Cannot favorite DanCourse: {song_obj}")
else:
self.all_song_files[str(song_obj)].box.is_favorite = True
box.is_favorite = True
logging.info(f"Object generation complete. "
f"Directories: {len(self.all_directories)}, "

View File

@@ -120,7 +120,7 @@ class SessionData:
result_bad: int = 0
result_max_combo: int = 0
result_total_drumroll: int = 0
result_gauge_length: int = 0
result_gauge_length: float = 0
prev_score: int = 0
@dataclass
@@ -142,7 +142,7 @@ class GlobalData:
session_data (list[SessionData]): Session data for both players.
"""
songs_played: int = 0
config: Config = field(default_factory=lambda: dict())
config: dict = field(default_factory=dict)
song_hashes: dict[str, list[dict]] = field(default_factory=lambda: dict()) #Hash to path
song_paths: dict[Path, str] = field(default_factory=lambda: dict()) #path to hash
song_progress: float = 0.0

View File

@@ -51,14 +51,17 @@ class Transition:
offset = 816 - self.rainbow_up.attribute
global_tex.draw_texture('rainbow_transition', 'text_bg', y=-self.rainbow_up.attribute - offset, color=color_2)
texture = self.title.texture
x = 1280//2 - texture.width//2
y = 1176 - texture.height//2 - int(self.rainbow_up.attribute) - offset - 20
self.title.draw(outline_color=ray.BLACK, x=x, y=y, color=color_1)
if isinstance(self.title, OutlinedText):
texture = self.title.texture
x = 1280//2 - texture.width//2
y = 1176 - texture.height//2 - int(self.rainbow_up.attribute) - offset - 20
self.title.draw(outline_color=ray.BLACK, x=x, y=y, color=color_1)
texture = self.subtitle.texture
x = 1280//2 - texture.width//2
self.subtitle.draw(outline_color=ray.BLACK, x=x, y=y + 50, color=color_1)
if isinstance(self.subtitle, OutlinedText):
texture = self.subtitle.texture
x = 1280//2 - texture.width//2
y = 1176 - texture.height//2 - int(self.rainbow_up.attribute) - offset - 20
self.subtitle.draw(outline_color=ray.BLACK, x=x, y=y + 50, color=color_1)
def draw(self):
"""Draw the transition effect."""

View File

@@ -54,9 +54,10 @@ class VideoPlayer:
image = ray.Image(frame_data, self.video.w, self.video.h, 1, ray.PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8)
self.texture = ray.load_texture_from_image(image)
else:
frame_bytes = frame_data.tobytes()
pixels_ptr = ray.ffi.cast('void *', ray.ffi.from_buffer('unsigned char[]', frame_bytes))
ray.update_texture(self.texture, pixels_ptr)
if frame_data is not None:
frame_bytes = frame_data.tobytes()
pixels_ptr = ray.ffi.cast('void *', ray.ffi.from_buffer('unsigned char[]', frame_bytes))
ray.update_texture(self.texture, pixels_ptr)
self.current_frame_data = frame_data
return True