Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New settings widgets (Number, Checkbox, Enum) #2942

Merged
merged 3 commits into from
Sep 16, 2024

Conversation

FlooferLand
Copy link
Contributor

@FlooferLand FlooferLand commented Jul 1, 2024

This PR separates the checkbox settings widget into its own thing (CheckboxPreferenceItem) and adds a NumberPreferenceItem and an EnumPreferenceItem

Code usage examples:

// Creates a new NumberPreferenceItem set up to handle percentages
createPrefItemPercentage('Note hit sound volume', 'Enable to play a click sound when hitting notes', function(value:Int):Void {
  Preferences.noteHitSoundVolume = value;
  var hitSound:String = Preferences.noteHitSound + "Hit";
  FunkinSound.playOnce(Paths.sound('noteHitSounds/${hitSound}') ?? Paths.sound('noteHitSounds/pingPongHit'));
}, Preferences.noteHitSoundVolume);

// NoteHitSoundType would be a string enum defined in MenuItemEnums.hx
createPrefItemEnum('Note hit sound', 'Enable to play a click sound when hitting notes', [
  NoteHitSoundType.None => "None",
  NoteHitSoundType.PingPong => "Ping pong",
  NoteHitSoundType.VineBoom => "Vine boom"
], function(value:String):Void {
  Preferences.noteHitSound = value;
  var hitSound:String = value + "Hit";
  FunkinSound.playOnce(Paths.sound('noteHitSounds/${hitSound}') ?? Paths.sound('noteHitSounds/pingPongHit'));
}, Preferences.noteHitSound);

// Simple checkbox, not much changed
createPrefItemCheckbox('Note splashiness', 'Disable to remove splash animations when hitting notes', function(value:Bool):Void {
  Preferences.noteSplash = value;
}, Preferences.noteSplash);

// There is also createPrefItemNumber, but I cannot be bothered to write an example for it as I paused mid-episode while watching Doctor Who to make this PR 🗿

* The callbacks get called every time the player changes the value, mainly for you to update the value inside Preferences, but its possible to use them for example to play a sound effect to let the user preview the volume of a sound every time they change the volume


This PR splits off features from #2793 as requested by @EliteMasterEric
Part of NumberPreferenceItem was implemented by @lemz1

@EliteMasterEric EliteMasterEric self-requested a review July 1, 2024 19:29
@EliteMasterEric EliteMasterEric self-assigned this Jul 1, 2024
@EliteMasterEric EliteMasterEric added type: enhancement Provides an enhancement or new feature. status: reviewing internally This PR is under internal review and quality assurance testing labels Jul 1, 2024
@EliteMasterEric
Copy link
Member

Going to review this immediately because this would save us a whole load of time if it works good.

@EliteMasterEric EliteMasterEric added status: accepted Approved for contribution. If it's not already merged, it may be merged on a private branch. and removed status: reviewing internally This PR is under internal review and quality assurance testing labels Jul 1, 2024
@EliteMasterEric
Copy link
Member

This worked great for me, it's really convenient to work with. I'll try to get this in and then implement some new options using it.

@EliteMasterEric EliteMasterEric changed the base branch from main to develop July 10, 2024 22:16
@EliteMasterEric EliteMasterEric added the large A large pull request with more than 100 changes label Jul 10, 2024
@EliteMasterEric EliteMasterEric deleted the branch FunkinCrew:develop July 12, 2024 01:00
@EliteMasterEric EliteMasterEric added this to the 0.5.0 milestone Jul 12, 2024
@EliteMasterEric EliteMasterEric merged commit b0c9365 into FunkinCrew:develop Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
large A large pull request with more than 100 changes status: accepted Approved for contribution. If it's not already merged, it may be merged on a private branch. type: enhancement Provides an enhancement or new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants