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] 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