Bestiary portraits in the high-res style: a painted pixel-art bust for every creature
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a24fc51605
commit
8d2362fc11
41 files changed
+308
-1
No files matched your search
+25
-1
@@ -174,7 +174,19 @@ impl Menu {
|
||||
_ => level,
|
||||
};
|
||||
match entry {
|
||||
Entry::Unit(kind, _) => draw_sprite(gfx, kind, show_level, x + k, y + k, pic),
|
||||
Entry::Unit(kind, _) => {
|
||||
// the high-res style shows the creature's portrait filling the box
|
||||
let box_size = pic + 2.0 * k;
|
||||
match crate::portraits::rect(kind).filter(|_| crate::gfx::high_res_ui()) {
|
||||
Some(src) => {
|
||||
let m = 2.0;
|
||||
draw_texture_ex(&crate::portraits::atlas(), x + m, y + m, WHITE, DrawTextureParams { source: Some(src), dest_size: Some(vec2(box_size - 2.0 * m, box_size - 2.0 * m)), ..Default::default() });
|
||||
draw_rectangle_lines(x + m, y + m, box_size - 2.0 * m, box_size - 2.0 * m, 2.0, Color::new(0.0, 0.0, 0.0, 0.8));
|
||||
draw_rectangle_lines(x, y, box_size, box_size, 2.0, FRAME);
|
||||
}
|
||||
None => draw_sprite(gfx, kind, show_level, x + k, y + k, pic),
|
||||
}
|
||||
}
|
||||
Entry::Rank(l) => draw_sprite(gfx, EK::Ogre, l, x + k, y + k, pic),
|
||||
Entry::Building(i) => {
|
||||
let icon = tool_info(TOOLS[i]).icon;
|
||||
@@ -321,3 +333,15 @@ fn draw_sprite(gfx: &Gfx, kind: EK, level: u32, x: f32, y: f32, size: f32) {
|
||||
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() });
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn every_bestiary_unit_has_a_portrait() {
|
||||
for &k in CREATURES.iter().chain(HUMANS.iter()) {
|
||||
assert!(crate::portraits::rect(k).is_some(), "no portrait for {:?}", k);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user