Interface on the pixel grid: a virtual screen of whole multiples of the world's rows, sharp-scaled to every device; compact title menu on short screens

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-06 07:33:25 +01:00
1 parent aa39e66da9
commit e7fc0a4751
5 files changed
+142 -66

No files matched your search

+20 -2
View File
@@ -999,9 +999,13 @@ impl Menu {
}
fn column(&mut self, gfx: &Gfx, x: f32, y: f32, w: f32, items: &[(Btn, String)]) {
self.column_pitch(gfx, x, y, w, items, CH() * 3.0);
}
fn column_pitch(&mut self, gfx: &Gfx, x: f32, y: f32, w: f32, items: &[(Btn, String)], pitch: f32) {
let (mx, my) = mouse();
for (k, (b, label)) in items.iter().enumerate() {
let r = Rect::new(x, y + k as f32 * CH() * 3.0, w, CH() * 2.0);
let r = Rect::new(x, y + k as f32 * pitch, w, CH() * 2.0);
button(gfx, r, label, r.contains(vec2(mx, my)), FRAME);
self.buttons.push((r, *b));
}
@@ -1114,7 +1118,21 @@ impl Menu {
items.push((Btn::Help, tr("menu.help")));
let w = 26.0 * CW();
let y = ty + GH * big + CH() * 4.0;
self.column(gfx, grid_center(sw, w), y, w, &items);
// the buttons end above the hints and credits; on a short screen they move closer
// together or into two columns
let bottom = sh - CH() * 9.0;
let fits = |pitch: f32| y + items.len() as f32 * pitch <= bottom;
if fits(CH() * 3.0) {
self.column(gfx, grid_center(sw, w), y, w, &items);
} else if fits(CH() * 2.5) {
self.column_pitch(gfx, grid_center(sw, w), y, w, &items, CH() * 2.5);
} else {
let half = (items.len() + 1) / 2;
let gap = CW() * 2.0;
let x0 = grid_center(sw, w * 2.0 + gap);
self.column_pitch(gfx, x0, y, w, &items[..half], CH() * 2.5);
self.column_pitch(gfx, x0 + w + gap, y, w, &items[half..], CH() * 2.5);
}
let hint = tr("menu.drop_hint");
gfx.text(&hint, grid_center(sw, gfx.measure(&hint, SMALL())), sh - CH() * 8.0, SMALL(), DIM);
let credit = tr("help.font");