BepInEx / BepInEx.ConfigurationManager

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

Please add some method of specifying ordering of groups and items within them! #22

Closed billw2012 closed 3 years ago

billw2012 commented 3 years ago

Currently I have resorted to prefixing numbers on all my group and item names, but that is fragile, difficult to maintain and impossible to change without losing peoples saved settings.

ManlyMarco commented 3 years ago

Read this https://github.com/BepInEx/BepInEx.ConfigurationManager#overriding-default-configuration-manager-behavior Ordering categories is not currently supported but it should still be possible by adding ! to the start of category names in ConfigurationManagerAttributes. It was an old feature that stopped being supported because no one used it.

billw2012 commented 3 years ago

https://github.com/BepInEx/BepInEx.ConfigurationManager/blob/d402bde665794e1685ec9aaa86abc7d70da36f7e/ConfigurationManager/ConfigurationManager.cs#L207

It doesn't look like ! has any affect, I can see it being stripped in a number of places, but I don't see how it changes ordering, or what effect it could have that would make sense (I haven't specified an ordering, just added an !).

This seems like a necessary and obvious feature to me, if people didn't use it I can only assume its because its implementation is arcane. Ordering should be a first class feature, not something one has to jump through hoops for, i.e. it should be a parameter of the Bind function next to default. And it should affect the config file as well of course.

Its clear people want it because I have noticed multiple mods using 00 numbering on groups and entries to ensure it happens. This solution sucks though because as soon as you want to insert a new setting you are changing the names of a bunch of them, losing your users saved settings.

ManlyMarco commented 3 years ago

Names are sorted alphabetically so ! will be first in order, then you can add multiple ! at start to control ordering of multiple items. This is no longer supported and only exists in code for legacy reasons. Not many people needed the feature so it got changed into the new Order override, which is documented in the readme. If you need a way to override category ordering then I'll gladly take a PR for it.

Ordering should be a first class feature, not something one has to jump through hoops for, i.e. it should be a parameter of the Bind function next to default. And it should affect the config file as well of course.

This plugin is completely separate from BepInEx and its configuration system. Ordering settings doesn't make much sense in context of plugin configs and so it is not included in BepInEx itself to keep the API simple.

billw2012 commented 3 years ago

Ordering settings doesn't make much sense in context of plugin configs and so it is not included in BepInEx itself to keep the API simple.

I disagree. Without the Configuration Manager the player is editing the config file, at which point the exact same reasoning applies as it does for ordering UI: imparting semantic meaning through intuitive ordering of the entries (e.g. "enable X" goes just before the settings for X, not randomly somewhere in the middle, because it is the primary setting for X that controls the ones below it).

If people are writing the config file themselves from scratch, and BepInEx won't change its ordering, then this is not an issue of course, but I have only seen people edit the config files BepInEx generates automatically for them. Is there already some way to control the generation of that initial file precisely?

If you need a way to override category ordering then I'll gladly take a PR for it. Yes I will consider it, its not immediately obvious how without category metadata already being a thing (that I noticed anyway).

I also wrote a fluent API wrapper for specifying my config which embeds ordering, I think it is quite a lot cleaner, but it has some quirks. I might make a PR for this if it sounds interesting.

ManlyMarco commented 3 years ago

In this case this should be a discussion in BepInEx issues or on the BepInEx discord server, since the config system is a part of that.