add dan result screen

This commit is contained in:
Anthony Samms
2025-11-08 17:31:02 -05:00
parent 20f9f6f05a
commit d03eac9e29
9 changed files with 401 additions and 57 deletions

View File

@@ -492,7 +492,7 @@ class YellowBox:
self._draw_text(song_box)
class DanBox:
def __init__(self, title: str, color: int, songs: list[tuple[TJAParser, int, int]], exams: list['Exam']):
def __init__(self, title: str, color: int, songs: list[tuple[TJAParser, int, int, int]], exams: list['Exam']):
self.position = -11111
self.start_position = -1
self.target_position = -1
@@ -505,7 +505,7 @@ class DanBox:
self.exams = exams
self.song_text: list[tuple[OutlinedText, OutlinedText]] = []
self.total_notes = 0
for song, genre_index, difficulty in self.songs:
for song, genre_index, difficulty, level in self.songs:
notes, branch_m, branch_e, branch_n = song.notes_to_position(difficulty)
self.total_notes += sum(1 for note in notes.play_notes if note.type < 5)
for branch in branch_m:
@@ -550,7 +550,7 @@ class DanBox:
self.name = OutlinedText(self.title, 40, ray.WHITE, vertical=True)
self.hori_name = OutlinedText(self.title, 40, ray.WHITE)
if self.is_open and not self.song_text:
for song, genre, difficulty in self.songs:
for song, genre, difficulty, level in self.songs:
title = song.metadata.title.get(global_data.config["general"]["language"], song.metadata.title["en"])
subtitle = song.metadata.subtitle.get(global_data.config["general"]["language"], "")
title_text = OutlinedText(title, 40, ray.WHITE, vertical=True)
@@ -907,7 +907,8 @@ class DanCourse(FileSystemItem):
_, genre_index, _ = parse_box_def(path.parent.parent)
else:
genre_index = 9
self.charts.append((TJAParser(path), genre_index, difficulty))
tja = TJAParser(path)
self.charts.append((tja, genre_index, difficulty, tja.metadata.course_data[difficulty].level))
else:
pass
#do something with song_title, song_subtitle

View File

@@ -90,6 +90,65 @@ class Modifiers:
inverse: bool = False
random: int = 0
@dataclass
class DanResultSong:
"""
Data class for storing dan result song data.
"""
selected_difficulty: int = 0
diff_level: int = 0
song_title: str = "default_title"
genre_index: int = 0
good: int = 0
ok: int = 0
bad: int = 0
drumroll: int = 0
class DanResultExam:
"""
Data class for storing dan result exam data.
"""
progress: float = 0
counter_value: int = 0
bar_texture: str = "exam_red"
failed: bool = False
@dataclass
class DanResultData:
"""
Data class for storing dan result data.
"""
dan_color: int = 0
dan_title: str = "default_title"
score: int = 0
gauge_length: float = 0.0
max_combo: int = 0
songs: list[DanResultSong] = field(default_factory=list)
exams: list[Any] = field(default_factory=list)
exam_data: list[DanResultExam] = field(default_factory=list)
@dataclass
class ResultData:
"""
Data class for storing result data.
result_score: The score achieved in the game.
result_good: The number of good notes achieved in the game.
result_ok: The number of ok notes achieved in the game.
result_bad: The number of bad notes achieved in the game.
result_max_combo: The maximum combo achieved in the game.
result_total_drumroll: The total drumroll achieved in the game.
result_gauge_length: The length of the gauge achieved in the game.
prev_score: The previous score pulled from the database.
"""
score: int = 0
good: int = 0
ok: int = 0
bad: int = 0
max_combo: int = 0
total_drumroll: int = 0
gauge_length: float = 0
prev_score: int = 0
@dataclass
class SessionData:
"""Data class for storing session data. Wiped after the result screen.
@@ -99,30 +158,16 @@ class SessionData:
dan_color: int: The emblem color of the selected dan
selected_difficulty: The difficulty level selected by the user.
song_title: The title of the song being played.
genre_index: The index of the genre being played.
result_score: The score achieved in the game.
result_good: The number of good notes achieved in the game.
result_ok: The number of ok notes achieved in the game.
result_bad: The number of bad notes achieved in the game.
result_max_combo: The maximum combo achieved in the game.
result_total_drumroll: The total drumroll achieved in the game.
result_gauge_length: The length of the gauge achieved in the game.
prev_score: The previous score pulled from the database."""
genre_index: The index of the genre being played."""
selected_song: Path = Path()
selected_dan: list[tuple[Any, 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: [])
dan_color: int = 0
selected_difficulty: int = 0
song_title: str = ''
song_title: str = "default_title"
genre_index: int = 0
result_score: int = 0
result_good: int = 0
result_ok: int = 0
result_bad: int = 0
result_max_combo: int = 0
result_total_drumroll: int = 0
result_gauge_length: float = 0
prev_score: int = 0
result_data: ResultData = field(default_factory=lambda: ResultData())
dan_result_data: DanResultData = field(default_factory=lambda: DanResultData())
@dataclass
class GlobalData:

View File

@@ -26,7 +26,7 @@ class Nameplate:
self.is_gold = is_gold
self.is_rainbow = is_rainbow
self.title_bg = title_bg
if self.is_rainbow == True:
if self.is_rainbow:
self.rainbow_animation = global_tex.get_animation(12)
self.rainbow_animation.start()
def update(self, current_time_ms: float):
@@ -35,7 +35,7 @@ class Nameplate:
Args:
current_time_ms (float): The current time in milliseconds.
"""
if self.is_rainbow == True:
if self.is_rainbow:
self.rainbow_animation.update(current_time_ms)
if self.rainbow_animation.is_finished:
self.rainbow_animation.restart()
@@ -60,7 +60,7 @@ class Nameplate:
else:
frame = self.title_bg
title_offset = 14
if self.is_rainbow == True:
if self.is_rainbow:
if 0 < self.rainbow_animation.attribute < 6:
tex.draw_texture('nameplate', 'frame_top_rainbow', frame=self.rainbow_animation.attribute-1, x=x, y=y, fade=fade)
tex.draw_texture('nameplate', 'frame_top_rainbow', frame=self.rainbow_animation.attribute, x=x, y=y, fade=fade)