From 3c5ede28e43a846e2323d73a4f8522d0e25e2baf Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 17 Jan 2024 10:23:42 -0800 Subject: [PATCH] Added basic planet descriptions --- content/system.toml | 14 ++++++++++++++ crates/content/src/part/system.rs | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/content/system.toml b/content/system.toml index 73d3d66..340e2d1 100644 --- a/content/system.toml +++ b/content/system.toml @@ -15,6 +15,20 @@ object.earth.size = 1000 # TODO: satisfy conditions to land object.earth.landable = true +object.earth.name = "Earth" +object.earth.desc = """ + The ancestral home world of humanity, Earth has a population twice that of any other inhabited planet. +Sprawling cities cover large portions of its surface, many of them overcrowded and dangerous. +Some people work to scrape together enough money to leave, while at the same time others, born +on distant worlds, make a pilgrimage of sorts to see this planet that once cradled the entirety +of the human species. +

+ Earth is also the capital of the Republic. Representative government becomes complicated when +one planet has a greater population than a hundred planets elsewhere. As a result, +settlements of less than a million are grouped together into planetary districts that +elect a single representative between them - a source of much frustration in the frontier worlds. +""" + object.luna.sprite = "planet::luna" object.luna.position.center = "earth" diff --git a/crates/content/src/part/system.rs b/crates/content/src/part/system.rs index 85dc425..4d013d6 100644 --- a/crates/content/src/part/system.rs +++ b/crates/content/src/part/system.rs @@ -29,6 +29,8 @@ pub(crate) mod syntax { pub radius: Option, pub angle: Option, pub landable: Option, + pub name: Option, + pub desc: Option, } #[derive(Debug, Deserialize)] @@ -122,6 +124,12 @@ pub struct SystemObject { /// If true, ships may land on this object pub landable: bool, + + /// The display name of this object + pub name: String, + + /// The description of this object + pub desc: String, } /// Helper function for resolve_position, never called on its own. @@ -223,6 +231,18 @@ impl crate::Build for System { body_index: 0, }, landable: obj.landable.unwrap_or(false), + name: obj + .name + .as_ref() + .map(|x| x.clone()) + .unwrap_or("".to_string()), + + // TODO: better linebreaks, handle double spaces + desc: obj + .desc + .as_ref() + .map(|x| x.replace("\n", " ").replace("
", "\n")) + .unwrap_or("".to_string()), }); }