diff --git a/content/outfits.toml b/content/outfits.toml index c466b5a..acc373b 100644 --- a/content/outfits.toml +++ b/content/outfits.toml @@ -1,7 +1,7 @@ [outfit."plasma engines"] +thumbnail = "icon::engine" space.engine = 20 - engine.thrust = 100 engine.flare.sprite = "flare::ion" engine.flare.on_start = "rise:top" @@ -10,15 +10,16 @@ steering.power = 20 [outfit."shield generator"] +thumbnail = "icon::shield" space.outfit = 5 - shield.generation = 10 shield.strength = 500 shield.delay = 2.0 [outfit."blaster"] +thumbnail = "icon::shield" space.weapon = 10 diff --git a/content/ship.toml b/content/ship.toml index 3a91013..561cb8c 100644 --- a/content/ship.toml +++ b/content/ship.toml @@ -1,6 +1,6 @@ [ship."Gypsum"] sprite = "ship::gypsum" -thumb = "icon::gypsum" +thumbnail = "icon::gypsum" size = 100 mass = 1 hull = 200 diff --git a/crates/content/src/part/outfit.rs b/crates/content/src/part/outfit.rs index 4d8c0d7..6ac560c 100644 --- a/crates/content/src/part/outfit.rs +++ b/crates/content/src/part/outfit.rs @@ -17,6 +17,7 @@ pub(crate) mod syntax { #[derive(Debug, Deserialize)] pub struct Outfit { + pub thumbnail: String, pub engine: Option, pub steering: Option, pub space: outfitspace::syntax::OutfitSpace, @@ -127,6 +128,9 @@ pub(crate) mod syntax { /// Represents an outfit that may be attached to a ship. #[derive(Debug, Clone)] pub struct Outfit { + /// This outfit's thumbnail + pub thumbnail: SpriteHandle, + /// How much space this outfit requires pub space: OutfitSpace, @@ -260,7 +264,19 @@ impl crate::Build for Outfit { ), }; + let thumb_handle = match content.sprite_index.get(&outfit.thumbnail) { + None => { + return Err(anyhow!( + "thumbnail sprite `{}` doesn't exist", + outfit.thumbnail + )) + .with_context(|| format!("in outfit `{}`", outfit_name)); + } + Some(t) => *t, + }; + let mut o = Self { + thumbnail: thumb_handle, gun, handle, name: outfit_name.clone(), diff --git a/crates/content/src/part/ship.rs b/crates/content/src/part/ship.rs index a8cdc80..887fbb0 100644 --- a/crates/content/src/part/ship.rs +++ b/crates/content/src/part/ship.rs @@ -16,7 +16,7 @@ pub(crate) mod syntax { #[derive(Debug, Deserialize)] pub struct Ship { pub sprite: String, - pub thumb: String, + pub thumbnail: String, pub size: f32, pub engines: Vec, pub guns: Vec, @@ -98,7 +98,7 @@ pub struct Ship { pub sprite: SpriteHandle, /// This ship's thumbnail - pub thumb: SpriteHandle, + pub thumbnail: SpriteHandle, /// The size of this ship. /// Measured as unrotated height, @@ -276,11 +276,11 @@ impl crate::Build for Ship { Some(t) => *t, }; - let thumb = match ct.sprite_index.get(&ship.thumb) { + let thumbnail = match ct.sprite_index.get(&ship.thumbnail) { None => bail!( "In ship `{}`: thumbnail sprite `{}` doesn't exist", ship_name, - ship.thumb + ship.thumbnail ), Some(t) => *t, }; @@ -429,7 +429,7 @@ impl crate::Build for Ship { ct.ships.push(Self { sprite, - thumb, + thumbnail, aspect, collapse, damage, diff --git a/crates/render/src/ui/api/state.rs b/crates/render/src/ui/api/state.rs index 5f3a753..0163370 100644 --- a/crates/render/src/ui/api/state.rs +++ b/crates/render/src/ui/api/state.rs @@ -90,7 +90,7 @@ impl CustomType for ShipState { s.get_ship().get_data().get_state().is_collapsing() }) .with_fn("name", |s: &mut Self| s.get_content().name.clone()) - .with_fn("thumbnail", |s: &mut Self| s.get_content().thumb) + .with_fn("thumbnail", |s: &mut Self| s.get_content().thumbnail) .with_fn("landed_on", |s: &mut Self| s.landed_on()) .with_fn("get_shields", |s: &mut Self| { s.get_ship().get_data().get_shields()