minor fixes

This commit is contained in:
Anthony Samms
2025-12-06 22:53:22 -05:00
parent e2d9642d90
commit 1ef4d10ed6
7 changed files with 24 additions and 58 deletions

View File

@@ -280,9 +280,9 @@ class FolderBox(BaseBox):
if self.crown: #Folder lamp
highest_crown = max(self.crown)
if self.crown[highest_crown] == 'DFC':
if self.crown[highest_crown] == Crown.DFC:
tex.draw_texture('yellow_box', 'crown_dfc', x=x, y=y, frame=min(Difficulty.URA, highest_crown), fade=outer_fade_override)
elif self.crown[highest_crown] == 'FC':
elif self.crown[highest_crown] == Crown.FC:
tex.draw_texture('yellow_box', 'crown_fc', x=x, y=y, frame=min(Difficulty.URA, highest_crown), fade=outer_fade_override)
else:
tex.draw_texture('yellow_box', 'crown_clear', x=x, y=y, frame=min(Difficulty.URA, highest_crown), fade=outer_fade_override)
@@ -1376,10 +1376,7 @@ class FileNavigator:
all_scores = dict()
crowns = dict()
for tja_path in tja_files:
song_key = str(tja_path)
if song_key in self.all_song_files:
song_obj = self.all_song_files[song_key]
for song_obj in tja_files:
if not isinstance(song_obj, SongFile):
continue
for diff in song_obj.box.scores:
@@ -1389,11 +1386,11 @@ class FileNavigator:
for diff in all_scores:
if all(score is not None and score[5] == Crown.DFC for score in all_scores[diff]):
crowns[diff] = 'DFC'
crowns[diff] = Crown.DFC
elif all(score is not None and score[5] == Crown.FC for score in all_scores[diff]):
crowns[diff] = 'FC'
crowns[diff] = Crown.FC
elif all(score is not None and score[5] >= Crown.CLEAR for score in all_scores[diff]):
crowns[diff] = 'CLEAR'
crowns[diff] = Crown.CLEAR
self.directory_crowns[dir_key] = crowns
@@ -1455,7 +1452,8 @@ class FileNavigator:
original_hash = hash_val
if hash_val in global_data.song_hashes:
file_path = Path(global_data.song_hashes[hash_val][0]["file_path"])
for entry in global_data.song_hashes[hash_val]:
file_path = Path(entry["file_path"])
if file_path.exists() and file_path not in tja_files:
tja_files.append(file_path)
else:
@@ -1463,8 +1461,8 @@ class FileNavigator:
for key, value in global_data.song_hashes.items():
for i in range(len(value)):
song = value[i]
if (song["title"]["en"] == title and
song["subtitle"]["en"] == subtitle and
if (song["title"]["en"].strip() == title and
song["subtitle"]["en"].strip() == subtitle.removeprefix('--') and
Path(song["file_path"]).exists()):
hash_val = key
tja_files.append(Path(global_data.song_hashes[hash_val][i]["file_path"]))
@@ -1472,7 +1470,7 @@ class FileNavigator:
if hash_val != original_hash:
file_updated = True
updated_lines.append(f"{hash_val}|{title}|{subtitle}")
updated_lines.append(f"{hash_val}|{title}|{subtitle.removeprefix('--')}")
# Write back updated song list if needed
if file_updated:

View File

@@ -111,6 +111,7 @@ class SessionData:
song_title: The title of the song being played.
genre_index: The index of the genre being played."""
selected_song: Path = Path()
song_hash: str = ""
selected_dan: list[tuple[Any, int, int, int]] = field(default_factory=lambda: [])
selected_dan_exam: list[Any] = field(default_factory=lambda: [])
dan_color: int = 0

View File

@@ -21,11 +21,6 @@ def get_ms_per_measure(bpm_val: float, time_sig: float):
return 0
return 60000 * (time_sig * 4) / bpm_val
@lru_cache(maxsize=64)
def get_pixels_per_ms(pixels_per_frame: float):
"""Calculate the number of pixels per millisecond."""
return pixels_per_frame / (1000 / 60)
class NoteType(IntEnum):
NONE = 0
DON = 1

View File

@@ -4,7 +4,6 @@ import sys
import logging
import time
from libs.global_data import PlayerNum, global_data
from functools import lru_cache
from pathlib import Path
from typing import Optional
@@ -57,16 +56,6 @@ def strip_comments(code: str) -> str:
index += 1
return result
@lru_cache
def get_pixels_per_frame(bpm: float, time_signature: float, distance: float) -> float:
"""Calculate the number of pixels per frame"""
if bpm == 0:
return 0
beat_duration = 60 / bpm
total_time = time_signature * beat_duration
total_frames = 60 * total_time
return (distance / total_frames)
def is_input_key_pressed(keys: list[int], gamepad_buttons: list[int]):
if global_data.input_locked:
return False

View File

@@ -147,26 +147,6 @@ class GameScreen(Screen):
self.player_1 = Player(self.tja, global_data.player_num, global_data.session_data[global_data.player_num].selected_difficulty, False, global_data.modifiers[global_data.player_num])
self.start_ms = get_current_ms() - self.tja.metadata.offset*1000
def get_song_hash(self, song: Path):
notes, branch_m, branch_e, branch_n = TJAParser.notes_to_position(TJAParser(song), self.player_1.difficulty)
if branch_m:
for branch in branch_m:
notes.play_notes.extend(branch.play_notes)
notes.draw_notes.extend(branch.draw_notes)
notes.bars.extend(branch.bars)
if branch_e:
for branch in branch_e:
notes.play_notes.extend(branch.play_notes)
notes.draw_notes.extend(branch.draw_notes)
notes.bars.extend(branch.bars)
if branch_n:
for branch in branch_n:
notes.play_notes.extend(branch.play_notes)
notes.draw_notes.extend(branch.draw_notes)
notes.bars.extend(branch.bars)
hash = self.tja.hash_note_data(notes)
return hash
def write_score(self):
"""Write the score to the database"""
if global_data.modifiers[global_data.player_num].auto:
@@ -174,7 +154,7 @@ class GameScreen(Screen):
with sqlite3.connect('scores.db') as con:
session_data = global_data.session_data[global_data.player_num]
cursor = con.cursor()
hash = self.get_song_hash(session_data.selected_song)
hash = session_data.song_hash
check_query = "SELECT score, clear FROM Scores WHERE hash = ? LIMIT 1"
cursor.execute(check_query, (hash,))
result = cursor.fetchone()

View File

@@ -3,6 +3,7 @@ import pyray as ray
from libs.audio import audio
from libs.screen import Screen
from libs.texture import tex
from libs.utils import (
global_data,
is_l_don_pressed,
@@ -227,6 +228,7 @@ class SettingsScreen(Screen):
def draw(self):
# Draw title
ray.draw_rectangle(0, 0, tex.screen_width, tex.screen_height, ray.BLACK)
ray.draw_text("SETTINGS", 20, 20, 30, ray.WHITE)
# Draw section headers

View File

@@ -85,6 +85,7 @@ class SongSelectScreen(Screen):
def finalize_song(self, current_item: SongFile):
global_data.session_data[global_data.player_num].selected_song = current_item.path
global_data.session_data[global_data.player_num].song_hash = global_data.song_hashes[current_item.hash][0]["diff_hashes"][self.player_1.selected_difficulty]
global_data.session_data[global_data.player_num].selected_difficulty = self.player_1.selected_difficulty
global_data.session_data[global_data.player_num].genre_index = current_item.box.name_texture_index