pub struct OpenMWConfiguration { /* private fields */ }
Expand description
Core struct representing the composed OpenMW configuration, After it has been fully resolved.
Implementations§
Source§impl OpenMWConfiguration
impl OpenMWConfiguration
pub fn from_env() -> Result<Self, ConfigError>
pub fn new(path: Option<PathBuf>) -> Result<Self, ConfigError>
Sourcepub fn root_config_file(&self) -> &PathBuf
pub fn root_config_file(&self) -> &PathBuf
Path to the configuration file which is the root of the configuration chain
Typically, this will be whatever is defined in the Paths
documentation for the appropriate platform:
https://openmw.readthedocs.io/en/latest/reference/modding/paths.html#configuration-files-and-log-files
Sourcepub fn root_config_dir(&self) -> PathBuf
pub fn root_config_dir(&self) -> PathBuf
Same as root_config_file, but returns the directory it’s in. Useful for reading other configuration files, or if assuming openmw.cfg Is always called openmw.cfg (which it should be)
pub fn is_user_config(&self) -> bool
pub fn user_config(self) -> Result<Self, ConfigError>
Sourcepub fn user_config_path(&self) -> PathBuf
pub fn user_config_path(&self) -> PathBuf
In order of priority, the list of all openmw.cfg files which were loaded by the configuration chain after the root. If the root openmw.cfg is different than the user one, this list will contain the user openmw.cfg as its last element. If the root and user openmw.cfg are the same, then this list will be empty and the root config should be considered the user config. Otherwise, if one wishes to get the contents of the user configuration specifically, construct a new OpenMWConfiguration from the last sub_config.
Openmw.cfg files are added in order of the sequence in which they are defined by one openmw.cfg, and then each of those openmw.cfg files is then processed in their entirety, sequentially, after the first one has resolved. The highest-priority openmw.cfg loaded (the last one!) is considered the user openmw.cfg, and will be the one which is modifiable by OpenMW-Launcher and OpenMW proper.
See https://openmw.readthedocs.io/en/latest/reference/modding/paths.html#configuration-sources for examples and further explanation of multiple config sources. Path to the highest-level configuration directory
pub fn userdata(&self) -> Option<&DirectorySetting>
pub fn set_userdata(&mut self, new: Option<DirectorySetting>)
pub fn resources(&self) -> Option<&DirectorySetting>
pub fn set_resources(&mut self, new: Option<DirectorySetting>)
pub fn data_local(&self) -> Option<&DirectorySetting>
pub fn set_data_local(&mut self, new: Option<DirectorySetting>)
pub fn encoding(&self) -> Option<&EncodingSetting>
pub fn set_encoding(&mut self, new: Option<EncodingSetting>)
Sourcepub fn content_files(&self) -> Vec<&String>
pub fn content_files(&self) -> Vec<&String>
Content files are the actual mods or plugins which are created by either OpenCS or Bethesda’s construction set These entries only refer to the names and ordering of content files. vfstool-lib should be used to derive paths
pub fn content_files_iter(&self) -> impl Iterator<Item = &FileSetting>
pub fn has_content_file(&self, file_name: &str) -> bool
pub fn has_groundcover_file(&self, file_name: &str) -> bool
pub fn has_archive_file(&self, file_name: &str) -> bool
pub fn has_data_dir(&self, file_name: &str) -> bool
pub fn add_content_file( &mut self, content_file: &str, ) -> Result<(), ConfigError>
pub fn groundcover(&self) -> Vec<&String>
pub fn groundcover_iter(&self) -> impl Iterator<Item = &FileSetting>
pub fn add_groundcover_file( &mut self, content_file: &str, ) -> Result<(), ConfigError>
pub fn remove_content_file(&mut self, file_name: &str)
pub fn remove_groundcover_file(&mut self, file_name: &str)
pub fn remove_archive_file(&mut self, file_name: &str)
Sourcepub fn remove_data_directory(&mut self, data_dir: &PathBuf)
pub fn remove_data_directory(&mut self, data_dir: &PathBuf)
Removed any path matching either the relativized original version in openmw.cfg or the fully resolved absolute version the config itself relies on
Sourcepub fn add_data_directory(&mut self, dir: PathBuf)
pub fn add_data_directory(&mut self, dir: PathBuf)
Does not validate duplicate data directories Jest don’t feel like it atm Let’s add comments later after we’re not super burned out on this whole config thing
pub fn add_archive_file( &mut self, archive_file: &str, ) -> Result<(), ConfigError>
pub fn fallback_archives(&self) -> Vec<&String>
pub fn fallback_archives_iter(&self) -> impl Iterator<Item = &FileSetting>
Sourcepub fn set_content_files(&mut self, plugins: Option<Vec<String>>)
pub fn set_content_files(&mut self, plugins: Option<Vec<String>>)
This early iteration of the crate provides no input validation for setter functions.
pub fn set_fallback_archives(&mut self, archives: Option<Vec<String>>)
pub fn settings_matching<'a, P>( &'a self, predicate: P, ) -> impl Iterator<Item = &'a SettingValue>
pub fn clear_matching<P>(&mut self, predicate: P)
Sourcepub fn set_data_directories(&mut self, dirs: Option<Vec<PathBuf>>)
pub fn set_data_directories(&mut self, dirs: Option<Vec<PathBuf>>)
This early iteration of the crate provides no input validation for setter functions.
Sourcepub fn set_game_setting(
&mut self,
base_value: &str,
config_path: Option<PathBuf>,
comment: &mut String,
) -> Result<(), ConfigError>
pub fn set_game_setting( &mut self, base_value: &str, config_path: Option<PathBuf>, comment: &mut String, ) -> Result<(), ConfigError>
Given a string resembling a fallback= entry’s value, as it would exist in openmw.cfg, Add it to the settings map. This process must be non-destructive
Sourcepub fn set_game_settings(
&mut self,
settings: Option<Vec<String>>,
) -> Result<(), ConfigError>
pub fn set_game_settings( &mut self, settings: Option<Vec<String>>, ) -> Result<(), ConfigError>
This early iteration of the crate provides no input validation for setter functions.
pub fn sub_configs(&self) -> impl Iterator<Item = &DirectorySetting>
Sourcepub fn game_settings(&self) -> impl Iterator<Item = &GameSettingType>
pub fn game_settings(&self) -> impl Iterator<Item = &GameSettingType>
Fallback entries are k/v pairs baked into the value side of k/v pairs in fallback=
entries of openmw.cfg
They are used to express settings which are defined in Morrowind.ini for things such as:
weather, lighting behaviors, UI Colors, and levelup messages
Sourcepub fn get_game_setting(&self, key: &str) -> Option<&GameSettingType>
pub fn get_game_setting(&self, key: &str) -> Option<&GameSettingType>
Retrieves a gamesetting according to its name.
This would be whatever text comes after the equals sign =
and before the first comma ,
Case-sensitive!
Sourcepub fn data_directories(&self) -> Vec<&PathBuf>
pub fn data_directories(&self) -> Vec<&PathBuf>
Data directories are the bulk of an OpenMW Configuration’s contents, Composing the list of files from which a VFS is constructed. For a VFS implementation, see: https://github.com/magicaldave/vfstool/tree/main/vfstool_lib
Calling this function will give the post-parsed versions of directories defined by an openmw.cfg, So the real ones may easily be iterated and loaded. There is not actually validation anywhere in the crate that DirectorySettings refer to a directory which actually exists. This is according to the openmw.cfg specification and doesn’t technically break anything but should be considered when using these paths.
pub fn data_directories_iter(&self) -> impl Iterator<Item = &DirectorySetting>
Sourcepub fn save_user(&self) -> Result<(), String>
pub fn save_user(&self) -> Result<(), String>
Saves the currently-defined user openmw.cfg configuration It should be noted that while modifications may be performed at runtime, Because of how extensive those modifications to a given configuration may be, it’s more or less impossible to guarantee that saving any lower priority openmw.cfg will not completely destroy it. You’ve been warned!
Sourcepub fn save_subconfig(&self, target_dir: PathBuf) -> Result<(), String>
pub fn save_subconfig(&self, target_dir: PathBuf) -> Result<(), String>
Save the openmw.cfg to an arbitrary path, instead of the (safe) user configuration. This doesn’t prevent bad usages of the configuration such as overriding an existing one with the original root configuration, So you should exercise caution when writing an openmw.cfg and be very sure you know it is going where you think it is.
Trait Implementations§
Source§impl Debug for OpenMWConfiguration
impl Debug for OpenMWConfiguration
Source§impl Default for OpenMWConfiguration
impl Default for OpenMWConfiguration
Source§fn default() -> OpenMWConfiguration
fn default() -> OpenMWConfiguration
Source§impl Display for OpenMWConfiguration
Keep in mind this is not meant to be used as a mechanism to write the openmw.cfg contents.
Since the openmw.cfg is a merged entity, it is impossible to distinguish the origin of one particular data directory
Or content file once it has been applied - this is doubly true for entries which may only exist once in openmw.cfg.
Thus, what this method provides is the composite configuration.
impl Display for OpenMWConfiguration
Keep in mind this is not meant to be used as a mechanism to write the openmw.cfg contents. Since the openmw.cfg is a merged entity, it is impossible to distinguish the origin of one particular data directory Or content file once it has been applied - this is doubly true for entries which may only exist once in openmw.cfg. Thus, what this method provides is the composite configuration.
It may be safely used to write an openmw.cfg as all directories will be absolutized upon loading the config.
Token information is also lost when a config file is processed. It is not necessarily recommended to write a configuration file which loads other ones or uses tokens for this reason.
Comments are also preserved.