optimize judge counter

This commit is contained in:
Anthony Samms
2025-10-22 00:30:15 -04:00
parent bf14857834
commit f7f2f42aac
2 changed files with 23 additions and 17 deletions

View File

@@ -182,7 +182,6 @@ class AudioEngine:
if lib.is_sound_valid(sound): # type: ignore if lib.is_sound_valid(sound): # type: ignore
self.sounds[name] = sound self.sounds[name] = sound
print(f"Loaded sound from {file_path} as {name}")
return name return name
else: else:
print(f"Failed to load sound: {file_path}") print(f"Failed to load sound: {file_path}")
@@ -196,7 +195,6 @@ class AudioEngine:
if name in self.sounds: if name in self.sounds:
lib.unload_sound(self.sounds[name]) # type: ignore lib.unload_sound(self.sounds[name]) # type: ignore
del self.sounds[name] del self.sounds[name]
print(f"Unloaded sound {name}")
else: else:
print(f"Sound {name} not found") print(f"Sound {name} not found")

View File

@@ -32,6 +32,7 @@ from libs.utils import (
is_l_kat_pressed, is_l_kat_pressed,
is_r_don_pressed, is_r_don_pressed,
is_r_kat_pressed, is_r_kat_pressed,
rounded,
session_data, session_data,
) )
from libs.video import VideoPlayer from libs.video import VideoPlayer
@@ -1954,14 +1955,18 @@ class JudgeCounter:
self.ok = 0 self.ok = 0
self.bad = 0 self.bad = 0
self.drumrolls = 0 self.drumrolls = 0
def update(self, good, ok, bad, drumrolls): self.orange = ray.Color(253, 161, 0, 255)
self.white = ray.WHITE
def update(self, good: int, ok: int, bad: int, drumrolls: int):
self.good = good self.good = good
self.ok = ok self.ok = ok
self.bad = bad self.bad = bad
self.drumrolls = drumrolls self.drumrolls = drumrolls
def draw_counter(self, counter: float, x: int, y: int, margin: int, color: ray.Color): def draw_counter(self, counter: float, x: int, y: int, margin: int, color: ray.Color):
for i, digit in enumerate(str(int(counter))): counter_str = str(int(counter))
tex.draw_texture('judge_counter', 'counter', frame=int(digit), x=x-(len(str(int(counter))) - i) * margin, y=y, color=color) counter_len = len(counter_str)
for i, digit in enumerate(counter_str):
tex.draw_texture('judge_counter', 'counter', frame=int(digit), x=x - (counter_len - i) * margin, y=y, color=color)
def draw(self): def draw(self):
tex.draw_texture('judge_counter', 'bg') tex.draw_texture('judge_counter', 'bg')
tex.draw_texture('judge_counter', 'total_percent') tex.draw_texture('judge_counter', 'total_percent')
@@ -1969,20 +1974,23 @@ class JudgeCounter:
tex.draw_texture('judge_counter', 'drumrolls') tex.draw_texture('judge_counter', 'drumrolls')
for i in range(4): for i in range(4):
tex.draw_texture('judge_counter', 'percent', index=i, color=ray.Color(253, 161, 0, 255)) tex.draw_texture('judge_counter', 'percent', index=i, color=self.orange)
total_notes = self.good + self.ok + self.bad total_notes = self.good + self.ok + self.bad or 1
if total_notes == 0: inv_total = rounded(100.0 / total_notes)
total_notes = 1 good_percent = self.good * inv_total
self.draw_counter(self.good / total_notes * 100, 260, 440, 23, ray.Color(253, 161, 0, 255)) ok_percent = self.ok * inv_total
self.draw_counter(self.ok / total_notes * 100, 260, 477, 23, ray.Color(253, 161, 0, 255)) bad_percent = self.bad * inv_total
self.draw_counter(self.bad / total_notes * 100, 260, 515, 23, ray.Color(253, 161, 0, 255)) combo_percent = (self.good + self.ok) * inv_total
self.draw_counter((self.good + self.ok) / total_notes * 100, 270, 388, 23, ray.Color(253, 161, 0, 255)) self.draw_counter(good_percent, 260, 440, 23, self.orange)
self.draw_counter(ok_percent, 260, 477, 23, self.orange)
self.draw_counter(bad_percent, 260, 515, 23, self.orange)
self.draw_counter(combo_percent, 270, 388, 23, self.orange)
self.draw_counter(self.good, 180, 440, 23, ray.WHITE) self.draw_counter(self.good, 180, 440, 23, self.white)
self.draw_counter(self.ok, 180, 477, 23, ray.WHITE) self.draw_counter(self.ok, 180, 477, 23, self.white)
self.draw_counter(self.bad, 180, 515, 23, ray.WHITE) self.draw_counter(self.bad, 180, 515, 23, self.white)
self.draw_counter(self.drumrolls, 180, 577, 23, ray.WHITE) self.draw_counter(self.drumrolls, 180, 577, 23, self.white)
class Gauge: class Gauge: