-
Notifications
You must be signed in to change notification settings - Fork 1
Options Package
The ModOptions object is used to contain all of your ModOption objects in a single index-able location. It also allows for easy passing of data between your mod and the StardewConfigMenu mod which displays the components.
Each mod should create only a single ModOptions instance. Good practice would be to create the object during the SMAPI Entry() method and assign it to a static property. The constructor must be passed the Mod object for logging and manifest information.
public class ModEntry: Mod
{
internal static ModOptions MyOptions;
public override void Entry(IModHelper helper)
{
var settingsFramework = IModSettingsFramework.Instance;
ModEntry.MyOptions = new ModOptions(this);
settingsFramework.AddModOptions(MyOptions);
}
}Once you have created the static ModOptions object, you can begin adding to it anywhere.
internal class myClass
{
internal myMethod() {
var label = new ModOptionCategoryLabel("catlabel", "Category Label");
ModEntry.MyOptions.AddModOption(label);
}
}This will add a category label to the last position of your mods settings page. You will likely want to create references to each ModOption before adding them to ModOptions to allow for later modifications or reading user inputs. For more information on the individual ModOption classes, see their Wiki pages.
public ModOptions(Mod mod);public static ModOptions LoadUserSettings(Mod mod);
public static ModOptions LoadCharacterSettings(Mod mod, string farmerName);
public void SaveUserSettings();
public void SaveCharacterSettings(string farmerName);
public T GetOptionWithIdentifier<T>(string identifier) where T : ModOption;
public ModOption GetOptionWithIdentifier(string identifier);
public Type GetTypeOfIdentifier(string identifier);
public ModOption RemoveAtIndex(int index);
public ModOption RemoveModOptionWithIdentifier(string identifier);
public void AddModOption(ModOption option);
public void InsertModOption(ModOption option, int index);public IManifest modManifest { get; }
public ISemanticVersion OptionsVersion;
public IList<ModOption> List { get; }