feat: procedurally scalable UI — font_scale auto-computed from screen size
- UiLayer.font_scale: dynamically computed as (ui_height / 200).clamp(2, 6) Larger screens get bigger UI text automatically - draw_text: renders each font pixel as font_scale×font_scale block (was 1×1, now 2×2 to 6×6 depending on screen size) - text_width: now instance method, returns scaled width - draw_health_bar: bar width scales with font_scale - draw_character_panel: panel dimensions and row spacing scale - draw_hud: bar height, row spacing, bar width scale - draw_inventory_overlay: slot sizes scale with font_scale - draw_messages: line spacing scales with font_height - draw_death_screen: centered text uses scaled text_width - All 185 tests + 14 scenarios pass - Benchmark: 61.9 FPS (was 82.7 — 25% regression from more set_alpha calls)
This commit is contained in:
+6
-3
@@ -69,11 +69,14 @@ fn depth_shown_in_hud() {
|
||||
"LV:{} XP:{} K:{} S:{} D:{} T:{}",
|
||||
player.level, player.xp, 0, 0, s.game.depth, s.game.tick
|
||||
);
|
||||
let stats_w = verbatim::ui::UiLayer::text_width(&stats);
|
||||
let stats_w = ui.text_width(&stats);
|
||||
let stats_x = (screen_w as i32 - stats_w as i32).max(0);
|
||||
let y_row3 = screen_h as i32 - 28 + 22;
|
||||
let fs = ui.font_scale();
|
||||
let fh = 5 * fs;
|
||||
let bar_h = (28 * fs / 2).max(fh * 3);
|
||||
let y_row3 = screen_h as i32 - bar_h + 2 + (fh + 2) * 2;
|
||||
let line: String = (stats_x as i32..screen_w as i32)
|
||||
.step_by(3)
|
||||
.step_by(fs as usize * 3)
|
||||
.map(|x| ui.get(x, y_row3).map(|c| c.ch).unwrap_or(' '))
|
||||
.collect();
|
||||
assert!(line.contains("D:1"), "HUD should show depth: {}", line);
|
||||
|
||||
Reference in New Issue
Block a user