diff --git a/MiraAPI/GameOptions/IModdedOptionList.cs b/MiraAPI/GameOptions/IModdedOptionList.cs new file mode 100644 index 0000000..da6da53 --- /dev/null +++ b/MiraAPI/GameOptions/IModdedOptionList.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using BepInEx.Configuration; +using MiraAPI.Networking; +using MiraAPI.PluginLoading; +using UnityEngine; + +namespace MiraAPI.GameOptions; + +/// +/// Interface for list of modded options. +/// +public interface IModdedOptionList +{ + /// + /// Gets the number of options in the list. + /// + int Count { get; } + + /// + /// Gets the unique identifiers for the options. + /// + IReadOnlyList Ids { get; } + + /// + /// Gets or sets the titles of the options. + /// The end title will equal this value with its index appended (e.g., Title1). + /// + string Title { get; set; } + + /// + /// Gets or sets a value indicating whether the first option's title has a 0, else starts with 1. + /// + bool ZeroIndexTitle { get; set; } + + /// + /// Gets the StringName for the options, used for localization. + /// + IReadOnlyList StringNames { get; } + + /// + /// Gets or sets the MiraPlugin that created these options. + /// + IMiraPlugin? ParentMod { get; set; } + + /// + /// Gets the game setting data for the options. + /// + IReadOnlyList Data { get; } + + /// + /// Gets the OptionBehaviour object of the options. + /// + IReadOnlyList OptionBehaviours { get; } + + /// + /// Gets or sets the visibility function for the options. + /// + Func Visible { get; set; } + + /// + /// Gets or sets a value indicating whether the options should be included with presets. + /// + bool IncludeInPreset { get; set; } + + /// + /// Gets the array of ConfigDefinition for the options, used for BepInEx configuration. + /// + ConfigDefinition?[] ConfigDefinitions { get; } + + /// + /// Creates the option behaviour for the modded option at index . + /// + /// The option's index. + /// The ToggleOption template. + /// The NumberOption template. + /// The StringOption template. + /// The PlayerOption template. + /// >The Transform container for the option. + /// The created OptionBehaviour object. + OptionBehaviour CreateOption(int idx, ToggleOption toggleOpt, NumberOption numberOpt, StringOption stringOpt, PlayerOption playerOpt, Transform container); + + /// + /// Gets the value at index as a float. + /// + /// The option's index. + /// The value of the option as a float. + float GetFloatData(int idx); + + /// + /// Gets the NetData for the option at index , used for network synchronization. + /// + /// The option's index. + /// Returns the NetData object for the option. + NetData GetNetData(int idx); + + /// + /// Handles incoming network data for the option at index . + /// + /// The option's index. + /// The byte array representing the network data. + void HandleNetData(int idx, byte[] data); + + /// + /// Saves the options to a preset configuration file. + /// + /// The ConfigFile representing the preset configuration. + /// Indicates whether to save the default value instead of the current value. + void SaveToPreset(ConfigFile presetConfig, bool saveDefault = false); + + /// + /// Binds the options to a configuration file. + /// + /// The ConfigFile to bind the option to. + void Bind(ConfigFile config); + + /// + /// Loads the options from a preset configuration file, applying the values to the options' configuration. + /// + /// The ConfigFile representing the preset configuration. + void LoadFromPreset(ConfigFile presetConfig); +}