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

Allow easier keyboard reading in custom drawers #56

Closed JKohlman closed 1 year ago

JKohlman commented 1 year ago

Currently as it stands reading from the keyboard (Input.GetKeyDown, etc..) appears to be, at best, very difficult from a custom drawer without requiring a reference to ConfigurationManager.dll.

The main root of this lies in the config manager OnGUI at https://github.com/BepInEx/BepInEx.ConfigurationManager/blob/da2fc62b987565d0296f9cbbc17789ca944fe92b/ConfigurationManager/ConfigurationManager.cs#L273-L274 which resets the keyboard inputs every frame. This is easy to work around in a global drawer by including ConfigurationManager.dll and simply setting SettingFieldDrawer._currentKeyboardShortcutToSet to your current SettingEntryBase. https://github.com/BepInEx/BepInEx.ConfigurationManager/blob/da2fc62b987565d0296f9cbbc17789ca944fe92b/ConfigurationManager/SettingFieldDrawer.cs#L27-L28 HOWEVER, in a drawer that is not global and does not include ConfigurationManager.dll, the signature is:

static void CustomDrawer(BepInEx.Configuration.ConfigEntryBase entry)

And of course since the type is different you can no longer simply set that variable.

If there is an easy workaround that I'm missing I'd gladly make use of it but I can't seem to find one.