Skip to content

Conversation

@VirtuGuy
Copy link
Contributor

@VirtuGuy VirtuGuy commented Nov 7, 2025

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's modOptions!

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.

image

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

image

@github-actions github-actions bot added size: large A large pull request with more than 100 changes. status: pending triage Awaiting review. pr: haxe PR modifies game code. labels Nov 7, 2025
@VirtuGuy VirtuGuy changed the title [FEATURE] ModOptions [ENHANCEMENT] ModOptions Nov 7, 2025
@AbnormalPoof AbnormalPoof added type: enhancement Involves an enhancement or new feature. topic: mods Related to the creation or use of mods. labels Nov 7, 2025
@VirtuGuy
Copy link
Contributor Author

VirtuGuy commented Nov 7, 2025

Sometime I'll have to change how the preferences are actually loaded in. Yes it works fine, but checkboxes always load before anything else and I would also like to sort them in alphabetical order.

This adds some proper sorting to modded options.
@VirtuGuy
Copy link
Contributor Author

VirtuGuy commented Nov 7, 2025

Sometime I'll have to change how the preferences are actually loaded in. Yes it works fine, but checkboxes always load before anything else and I would also like to sort them in alphabetical order.

Done and done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: haxe PR modifies game code. size: large A large pull request with more than 100 changes. status: pending triage Awaiting review. topic: mods Related to the creation or use of mods. type: enhancement Involves an enhancement or new feature.

Development

Successfully merging this pull request may close these issues.

2 participants