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 and customizable note effects #2793

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

FlooferLand
Copy link

@FlooferLand FlooferLand commented Jun 13, 2024

This PR:

  • Separates the checkbox settings widget into its own thing (CheckboxPreferenceItem) and adds a PercentagePreferenceItem and an EnumPreferenceItem
      // NoteHitSoundType is an enum defined in another file
      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 {
            // Called when the setting is changed
            Preferences.noteHitSound = value;
            var hitSound:String = value + "Hit";
            FunkinSound.playOnce(Paths.sound('noteHitSounds/${hitSound}') ?? Paths.sound('noteHitSounds/pingPongHit'));
          }, Preferences.noteHitSound);
  • Adds a checkbox in settings to toggle note splashes (Added I saw a TODO requesting it), a percentage item in settings for note hit sound volume, and an enum item to let you choose the note hit sound
  • Hit sounds that play on sick scores using HitNoteScriptEvent (did this as it makes it look like the note splashes have a sound effect, but it sometimes leads to hit sounds not playing since not everyone is built like an autoclicker)

These additions were made to easily allow hold (note cover) roll sounds to be added in the future but I haven't started implementing those since I'm not knowledged enough with Haxe or FNF's codebase to add them, and users might not want the weird RrRRrrRrrRrrRrrRrrRrr sounds when holding notes.


See the following for a showcase of this PR: https://youtu.be/WcJCl3hX6YM (dw its unlisted)


See funkin.assets#36 for the associated funkin.assets PR (it should be merged/reviewed first if possible, as I'll have to change things in this PR to add/remove any new sounds/changes added there)

@charlesisfeline
Copy link

can we also add a fps option to go along with the PercentagePreferenceItem widget

theres already a pr for it, but yeah

@FlooferLand
Copy link
Author

can we also add a fps option to go along with the PercentagePreferenceItem widget

theres already a pr for it, but yeah

An FPS cap?
That shouldn't be hard to implement with the new PercentagePreferenceItem from this PR. You just make a new setting in Save.hx, slap createPrefItemPercentage(name, description, ..) into PreferencesMenu, then you're done.

Though, you may want to open a separate PR yourself for that if this one gets merged.
I wanna keep this PR on-topic, centered around user-customizable note effects. The new settings UI widgets are just a side-effect since the game didn't have any way of letting the user change volume for specific sounds or letting them choose between several options xD

@EliteMasterEric EliteMasterEric changed the base branch from main to develop June 16, 2024 22:32
@EliteMasterEric EliteMasterEric added the status: pending triage The bug or PR has not been reviewed yet. label Jun 17, 2024
@EliteMasterEric EliteMasterEric changed the title [FEATURE] Note hit sounds, toggleable note splashes, and new settings widgets New settings widgets and customizable note effects Jun 17, 2024
@EliteMasterEric EliteMasterEric self-requested a review June 17, 2024 03:05
@EliteMasterEric EliteMasterEric added type: enhancement Provides an enhancement or new feature. status: reviewing internally This PR is under internal review and quality assurance testing and removed status: pending triage The bug or PR has not been reviewed yet. labels Jun 17, 2024
@FlooferLand
Copy link
Author

FlooferLand commented Jun 21, 2024

The referenced PRs might want to both use my implementation of the new settings widget system, since arguably after check out both of them my commit history and code are the least chaotic out of both xD (except some ninjamuffin commits show up on mine for some reason and I have no idea why)

