From edfde606a145e42af36eacbea826a17b663ffd90 Mon Sep 17 00:00:00 2001 From: Burgerballs <107233412+Burgerballs@users.noreply.github.com> Date: Thu, 9 May 2024 17:51:03 +0100 Subject: [PATCH 01/10] magical machine of death --- source/funkin/play/PlayState.hx | 48 +++++- .../play/event/AdditiveScrollSpeedEvent.hx | 138 ++++++++++++++++++ source/funkin/play/notes/Strumline.hx | 17 ++- source/funkin/play/notes/SustainTrail.hx | 31 +++- .../components/ChartEditorHoldNoteSprite.hx | 4 +- 5 files changed, 227 insertions(+), 11 deletions(-) create mode 100644 source/funkin/play/event/AdditiveScrollSpeedEvent.hx diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 0ba4e17ec..0b76ec6ee 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -236,6 +236,11 @@ class PlayState extends MusicBeatSubState */ public var cameraZoomTween:FlxTween; + /** + * An FlxTween that changes the additive speed to the desired amount. + */ + public var additiveScrollSpeedTween:FlxTween; + /** * The camera follow point from the last stage. * Used to persist the position of the `cameraFollowPosition` between levels. @@ -1179,6 +1184,11 @@ class PlayState extends MusicBeatSubState cameraZoomTween.active = false; cameraTweensPausedBySubState.add(cameraZoomTween); } + if (additiveScrollSpeedTween != null && additiveScrollSpeedTween.active) + { + additiveScrollSpeedTween.active = false; + cameraTweensPausedBySubState.add(additiveScrollSpeedTween); + } // Pause the countdown. Countdown.pauseCountdown(); @@ -3023,8 +3033,9 @@ class PlayState extends MusicBeatSubState // Stop camera zooming on beat. cameraZoomRate = 0; - // Cancel camera tweening if it's active. + // Cancel camera and scroll tweening if it's active. cancelAllCameraTweens(); + cancelAdditiveScrollSpeedTween(); // If the opponent is GF, zoom in on the opponent. // Else, if there is no GF, zoom in on BF. @@ -3244,6 +3255,41 @@ class PlayState extends MusicBeatSubState cancelCameraZoomTween(); } + /** + * The magical function that shall tween the additive scroll speed. + */ + public function tweenAdditiveScrollSpeed(?speed:Float, ?duration:Float, ?ease:NullFloat>):Void + { + // Cancel the current tween if it's active. + cancelAdditiveScrollSpeedTween(); + var strumLineTargets:Array = [ + playerStrumline.scrollSpeedAdditive + speed, + opponentStrumline.scrollSpeedAdditive + speed + ]; + + if (duration == 0) + { + playerStrumline.scrollSpeedAdditive = strumLineTargets[0]; + opponentStrumline.scrollSpeedAdditive = strumLineTargets[1]; + } + else + { + additiveScrollSpeedTween = FlxTween.tween(this, + { + "playerStrumline.scrollSpeedAdditive": strumLineTargets[0], + "opponentStrumline.scrollSpeedAdditive": strumLineTargets[1] + }, duration, {ease: ease}); + } + } + + public function cancelAdditiveScrollSpeedTween() + { + if (additiveScrollSpeedTween != null) + { + additiveScrollSpeedTween.cancel(); + } + } + #if (debug || FORCE_DEBUG_VERSION) /** * Jumps forward or backward a number of sections in the song. diff --git a/source/funkin/play/event/AdditiveScrollSpeedEvent.hx b/source/funkin/play/event/AdditiveScrollSpeedEvent.hx new file mode 100644 index 000000000..f66f3b257 --- /dev/null +++ b/source/funkin/play/event/AdditiveScrollSpeedEvent.hx @@ -0,0 +1,138 @@ +package funkin.play.event; + +import flixel.tweens.FlxTween; +import flixel.FlxCamera; +import flixel.tweens.FlxEase; +// Data from the chart +import funkin.data.song.SongData; +import funkin.data.song.SongData.SongEventData; +// Data from the event schema +import funkin.play.event.SongEvent; +import funkin.data.event.SongEventSchema; +import funkin.data.event.SongEventSchema.SongEventFieldType; + +/** + * This class represents a handler for scroll speed events. + * + * Example: Scroll speed change of both strums from 1x to 1.3x: + * ``` + * { + * 'e': 'AdditiveScrollSpeed', + * "v": { + * "scroll": "0.3", + * "duration": "4", + * "ease": "linear" + * } + * } + * ``` + */ +class AdditiveScrollSpeedEvent extends SongEvent +{ + public function new() + { + super('AdditiveScrollSpeed'); + } + + static final DEFAULT_SCROLL:Float = 0; + static final DEFAULT_DURATION:Float = 4.0; + static final DEFAULT_EASE:String = 'linear'; + + public override function handleEvent(data:SongEventData):Void + { + // Does nothing if there is no PlayState camera or stage. + if (PlayState.instance == null || PlayState.instance.currentStage == null) return; + + var scroll:Float = data.getFloat('scroll') ?? DEFAULT_SCROLL; + + var duration:Float = data.getFloat('duration') ?? DEFAULT_DURATION; + + var ease:String = data.getString('ease') ?? DEFAULT_EASE; + + // If it's a string, check the value. + switch (ease) + { + case 'INSTANT': + PlayState.instance.tweenAdditiveScrollSpeed(scroll, 0); + default: + var durSeconds = Conductor.instance.stepLengthMs * duration / 1000; + var easeFunction:NullFloat> = Reflect.field(FlxEase, ease); + if (easeFunction == null) + { + trace('Invalid ease function: $ease'); + return; + } + + PlayState.instance.tweenAdditiveScrollSpeed(scroll, durSeconds, easeFunction); + } + } + + public override function getTitle():String + { + return 'Additive Scroll Speed'; + } + + /** + * ``` + * { + * 'scroll': FLOAT, // Target additive scroll level. + * 'duration': FLOAT, // Duration in steps. + * 'ease': ENUM, // Easing function. + * } + * @return SongEventSchema + */ + public override function getEventSchema():SongEventSchema + { + return new SongEventSchema([ + { + name: 'scroll', + title: 'Additive Scroll Amount', + defaultValue: 0.0, + step: 0.1, + type: SongEventFieldType.FLOAT, + units: 'x' + }, + { + name: 'duration', + title: 'Duration', + defaultValue: 4.0, + step: 0.5, + type: SongEventFieldType.FLOAT, + units: 'steps' + }, + { + name: 'ease', + title: 'Easing Type', + defaultValue: 'linear', + type: SongEventFieldType.ENUM, + keys: [ + 'Linear' => 'linear', + 'Instant' => 'INSTANT', + 'Sine In' => 'sineIn', + 'Sine Out' => 'sineOut', + 'Sine In/Out' => 'sineInOut', + 'Quad In' => 'quadIn', + 'Quad Out' => 'quadOut', + 'Quad In/Out' => 'quadInOut', + 'Cube In' => 'cubeIn', + 'Cube Out' => 'cubeOut', + 'Cube In/Out' => 'cubeInOut', + 'Quart In' => 'quartIn', + 'Quart Out' => 'quartOut', + 'Quart In/Out' => 'quartInOut', + 'Quint In' => 'quintIn', + 'Quint Out' => 'quintOut', + 'Quint In/Out' => 'quintInOut', + 'Expo In' => 'expoIn', + 'Expo Out' => 'expoOut', + 'Expo In/Out' => 'expoInOut', + 'Smooth Step In' => 'smoothStepIn', + 'Smooth Step Out' => 'smoothStepOut', + 'Smooth Step In/Out' => 'smoothStepInOut', + 'Elastic In' => 'elasticIn', + 'Elastic Out' => 'elasticOut', + 'Elastic In/Out' => 'elasticInOut' + ] + } + ]); + } +} diff --git a/source/funkin/play/notes/Strumline.hx b/source/funkin/play/notes/Strumline.hx index 95e0668be..bd0c8a1be 100644 --- a/source/funkin/play/notes/Strumline.hx +++ b/source/funkin/play/notes/Strumline.hx @@ -52,6 +52,15 @@ class Strumline extends FlxSpriteGroup */ public var conductorInUse(get, set):Conductor; + // Used in-game to control the scroll speed within a song, for example if a song has an additive scroll speed of 1 and the base scroll speed is 1, it will be 2 - burgerballs + public var scrollSpeedAdditive:Float = 0; + public var scrollSpeed(get, never):Float; + + function get_scrollSpeed():Float + { + return (PlayState.instance?.currentChart?.scrollSpeed ?? 1.0) + scrollSpeedAdditive; + } + var _conductorInUse:Null; function get_conductorInUse():Conductor @@ -208,6 +217,11 @@ class Strumline extends FlxSpriteGroup return null; } + public function resetScrollSpeed():Void + { + scrollSpeedAdditive = 0; + } + public function getHoldNoteSprite(noteData:SongNoteData):SustainTrail { if (noteData == null || ((noteData.length ?? 0.0) <= 0.0)) return null; @@ -283,7 +297,6 @@ class Strumline extends FlxSpriteGroup // var vwoosh:Float = (strumTime < Conductor.songPosition) && vwoosh ? 2.0 : 1.0; // ^^^ commented this out... do NOT make it move faster as it moves offscreen! var vwoosh:Float = 1.0; - var scrollSpeed:Float = PlayState.instance?.currentChart?.scrollSpeed ?? 1.0; return Constants.PIXELS_PER_MS * (conductorInUse.songPosition - strumTime - Conductor.instance.inputOffset) * scrollSpeed * vwoosh * (Preferences.downscroll ? 1 : -1); @@ -539,6 +552,7 @@ class Strumline extends FlxSpriteGroup { playStatic(dir); } + scrollSpeedAdditive = 0; } public function applyNoteData(data:Array):Void @@ -705,6 +719,7 @@ class Strumline extends FlxSpriteGroup if (holdNoteSprite != null) { + holdNoteSprite.parentStrumline = this; holdNoteSprite.noteData = note; holdNoteSprite.strumTime = note.time; holdNoteSprite.noteDirection = note.getDirection(); diff --git a/source/funkin/play/notes/SustainTrail.hx b/source/funkin/play/notes/SustainTrail.hx index 056a6a5a9..b358d7f03 100644 --- a/source/funkin/play/notes/SustainTrail.hx +++ b/source/funkin/play/notes/SustainTrail.hx @@ -32,6 +32,7 @@ class SustainTrail extends FlxSprite public var sustainLength(default, set):Float = 0; // millis public var fullSustainLength:Float = 0; public var noteData:Null; + public var parentStrumline:Strumline; public var cover:NoteHoldCover = null; @@ -119,7 +120,7 @@ class SustainTrail extends FlxSprite // CALCULATE SIZE graphicWidth = graphic.width / 8 * zoom; // amount of notes * 2 - graphicHeight = sustainHeight(sustainLength, getScrollSpeed()); + graphicHeight = sustainHeight(sustainLength, parentStrumline?.scrollSpeed ?? 1.0); // instead of scrollSpeed, PlayState.SONG.speed flipY = Preferences.downscroll; @@ -135,9 +136,21 @@ class SustainTrail extends FlxSprite this.active = true; // This NEEDS to be true for the note to be drawn! } - function getScrollSpeed():Float + function getBaseScrollSpeed() { - return PlayState?.instance?.currentChart?.scrollSpeed ?? 1.0; + return (PlayState.instance?.currentChart?.scrollSpeed ?? 1.0); + } + + var previousScrollSpeed:Float = 1; + + override function update(elapsed) + { + super.update(elapsed); + if (previousScrollSpeed != (parentStrumline?.scrollSpeed ?? 1.0)) + { + triggerRedraw(); + } + previousScrollSpeed = parentStrumline?.scrollSpeed ?? 1.0; } /** @@ -155,12 +168,16 @@ class SustainTrail extends FlxSprite if (s < 0.0) s = 0.0; if (sustainLength == s) return s; - - graphicHeight = sustainHeight(s, getScrollSpeed()); this.sustainLength = s; + triggerRedraw(); + return this.sustainLength; + } + + function triggerRedraw() + { + graphicHeight = sustainHeight(sustainLength, parentStrumline?.scrollSpeed ?? 1.0); updateClipping(); updateHitbox(); - return this.sustainLength; } public override function updateHitbox():Void @@ -178,7 +195,7 @@ class SustainTrail extends FlxSprite */ public function updateClipping(songTime:Float = 0):Void { - var clipHeight:Float = FlxMath.bound(sustainHeight(sustainLength - (songTime - strumTime), getScrollSpeed()), 0, graphicHeight); + var clipHeight:Float = FlxMath.bound(sustainHeight(sustainLength - (songTime - strumTime), parentStrumline?.scrollSpeed ?? 1.0), 0, graphicHeight); if (clipHeight <= 0.1) { visible = false; diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index aeb6dd0e4..663f2bbf4 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -58,11 +58,11 @@ class ChartEditorHoldNoteSprite extends SustainTrail { if (lerp) { - sustainLength = FlxMath.lerp(sustainLength, h / (getScrollSpeed() * Constants.PIXELS_PER_MS), 0.25); + sustainLength = FlxMath.lerp(sustainLength, h / (getBaseScrollSpeed() * Constants.PIXELS_PER_MS), 0.25); } else { - sustainLength = h / (getScrollSpeed() * Constants.PIXELS_PER_MS); + sustainLength = h / (getBaseScrollSpeed() * Constants.PIXELS_PER_MS); } fullSustainLength = sustainLength; From e5ee6efdf4cf052c33333ecb937617c231bd19e8 Mon Sep 17 00:00:00 2001 From: Burgerballs <107233412+Burgerballs@users.noreply.github.com> Date: Thu, 9 May 2024 20:01:26 +0100 Subject: [PATCH 02/10] redundancy is bad!!!! --- source/funkin/play/notes/SustainTrail.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/play/notes/SustainTrail.hx b/source/funkin/play/notes/SustainTrail.hx index b358d7f03..9155c9b0a 100644 --- a/source/funkin/play/notes/SustainTrail.hx +++ b/source/funkin/play/notes/SustainTrail.hx @@ -168,6 +168,7 @@ class SustainTrail extends FlxSprite if (s < 0.0) s = 0.0; if (sustainLength == s) return s; + graphicHeight = sustainHeight(s, parentStrumline?.scrollSpeed ?? 1.0); this.sustainLength = s; triggerRedraw(); return this.sustainLength; @@ -175,7 +176,6 @@ class SustainTrail extends FlxSprite function triggerRedraw() { - graphicHeight = sustainHeight(sustainLength, parentStrumline?.scrollSpeed ?? 1.0); updateClipping(); updateHitbox(); } From a5700b37e10e35f6fc338b646951903887c221a6 Mon Sep 17 00:00:00 2001 From: Burgerballs <107233412+Burgerballs@users.noreply.github.com> Date: Fri, 10 May 2024 21:23:35 +0100 Subject: [PATCH 03/10] awesome shit (see desc) No longer Additive, it just sets the scroll speed Now you can set it to either strumline --- source/funkin/play/PlayState.hx | 60 ++++++++++--------- ...crollSpeedEvent.hx => ScrollSpeedEvent.hx} | 51 ++++++++++++---- source/funkin/play/notes/Strumline.hx | 17 ++---- 3 files changed, 77 insertions(+), 51 deletions(-) rename source/funkin/play/event/{AdditiveScrollSpeedEvent.hx => ScrollSpeedEvent.hx} (69%) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 0b76ec6ee..b4c733ee3 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -239,7 +239,7 @@ class PlayState extends MusicBeatSubState /** * An FlxTween that changes the additive speed to the desired amount. */ - public var additiveScrollSpeedTween:FlxTween; + public var scrollSpeedTweens:Array = []; /** * The camera follow point from the last stage. @@ -1184,10 +1184,14 @@ class PlayState extends MusicBeatSubState cameraZoomTween.active = false; cameraTweensPausedBySubState.add(cameraZoomTween); } - if (additiveScrollSpeedTween != null && additiveScrollSpeedTween.active) + + for (tween in scrollSpeedTweens) { - additiveScrollSpeedTween.active = false; - cameraTweensPausedBySubState.add(additiveScrollSpeedTween); + if (tween != null && tween.active) + { + tween.active = false; + cameraTweensPausedBySubState.add(tween); + } } // Pause the countdown. @@ -3035,7 +3039,7 @@ class PlayState extends MusicBeatSubState // Cancel camera and scroll tweening if it's active. cancelAllCameraTweens(); - cancelAdditiveScrollSpeedTween(); + cancelScrollSpeedTweens(); // If the opponent is GF, zoom in on the opponent. // Else, if there is no GF, zoom in on BF. @@ -3256,37 +3260,39 @@ class PlayState extends MusicBeatSubState } /** - * The magical function that shall tween the additive scroll speed. + * The magical function that shall tween the scroll speed. */ - public function tweenAdditiveScrollSpeed(?speed:Float, ?duration:Float, ?ease:NullFloat>):Void + public function tweenScrollSpeed(?speed:Float, ?duration:Float, ?ease:NullFloat>, strumlines:Array):Void { // Cancel the current tween if it's active. - cancelAdditiveScrollSpeedTween(); - var strumLineTargets:Array = [ - playerStrumline.scrollSpeedAdditive + speed, - opponentStrumline.scrollSpeedAdditive + speed - ]; + cancelScrollSpeedTweens(); + for (i in strumlines) + { + var value:Float = speed; + var strum:Strumline = Reflect.getProperty(this, i); - if (duration == 0) - { - playerStrumline.scrollSpeedAdditive = strumLineTargets[0]; - opponentStrumline.scrollSpeedAdditive = strumLineTargets[1]; - } - else - { - additiveScrollSpeedTween = FlxTween.tween(this, - { - "playerStrumline.scrollSpeedAdditive": strumLineTargets[0], - "opponentStrumline.scrollSpeedAdditive": strumLineTargets[1] - }, duration, {ease: ease}); + if (duration == 0) + { + strum.scrollSpeed = value; + } + else + { + scrollSpeedTweens.push(FlxTween.tween(strum, + { + 'scrollSpeed': value + }, duration, {ease: ease})); + } } } - public function cancelAdditiveScrollSpeedTween() + public function cancelScrollSpeedTweens() { - if (additiveScrollSpeedTween != null) + for (tween in scrollSpeedTweens) { - additiveScrollSpeedTween.cancel(); + if (tween != null) + { + tween.cancel(); + } } } diff --git a/source/funkin/play/event/AdditiveScrollSpeedEvent.hx b/source/funkin/play/event/ScrollSpeedEvent.hx similarity index 69% rename from source/funkin/play/event/AdditiveScrollSpeedEvent.hx rename to source/funkin/play/event/ScrollSpeedEvent.hx index f66f3b257..22da45b0c 100644 --- a/source/funkin/play/event/AdditiveScrollSpeedEvent.hx +++ b/source/funkin/play/event/ScrollSpeedEvent.hx @@ -17,30 +17,31 @@ import funkin.data.event.SongEventSchema.SongEventFieldType; * Example: Scroll speed change of both strums from 1x to 1.3x: * ``` * { - * 'e': 'AdditiveScrollSpeed', + * 'e': 'ScrollSpeed', * "v": { - * "scroll": "0.3", + * "scroll": "1.3", * "duration": "4", * "ease": "linear" * } * } * ``` */ -class AdditiveScrollSpeedEvent extends SongEvent +class ScrollSpeedEvent extends SongEvent { public function new() { - super('AdditiveScrollSpeed'); + super('ScrollSpeed'); } - static final DEFAULT_SCROLL:Float = 0; + static final DEFAULT_SCROLL:Float = 1; static final DEFAULT_DURATION:Float = 4.0; static final DEFAULT_EASE:String = 'linear'; + static final DEFAULT_STRUMLINE:String = 'both'; // my special little trick public override function handleEvent(data:SongEventData):Void { - // Does nothing if there is no PlayState camera or stage. - if (PlayState.instance == null || PlayState.instance.currentStage == null) return; + // Does nothing if there is no PlayState. + if (PlayState.instance == null) return; var scroll:Float = data.getFloat('scroll') ?? DEFAULT_SCROLL; @@ -48,11 +49,28 @@ class AdditiveScrollSpeedEvent extends SongEvent var ease:String = data.getString('ease') ?? DEFAULT_EASE; + var strumline:String = data.getString('strumline') ?? DEFAULT_STRUMLINE; + + var strumlineNames:Array = []; + + if (scroll == 0) + { + // if the parameter is set to 0, reset the scroll speed to normal. + scroll = PlayState.instance?.currentChart?.scrollSpeed ?? 1.0; + } + + switch (strumline) + { + case 'both': + strumlineNames = ['playerStrumline', 'opponentStrumline']; + default: + strumlineNames = [strumline + 'Strumline']; + } // If it's a string, check the value. switch (ease) { case 'INSTANT': - PlayState.instance.tweenAdditiveScrollSpeed(scroll, 0); + PlayState.instance.tweenScrollSpeed(scroll, 0, null, strumlineNames); default: var durSeconds = Conductor.instance.stepLengthMs * duration / 1000; var easeFunction:NullFloat> = Reflect.field(FlxEase, ease); @@ -62,19 +80,19 @@ class AdditiveScrollSpeedEvent extends SongEvent return; } - PlayState.instance.tweenAdditiveScrollSpeed(scroll, durSeconds, easeFunction); + PlayState.instance.tweenScrollSpeed(scroll, durSeconds, easeFunction, strumlineNames); } } public override function getTitle():String { - return 'Additive Scroll Speed'; + return 'Scroll Speed'; } /** * ``` * { - * 'scroll': FLOAT, // Target additive scroll level. + * 'scroll': FLOAT, // Target scroll level. * 'duration': FLOAT, // Duration in steps. * 'ease': ENUM, // Easing function. * } @@ -85,7 +103,7 @@ class AdditiveScrollSpeedEvent extends SongEvent return new SongEventSchema([ { name: 'scroll', - title: 'Additive Scroll Amount', + title: 'Scroll Amount', defaultValue: 0.0, step: 0.1, type: SongEventFieldType.FLOAT, @@ -106,7 +124,7 @@ class AdditiveScrollSpeedEvent extends SongEvent type: SongEventFieldType.ENUM, keys: [ 'Linear' => 'linear', - 'Instant' => 'INSTANT', + 'Instant (Ignores Duration)' => 'INSTANT', 'Sine In' => 'sineIn', 'Sine Out' => 'sineOut', 'Sine In/Out' => 'sineInOut', @@ -132,6 +150,13 @@ class AdditiveScrollSpeedEvent extends SongEvent 'Elastic Out' => 'elasticOut', 'Elastic In/Out' => 'elasticInOut' ] + }, + { + name: 'strumline', + title: 'Target Strumline', + defaultValue: 'both', + type: SongEventFieldType.ENUM, + keys: ['Both' => 'both', 'Player' => 'player', 'Opponent' => 'opponent'] } ]); } diff --git a/source/funkin/play/notes/Strumline.hx b/source/funkin/play/notes/Strumline.hx index bd0c8a1be..dbc8569c5 100644 --- a/source/funkin/play/notes/Strumline.hx +++ b/source/funkin/play/notes/Strumline.hx @@ -52,13 +52,12 @@ class Strumline extends FlxSpriteGroup */ public var conductorInUse(get, set):Conductor; - // Used in-game to control the scroll speed within a song, for example if a song has an additive scroll speed of 1 and the base scroll speed is 1, it will be 2 - burgerballs - public var scrollSpeedAdditive:Float = 0; - public var scrollSpeed(get, never):Float; + // Used in-game to control the scroll speed within a song + public var scrollSpeed:Float = 1.0; - function get_scrollSpeed():Float + public function resetScrollSpeed():Void { - return (PlayState.instance?.currentChart?.scrollSpeed ?? 1.0) + scrollSpeedAdditive; + scrollSpeed = PlayState.instance?.currentChart?.scrollSpeed ?? 1.0; } var _conductorInUse:Null; @@ -143,6 +142,7 @@ class Strumline extends FlxSpriteGroup this.refresh(); this.onNoteIncoming = new FlxTypedSignalVoid>(); + resetScrollSpeed(); for (i in 0...KEY_COUNT) { @@ -217,11 +217,6 @@ class Strumline extends FlxSpriteGroup return null; } - public function resetScrollSpeed():Void - { - scrollSpeedAdditive = 0; - } - public function getHoldNoteSprite(noteData:SongNoteData):SustainTrail { if (noteData == null || ((noteData.length ?? 0.0) <= 0.0)) return null; @@ -552,7 +547,7 @@ class Strumline extends FlxSpriteGroup { playStatic(dir); } - scrollSpeedAdditive = 0; + resetScrollSpeed(); } public function applyNoteData(data:Array):Void From 5fd2ea0bcf0c60ed4ea654b34485df86c34a88fc Mon Sep 17 00:00:00 2001 From: Burgerballs <107233412+Burgerballs@users.noreply.github.com> Date: Fri, 10 May 2024 21:37:46 +0100 Subject: [PATCH 04/10] optimization of the cleary boy (: --- source/funkin/play/PlayState.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index b4c733ee3..4ce778fc1 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -3294,6 +3294,7 @@ class PlayState extends MusicBeatSubState tween.cancel(); } } + scrollSpeedTweens = []; } #if (debug || FORCE_DEBUG_VERSION) From 96de434d75d459ebeb13fdfc1aba7adf57b9d705 Mon Sep 17 00:00:00 2001 From: Burgerballs <107233412+Burgerballs@users.noreply.github.com> Date: Wed, 15 May 2024 17:17:09 +0100 Subject: [PATCH 05/10] multiplicative added!! + sum tween fixes --- source/funkin/play/PlayState.hx | 16 ++++++++++++++++ source/funkin/play/event/ScrollSpeedEvent.hx | 19 ++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 4ce778fc1..d63854d3f 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -3259,6 +3259,8 @@ class PlayState extends MusicBeatSubState cancelCameraZoomTween(); } + var prevScrollTargets:Array = []; // used to snap scroll speed when things go unruely + /** * The magical function that shall tween the scroll speed. */ @@ -3266,6 +3268,18 @@ class PlayState extends MusicBeatSubState { // Cancel the current tween if it's active. cancelScrollSpeedTweens(); + + // Snap to previous event value to prevent the tween breaking when another event cancels the previous tween. + for (i in prevScrollTargets) + { + var value:Float = i[1]; + var strum:Strumline = Reflect.getProperty(this, i[0]); + strum.scrollSpeed = value; + } + + // for next event, clean array. + prevScrollTargets = []; + for (i in strumlines) { var value:Float = speed; @@ -3282,6 +3296,8 @@ class PlayState extends MusicBeatSubState 'scrollSpeed': value }, duration, {ease: ease})); } + // make sure charts dont break if the charter is dumb and stupid + prevScrollTargets.push([value, i]); } } diff --git a/source/funkin/play/event/ScrollSpeedEvent.hx b/source/funkin/play/event/ScrollSpeedEvent.hx index 22da45b0c..9abd4be90 100644 --- a/source/funkin/play/event/ScrollSpeedEvent.hx +++ b/source/funkin/play/event/ScrollSpeedEvent.hx @@ -36,6 +36,7 @@ class ScrollSpeedEvent extends SongEvent static final DEFAULT_SCROLL:Float = 1; static final DEFAULT_DURATION:Float = 4.0; static final DEFAULT_EASE:String = 'linear'; + static final DEFAULT_ABSOLUTE:Bool = false; static final DEFAULT_STRUMLINE:String = 'both'; // my special little trick public override function handleEvent(data:SongEventData):Void @@ -51,12 +52,14 @@ class ScrollSpeedEvent extends SongEvent var strumline:String = data.getString('strumline') ?? DEFAULT_STRUMLINE; + var absolute:Bool = data.getBool('absolute') ?? DEFAULT_ABSOLUTE; + var strumlineNames:Array = []; - if (scroll == 0) + if (!absolute) { - // if the parameter is set to 0, reset the scroll speed to normal. - scroll = PlayState.instance?.currentChart?.scrollSpeed ?? 1.0; + // If absolute is set to false, do the awesome multiplicative thing + scroll = scroll * (PlayState.instance?.currentChart?.scrollSpeed ?? 1.0); } switch (strumline) @@ -103,8 +106,8 @@ class ScrollSpeedEvent extends SongEvent return new SongEventSchema([ { name: 'scroll', - title: 'Scroll Amount', - defaultValue: 0.0, + title: 'Target Value', + defaultValue: 1.0, step: 0.1, type: SongEventFieldType.FLOAT, units: 'x' @@ -157,6 +160,12 @@ class ScrollSpeedEvent extends SongEvent defaultValue: 'both', type: SongEventFieldType.ENUM, keys: ['Both' => 'both', 'Player' => 'player', 'Opponent' => 'opponent'] + }, + { + name: 'absolute', + title: 'Absolute', + defaultValue: false, + type: SongEventFieldType.BOOL, } ]); } From eaf998adf71a0e9060f6604dd23e070f3036d8f4 Mon Sep 17 00:00:00 2001 From: Burgerballs <107233412+Burgerballs@users.noreply.github.com> Date: Wed, 15 May 2024 17:24:04 +0100 Subject: [PATCH 06/10] curse burgerballs --- source/funkin/play/PlayState.hx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index d63854d3f..176f3817c 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -827,6 +827,8 @@ class PlayState extends MusicBeatSubState { if (!assertChartExists()) return; + prevScrollTargets = []; + dispatchEvent(new ScriptEvent(SONG_RETRY)); resetCamera(); @@ -3272,8 +3274,8 @@ class PlayState extends MusicBeatSubState // Snap to previous event value to prevent the tween breaking when another event cancels the previous tween. for (i in prevScrollTargets) { - var value:Float = i[1]; - var strum:Strumline = Reflect.getProperty(this, i[0]); + var value:Float = i[0]; + var strum:Strumline = Reflect.getProperty(this, i[1]); strum.scrollSpeed = value; } From 21333ee8dc5a65600e5b886f608bd76de8967233 Mon Sep 17 00:00:00 2001 From: Burgerballs <107233412+Burgerballs@users.noreply.github.com> Date: Wed, 15 May 2024 17:26:03 +0100 Subject: [PATCH 07/10] burgerbugs require burgerfixes --- source/funkin/play/notes/SustainTrail.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/play/notes/SustainTrail.hx b/source/funkin/play/notes/SustainTrail.hx index 9155c9b0a..b358d7f03 100644 --- a/source/funkin/play/notes/SustainTrail.hx +++ b/source/funkin/play/notes/SustainTrail.hx @@ -168,7 +168,6 @@ class SustainTrail extends FlxSprite if (s < 0.0) s = 0.0; if (sustainLength == s) return s; - graphicHeight = sustainHeight(s, parentStrumline?.scrollSpeed ?? 1.0); this.sustainLength = s; triggerRedraw(); return this.sustainLength; @@ -176,6 +175,7 @@ class SustainTrail extends FlxSprite function triggerRedraw() { + graphicHeight = sustainHeight(sustainLength, parentStrumline?.scrollSpeed ?? 1.0); updateClipping(); updateHitbox(); } From dcfc51cdcd53cd52b1b5ee34f0df6778afa1f2b9 Mon Sep 17 00:00:00 2001 From: gamerbross <55158797+gamerbross@users.noreply.github.com> Date: Mon, 20 May 2024 01:37:35 +0200 Subject: [PATCH 08/10] Fix Charting Sustain Trails Inverted --- .../ui/debug/charting/components/ChartEditorHoldNoteSprite.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index aeb6dd0e4..7c20358a4 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -36,6 +36,8 @@ class ChartEditorHoldNoteSprite extends SustainTrail zoom *= 0.7; zoom *= ChartEditorState.GRID_SIZE / Strumline.STRUMLINE_SIZE; + flipY = false; + setup(); } From 9a18e3fde6ee779ca391dece4a0d94e79f584501 Mon Sep 17 00:00:00 2001 From: gamerbross <55158797+gamerbross@users.noreply.github.com> Date: Mon, 20 May 2024 01:38:52 +0200 Subject: [PATCH 09/10] Fix Charting Dragging Sustain Trails --- source/funkin/ui/debug/charting/ChartEditorState.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index b75cd8bf1..d426abaaf 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4566,8 +4566,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } gridGhostHoldNote.visible = true; - gridGhostHoldNote.noteData = gridGhostNote.noteData; - gridGhostHoldNote.noteDirection = gridGhostNote.noteData.getDirection(); + gridGhostHoldNote.noteData = currentPlaceNoteData; + gridGhostHoldNote.noteDirection = currentPlaceNoteData.getDirection(); gridGhostHoldNote.setHeightDirectly(dragLengthPixels, true); gridGhostHoldNote.updateHoldNotePosition(renderedHoldNotes); From ee4be810622f896fb1ff12e9f9ad03889e85f455 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 29 May 2024 15:16:31 -0300 Subject: [PATCH 10/10] Now Preloader resets CWD --- source/funkin/ui/transition/preload/FunkinPreloader.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/funkin/ui/transition/preload/FunkinPreloader.hx b/source/funkin/ui/transition/preload/FunkinPreloader.hx index b71af2b3b..9d2569588 100644 --- a/source/funkin/ui/transition/preload/FunkinPreloader.hx +++ b/source/funkin/ui/transition/preload/FunkinPreloader.hx @@ -136,6 +136,8 @@ class FunkinPreloader extends FlxBasePreloader // We can't even call trace() yet, until Flixel loads. trace('Initializing custom preloader...'); + funkin.util.CLIUtil.resetWorkingDir(); + this.siteLockTitleText = Constants.SITE_LOCK_TITLE; this.siteLockBodyText = Constants.SITE_LOCK_DESC; }