diff --git a/source/funkin/backend/chart/EventsData.hx b/source/funkin/backend/chart/EventsData.hx index 11bf0673..0ec9b2eb 100644 --- a/source/funkin/backend/chart/EventsData.hx +++ b/source/funkin/backend/chart/EventsData.hx @@ -10,7 +10,7 @@ import openfl.Assets; using StringTools; class EventsData { - public static var defaultEventsList:Array = ["HScript Call", "Camera Movement", "Add Camera Zoom", "Camera Zoom", "Camera Modulo Change", "Camera Flash", "BPM Change", "Scroll Speed Change", "Alt Animation Toggle", "Play Animation"]; + public static var defaultEventsList:Array = ["HScript Call", "Camera Movement", "Camera Position", "Add Camera Zoom", "Camera Zoom", "Camera Modulo Change", "Camera Flash", "BPM Change", "Scroll Speed Change", "Alt Animation Toggle", "Play Animation"]; public static var defaultEventsParams:Map> = [ "HScript Call" => [ {name: "Function Name", type: TString, defValue: "myFunc"}, @@ -20,7 +20,7 @@ class EventsData { {name: "Camera Target", type: TStrumLine, defValue: 0}, {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}, - { // since its the most used event, we'll set saveIfDefault false to avoid filling up with unnecessary parameters the files - Nex + { // since its the most used event even by default, we'll set saveIfDefault false to avoid filling up with unnecessary parameters the files - Nex 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", @@ -33,6 +33,22 @@ class EventsData { saveIfDefault: false } ], + "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 Ease (ex: circ, quad, cube)", + type: TDropDown(['CLASSIC', 'linear', 'back', 'bounce', 'circ', 'cube', 'elastic', 'expo', 'quad', 'quart', 'quint', 'sine', 'smoothStep', 'smootherStep']), + defValue: "CLASSIC" + }, + { + name: "Tween Type (excluded if CLASSIC or linear, ex: InOut)", + type: TDropDown(['In', 'Out', 'InOut']), + defValue: "In" + } + ], "Add Camera Zoom" => [ {name: "Amount", type: TFloat(-10, 10, 0.01, 2), defValue: 0.05}, {name: "Camera", type: TDropDown(['camGame', 'camHUD']), defValue: "camGame"} @@ -52,7 +68,7 @@ class EventsData { type: TDropDown(['In', 'Out', 'InOut']), defValue: "In" }, - {name: "Mode", type: TDropDown(['stage', 'direct']), defValue: "stage"}, + {name: "Mode", type: TDropDown(['direct', 'stage']), defValue: "direct"}, {name: "Multiplicative?", type: TBool, defValue: true} ], "Camera Modulo Change" => [ diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 202c2677..0e2b2db6 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1480,6 +1480,20 @@ class PlayState extends MusicBeatState ); } } + case "Camera Position": + var tween = eventsTween.get("cameraMovement"); + if (tween != null) tween.cancel(); + + curCameraTarget = -1; + camFollow.setPosition(event.params[0], event.params[1]); + + if (event.params[2] == false) { + FlxG.camera.snapToTarget(); + } else if (event.params[4] != "CLASSIC") { + 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])}) + ); + } case "Add Camera Zoom": var camera:FlxCamera = event.params[1] == "camHUD" ? camHUD : camGame; camera.zoom += event.params[0]; @@ -1488,10 +1502,8 @@ class PlayState extends MusicBeatState var name = (event.params[2] == "camHUD" ? "camHUD" : "camGame") + ".zoom"; // avoiding having different values from these 2 - Nex var tween = eventsTween.get(name); if (tween != null) tween.cancel(); - var ease = CoolUtil.flxeaseFromString(event.params[4], event.params[5]); - var direct = event.params[6] == 'direct'; - var finalZoom:Float = event.params[1] * (direct ? FlxCamera.defaultZoom : stage.defaultZoom); + var finalZoom:Float = event.params[1] * (event.params[6] == 'direct' ? FlxCamera.defaultZoom : stage.defaultZoom); if (event.params[7] == true) finalZoom *= cam.zoom; if (event.params[0] == false) { @@ -1499,7 +1511,7 @@ class PlayState extends MusicBeatState if (cam == camHUD) defaultHudZoom = finalZoom; else defaultCamZoom = finalZoom; } else - eventsTween.set(name, FlxTween.tween(cam, {zoom: finalZoom}, (Conductor.stepCrochet / 1000) * event.params[3], {ease: ease, onUpdate: function(_) { + eventsTween.set(name, FlxTween.tween(cam, {zoom: finalZoom}, (Conductor.stepCrochet / 1000) * event.params[3], {ease: CoolUtil.flxeaseFromString(event.params[4], event.params[5]), onUpdate: function(_) { if (cam == camHUD) defaultHudZoom = cam.zoom; else defaultCamZoom = cam.zoom; }})); diff --git a/source/funkin/game/Stage.hx b/source/funkin/game/Stage.hx index 35d926f7..4fcb6351 100644 --- a/source/funkin/game/Stage.hx +++ b/source/funkin/game/Stage.hx @@ -70,7 +70,7 @@ class Stage extends FlxBasic implements IBeatReceiver { if((parsed = Std.parseFloat(stageXML.getAtt("startCamPosX"))).isNotNull()) startCam.x = parsed; if((parsed = Std.parseFloat(stageXML.getAtt("startCamPosY"))).isNotNull()) startCam.y = parsed; if((parsed = Std.parseFloat(stageXML.getAtt("zoom"))).isNotNull()) defaultZoom = parsed; - + stageName = stageXML.getAtt("name").getDefault(stage); if (PlayState.instance == state) { @@ -306,6 +306,11 @@ class Stage extends FlxBasic implements IBeatReceiver { public function measureHit(curMeasure:Int) {} + public override function destroy() { + startCam.put(); + super.destroy(); + } + /** * Gets a list of stages that are available to be used. * @param mods Whenever only the mods folder should be checked @@ -341,7 +346,6 @@ class StageCharPos extends FlxObject { public override function destroy() { scale.put(); - startCam.put(); super.destroy(); }