As of Fzzy Config 0.5.0, you can define arbitrary on-click action buttons in configs. These actions don't maintain or store any config state (directly), but can be used for any variety of useful secondary functions:
- Opening a wiki or documentation link
- Giving the player something, like the mod guide book if they lost theirs
- Or, just opening the Patchouli screen directly!
- Performing some specialized action on the config that's outside the normal scope of what Fzzy Config settings can do
- Clearing some particular player data
- Basically anything!
Creation
To define an action button, simply add a ConfigAction
as a property/field in the config class. The config GUI will gain an action button in the order that you place the action in the classes fields, just like any other setting. It might be helpful for users if you place your special buttons together, and at the top or bottom. Or maybe, place them in an object and have all your special actions in one convenient popup!
IgnoreVisibility
can be used with action just like any other config field. Also like any other config field, it can't be final.
Actions
Actions can take two general forms
Runnable
- A generic Runnable lambda or instance. Does whatever you want it to.ClickEvent
- Pass aClickEvent
for pre-defined vanilla functionality like opening URL links, running commands, and so on.
Decoration
Decorations are the white wireframe icons that appear to the left of certain setting buttons to signify to the user that they perform a certain special functionality. ConfigAction
is no different.
- It has a default "mouse pointer clicking a button decoration"
- For
ClickEvent
actions, there is a decoration defined for each event type. - You can define a custom decoration by passing a sprite identifier into the builder or constructor. Fzzy Config provides a modest list of pre-defined decorations in the
TextureIds
class that can be used; or define one of your own! Decorations are typically a 20 x 20 pixel texture.