mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
optimize judge counter
This commit is contained in:
@@ -32,6 +32,7 @@ from libs.utils import (
|
||||
is_l_kat_pressed,
|
||||
is_r_don_pressed,
|
||||
is_r_kat_pressed,
|
||||
rounded,
|
||||
session_data,
|
||||
)
|
||||
from libs.video import VideoPlayer
|
||||
@@ -1954,14 +1955,18 @@ class JudgeCounter:
|
||||
self.ok = 0
|
||||
self.bad = 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.ok = ok
|
||||
self.bad = bad
|
||||
self.drumrolls = drumrolls
|
||||
def draw_counter(self, counter: float, x: int, y: int, margin: int, color: ray.Color):
|
||||
for i, digit in enumerate(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_str = str(int(counter))
|
||||
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):
|
||||
tex.draw_texture('judge_counter', 'bg')
|
||||
tex.draw_texture('judge_counter', 'total_percent')
|
||||
@@ -1969,20 +1974,23 @@ class JudgeCounter:
|
||||
tex.draw_texture('judge_counter', 'drumrolls')
|
||||
|
||||
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
|
||||
if total_notes == 0:
|
||||
total_notes = 1
|
||||
self.draw_counter(self.good / total_notes * 100, 260, 440, 23, ray.Color(253, 161, 0, 255))
|
||||
self.draw_counter(self.ok / total_notes * 100, 260, 477, 23, ray.Color(253, 161, 0, 255))
|
||||
self.draw_counter(self.bad / total_notes * 100, 260, 515, 23, ray.Color(253, 161, 0, 255))
|
||||
self.draw_counter((self.good + self.ok) / total_notes * 100, 270, 388, 23, ray.Color(253, 161, 0, 255))
|
||||
total_notes = self.good + self.ok + self.bad or 1
|
||||
inv_total = rounded(100.0 / total_notes)
|
||||
good_percent = self.good * inv_total
|
||||
ok_percent = self.ok * inv_total
|
||||
bad_percent = self.bad * inv_total
|
||||
combo_percent = (self.good + self.ok) * inv_total
|
||||
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.ok, 180, 477, 23, ray.WHITE)
|
||||
self.draw_counter(self.bad, 180, 515, 23, ray.WHITE)
|
||||
self.draw_counter(self.drumrolls, 180, 577, 23, ray.WHITE)
|
||||
self.draw_counter(self.good, 180, 440, 23, self.white)
|
||||
self.draw_counter(self.ok, 180, 477, 23, self.white)
|
||||
self.draw_counter(self.bad, 180, 515, 23, self.white)
|
||||
self.draw_counter(self.drumrolls, 180, 577, 23, self.white)
|
||||
|
||||
|
||||
class Gauge:
|
||||
|
||||
Reference in New Issue
Block a user