Skip to main content

Crate openmw_config

Crate openmw_config 

Source
Expand description

Parser, resolver, and serializer for OpenMW configuration chains.

OpenMW loads one or more openmw.cfg files in a chain: the root config can reference additional configs via config= entries, and each file can accumulate or override settings from its parent. This crate walks that chain, resolves token substitutions (?local?, ?global?, ?userdata?, ?userconfig?), normalises paths, and exposes the composed result as OpenMWConfiguration.

§Quick start

use openmw_config::OpenMWConfiguration;

// Load using OpenMW-style root config discovery.
// OPENMW_CONFIG and OPENMW_CONFIG_DIR override discovery.
let config = OpenMWConfiguration::from_env()?;

// Iterate content files in load order
for plugin in config.content_files_iter() {
    println!("{}", plugin.value());
}

§Configuration sources

See the OpenMW path documentation for platform-specific default locations. The environment variables OPENMW_CONFIG (path to an openmw.cfg file) and OPENMW_CONFIG_DIR (directory containing openmw.cfg) override root config discovery. Without those, OpenMWConfiguration::from_env tries an openmw.cfg adjacent to the running executable, then the platform global OpenMW config. User config is loaded only when referenced by the root config, usually through config="?userconfig?".

Path helpers intentionally distinguish the user config path (?userconfig?, try_default_config_path), the global config path (try_default_global_config_path), and the global data-token path (?global?, try_default_global_path). Those are not synonyms.

Serialization has two contracts. OpenMWConfiguration’s std::fmt::Display implementation and preservation save APIs keep directory settings in their original spelling for round-trips. OpenMWConfiguration::to_resolved_string and OpenMWConfiguration::save_resolved_to_path emit flattened relocation-safe output, resolving directory values and omitting chain-control entries such as config= and replace=.

Macros§

bail_config
config_err
impl_singleton_setting

Structs§

ConfigChainEntry
DirectorySetting
A directory path entry from an openmw.cfg file (data=, config=, user-data=, etc.).
EncodingSetting
A parsed encoding= entry from an openmw.cfg file.
FileSetting
A plain filename entry from an openmw.cfg file (content=, fallback-archive=, groundcover=).
GameSettingMeta
Source-tracking metadata attached to every setting value.
GenericSetting
OpenMWConfiguration
A fully-resolved OpenMW configuration chain.

Enums§

ConfigChainStatus
ConfigError
Errors that can arise while loading, mutating, or saving an OpenMW configuration.
EncodingType
The text encoding used to interpret byte strings in plugin data.
GameSettingType
A typed fallback=Key,Value entry from an openmw.cfg file.

Functions§

default_config_path
Path to input bindings and core configuration These functions are not expected to fail and should they fail, indicate either: a severe issue with the system or that an unsupported system is being used.
default_data_local_path
Path to the data-local directory as defined by the engine’s defaults.
default_global_config_path
Path to OpenMW’s global config directory.
default_global_path
Path that backs the ?global? token.
default_local_path
Path that backs the ?local? token.
default_root_config_path
Path to the default root openmw.cfg discovered with OpenMW startup semantics.
default_userdata_path
Path to save storage, screenshots, navmeshdb, and data-local These functions are not expected to fail and should they fail, indicate either: a severe issue with the system or that an unsupported system is being used.
try_default_config_path
Fallible variant of default_config_path.
try_default_global_config_path
Fallible variant of default_global_config_path.
try_default_global_path
Fallible variant of default_global_path.
try_default_local_path
Fallible variant of default_local_path.
try_default_root_config_path
Find the default root openmw.cfg using OpenMW’s root config discovery order.
try_default_userdata_path
Fallible variant of default_userdata_path.