Mine also provides a settings widget for enums and allows for features to let the user preview what the settings do (ex: playing a hit sound when its selected by the user to tell the user what it'll sounds like).

I'm happy to discuss and implement any changes needed here, as well as answering any questions you two have! @prplnorangesoda @lemz1

@lemz1
Copy link
Contributor

lemz1 commented Jun 23, 2024

the only thing i would change is maybe the offset that the percentage and enum items have when not being selected.
the leftHandText and itemText are quite close, but that might just be me.

i've also updated my pr to use your implementation, since yours is arguably better

if you make some changes, just @ me

left-most offset, so things like the text wouldn't look crammed in
@FlooferLand
Copy link
Author

FlooferLand commented Jun 24, 2024

I adjusted the offset, now looks about the same as it does for the checkbox widget. No changes needed on your side!
I'm still waiting on the other contributor's input, but I'd say this is ready to be merged.

PS: I forgot to make a new branch for the PR and I ended up pushing a whole ass Pico Dadbattle rechart to it because I can't git lmao. The PR under this comment is the new one for the assets, I closed the old one.

@EliteMasterEric
Copy link
Member

@FlooferLand Could you make a pull request that contains JUST the EnumPreferenceItem and PercentagePreferenceItem? They'd save me a bunch of time to have and I don't want to steal them from you but I don't think we're going to merge the hitsounds themselves, at least not for a while.

@EliteMasterEric EliteMasterEric added status: needs revision Cannot be approved because it is awaiting some work by the contributor. and removed status: reviewing internally This PR is under internal review and quality assurance testing labels Jun 30, 2024
@lemz1
Copy link
Contributor

lemz1 commented Jun 30, 2024

@FlooferLand Could you make a pull request that contains JUST the EnumPreferenceItem and PercentagePreferenceItem? They'd save me a bunch of time to have and I don't want to steal them from you but I don't think we're going to merge the hitsounds themselves, at least not for a while.

In that case I would also like to see the NumberPreferenceItem added. Im using it for this pr #2602, but it could also be used for other things.
In short this item can change options that have numeric values.

Maybe we could combine NumberPreferenceItem and PercentagePreferenceItem by adding a suffix or format variable to NumberPreferenceItem.

funkin/ui/options/items/NumberPreferenceItem.hx

package funkin.ui.options.items;

import funkin.ui.TextMenuList;
import funkin.ui.AtlasText;
import funkin.input.Controls;

/**
 * Preference item that allows the player to pick a value between min and max
 */
class NumberPreferenceItem extends TextMenuItem
{
  function controls():Controls
  {
    return PlayerSettings.player1.controls;
  }

  public var lefthandText:AtlasText;

  public var currentValue:Float;
  public var min:Float;
  public var max:Float;
  public var step:Float;
  public var precision:Int;
  public var onChangeCallback:Null<Float->Void>;

  public function new(x:Float, y:Float, name:String, defaultValue:Float, min:Float, max:Float, step:Float, precision:Int, ?callback:Float->Void):Void
  {
    super(x, y, name, function() {
      callback(this.currentValue);
    });
    lefthandText = new AtlasText(15, y, formatted(defaultValue), AtlasFont.DEFAULT);

    updateHitbox();

    this.currentValue = defaultValue;
    this.min = min;
    this.max = max;
    this.step = step;
    this.precision = precision;
    this.onChangeCallback = callback;
  }

  static final HOLD_DELAY:Float = 0.5; // seconds
  static final CHANGE_RATE:Float = 0.02; // seconds

  var holdDelayTimer:Float = HOLD_DELAY; // seconds
  var changeRateTimer:Float = 0.0; // seconds

  override function update(elapsed:Float):Void
  {
    super.update(elapsed);

    // var fancyTextFancyColor:Color;
    if (selected)
    {
      holdDelayTimer -= elapsed;
      if (holdDelayTimer <= 0.0)
      {
        changeRateTimer -= elapsed;
      }

      var jpLeft:Bool = controls().UI_LEFT_P;
      var jpRight:Bool = controls().UI_RIGHT_P;

      if (jpLeft || jpRight)
      {
        holdDelayTimer = HOLD_DELAY;
        changeRateTimer = 0.0;
      }

      var shouldDecrease:Bool = jpLeft;
      var shouldIncrease:Bool = jpRight;

      if (controls().UI_LEFT && holdDelayTimer <= 0.0 && changeRateTimer <= 0.0)
      {
        shouldDecrease = true;
        changeRateTimer = CHANGE_RATE;
      }
      else if (controls().UI_RIGHT && holdDelayTimer <= 0.0 && changeRateTimer <= 0.0)
      {
        shouldIncrease = true;
        changeRateTimer = CHANGE_RATE;
      }

      if (shouldDecrease) currentValue -= step;
      else if (shouldIncrease) currentValue += step;
      currentValue = currentValue.clamp(min, max);
      if (onChangeCallback != null && (shouldIncrease || shouldDecrease))
      {
        onChangeCallback(currentValue);
      }
    }

    lefthandText.text = formatted(currentValue);
  }

  function formatted(value:Float):String
  {
    return '${toFixed(value)}';
  }

  function toFixed(value:Float):Float
  {
    var multiplier:Float = Math.pow(10, precision);
    return Math.floor(value * multiplier) / multiplier;
  }
}

funkin/ui/options/PreferencesMenu.hx

  function createPrefItemNumber(prefName:String, prefDesc:String, onChange:Float->Void, defaultValue:Float, min:Float, max:Float, step:Float,
      precision:Int):Void
  {
    var item = new NumberPreferenceItem(0, (120 * items.length) + 30, prefName, defaultValue, min, max, step, precision, onChange);
    items.addItem(prefName, item);
    preferenceItems.add(item.lefthandText);
  }

@FlooferLand
Copy link
Author

FlooferLand commented Jul 1, 2024

I moved the new settings widgets to their own separate branch/PR as requested by Eric,
As well as merged my PercentagePreferenceItem into Lemz's NumberPreferenceItem.
Check the mentioned PR above!!

There appear to be no breaking changes between this PR and the new PR for people using my settings widgets. Just do a git pull and any settings you added previously should work just fine.


I'm not quite sure what to do about this PR now as the settings widgets have been moved into the new one, as I can't exactly delete the entire Git history of this PR and rename it in order to make it only implement my hitsounds changes.

@EliteMasterEric EliteMasterEric added status: pending pull request Has a PR which resolves it that is pending review. large A large pull request with more than 100 changes and removed status: needs revision Cannot be approved because it is awaiting some work by the contributor. labels Jul 10, 2024
@EliteMasterEric EliteMasterEric deleted the branch FunkinCrew:develop July 12, 2024 01:00
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: pending pull request Has a PR which resolves it that is pending review. type: enhancement Provides an enhancement or new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants