Graphics style: pixel art (360 rows) or high-res (1080 rows, detailed sprites)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-07 20:50:26 +01:00
1 parent 928c34e78b
commit 807a124a0b
23 files changed
+81 -48

No files matched your search

+2 -2
View File
@@ -1373,8 +1373,8 @@ const SPR_CELL: u32 = 12;
const SPR_K: u32 = 3;
pub const ACELL: u32 = SPR_CELL * SPR_K;
// Detailed 32x32 sprites (generated, see art/generated/), used instead of the 10x10 ones when
// the world is rendered fine enough (render3d::billboards). Five views side by side like VIEWS,
// Detailed 32x32 sprites (generated, see art/generated/), used instead of the 10x10 ones in the
// high-res graphics style when close enough (render3d::billboards). Five views side by side like VIEWS,
// transparent background, the feet on the bottom row. No gear yet: every tier looks the same.
const HD_SPRITES: [(EK, &[u8]); 1] = [(EK::Worker, include_bytes!("../assets/sprites/imp-32.png"))];
const HD: u32 = 32;
+2 -2
View File
@@ -151,7 +151,7 @@ fn item_value(it: Item, s: &Settings) -> String {
Item::DebugTriggerZones => onoff(s.debug_trigger_zones),
Item::DebugCommandMarkers => onoff(s.debug_command_markers),
Item::DebugPathLines => onoff(s.debug_path_lines),
Item::RenderScale => crate::i18n::trf("set.pixel_rows_val", &[s.pixel_rows.to_string()]),
Item::RenderScale => tr(if crate::settings::pixel_rows(s.pixel_rows) == crate::settings::HIGH_RES_ROWS as u32 { "set.style_highres" } else { "set.style_pixel" }),
Item::GameSpeed => format!("{}x", s.game_speed as i32),
Item::Hints => onoff(s.hints),
Item::Events => onoff(s.events),
@@ -200,7 +200,7 @@ fn item_change(it: Item, s: &mut Settings, d: i32) {
Item::WallDetail => s.wall_detail = cycle(&[1u8, 2, 3], s.wall_detail, d),
Item::Lights => s.max_lights = cycle(&[8u8, 16, 24], s.max_lights, d),
Item::UiScale => s.ui_size = cycle(&crate::settings::UI_SIZES, s.ui_size, d),
Item::RenderScale => s.pixel_rows = cycle(&crate::settings::PIXEL_ROWS, crate::settings::pixel_rows(s.pixel_rows) as u16, d),
Item::RenderScale => s.pixel_rows = cycle(&crate::settings::STYLES, crate::settings::pixel_rows(s.pixel_rows) as u16, d),
Item::DebugFps => s.debug_fps = !s.debug_fps,
Item::DebugFrameTime => s.debug_frame_time = !s.debug_frame_time,
Item::DebugPing => s.debug_ping = !s.debug_ping,
+4 -3
View File
@@ -1658,8 +1658,9 @@ impl R3d {
let mut mb = MB::new();
let sw = SPRITE_TEX_W;
let sh = SPRITE_TEX_H;
// screen pixels per tile: a sprite's cell (1.2 sizes high) shows a detailed sprite when
// every texel of it gets nearly a pixel; fewer pixels would only turn it into noise
// detailed sprites only in the high-res style, and only where a sprite's cell (1.2 sizes
// high) gives every texel nearly a pixel; fewer pixels would only turn it into noise
let hd = self.pixel_rows >= crate::settings::HIGH_RES_ROWS as u32;
let px_per_tile = world_rows / cam.view_h().max(0.1);
for e in &g.ents {
if !e.alive || e.held || unit_hidden(g, e) {
@@ -1760,7 +1761,7 @@ impl R3d {
}
let white = e.flash > 0.07;
let v = if e.captive != 0 { 0 } else { view };
let detailed = w * 1.2 * px_per_tile >= crate::gfx::ACELL as f32 * 0.85;
let detailed = hd && w * 1.2 * px_per_tile >= crate::gfx::ACELL as f32 * 0.85;
let src = detailed.then(|| Gfx::hd_cell_view(e.kind, white, e.level, v)).flatten().unwrap_or_else(|| Gfx::sprite_cell_view(e.kind, white, e.level, v));
let (mut u0, v0) = (src.x / sw, src.y / sh);
let (mut u1, v1) = ((src.x + src.w) / sw, (src.y + src.h) / sh);
+18 -4
View File
@@ -151,7 +151,7 @@ pub struct Settings {
pub ui_factor: u8, // old interface size (2 large, 3 medium, 4 small; only read to carry old settings over)
pub ui_size: u16, // interface size in percent of the standard (100 = 1080 interface rows), 0 = automatic
pub render_scale: u8, // old pixel-look divisor (no longer used, kept for old settings files)
pub pixel_rows: u16, // pixel look: rows of the world on every screen (one of PIXEL_ROWS)
pub pixel_rows: u16, // graphics style: rows of the world on every screen (360 pixel art, 1080 high-res)
pub touch_ui: u8, // touch interface: 0 = automatic (after the first touch), 1 = on, 2 = off
pub debug_fps: bool, // show FPS and rendering backend
pub debug_frame_time: bool, // show the frame-time line and graph
@@ -264,11 +264,15 @@ impl Settings {
}
}
// the world's pixel rows of the settings menu (more rows: finer world, detailed sprites fit)
pub const PIXEL_ROWS: [u16; 5] = [270, 360, 480, 540, 1080];
// the graphics styles of the settings menu as the world's pixel rows: pixel art (360 rows, the
// small hand-made sprites) and high-res (1080 rows, detailed sprites; other values from older
// settings files count as pixel art)
pub const PIXEL_ART_ROWS: u16 = 360;
pub const HIGH_RES_ROWS: u16 = 1080;
pub const STYLES: [u16; 2] = [PIXEL_ART_ROWS, HIGH_RES_ROWS];
pub fn pixel_rows(set: u16) -> u32 {
if PIXEL_ROWS.contains(&set) { set as u32 } else { 360 }
if set == HIGH_RES_ROWS { HIGH_RES_ROWS as u32 } else { PIXEL_ART_ROWS as u32 }
}
// the interface sizes of the settings menu in percent (0 = automatic), from small to large
@@ -318,4 +322,14 @@ mod tests {
assert_eq!(ui_size_rows(150), 720);
assert!(ui_size_rows(200) < ui_size_rows(175));
}
#[test]
fn graphics_styles() {
assert_eq!(pixel_rows(1080), 1080);
assert_eq!(pixel_rows(360), 360);
// older pixel-look values count as pixel art
for old in [270u16, 480, 540, 0] {
assert_eq!(pixel_rows(old), 360);
}
}
}