mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
minor fixes
This commit is contained in:
@@ -280,9 +280,9 @@ class FolderBox(BaseBox):
|
|||||||
|
|
||||||
if self.crown: #Folder lamp
|
if self.crown: #Folder lamp
|
||||||
highest_crown = max(self.crown)
|
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)
|
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)
|
tex.draw_texture('yellow_box', 'crown_fc', x=x, y=y, frame=min(Difficulty.URA, highest_crown), fade=outer_fade_override)
|
||||||
else:
|
else:
|
||||||
tex.draw_texture('yellow_box', 'crown_clear', x=x, y=y, frame=min(Difficulty.URA, highest_crown), fade=outer_fade_override)
|
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()
|
all_scores = dict()
|
||||||
crowns = dict()
|
crowns = dict()
|
||||||
|
|
||||||
for tja_path in tja_files:
|
for song_obj in tja_files:
|
||||||
song_key = str(tja_path)
|
|
||||||
if song_key in self.all_song_files:
|
|
||||||
song_obj = self.all_song_files[song_key]
|
|
||||||
if not isinstance(song_obj, SongFile):
|
if not isinstance(song_obj, SongFile):
|
||||||
continue
|
continue
|
||||||
for diff in song_obj.box.scores:
|
for diff in song_obj.box.scores:
|
||||||
@@ -1389,11 +1386,11 @@ class FileNavigator:
|
|||||||
|
|
||||||
for diff in all_scores:
|
for diff in all_scores:
|
||||||
if all(score is not None and score[5] == Crown.DFC for score in all_scores[diff]):
|
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]):
|
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]):
|
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
|
self.directory_crowns[dir_key] = crowns
|
||||||
|
|
||||||
@@ -1455,7 +1452,8 @@ class FileNavigator:
|
|||||||
original_hash = hash_val
|
original_hash = hash_val
|
||||||
|
|
||||||
if hash_val in global_data.song_hashes:
|
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:
|
if file_path.exists() and file_path not in tja_files:
|
||||||
tja_files.append(file_path)
|
tja_files.append(file_path)
|
||||||
else:
|
else:
|
||||||
@@ -1463,8 +1461,8 @@ class FileNavigator:
|
|||||||
for key, value in global_data.song_hashes.items():
|
for key, value in global_data.song_hashes.items():
|
||||||
for i in range(len(value)):
|
for i in range(len(value)):
|
||||||
song = value[i]
|
song = value[i]
|
||||||
if (song["title"]["en"] == title and
|
if (song["title"]["en"].strip() == title and
|
||||||
song["subtitle"]["en"] == subtitle and
|
song["subtitle"]["en"].strip() == subtitle.removeprefix('--') and
|
||||||
Path(song["file_path"]).exists()):
|
Path(song["file_path"]).exists()):
|
||||||
hash_val = key
|
hash_val = key
|
||||||
tja_files.append(Path(global_data.song_hashes[hash_val][i]["file_path"]))
|
tja_files.append(Path(global_data.song_hashes[hash_val][i]["file_path"]))
|
||||||
@@ -1472,7 +1470,7 @@ class FileNavigator:
|
|||||||
|
|
||||||
if hash_val != original_hash:
|
if hash_val != original_hash:
|
||||||
file_updated = True
|
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
|
# Write back updated song list if needed
|
||||||
if file_updated:
|
if file_updated:
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ class SessionData:
|
|||||||
song_title: The title of the song being played.
|
song_title: The title of the song being played.
|
||||||
genre_index: The index of the genre being played."""
|
genre_index: The index of the genre being played."""
|
||||||
selected_song: Path = Path()
|
selected_song: Path = Path()
|
||||||
|
song_hash: str = ""
|
||||||
selected_dan: list[tuple[Any, int, int, int]] = field(default_factory=lambda: [])
|
selected_dan: list[tuple[Any, int, int, int]] = field(default_factory=lambda: [])
|
||||||
selected_dan_exam: list[Any] = field(default_factory=lambda: [])
|
selected_dan_exam: list[Any] = field(default_factory=lambda: [])
|
||||||
dan_color: int = 0
|
dan_color: int = 0
|
||||||
|
|||||||
@@ -21,11 +21,6 @@ def get_ms_per_measure(bpm_val: float, time_sig: float):
|
|||||||
return 0
|
return 0
|
||||||
return 60000 * (time_sig * 4) / bpm_val
|
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):
|
class NoteType(IntEnum):
|
||||||
NONE = 0
|
NONE = 0
|
||||||
DON = 1
|
DON = 1
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import sys
|
|||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from libs.global_data import PlayerNum, global_data
|
from libs.global_data import PlayerNum, global_data
|
||||||
from functools import lru_cache
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@@ -57,16 +56,6 @@ def strip_comments(code: str) -> str:
|
|||||||
index += 1
|
index += 1
|
||||||
return result
|
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]):
|
def is_input_key_pressed(keys: list[int], gamepad_buttons: list[int]):
|
||||||
if global_data.input_locked:
|
if global_data.input_locked:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -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.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
|
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):
|
def write_score(self):
|
||||||
"""Write the score to the database"""
|
"""Write the score to the database"""
|
||||||
if global_data.modifiers[global_data.player_num].auto:
|
if global_data.modifiers[global_data.player_num].auto:
|
||||||
@@ -174,7 +154,7 @@ class GameScreen(Screen):
|
|||||||
with sqlite3.connect('scores.db') as con:
|
with sqlite3.connect('scores.db') as con:
|
||||||
session_data = global_data.session_data[global_data.player_num]
|
session_data = global_data.session_data[global_data.player_num]
|
||||||
cursor = con.cursor()
|
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"
|
check_query = "SELECT score, clear FROM Scores WHERE hash = ? LIMIT 1"
|
||||||
cursor.execute(check_query, (hash,))
|
cursor.execute(check_query, (hash,))
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import pyray as ray
|
|||||||
|
|
||||||
from libs.audio import audio
|
from libs.audio import audio
|
||||||
from libs.screen import Screen
|
from libs.screen import Screen
|
||||||
|
from libs.texture import tex
|
||||||
from libs.utils import (
|
from libs.utils import (
|
||||||
global_data,
|
global_data,
|
||||||
is_l_don_pressed,
|
is_l_don_pressed,
|
||||||
@@ -227,6 +228,7 @@ class SettingsScreen(Screen):
|
|||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
# Draw title
|
# Draw title
|
||||||
|
ray.draw_rectangle(0, 0, tex.screen_width, tex.screen_height, ray.BLACK)
|
||||||
ray.draw_text("SETTINGS", 20, 20, 30, ray.WHITE)
|
ray.draw_text("SETTINGS", 20, 20, 30, ray.WHITE)
|
||||||
|
|
||||||
# Draw section headers
|
# Draw section headers
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class SongSelectScreen(Screen):
|
|||||||
|
|
||||||
def finalize_song(self, current_item: SongFile):
|
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].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].selected_difficulty = self.player_1.selected_difficulty
|
||||||
global_data.session_data[global_data.player_num].genre_index = current_item.box.name_texture_index
|
global_data.session_data[global_data.player_num].genre_index = current_item.box.name_texture_index
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user