Add mod config option for loose files

Just the field in the config file, for now.
This commit is contained in:
Lucas Schwiderski 2023-11-08 15:04:32 +01:00
parent b7b76412a3
commit 7f84b2fe9a
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8
3 changed files with 16 additions and 0 deletions

View file

@ -109,6 +109,7 @@ pub(crate) struct ModInfo {
#[data(ignore)]
pub resources: ModResourceInfo,
pub depends: Vector<ModDependency>,
pub bundle: bool,
#[data(ignore)]
pub nexus: Option<NexusInfo>,
}
@ -129,6 +130,7 @@ impl ModInfo {
version: cfg.version,
enabled: false,
packages,
bundle: cfg.bundle,
image,
categories: cfg.categories.into_iter().collect(),
resources: ModResourceInfo {

View file

@ -350,6 +350,7 @@ pub(crate) async fn run(_ctx: sdk::Context, matches: &ArgMatches) -> Result<()>
localization: mod_file.localization,
},
depends: vec![ModDependency::ID(String::from("DMF"))],
bundle: true,
};
tracing::debug!(?dtmt_cfg);

View file

@ -30,6 +30,17 @@ pub enum ModDependency {
Config { id: String, order: ModOrder },
}
// A bit dumb, but serde doesn't support literal values with the
// `default` attribute, only paths.
fn default_true() -> bool {
true
}
// Similarly dumb, as the `skip_serializing_if` attribute needs a function
fn is_true(val: &bool) -> bool {
*val
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct ModConfig {
#[serde(skip)]
@ -51,6 +62,8 @@ pub struct ModConfig {
pub resources: ModConfigResources,
#[serde(default)]
pub depends: Vec<ModDependency>,
#[serde(default = "default_true", skip_serializing_if = "is_true")]
pub bundle: bool,
}
pub const STEAMAPP_ID: u32 = 1361210;