Add additional adjustments in the ZoomCamerasong event for widescreen

This commit is contained in:
sector-a
2026-03-17 23:55:19 -06:00
committed by Hundrec
parent 11c826daa6
commit c8e60bed34
@@ -1,7 +1,11 @@
package funkin.play.event;
import flixel.tweens.FlxEase; // Data from the chart
import funkin.data.song.SongData.SongEventData; // Data from the event schema
import flixel.tweens.FlxEase;
import flixel.math.FlxPoint;
import funkin.ui.FullScreenScaleMode;
// Data from the chart
import funkin.data.song.SongData.SongEventData;
// Data from the event schema
import funkin.data.event.SongEventSchema;
import funkin.data.event.SongEventSchema.SongEventFieldType;
@@ -25,9 +29,10 @@ class ZoomCameraSongEvent extends SongEvent
});
}
static final DEFAULT_ZOOM:Float = 1.0;
static final DEFAULT_DURATION:Float = 4.0;
static final DEFAULT_MODE:String = 'direct';
public static final DEFAULT_ZOOM:Float = 1.0;
public static final DEFAULT_WIDESCREEN_SCALE:Float = 0.0;
public static final DEFAULT_DURATION:Float = 4.0;
public static final DEFAULT_MODE:String = 'direct';
public override function handleEvent(data:SongEventData):Void
{
@@ -39,6 +44,11 @@ class ZoomCameraSongEvent extends SongEvent
var zoom:Float = data.getFloat('zoom') ?? DEFAULT_ZOOM;
var widescreenScaleX:Float = data.getFloat('widescreenScaleX') ?? DEFAULT_WIDESCREEN_SCALE;
var widescreenScaleY:Float = data.getFloat('widescreenScaleY') ?? DEFAULT_WIDESCREEN_SCALE;
var scaledZoom:Float = zoom + (zoom * calculateScale(FullScreenScaleMode.wideScale, FlxPoint.get(widescreenScaleX, widescreenScaleY)));
var duration:Float = data.getFloat('duration') ?? DEFAULT_DURATION;
var mode:String = data.getString('mode') ?? DEFAULT_MODE;
@@ -53,7 +63,7 @@ class ZoomCameraSongEvent extends SongEvent
switch (ease)
{
case 'INSTANT':
PlayState.instance.tweenCameraZoom(zoom, 0, isDirectMode);
PlayState.instance.tweenCameraZoom(scaledZoom, 0, isDirectMode);
default:
var durSeconds = Conductor.instance.stepLengthMs * duration / 1000;
var easeFunctionName = '$ease$easeDir';
@@ -64,10 +74,15 @@ class ZoomCameraSongEvent extends SongEvent
return;
}
PlayState.instance.tweenCameraZoom(zoom, durSeconds, isDirectMode, easeFunction);
PlayState.instance.tweenCameraZoom(scaledZoom, durSeconds, isDirectMode, easeFunction);
}
}
function calculateScale(wideScale:FlxPoint, scale:FlxPoint)
{
return (wideScale.x - 1) * scale.x + (wideScale.y - 1) * scale.y;
}
public override function getTitle():String
{
return 'Zoom Camera';
@@ -125,6 +140,22 @@ class ZoomCameraSongEvent extends SongEvent
defaultValue: DEFAULT_MODE,
type: SongEventFieldType.ENUM,
keys: ['Stage zoom' => 'stage', 'Absolute zoom' => 'direct']
}, {
name: 'widescreenScaleX',
title: 'Widescreen Scale X',
defaultValue: DEFAULT_WIDESCREEN_SCALE,
min: 0,
max: 1,
type: SongEventFieldType.FLOAT,
units: 'x'
}, {
name: 'widescreenScaleY',
title: 'Widescreen Scale Y',
defaultValue: DEFAULT_WIDESCREEN_SCALE,
min: 0,
max: 1,
type: SongEventFieldType.FLOAT,
units: 'x'
}]
}]);
}