Added outfit thumbnails

master
Mark 2024-02-05 14:17:18 -08:00
parent cbcb060c66
commit 1c23500db2
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
5 changed files with 26 additions and 9 deletions

View File

@ -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

View File

@ -1,6 +1,6 @@
[ship."Gypsum"]
sprite = "ship::gypsum"
thumb = "icon::gypsum"
thumbnail = "icon::gypsum"
size = 100
mass = 1
hull = 200

View File

@ -17,6 +17,7 @@ pub(crate) mod syntax {
#[derive(Debug, Deserialize)]
pub struct Outfit {
pub thumbnail: String,
pub engine: Option<Engine>,
pub steering: Option<Steering>,
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(),

View File

@ -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<Engine>,
pub guns: Vec<Gun>,
@ -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,

View File

@ -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()