isXander / YetAnotherConfigLib

YetAnotherConfigLib (yacl) is just that. A builder-based configuration library for Minecraft.
GNU Lesser General Public License v3.0
96 stars 37 forks source link

Add dropdown controllers #95

Closed Crendgrim closed 1 year ago

Crendgrim commented 1 year ago

This patch adds two "dropdown" controllers, one for String objects, and one for Item instances.

The controller has a list of valid values. For the item controller, this is any registered item identifier (whether from vanilla or mods). When the controller's string input field is selected, a dropdown is rendered containing all options of this list that match the current value of the input field. The list can be navigated using arrow keys.

On closing the input field (either through the "Enter" key or selecting a different option), the input field's value is set to whichever valid value was selected in the dropdown list.

The item controller has the bonus feature of rendering the item inside of the option. :)

Further, to allow the item controller to work, the built-in GSON config instance is taught to (de)serialize items to String values based on their identifier.


This upstreams these controllers from YACLX. Do note that the item controller in particular requires a few additional changes:

isXander commented 1 year ago

Also, could you post some videos/screenshots of this PR in action?

Crendgrim commented 1 year ago

Hi,

I pushed the changes necessary to add a suggestion-style dropdown entry. Please review, as I'm sure there's minor things left.

And then there's one big problem: the item controller works perfectly fine in autogen, but not in manual mode (crashes saying the binding's value is null). And I cannot figure out why. Could you have a look to see if I'm missing something obvious?

isXander commented 1 year ago

Last thing I need before I can merge this is a demo of these new controllers, pictures, videos etc (as well as the last review comment)

Crendgrim commented 1 year ago

The caching introduced several bugs related to invalidating that cache. Need to investigate further.