fixing a bunch of stuff + camera position event

This commit is contained in:
⍚~Nex
2025-05-04 19:53:54 +02:00
parent 4b2acd4a8e
commit 5751ad5d43
3 changed files with 41 additions and 9 deletions
+19 -3
View File
@@ -10,7 +10,7 @@ import openfl.Assets;
using StringTools; using StringTools;
class EventsData { class EventsData {
public static var defaultEventsList:Array<String> = ["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<String> = ["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<String, Array<EventParamInfo>> = [ public static var defaultEventsParams:Map<String, Array<EventParamInfo>> = [
"HScript Call" => [ "HScript Call" => [
{name: "Function Name", type: TString, defValue: "myFunc"}, {name: "Function Name", type: TString, defValue: "myFunc"},
@@ -20,7 +20,7 @@ class EventsData {
{name: "Camera Target", type: TStrumLine, defValue: 0}, {name: "Camera Target", type: TStrumLine, defValue: 0},
{name: "Tween Movement?", type: TBool, defValue: true, saveIfDefault: false}, {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 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)", name: "Tween Ease (ex: circ, quad, cube)",
type: TDropDown(['CLASSIC', 'linear', 'back', 'bounce', 'circ', 'cube', 'elastic', 'expo', 'quad', 'quart', 'quint', 'sine', 'smoothStep', 'smootherStep']), type: TDropDown(['CLASSIC', 'linear', 'back', 'bounce', 'circ', 'cube', 'elastic', 'expo', 'quad', 'quart', 'quint', 'sine', 'smoothStep', 'smootherStep']),
defValue: "CLASSIC", defValue: "CLASSIC",
@@ -33,6 +33,22 @@ class EventsData {
saveIfDefault: false 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" => [ "Add Camera Zoom" => [
{name: "Amount", type: TFloat(-10, 10, 0.01, 2), defValue: 0.05}, {name: "Amount", type: TFloat(-10, 10, 0.01, 2), defValue: 0.05},
{name: "Camera", type: TDropDown(['camGame', 'camHUD']), defValue: "camGame"} {name: "Camera", type: TDropDown(['camGame', 'camHUD']), defValue: "camGame"}
@@ -52,7 +68,7 @@ class EventsData {
type: TDropDown(['In', 'Out', 'InOut']), type: TDropDown(['In', 'Out', 'InOut']),
defValue: "In" defValue: "In"
}, },
{name: "Mode", type: TDropDown(['stage', 'direct']), defValue: "stage"}, {name: "Mode", type: TDropDown(['direct', 'stage']), defValue: "direct"},
{name: "Multiplicative?", type: TBool, defValue: true} {name: "Multiplicative?", type: TBool, defValue: true}
], ],
"Camera Modulo Change" => [ "Camera Modulo Change" => [
+16 -4
View File
@@ -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": case "Add Camera Zoom":
var camera:FlxCamera = event.params[1] == "camHUD" ? camHUD : camGame; var camera:FlxCamera = event.params[1] == "camHUD" ? camHUD : camGame;
camera.zoom += event.params[0]; 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 name = (event.params[2] == "camHUD" ? "camHUD" : "camGame") + ".zoom"; // avoiding having different values from these 2 - Nex
var tween = eventsTween.get(name); var tween = eventsTween.get(name);
if (tween != null) tween.cancel(); 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[7] == true) finalZoom *= cam.zoom;
if (event.params[0] == false) { if (event.params[0] == false) {
@@ -1499,7 +1511,7 @@ class PlayState extends MusicBeatState
if (cam == camHUD) defaultHudZoom = finalZoom; if (cam == camHUD) defaultHudZoom = finalZoom;
else defaultCamZoom = finalZoom; else defaultCamZoom = finalZoom;
} else } 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; if (cam == camHUD) defaultHudZoom = cam.zoom;
else defaultCamZoom = cam.zoom; else defaultCamZoom = cam.zoom;
}})); }}));
+6 -2
View File
@@ -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("startCamPosX"))).isNotNull()) startCam.x = parsed;
if((parsed = Std.parseFloat(stageXML.getAtt("startCamPosY"))).isNotNull()) startCam.y = parsed; if((parsed = Std.parseFloat(stageXML.getAtt("startCamPosY"))).isNotNull()) startCam.y = parsed;
if((parsed = Std.parseFloat(stageXML.getAtt("zoom"))).isNotNull()) defaultZoom = parsed; if((parsed = Std.parseFloat(stageXML.getAtt("zoom"))).isNotNull()) defaultZoom = parsed;
stageName = stageXML.getAtt("name").getDefault(stage); stageName = stageXML.getAtt("name").getDefault(stage);
if (PlayState.instance == state) { if (PlayState.instance == state) {
@@ -306,6 +306,11 @@ class Stage extends FlxBasic implements IBeatReceiver {
public function measureHit(curMeasure:Int) {} public function measureHit(curMeasure:Int) {}
public override function destroy() {
startCam.put();
super.destroy();
}
/** /**
* Gets a list of stages that are available to be used. * Gets a list of stages that are available to be used.
* @param mods Whenever only the mods folder should be checked * @param mods Whenever only the mods folder should be checked
@@ -341,7 +346,6 @@ class StageCharPos extends FlxObject {
public override function destroy() { public override function destroy() {
scale.put(); scale.put();
startCam.put();
super.destroy(); super.destroy();
} }