-
Notifications
You must be signed in to change notification settings - Fork 1
Options Package
An IOptionsPackage
object is used to contain all of your OptionTab
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 tabs and contained components.
Each mod should create only a single SimpleOptionsPackage
or TabbedOptionsPackage
instance. Due to SMAPI GetAPI
method restrictions a good practice would be to create the object during the SMAPI GameEvents.FirstUpdateTick
event. The constructor must be passed the Mod
object for its manifest information.
public class ModEntry: Mod
{
internal SimpleOptionsPackage Package;
public override void Entry(IModHelper helper)
{
GameEvents.FirstUpdateTick += AddPackageToMenu;
}
void AddPackageToMenu(object sender, System.EventArgs e) {
Menu = Helper.ModRegistry.GetApi<IConfigMenu>("Juice805.StardewConfigMenu");
Package = new SimpleOptionsPackage(this);
Menu.AddOptionsPackage(Package);
// Add options to your package
AddOptionsToPackage(Package);
}
}
Once you have created the IOptionsPackage
object, you can begin adding tabs and options. SimpleOptionsPackage
are initialized with 1 tab.
private AddOptionsToPackage(IOptionsPackage package) {
var label = new ConfigHeader("catlabel", "Category Label");
package.AddOption(label);
}
This will add a category label to the last position of your mods settings page. For more information on the individual ConfigOption
classes, see their Wiki pages.
SimpleOptionsPackage(Mod mod);
TabbedOptionsPackage(Mod mod);
IManifest ModManifest { get; }
IOrderedDictionary<IOptionsTab> Tabs { get; }
Includes all properties and methods of TabbedOptionsPackage
as well as adding convenience methods for retrieving and modifying options in the first tab.
T GetOption<T>(string identifier) where T : IConfigOption;
T GetOption<T>(int index) where T : IConfigOption;
IConfigOption GetOption(string identifier);
IConfigOption GetOption(int index);
int IndexOfOption(string identifier);
void AddOption(IConfigOption option);
void InsertOption(int index, IConfigOption option);
void RemoveOptionAt(int index);
bool RemoveOption(string identifier);
bool ContainsOption(string identifier);