asr

Module settings

Source
Expand description

Support for interacting with the settings of the auto splitter.

§Overview

Settings consist of two parts. One part is the settings Gui, that is used to let the user configure the settings. The other part is the settings values that are actually stored in the splits file. Those settings don’t necessarily correlate entirely with the settings Gui, because the stored splits might either be from a different version of the auto splitter or contain additional information such as the version of the settings, that the user doesn’t necessarily directly interact with. These stored settings are available as the global settings Map, which can be loaded, modified and stored freely. The keys used for the settings widgets directly correlate with the keys used in the settings Map. Any changes in the settings Gui will automatically be reflected in the global settings Map and vice versa.

§Defining a GUI

#[derive(Gui)]
struct Settings {
    /// General Settings
    _general_settings: Title,
    /// Use Game Time
    ///
    /// This is the tooltip.
    use_game_time: bool,
}

The type can then be used like so:

let mut settings = Settings::register();

loop {
   settings.update();
   // Do something with the settings.
}

Check the Gui derive macro and the Gui trait for more information.

§Modifying the global settings map

let mut map = settings::Map::load();
map.insert("key", true);
map.store();

Check the Map struct for more information.

Modules§

gui
This module allows you to add settings widgets to the settings GUI that the user can modify.

Structs§

List
A list of Values that can itself be a Value and thus be stored in a Map.
Map
A map consisting of settings that are configured. Every setting has a string based key and a Value. There is a global settings map that represents all the settings that the user has configured at the given time. Settings that are unmodified are usually not stored in the map. The global map is what gets stored to disk and loaded from disk. Any changes made in the settings GUI will be reflected in the global map and vice versa. The key of the settings widget is used as the key for the settings map. Additional settings that are not part of the GUI can be stored in the map as well, such as a version of the settings for handling old versions of an auto splitter.
Value
A value of a setting. This can be a value of any type that a setting can hold. Currently this is either a Map, a List, a bool, an i64, an f64, or a string.

Enums§

ValueType
The type of a setting Value.

Traits§

AsValue
A trait for types that can be converted into a Value or allow accessing it as a reference.
Gui
A trait that can be derived to describe an entire settings GUI through a struct declaration. Check the derive macro Gui for more information.

Derive Macros§

Gui
Implements the Gui trait for a struct that allows you to register its fields as settings widgets and returns the struct with the user’s settings applied.