Expand description
On-disk I/O for the mods directory’s single state file: ModsState
(persisted as mods.json), which replaces the older
enabled_mods.json + mod_configuration.json pair. Consolidating them
fixes a specific bug in that older layout: with two files, a mod’s
display position was reconstructed at load time from which bucket it
happened to be in (enabled vs. not), so toggling a mod would visibly
reshuffle the whole list.
ModsPreset is the one shape used both for the live, currently-applied
configuration (ModsState::active) and for every saved, not-currently
-active preset in ModsState::presets, deliberately the same type,
not two structs that happen to share field names. Each carries its own
full order (display position, doubling as DLL merge-priority order,
see ModsPreset::priority_order) alongside enabled (membership) and
configuration (per-mod overrides). order is never touched by
enabling/disabling a mod, only by an explicit reorder or by
ModsState::sync_active_order reconciling it against what’s actually
installed on disk.
Applying a saved preset (ModsState::apply_preset) is a plain
active = preset.clone, the preset’s order becomes the new display
order outright, dropping any locally-installed mod the preset doesn’t
mention. Those dropped mods aren’t lost: the next
ModsState::sync_active_order call (part of every discover_mods
scan) re-appends every installed mod not already in active.order, so
the launcher’s list still shows every installed mod after switching
presets, just with the preset’s chosen mods first, in the preset’s
order, and everything else appended after.
Structs§
- Mods
Preset - 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. - Mods
State - The full persisted state of a game’s mods directory: the currently- active configuration, and any named presets saved for later.
Constants§
- DEFAULT_
MODS_ DIR_ NAME - The on-disk mods directory, relative to the game’s root directory. Layout:
- MODS_
STATE_ FILE_ NAME - File name, within
DEFAULT_MODS_DIR_NAME, holdingModsState. - MOD_
FILE_ NAME - File name, within each mod’s own subdirectory, holding that mod’s metadata, rules and parameters.
Functions§
- load_
mods_ state - Reads
ModsStatefrom<mods_dir>/mods.json. A missing file reads as a fresh, empty state rather than an error, the common state before.supreme/mods/has ever been created, e.g. right after a fresh install. - save_
mods_ state - Writes
stateto<mods_dir>/mods.json, creatingmods_dirif it doesn’t exist yet.
Type Aliases§
- ModConfigurations
- Every mod’s current parameter overrides, values a person has
actually set via the launcher, keyed by mod directory name, then by
crate::mod_config::ModParameter::id, layered on top of that mod’s owncrate::mod_config::ModConfig::configurationdefaults at resolution time (seecrate::mod_config::ModConfig::effective_configuration).