High-res interface icons: tools, towers, traps, doors, spells, orders and siege

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-07 23:41:08 +01:00
1 parent 37e5250c52
commit d951c16902
28 files changed
+199

No files matched your search

+32
View File
@@ -414,6 +414,20 @@ const HD_DECALS: [(u32, &[u8], &[u8]); 8] = [
hd_obj!(D_SHARD, "shard"),
];
// the interface icons of the high-res style (art/generated/icons/): strips of icons, 64x64 and
// 128x128, for these cells in this order
macro_rules! hd_icons {
($name:literal, $cells:expr) => {
(include_bytes!(concat!("../assets/textures/icons/", $name, "-64.png")) as &[u8], include_bytes!(concat!("../assets/textures/icons/", $name, "-128.png")) as &[u8], $cells)
};
}
const HD_ICONS: [(&[u8], &[u8], &[u32]); 4] = [
hd_icons!("tools", &[I_PICK, I_HAND, I_SELL, I_FLAG, I_BOLT, I_HEAL, I_SUMMON, I_BRIDGE, I_WALL, I_STEEL]),
hd_icons!("towers", &[I_ARROW, I_CANNON, I_MAGIC, I_RUNE, I_DRAWBRIDGE, I_RAM, I_CATAPULT, I_ORDERS, I_ORDERS + 1, I_FREEZE]),
hd_icons!("traps", &[I_TRAPS, I_TRAPS + 1, I_TRAPS + 2, I_TRAPS + 3, I_TRAPS + 4, I_TRAPS + 5, I_TRAPS + 6, I_TRAPS + 7, I_TRAPS + 8, I_TRAPS + 9]),
hd_icons!("spells", &[I_SPELLS, I_SPELLS + 1, I_SPELLS + 2, I_SPELLS + 3, I_SPELLS + 4, I_SPELLS + 5, I_SPELLS + 6, I_SPELLS + 7]),
];
// Everything else in the world (see art/generated/textures/all/): a kind's own cells get as many
// variants as it has cells, tiles that fit together in any order (one seamless border, different
// middles), and a tile picks one by its position. (first cell, cells, 64x64 tiles side by side,
@@ -606,6 +620,17 @@ fn gen_hd_atlas(tile: u32) -> Image {
}
}
}
for &(png, png2, cells) in HD_ICONS.iter() {
let src = Image::from_file_with_format(if tile == HD_TILE2 { png2 } else { png }, Some(ImageFormat::Png)).expect("hd icons");
for (v, &id) in cells.iter().enumerate() {
let (ox, oy) = ((id % ATLAS_COLS) * tile, (id / ATLAS_COLS) * tile);
for y in 0..tile {
for x in 0..tile {
img.set_pixel(ox + x, oy + y, src.get_pixel(v as u32 * tile + x, y));
}
}
}
}
// the generated pictures take on the colours of the 16x16 cells they replace (mean and
// contrast per channel, most of the way), so switching between the styles keeps the look
let range = |a: u32, n: u32| (a..a + n).collect::<Vec<u32>>();
@@ -3269,6 +3294,13 @@ mod hd_atlas_tests {
}
}
}
// the icons: a strip with one icon per cell
for &(png, png2, cells) in HD_ICONS.iter() {
for tile in [HD_TILE, HD_TILE2] {
let src = Image::from_file_with_format(if tile == HD_TILE2 { png2 } else { png }, Some(ImageFormat::Png)).unwrap();
assert_eq!((src.width as u32, src.height as u32), (cells.len() as u32 * tile, tile));
}
}
// the variants: as many tiles as the kind has cells, every cell filled
for &(base, n, png, png2) in HD_VARS.iter() {
for tile in [HD_TILE, HD_TILE2] {