MiraAPI icon indicating copy to clipboard operation
MiraAPI copied to clipboard

Local Settings

Open xChipseq opened this issue 8 months ago • 2 comments

What did i add?

A local settings implementation that allows users to bind BepInEx config entries to settings. image

How does it work?

First you need to create a ModSettingsTab. The best way would be to create a variable for it in the plugin class It supports multiple tabs from one plugin

ModSettingsTab modTab = LocalSettingsManager.CreateSettingsTab(plugin);

image

Then you can bind config entries with:

modTab.BindEntry(YourConfigEntry);

BindEntry() method automatically binds any supported type of entry. You can bind bool, int, float and enum entries. By default, it grabs the name and description from the entry itself, but you can set a different one with the arguments.

To modify things specific to one type, use the corresponding to type bind method:

modTab.BindBoolEntry(BoolConfigEntry, onColor: Color.green, offColor: Color.red) // a bool one

modTab.BindEnumEntry( // an enum one
ExampleEnumEntry,
enumType: typeof(ExampleSettingEnum),
customNames: ["Cheeseburger", "Fries", "Pizza", "Chicken Nuggets"]
); 

Things that might break

The amount of settings you can add is limited because after binding lots of setting they go out of the screen, so the tab would need a scroller. This issue also exists in the tabs but you would need like 10 different mods, each one having their tabs for it to fill out so i don't think it would be an issue. From what i've tested, everything else seems to be fine

xChipseq avatar Apr 13 '25 17:04 xChipseq

xtra's readme changes also got added here for some reason lol

xChipseq avatar Apr 13 '25 17:04 xChipseq

Don't know how I feel about using config binds for everything. Might be better and more consistent to use an approach similar to options.

ang-xd avatar Apr 14 '25 14:04 ang-xd

btw im working on revamping this

xChipseq avatar Jun 27 '25 19:06 xChipseq