From 921ab3da63150ef1519a03ea52da5d35cde1381a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 4 May 2025 22:34:53 +0200 Subject: [PATCH] forgor vslice shits + better camera tweens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hopefully works, sen pls test these with your vslice charts🥹 --- source/funkin/backend/chart/EventsData.hx | 13 ++++++++----- source/funkin/backend/chart/VSliceParser.hx | 9 ++++++++- source/funkin/game/PlayState.hx | 20 +++++++++++++++----- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/source/funkin/backend/chart/EventsData.hx b/source/funkin/backend/chart/EventsData.hx index 0ec9b2eb..9a733ed7 100644 --- a/source/funkin/backend/chart/EventsData.hx +++ b/source/funkin/backend/chart/EventsData.hx @@ -36,18 +36,21 @@ class EventsData { "Camera Position" => [ {name: "X", type: TFloat(null, null, 10, 3), defValue: 0}, {name: "Y", type: TFloat(null, null, 10, 3), defValue: 0}, - {name: "Tween Movement?", type: TBool, defValue: true}, - {name: "Tween Time (Steps, IF NOT CLASSIC)", type: TFloat(0.25, 9999, 0.25, 2), defValue: 4}, + {name: "Tween Movement?", type: TBool, defValue: true, saveIfDefault: false}, + {name: "Tween Time (Steps, IF NOT CLASSIC)", type: TFloat(0.25, 9999, 0.25, 2), defValue: 4, saveIfDefault: false}, { name: "Tween Ease (ex: circ, quad, cube)", type: TDropDown(['CLASSIC', 'linear', 'back', 'bounce', 'circ', 'cube', 'elastic', 'expo', 'quad', 'quart', 'quint', 'sine', 'smoothStep', 'smootherStep']), - defValue: "CLASSIC" + defValue: "CLASSIC", + saveIfDefault: false }, { name: "Tween Type (excluded if CLASSIC or linear, ex: InOut)", type: TDropDown(['In', 'Out', 'InOut']), - defValue: "In" - } + defValue: "In", + saveIfDefault: false + }, + {name: "Is Offset?", type: TBool, defValue: false, saveIfDefault: false} ], "Add Camera Zoom" => [ {name: "Amount", type: TFloat(-10, 10, 0.01, 2), defValue: 0.05}, diff --git a/source/funkin/backend/chart/VSliceParser.hx b/source/funkin/backend/chart/VSliceParser.hx index 90f7fcef..cf44eaf6 100644 --- a/source/funkin/backend/chart/VSliceParser.hx +++ b/source/funkin/backend/chart/VSliceParser.hx @@ -108,8 +108,10 @@ class VSliceParser { { case "FocusCamera": var arr:Array = [switch(values.char) { + // more cases here in the future if they add em? (i hope not) - Nex case 0: 1; case 1: 0; + case -1: -1; default: 2; }]; if (values.ease != "CLASSIC" && values.ease != null) { @@ -119,7 +121,12 @@ class VSliceParser { arr = arr.concat([true, values.duration == null ? 4 : values.duration, cneEase[0], cneEase[1]]); } } - result.events.push({ + if (values.x != null || values.y != null) result.events.push({ + time: event.t, + name: "Camera Position", + params: [values.x, values.y, arr[1], arr[2], arr[3], arr[4], true] + }); + if (arr[0] != -1) result.events.push({ time: event.t, name: "Camera Movement", params: arr diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 0e2b2db6..59aa9338 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1463,7 +1463,6 @@ class PlayState extends MusicBeatState if (func != null && Reflect.isFunction(func)) Reflect.callMethod(null, func, args); } - case "Camera Movement": var tween = eventsTween.get("cameraMovement"); if (tween != null) tween.cancel(); @@ -1474,9 +1473,14 @@ class PlayState extends MusicBeatState moveCamera(); FlxG.camera.snapToTarget(); } else if (event.params[3] != null && event.params[3] != "CLASSIC") { // making more nullchecks in this event because of the default save value being false - Nex - moveCamera(); // i feel like i shouldnt nullify the camera target or else is gonna be annoying when scripts cancel the tween with setting back the target onComplete - Nex + moveCamera(); + var oldFollow = FlxG.camera.followEnabled; + FlxG.camera.followEnabled = false; eventsTween.set("cameraMovement", FlxTween.tween(FlxG.camera.scroll, {x: camFollow.x - FlxG.camera.width * 0.5, y: camFollow.y - FlxG.camera.height * 0.5}, - (Conductor.stepCrochet / 1000) * (event.params[2] == null ? 4 : event.params[2]), {ease: CoolUtil.flxeaseFromString(event.params[3], event.params[4])}) + (Conductor.stepCrochet / 1000) * (event.params[2] == null ? 4 : event.params[2]), { + ease: CoolUtil.flxeaseFromString(event.params[3], event.params[4]), + onComplete: (_) -> FlxG.camera.followEnabled = oldFollow + }) ); } } @@ -1485,13 +1489,19 @@ class PlayState extends MusicBeatState if (tween != null) tween.cancel(); curCameraTarget = -1; - camFollow.setPosition(event.params[0], event.params[1]); + var isOffset = event.params[6] == "true"; + camFollow.setPosition(isOffset ? camFollow.x + event.params[0] : event.params[0], isOffset ? camFollow.y + event.params[1] : event.params[1]); if (event.params[2] == false) { FlxG.camera.snapToTarget(); } else if (event.params[4] != "CLASSIC") { + var oldFollow = FlxG.camera.followEnabled; + FlxG.camera.followEnabled = false; eventsTween.set("cameraMovement", FlxTween.tween(FlxG.camera.scroll, {x: camFollow.x - FlxG.camera.width * 0.5, y: camFollow.y - FlxG.camera.height * 0.5}, - (Conductor.stepCrochet / 1000) * event.params[3], {ease: CoolUtil.flxeaseFromString(event.params[4], event.params[5])}) + (Conductor.stepCrochet / 1000) * event.params[3], { + ease: CoolUtil.flxeaseFromString(event.params[4], event.params[5]), + onComplete: (_) -> FlxG.camera.followEnabled = oldFollow + }) ); } case "Add Camera Zoom":