pub struct ModsPreset {
pub order: Vec<String>,
pub enabled: Vec<String>,
pub configuration: ModConfigurations,
}Expand description
A full mod configuration: every known mod’s display order, which of
them are enabled, and their settings. Used both as the live,
currently-applied configuration (ModsState::active) and as a named,
saved shortcut (ModsState::presets), the same shape either way, so
“the active configuration” and “a saved preset” can never structurally
drift apart.
Fields§
§order: Vec<String>Every mod’s directory name this configuration knows about, in
display order, including disabled ones. For the active
configuration this also doubles as DLL merge-priority order (see
ModsPreset::priority_order): dragging a mod in the launcher’s
list both moves it on screen and changes where it merges relative
to other enabled mods, deliberately, since those are the same
action. For a saved-but-inactive preset, order is simply frozen
at save time until the preset is applied.
enabled: Vec<String>Which mods (by directory name) are enabled, membership only,
order is meaningless here. This configuration’s actual priority
order is always order filtered to this set, computed on demand
by ModsPreset::priority_order, never stored separately, so it
can never drift from what order shows.
configuration: ModConfigurationsEvery enabled mod’s current parameter overrides, keyed by mod
directory name. A mod with no entry here simply has no overrides,
every parameter falls back to that mod’s own
crate::mod_config::ModConfig::configuration default, or fully
unset if it doesn’t have one either.
Implementations§
Source§impl ModsPreset
impl ModsPreset
Sourcepub fn priority_order(&self) -> Vec<&str>
pub fn priority_order(&self) -> Vec<&str>
This configuration’s effective merge-priority order: every name in
Self::order that’s also in Self::enabled, in order’s
order. Deliberately computed rather than stored, display order
is priority order, with no second copy that could disagree with
what the launcher’s list shows.
Sourcepub fn sync_order<I, S>(&mut self, discovered: I)
pub fn sync_order<I, S>(&mut self, discovered: I)
Reconciles Self::order against discovered, the mod
directory names actually found under mods_dir right now. Mods
present in discovered but not yet in order are appended at the
end, in discovered’s order (stable but otherwise arbitrary among
newly-seen mods, typically already alphabetical, since callers
usually pass a sorted directory listing). Mods in order but no
longer in discovered are dropped. Existing entries keep their
relative position.
This never touches Self::enabled, membership isn’t affected
by a mod folder simply appearing or disappearing on disk, only by
an explicit enable/disable.
Sourcepub fn set_enabled<'a>(
&mut self,
enabled_names: impl IntoIterator<Item = &'a str>,
)
pub fn set_enabled<'a>( &mut self, enabled_names: impl IntoIterator<Item = &'a str>, )
Sets which mods are enabled to exactly enabled_names,
membership only; their relative priority is still whatever order
says (see Self::priority_order), unaffected by the order
enabled_names happens to be given in. Call this after a checkbox
toggle. Does not touch order, dragging to reorder is a
separate, direct assignment to that field.
Trait Implementations§
Source§impl Clone for ModsPreset
impl Clone for ModsPreset
Source§fn clone(&self) -> ModsPreset
fn clone(&self) -> ModsPreset
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModsPreset
impl Debug for ModsPreset
Source§impl Default for ModsPreset
impl Default for ModsPreset
Source§fn default() -> ModsPreset
fn default() -> ModsPreset
Source§impl<'de> Deserialize<'de> for ModsPreset
impl<'de> Deserialize<'de> for ModsPreset
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ModsPreset
impl PartialEq for ModsPreset
Source§fn eq(&self, other: &ModsPreset) -> bool
fn eq(&self, other: &ModsPreset) -> bool
self and other values to be equal, and is used by ==.