BepInEx / BepInEx.ConfigurationManager

Plugin configuration manager for BepInEx
https://www.patreon.com/ManlyMarco
GNU Lesser General Public License v3.0
227 stars 54 forks source link

[2 Questions] drop-down list and Display all options by Default #69

Closed JoewAlabel closed 1 year ago

JoewAlabel commented 1 year ago

Hi! I have only those 2 question to finally releases my mod :D

1- Drop-Down List: I used enum to create the list, and used System.ComponentModel.DescriptionAttribute to my enum's items to override their displayed names. But I can not change the enum at Runtime.

So can you show me one example how can I use one Dictionary<string, string> with first string as the KEY (like as the enum value) and the second string in dic be the description to show up on drop down, please?

Like as, My Enum:

public enum ItemList 
    {
        [Description("Wooden Foundation")]
        RES_HOUSE_1_SET,

        [Description("Wooden Wall")]
        RES_HOUSE_2_SET,
    }

To the Dictionary:

public IDictionary<string, string> ItemLIst = new Dictionary<string, string>() {
    {"RES_HOUSE_1_SET", "Wooden Foundation"},
    {"RES_HOUSE_2_SET", "Wooden Wall"},
};

Or one example on how to use this Dictionary with AcceptableValueList, please!

My Bind:

public static ConfigEntry<ItemList> AddItemName2 { get; set; }
AddItemName2 = this.Config.Bind("1. Utils",
                                  "Item2",
                                  ItemList.RES_HOUSE_1_SET,
                                  "Add item - Key ALT + Insert");

2- Display all options by Default: After I press F1, i saw on the GUI the name of my plugin and three period (dots), so I have to click on it to show up all the config options: Screen Shot

How I make it to default shows up all configs, please? This way the users do not need to do the first click to show the options ;)

Btw, thank you very much for all support and help!!!!

ManlyMarco commented 1 year ago

1 - If you want to change acceptable values at runtime then you can't use an enum. You have to use string as setting type and add AcceptableValueList<string> to its description. Whenever you want to change the acceptable values you have to tell ConfigurationManager to reload the settings list by calling ConfigurationManager.BuildSettingList.

2 - You can't control the collapsed state from the plugin, it's up to the user to collapse / expand one or all settings. This is because once there are more than a couple of plugins it makes it hard to find the setting you want.

JoewAlabel commented 1 year ago

1 - If you want to change acceptable values at runtime then you can't use an enum. You have to use string as setting type and add AcceptableValueList<string> to its description. Whenever you want to change the acceptable values you have to tell ConfigurationManager to reload the settings list by calling ConfigurationManager.BuildSettingList.

2 - You can't control the collapsed state from the plugin, it's up to the user to collapse / expand one or all settings. This is because once there are more than a couple of plugins it makes it hard to find the setting you want.

Thank you very much for all the support ;)