Skip to content

Commit

Permalink
feat: update result screen bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Mivik committed Nov 10, 2023
1 parent b4bb2df commit e6ee47d
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions prpr/src/scene/ending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,42 @@ impl Scene for EndingScene {
.size(s)
.draw_using(&BOLD_FONT);
let mut r = Rect::new(r.right() + 0.03, r.y + 0.004, 0.45, r.h);
ui.fill_rect(r, semi_black(0.4));
let draw_par = |ui: &mut Ui, r: Rect, p: f32, c: Color| {
let sl = 1.9 / 0.4;
let w = p * r.w;
let d = r.h / sl;
let mut b = ui.builder(c);
b.add(r.x, r.bottom());
if w < d {
b.add(r.x + w, r.bottom());
b.add(r.x + w, r.bottom() - w * sl);
b.triangle(0, 1, 2);
} else {
b.add(r.x + d, r.y);
b.add(r.x + w, r.y);
b.add(r.x + w.min(r.w - d), r.bottom());
b.triangle(0, 1, 2);
b.triangle(0, 2, 3);
if w + d > r.right() {
b.add(r.x + w, r.y + (r.w - w) * sl);
b.triangle(2, 3, 4);
}
}
b.commit();
};
draw_par(ui, r, 1., semi_black(0.4));
let ct = r.center();
let combo = (res.max_combo as f32 * p).round() as u32;
let combo = (res.num_of_notes as f32 * p).round() as u32;
let text = format!("{combo} / {}", res.num_of_notes);
ui.text(&text)
.pos(ct.x, ct.y)
.anchor(0.5, 0.5)
.no_baseline()
.size(0.4)
.draw_using(&BOLD_FONT);
r.w *= combo as f32 / res.num_of_notes as f32;
ui.fill_rect(r, WHITE);
let p = combo as f32 / res.num_of_notes as f32;
draw_par(ui, r, p, WHITE);
r.w *= p;
ui.scissor(r, |ui| {
ui.text(text)
.pos(ct.x, ct.y)
Expand Down

0 comments on commit e6ee47d

Please sign in to comment.