Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adding your own custom preferences to the game requires quite a bit of work and knowledge, but what if... there was a class made just for creating preferences without having to actually mess with the preferences menu or all the checks involved in adding the preference menu items?
This pr adds a new class called
ModOptions.hx. This new class comes with the ability to easily create four different types of preference options: checkbox, number, percentage, and enum. Not only can you easily create these with this class, but they automatically get saved to the save'smodOptions!These modded options have a parameter called
defaultValue. This is of course the fallback for if the option wasn't saved ever, or if it had been saved as a different type of option (this means that your game won't crash if something like a checkbox tries to use a value that's a string or whatever).Below is an example of how YOU can make a checkbox... as long as your testing the pr.
The parameters for this are the unique id, name, description, default value, whether the option is available, and a callback that runs when the option's value gets changed.
Obviously there's a bit more to this than being able to create a checkbox, but I just wanted to give an example on making a checkbox with this class because it would be the most basic type of option to create.
Just know that these options are not sorted in the order they're registered, but rather it's based on the alphabetical order of the unique ids.
Screenshots/Videos