New screenshots; fit long button labels, no HUD behind the title's match page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c7c3e979d6
commit
88061a8628
6 files changed
+36
-3
No files matched your search
+20
-3
@@ -451,8 +451,24 @@ pub struct Menu {
|
||||
fn button(gfx: &Gfx, r: Rect, label: &str, hot: bool, accent: Color) {
|
||||
draw_rectangle(r.x, r.y, r.w, r.h, if hot { Color::new(0.35, 0.22, 0.1, 1.0) } else { Color::new(0.13, 0.09, 0.08, 1.0) });
|
||||
draw_rectangle_lines(r.x, r.y, r.w, r.h, 2.0, if hot { FRAME_HI } else { accent });
|
||||
let s = S();
|
||||
gfx.text(label, r.x + (r.w - gfx.measure(label, s)) * 0.5, r.y + (r.h - GH * s) * 0.5, s, if hot { FRAME_HI } else { TXT });
|
||||
// a label too wide for the button gets the small font, and is cut short if that is not enough
|
||||
let mut s = S();
|
||||
let room = r.w - 8.0;
|
||||
let mut text = label.to_string();
|
||||
if gfx.measure(&text, s) > room {
|
||||
s = SMALL();
|
||||
while gfx.measure(&text, s) > room && text.chars().count() > 2 {
|
||||
text.pop();
|
||||
while text.ends_with(' ') {
|
||||
text.pop();
|
||||
}
|
||||
if gfx.measure(&format!("{text}…"), s) <= room {
|
||||
text.push('…');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
gfx.text(&text, r.x + (r.w - gfx.measure(&text, s)) * 0.5, r.y + (r.h - GH * s) * 0.5, s, if hot { FRAME_HI } else { TXT });
|
||||
}
|
||||
|
||||
impl Menu {
|
||||
@@ -2034,7 +2050,8 @@ impl Menu {
|
||||
items.push((Btn::MatchLeave, tr("net.leave")));
|
||||
}
|
||||
items.push((Btn::Back, tr("menu.back")));
|
||||
let bw = 14.0 * CW();
|
||||
// three buttons a row over the whole width
|
||||
let bw = ((w - 2.0 * CW()) / 3.0).max(14.0 * CW());
|
||||
let shown = items.iter().take(9).count();
|
||||
for (k, (b, label)) in items.iter().take(shown).enumerate() {
|
||||
let r = Rect::new(ix + (k % 3) as f32 * (bw + CW()), yy + (k / 3) as f32 * CH() * 2.4, bw, CH() * 2.0);
|
||||
|
||||
Reference in new issue
Block a user