From f6710550c8805f1a1c987723faa77b884243d002 Mon Sep 17 00:00:00 2001 From: ~ Care <126361810+usb-port-2@users.noreply.github.com> Date: Sun, 24 Nov 2024 16:32:40 +0000 Subject: [PATCH] allow me to use my mouse scroll wheel in the mod menu (+ more menus) (#450) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update ModSwitchMenu.hx * fixed * adding wheel to more menus * forgor pixel --------- Co-authored-by: ⍚~Nex <87421482+NexIsDumb@users.noreply.github.com> --- assets/data/scripts/week6-pause.hx | 12 ++++-------- source/funkin/menus/FreeplayState.hx | 2 +- source/funkin/menus/MainMenuState.hx | 11 +++++------ source/funkin/menus/ModSwitchMenu.hx | 4 ++-- source/funkin/menus/PauseSubState.hx | 11 +++++------ source/funkin/menus/StoryMenuState.hx | 2 +- 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/assets/data/scripts/week6-pause.hx b/assets/data/scripts/week6-pause.hx index 6a4455cd..a80598ce 100644 --- a/assets/data/scripts/week6-pause.hx +++ b/assets/data/scripts/week6-pause.hx @@ -92,15 +92,11 @@ function update(elapsed) { if (!canDoShit) return; var oldSec = curSelected; - if (controls.DOWN_P) - changeSelection(1, false); - if (controls.UP_P) - changeSelection(-1); - if (oldSec != curSelected) { + changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel); + + if (oldSec != curSelected) FlxG.sound.play(Paths.sound(isThorns ? 'pixel/type' : 'pixel/pixelText')); - } - if (controls.ACCEPT) { FlxG.sound.play(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText')); @@ -118,7 +114,7 @@ function update(elapsed) { } } -function changeSelection(change) { +function changeSelection(change) { // this overrides the function inside of the normal pause btw, so no event gets called - Nex curSelected += change; if (curSelected < 0) diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index 7ca66b02..96aab829 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -216,7 +216,7 @@ class FreeplayState extends MusicBeatState lerpScore = intendedScore; if (canSelect) { - changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0)); + changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel); changeDiff((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0)); changeCoopMode((FlxG.keys.justPressed.TAB ? 1 : 0)); // putting it before so that its actually smooth diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 448552ac..968494f1 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -109,11 +109,12 @@ class MainMenuState extends MusicBeatState */ } - if (controls.UP_P) - changeItem(-1); + var upP = controls.UP_P; + var downP = controls.DOWN_P; + var scroll = FlxG.mouse.wheel; - if (controls.DOWN_P) - changeItem(1); + if (upP || downP || scroll != 0) // like this we wont break mods that expect a 0 change event when calling sometimes - Nex + changeItem((upP ? -1 : 0) + (downP ? 1 : 0) - scroll); if (controls.BACK) FlxG.switchState(new TitleState()); @@ -127,9 +128,7 @@ class MainMenuState extends MusicBeatState #end if (controls.ACCEPT) - { selectItem(); - } } super.update(elapsed); diff --git a/source/funkin/menus/ModSwitchMenu.hx b/source/funkin/menus/ModSwitchMenu.hx index 1b23b9d2..eac992dc 100644 --- a/source/funkin/menus/ModSwitchMenu.hx +++ b/source/funkin/menus/ModSwitchMenu.hx @@ -39,7 +39,7 @@ class ModSwitchMenu extends MusicBeatSubstate { public override function update(elapsed:Float) { super.update(elapsed); - changeSelection((controls.DOWN_P ? 1 : 0) + (controls.UP_P ? -1 : 0)); + changeSelection((controls.DOWN_P ? 1 : 0) + (controls.UP_P ? -1 : 0) - FlxG.mouse.wheel); if (controls.ACCEPT) { ModsFolder.switchMod(mods[curSelected]); @@ -64,4 +64,4 @@ class ModSwitchMenu extends MusicBeatSubstate { alphabets.members[curSelected].alpha = 1; } } -#end \ No newline at end of file +#end diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index bff3cd4d..ecf2fa7d 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -124,13 +124,12 @@ class PauseSubState extends MusicBeatSubstate var upP = controls.UP_P; var downP = controls.DOWN_P; - var accepted = controls.ACCEPT; + var scroll = FlxG.mouse.wheel; - if (upP) - changeSelection(-1); - if (downP) - changeSelection(1); - if (accepted) + if (upP || downP || scroll != 0) // like this we wont break mods that expect a 0 change event when calling sometimes - Nex + changeSelection((upP ? -1 : 0) + (downP ? 1 : 0) - scroll); + + if (controls.ACCEPT) selectOption(); } diff --git a/source/funkin/menus/StoryMenuState.hx b/source/funkin/menus/StoryMenuState.hx index d69d0c5b..847d921e 100644 --- a/source/funkin/menus/StoryMenuState.hx +++ b/source/funkin/menus/StoryMenuState.hx @@ -142,7 +142,7 @@ class StoryMenuState extends MusicBeatState { } changeDifficulty((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0)); - changeWeek((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0)); + changeWeek((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel); if (controls.ACCEPT) selectWeek();