-
Notifications
You must be signed in to change notification settings - Fork 1
Options Tab
An OptionsTab
object is used to contain all of your ConfigOption
objects of the same grouping in a single index-able location. Tabs are contained within an IOptionsPackage
and are passed with the package to be displayed with its ConfigOption
by the menu.
An OptionsTab
has a collection of ConfigOption
accessible through the Options
property. Options
can be modified through its methods to add, remove or access options. An OptionsTab
can be added, removed or accessed through an IOptionsPackage
Tabs
property. An IOptionsPackage
objects may contain many OptionsTab
.
Note: A SimpleOptionsPackage
is initialized with a single tab, while TabbedOptionsPackage
is initialized with no tabs. Regardless of type, a package with a single tab will not display the tab list.
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 TabbedOptionsPackage(this);
Menu.AddOptionsPackage(Package);
// Add options to your package
AddOptionsToPackage(Package);
}
}
Once you have created the IOptionsPackage
object, you can begin adding OptionsTab
and options.
private AddOptionsToPackage(IOptionsPackage package) {
var label = new ConfigHeader("catlabel", "Category Label");
var tab = new OptionsTab("firstTab", "Main");
tab.Options.Add(label);
package.Tabs.Add(tab)
}
OptionsTab(string identifier, string label);
IOrderedDictionary<IConfigOption> Options { get; }
string Identifier { get; }
string Label { get; set; }
T GetOption<T>(string identifier) where T : IConfigOption;
T GetOption<T>(int index) where T : IConfigOption;