From fd100a6b212302000d0937b34a10979cf9c73e88 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Mon, 26 Jun 2023 14:11:41 +0200 Subject: [PATCH] Changes to Freeplay Moddability --- .../events/FreeplayAlphaUpdateEvent.hx | 24 +++++++++++++++++++ source/funkin/menus/FreeplayState.hx | 21 ++++++++++------ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 source/funkin/backend/scripting/events/FreeplayAlphaUpdateEvent.hx diff --git a/source/funkin/backend/scripting/events/FreeplayAlphaUpdateEvent.hx b/source/funkin/backend/scripting/events/FreeplayAlphaUpdateEvent.hx new file mode 100644 index 00000000..5862f280 --- /dev/null +++ b/source/funkin/backend/scripting/events/FreeplayAlphaUpdateEvent.hx @@ -0,0 +1,24 @@ +package funkin.backend.scripting.events; + +final class FreeplayAlphaUpdateEvent extends CancellableEvent { + /** + * The alpha when nothing is playing and isnt selected + */ + public var idleAlpha:Float; + /** + * The alpha when something is playing and isnt selected + */ + public var idlePlayingAlpha:Float; + /** + * The alpha when nothing is playing and selected + */ + public var selectedAlpha:Float; + /** + * The alpha when something is playing and selected + */ + public var selectedPlayingAlpha:Float; + /** + * The lerp of the alpha + */ + public var lerp:Float; +} \ No newline at end of file diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index 50692a7e..8a77b0e9 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -22,7 +22,11 @@ class FreeplayState extends MusicBeatState /** * How much time a song stays selected until it autoplays. */ - public inline static var timeUntilAutoplay:Float = 1; + public var timeUntilAutoplay:Float = 1; + /** + * Whenever the song autoplays when hovered over. + */ + public var disableAutoPlay:Bool = false; /** * Array containing all of the songs metadatas @@ -202,7 +206,7 @@ class FreeplayState extends MusicBeatState if (FlxG.sound.music != null && FlxG.sound.music.volume < 0.7) { - FlxG.sound.music.volume += 0.5 * FlxG.elapsed; + FlxG.sound.music.volume += 0.5 * elapsed; } lerpScore = Math.floor(lerp(lerpScore, intendedScore, 0.4)); @@ -233,7 +237,7 @@ class FreeplayState extends MusicBeatState var dontPlaySongThisFrame = false; #if PRELOAD_ALL autoplayElapsed += elapsed; - if (!songInstPlaying && (autoplayElapsed > timeUntilAutoplay || FlxG.keys.justPressed.SPACE)) { + if (!disableAutoPlay && !songInstPlaying && (autoplayElapsed > timeUntilAutoplay || FlxG.keys.justPressed.SPACE)) { if (curPlayingInst != (curPlayingInst = Paths.inst(songs[curSelected].name, songs[curSelected].difficulties[curDifficulty]))) FlxG.sound.playMusic(curPlayingInst, 0); songInstPlaying = true; @@ -398,22 +402,25 @@ class FreeplayState extends MusicBeatState } function updateOptionsAlpha() { + var event = event("onUpdateOptionsAlpha", EventManager.get(FreeplayAlphaUpdateEvent).recycle(0.6, 0.45, 1, 1, 0.25)); + if (event.cancelled) return; + var bullShit:Int = 0; for (i in 0...iconArray.length) - iconArray[i].alpha = lerp(iconArray[i].alpha, #if PRELOAD_ALL songInstPlaying ? 0.45 : #end 0.6, 0.25); + iconArray[i].alpha = lerp(iconArray[i].alpha, #if PRELOAD_ALL songInstPlaying ? event.idlePlayingAlpha : #end event.idleAlpha, event.lerp); - iconArray[curSelected].alpha = 1; + iconArray[curSelected].alpha = #if PRELOAD_ALL songInstPlaying ? event.selectedPlayingAlpha : #end event.selectedAlpha; for (item in grpSongs.members) { item.targetY = bullShit - curSelected; bullShit++; - item.alpha = lerp(item.alpha, #if PRELOAD_ALL songInstPlaying ? 0.45 : #end 0.6, 0.25); + item.alpha = lerp(item.alpha, #if PRELOAD_ALL songInstPlaying ? event.idlePlayingAlpha : #end event.idleAlpha, event.lerp); if (item.targetY == 0) - item.alpha = 1; + item.alpha = #if PRELOAD_ALL songInstPlaying ? event.selectedPlayingAlpha : #end event.selectedAlpha; } } }