From 5f70992cfb9fff5ceeae8a0dcbe5ab75d04abba5 Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Sat, 7 Nov 2026 22:50:47 +0100 Subject: [PATCH] Room and tool buttons draw from the high-res atlas in the high-res style Co-Authored-By: Claude Opus 5.5 --- src/gfx.rs | 17 +++++++++++++++-- src/main.rs | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gfx.rs b/src/gfx.rs index 06ac132..4ff0565 100644 --- a/src/gfx.rs +++ b/src/gfx.rs @@ -332,6 +332,15 @@ fn earth_px(x: i32, y: i32, v: u32) -> Color { shade(base, (big + fine) as i32) } +thread_local! { + // the interface draws atlas cells from the high-res atlas (the high-res graphics style) + static HIGH_RES_UI: std::cell::Cell = const { std::cell::Cell::new(false) }; +} + +pub fn set_high_res_ui(on: bool) { + HIGH_RES_UI.with(|h| h.set(on)); +} + // ---- 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 { @@ -2844,13 +2853,17 @@ impl Gfx { } } + // an atlas cell in the interface (tool and room buttons); the high-res style shows the + // high-res atlas, so the room buttons show the rooms' new floors pub fn draw_cell(&self, id: u32, x: f32, y: f32, w: f32, h: f32, color: Color) { + let (tex, k) = if HIGH_RES_UI.with(|h| h.get()) { (&self.atlas_hd, (HD_TILE / 16) as f32) } else { (&self.atlas, 1.0) }; + let r = Self::cell(id); draw_texture_ex( - &self.atlas, + tex, x, y, color, - DrawTextureParams { dest_size: Some(vec2(w, h)), source: Some(Self::cell(id)), ..Default::default() }, + DrawTextureParams { dest_size: Some(vec2(w, h)), source: Some(Rect::new(r.x * k, r.y * k, r.w * k, r.h * k)), ..Default::default() }, ); } diff --git a/src/main.rs b/src/main.rs index ed76fe0..cecdcdb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -481,6 +481,7 @@ fn apply_settings(s: &Settings, r3d: &mut R3d) { r3d.max_lights = s.max_lights as usize; r3d.pixel_rows = settings::pixel_rows(s.pixel_rows); holiday::set_override(s.debug_holiday); + gfx::set_high_res_ui(r3d.pixel_rows >= settings::HIGH_RES_ROWS as u32); audio::set_volumes(s.music_volume, s.volume, s.muted); }