Compare commits

...

2 Commits

Author SHA1 Message Date
Mark 250dc402a4
Updated TODO 2024-02-05 14:17:23 -08:00
Mark 1c23500db2
Added outfit thumbnails 2024-02-05 14:17:18 -08:00
6 changed files with 28 additions and 9 deletions

View File

@ -1,6 +1,8 @@
# Specific projects # Specific projects
## Now: ## Now:
- Replace handles with Arcs in content
- clean up content
- Clean up state api - Clean up state api
- Persistent variables - Persistent variables
- Better planet icons - Better planet icons

View File

@ -1,7 +1,7 @@
[outfit."plasma engines"] [outfit."plasma engines"]
thumbnail = "icon::engine"
space.engine = 20 space.engine = 20
engine.thrust = 100 engine.thrust = 100
engine.flare.sprite = "flare::ion" engine.flare.sprite = "flare::ion"
engine.flare.on_start = "rise:top" engine.flare.on_start = "rise:top"
@ -10,15 +10,16 @@ steering.power = 20
[outfit."shield generator"] [outfit."shield generator"]
thumbnail = "icon::shield"
space.outfit = 5 space.outfit = 5
shield.generation = 10 shield.generation = 10
shield.strength = 500 shield.strength = 500
shield.delay = 2.0 shield.delay = 2.0
[outfit."blaster"] [outfit."blaster"]
thumbnail = "icon::shield"
space.weapon = 10 space.weapon = 10

View File

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

View File

@ -17,6 +17,7 @@ pub(crate) mod syntax {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct Outfit { pub struct Outfit {
pub thumbnail: String,
pub engine: Option<Engine>, pub engine: Option<Engine>,
pub steering: Option<Steering>, pub steering: Option<Steering>,
pub space: outfitspace::syntax::OutfitSpace, pub space: outfitspace::syntax::OutfitSpace,
@ -127,6 +128,9 @@ pub(crate) mod syntax {
/// Represents an outfit that may be attached to a ship. /// Represents an outfit that may be attached to a ship.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Outfit { pub struct Outfit {
/// This outfit's thumbnail
pub thumbnail: SpriteHandle,
/// How much space this outfit requires /// How much space this outfit requires
pub space: OutfitSpace, 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 { let mut o = Self {
thumbnail: thumb_handle,
gun, gun,
handle, handle,
name: outfit_name.clone(), name: outfit_name.clone(),

View File

@ -16,7 +16,7 @@ pub(crate) mod syntax {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct Ship { pub struct Ship {
pub sprite: String, pub sprite: String,
pub thumb: String, pub thumbnail: String,
pub size: f32, pub size: f32,
pub engines: Vec<Engine>, pub engines: Vec<Engine>,
pub guns: Vec<Gun>, pub guns: Vec<Gun>,
@ -98,7 +98,7 @@ pub struct Ship {
pub sprite: SpriteHandle, pub sprite: SpriteHandle,
/// This ship's thumbnail /// This ship's thumbnail
pub thumb: SpriteHandle, pub thumbnail: SpriteHandle,
/// The size of this ship. /// The size of this ship.
/// Measured as unrotated height, /// Measured as unrotated height,
@ -276,11 +276,11 @@ impl crate::Build for Ship {
Some(t) => *t, Some(t) => *t,
}; };
let thumb = match ct.sprite_index.get(&ship.thumb) { let thumbnail = match ct.sprite_index.get(&ship.thumbnail) {
None => bail!( None => bail!(
"In ship `{}`: thumbnail sprite `{}` doesn't exist", "In ship `{}`: thumbnail sprite `{}` doesn't exist",
ship_name, ship_name,
ship.thumb ship.thumbnail
), ),
Some(t) => *t, Some(t) => *t,
}; };
@ -429,7 +429,7 @@ impl crate::Build for Ship {
ct.ships.push(Self { ct.ships.push(Self {
sprite, sprite,
thumb, thumbnail,
aspect, aspect,
collapse, collapse,
damage, damage,

View File

@ -90,7 +90,7 @@ impl CustomType for ShipState {
s.get_ship().get_data().get_state().is_collapsing() s.get_ship().get_data().get_state().is_collapsing()
}) })
.with_fn("name", |s: &mut Self| s.get_content().name.clone()) .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("landed_on", |s: &mut Self| s.landed_on())
.with_fn("get_shields", |s: &mut Self| { .with_fn("get_shields", |s: &mut Self| {
s.get_ship().get_data().get_shields() s.get_ship().get_data().get_shields()