From 0ada04f4fbf280a1603d416c9d4cff2307c723a9 Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Sat, 7 Nov 2026 23:33:41 +0100 Subject: [PATCH] High-res: bestiary shows the detailed sprites, toolbar buttons on stone Co-Authored-By: Claude Opus 5.5 --- src/gfx.rs | 4 ++++ src/menu/bestiary.rs | 12 +++++++++++- src/ui.rs | 9 ++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gfx.rs b/src/gfx.rs index d95e015..4f22b04 100644 --- a/src/gfx.rs +++ b/src/gfx.rs @@ -343,6 +343,10 @@ pub fn set_high_res_ui(on: bool) { HIGH_RES_UI.with(|h| h.set(on)); } +pub fn high_res_ui() -> bool { + HIGH_RES_UI.with(|h| h.get()) +} + // ---- furniture materials (crate::props::Mat order): grey detail the furniture's colours tint // (the page keeps its colours), 64x64 and 16x16; see art/generated/textures/materials/ macro_rules! material { diff --git a/src/menu/bestiary.rs b/src/menu/bestiary.rs index b2a9e27..44d9002 100644 --- a/src/menu/bestiary.rs +++ b/src/menu/bestiary.rs @@ -305,8 +305,18 @@ impl Menu { } } -// a unit sprite with the gear of a level, scaled up +// a unit sprite with the gear of a level, scaled up; the high-res style shows the detailed +// sprite (front view, 64x64 level; without the gear) fn draw_sprite(gfx: &Gfx, kind: EK, level: u32, x: f32, y: f32, size: f32) { + if crate::gfx::high_res_ui() { + if let Some(pic) = Gfx::hd_picture(kind, 0, None, false) { + let uv = Gfx::hd_uv(pic, true); + let (w, h) = crate::gfx::hd_tex_size(true); + let src = Rect::new(uv.x * w as f32, uv.y * h as f32, uv.w * w as f32, uv.h * h as f32); + draw_texture_ex(&gfx.hd_sprites, x, y, WHITE, DrawTextureParams { source: Some(src), dest_size: Some(vec2(size, size)), ..Default::default() }); + return; + } + } let src = Gfx::sprite_cell(kind, false, level); draw_texture_ex(&gfx.sprites, x, y, WHITE, DrawTextureParams { source: Some(src), dest_size: Some(vec2(size, size)), ..Default::default() }); } diff --git a/src/ui.rs b/src/ui.rs index cedbfeb..81cdcb5 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -912,7 +912,14 @@ impl Ui { // locked tools (campaign: not yet available) are drawn dark let tool_button = |bx: f32, by: f32, bw: f32, icon_id: u32, key: &str, label: &str, sel: bool, hovered: bool, locked: bool| { let r = Rect::new(bx + px, by, bw - 2.0 * px, 3.0 * CH()); - draw_rectangle(r.x, r.y, r.w, r.h, if sel { Color::new(0.42, 0.26, 0.1, 1.0) } else if hovered { Color::new(0.18, 0.13, 0.1, 1.0) } else { Color::new(0.1, 0.07, 0.07, 1.0) }); + let fill = if sel { Color::new(0.42, 0.26, 0.1, 1.0) } else if hovered { Color::new(0.18, 0.13, 0.1, 1.0) } else { Color::new(0.1, 0.07, 0.07, 1.0) }; + if crate::gfx::high_res_ui() { + // high-res: a slab of stone in the button's colour (the material is light grey) + let k = 1.6; + draw_texture_ex(&gfx.materials[1], r.x, r.y, Color::new(fill.r * k, fill.g * k, fill.b * k, 1.0), DrawTextureParams { dest_size: Some(vec2(r.w, r.h)), ..Default::default() }); + } else { + draw_rectangle(r.x, r.y, r.w, r.h, fill); + } // the active tool: pulsing frame let frame = if sel { if pulse { WHITE } else { FRAME_HI } } else { Color::new(0.35, 0.28, 0.2, 1.0) }; draw_rectangle_lines(r.x, r.y, r.w, r.h, if sel { 3.0 * px } else { 2.0 * px }, frame);