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, } ]); }