Event easing direction + backwards compatibility
This commit is contained in:
@@ -71,7 +71,10 @@ class FocusCameraSongEvent extends SongEvent
|
||||
var duration:Null<Float> = data.getFloat('duration');
|
||||
if (duration == null) duration = 4.0;
|
||||
var ease:Null<String> = data.getString('ease');
|
||||
if (ease == null) ease = 'CLASSIC';
|
||||
if (ease == null) ease = 'CLASSIC'; // No linear in defaults lol
|
||||
|
||||
var easeDir:String = data.getString('easeDir') ?? SongEvent.DEFAULT_EASE_DIR;
|
||||
if (SongEvent.EASE_TYPE_DIR_REGEX.match(ease) || ease == "linear") easeDir = "";
|
||||
|
||||
var currentStage = PlayState.instance.currentStage;
|
||||
|
||||
@@ -132,7 +135,7 @@ class FocusCameraSongEvent extends SongEvent
|
||||
PlayState.instance.tweenCameraToPosition(targetX, targetY, 0);
|
||||
default:
|
||||
var durSeconds = Conductor.instance.stepLengthMs * duration / 1000;
|
||||
var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease);
|
||||
var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease + easeDir);
|
||||
if (easeFunction == null)
|
||||
{
|
||||
trace('Invalid ease function: $ease');
|
||||
@@ -198,45 +201,28 @@ class FocusCameraSongEvent extends SongEvent
|
||||
type: SongEventFieldType.ENUM,
|
||||
keys: [
|
||||
'Linear' => 'linear',
|
||||
'Sine In' => 'sineIn',
|
||||
'Sine Out' => 'sineOut',
|
||||
'Sine In/Out' => 'sineInOut',
|
||||
'Quad In' => 'quadIn',
|
||||
'Quad Out' => 'quadOut',
|
||||
'Quad In/Out' => 'quadInOut',
|
||||
'Cube In' => 'cubeIn',
|
||||
'Cube Out' => 'cubeOut',
|
||||
'Cube In/Out' => 'cubeInOut',
|
||||
'Quart In' => 'quartIn',
|
||||
'Quart Out' => 'quartOut',
|
||||
'Quart In/Out' => 'quartInOut',
|
||||
'Quint In' => 'quintIn',
|
||||
'Quint Out' => 'quintOut',
|
||||
'Quint In/Out' => 'quintInOut',
|
||||
'Expo In' => 'expoIn',
|
||||
'Expo Out' => 'expoOut',
|
||||
'Expo In/Out' => 'expoInOut',
|
||||
'Smooth Step In' => 'smoothStepIn',
|
||||
'Smooth Step Out' => 'smoothStepOut',
|
||||
'Smooth Step In/Out' => 'smoothStepInOut',
|
||||
'Smoother Step In' => 'smootherStepIn',
|
||||
'Smoother Step Out' => 'smootherStepOut',
|
||||
'Smoother Step In/Out' => 'smootherStepInOut',
|
||||
'Elastic In' => 'elasticIn',
|
||||
'Elastic Out' => 'elasticOut',
|
||||
'Elastic In/Out' => 'elasticInOut',
|
||||
'Back In' => 'backIn',
|
||||
'Back Out' => 'backOut',
|
||||
'Back In/Out' => 'backInOut',
|
||||
'Bounce In' => 'bounceIn',
|
||||
'Bounce Out' => 'bounceOut',
|
||||
'Bounce In/Out' => 'bounceInOut',
|
||||
'Circ In' => 'circIn',
|
||||
'Circ Out' => 'circOut',
|
||||
'Circ In/Out' => 'circInOut',
|
||||
'Instant (Ignores duration)' => 'INSTANT',
|
||||
'Classic (Ignores duration)' => 'CLASSIC'
|
||||
'Classic (Ignores duration)' => 'CLASSIC',
|
||||
'Sine' => 'sine',
|
||||
'Quad' => 'quad',
|
||||
'Cube' => 'cube',
|
||||
'Quart' => 'quart',
|
||||
'Quint' => 'quint',
|
||||
'Expo' => 'expo',
|
||||
'Smooth Step' => 'smoothStep',
|
||||
'Smoother Step' => 'smootherStep',
|
||||
'Elastic' => 'elastic',
|
||||
'Back' => 'back',
|
||||
'Bounce' => 'bounce',
|
||||
'Circ ' => 'circ',
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'easeDir',
|
||||
title: 'Easing Direction',
|
||||
defaultValue: 'In',
|
||||
type: SongEventFieldType.ENUM,
|
||||
keys: ['In' => 'In', 'Out' => 'Out', 'In/Out' => 'InOut']
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ class ScrollSpeedEvent extends SongEvent
|
||||
|
||||
static final DEFAULT_SCROLL:Float = 1;
|
||||
static final DEFAULT_DURATION:Float = 4.0;
|
||||
static final DEFAULT_EASE:String = 'linear';
|
||||
static final DEFAULT_ABSOLUTE:Bool = false;
|
||||
static final DEFAULT_STRUMLINE:String = 'both'; // my special little trick
|
||||
|
||||
@@ -46,7 +45,10 @@ class ScrollSpeedEvent extends SongEvent
|
||||
|
||||
var duration:Float = data.getFloat('duration') ?? DEFAULT_DURATION;
|
||||
|
||||
var ease:String = data.getString('ease') ?? DEFAULT_EASE;
|
||||
var ease:String = data.getString('ease') ?? SongEvent.DEFAULT_EASE;
|
||||
var easeDir:String = data.getString('easeDir') ?? SongEvent.DEFAULT_EASE_DIR;
|
||||
|
||||
if (SongEvent.EASE_TYPE_DIR_REGEX.match(ease) || ease == "linear") easeDir = "";
|
||||
|
||||
var strumline:String = data.getString('strumline') ?? DEFAULT_STRUMLINE;
|
||||
|
||||
@@ -74,7 +76,7 @@ class ScrollSpeedEvent extends SongEvent
|
||||
PlayState.instance.tweenScrollSpeed(scroll, 0, null, strumlineNames);
|
||||
default:
|
||||
var durSeconds = Conductor.instance.stepLengthMs * duration / 1000;
|
||||
var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease);
|
||||
var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease + easeDir);
|
||||
if (easeFunction == null)
|
||||
{
|
||||
trace('Invalid ease function: $ease');
|
||||
@@ -96,6 +98,7 @@ class ScrollSpeedEvent extends SongEvent
|
||||
* 'scroll': FLOAT, // Target scroll level.
|
||||
* 'duration': FLOAT, // Duration in steps.
|
||||
* 'ease': ENUM, // Easing function.
|
||||
* 'easeDir': ENUM, // Easing function direction (In, Out, InOut).
|
||||
* 'strumline': ENUM, // Which strumline to change
|
||||
* 'absolute': BOOL, // True to set the scroll speed to the target level, false to set the scroll speed to (target level x base scroll speed)
|
||||
* }
|
||||
@@ -129,45 +132,28 @@ class ScrollSpeedEvent extends SongEvent
|
||||
type: SongEventFieldType.ENUM,
|
||||
keys: [
|
||||
'Linear' => 'linear',
|
||||
'Instant (Ignores Duration)' => 'INSTANT',
|
||||
'Sine In' => 'sineIn',
|
||||
'Sine Out' => 'sineOut',
|
||||
'Sine In/Out' => 'sineInOut',
|
||||
'Quad In' => 'quadIn',
|
||||
'Quad Out' => 'quadOut',
|
||||
'Quad In/Out' => 'quadInOut',
|
||||
'Cube In' => 'cubeIn',
|
||||
'Cube Out' => 'cubeOut',
|
||||
'Cube In/Out' => 'cubeInOut',
|
||||
'Quart In' => 'quartIn',
|
||||
'Quart Out' => 'quartOut',
|
||||
'Quart In/Out' => 'quartInOut',
|
||||
'Quint In' => 'quintIn',
|
||||
'Quint Out' => 'quintOut',
|
||||
'Quint In/Out' => 'quintInOut',
|
||||
'Expo In' => 'expoIn',
|
||||
'Expo Out' => 'expoOut',
|
||||
'Expo In/Out' => 'expoInOut',
|
||||
'Smooth Step In' => 'smoothStepIn',
|
||||
'Smooth Step Out' => 'smoothStepOut',
|
||||
'Smooth Step In/Out' => 'smoothStepInOut',
|
||||
'Smoother Step In' => 'smootherStepIn',
|
||||
'Smoother Step Out' => 'smootherStepOut',
|
||||
'Smoother Step In/Out' => 'smootherStepInOut',
|
||||
'Elastic In' => 'elasticIn',
|
||||
'Elastic Out' => 'elasticOut',
|
||||
'Elastic In/Out' => 'elasticInOut',
|
||||
'Back In' => 'backIn',
|
||||
'Back Out' => 'backOut',
|
||||
'Back In/Out' => 'backInOut',
|
||||
'Bounce In' => 'bounceIn',
|
||||
'Bounce Out' => 'bounceOut',
|
||||
'Bounce In/Out' => 'bounceInOut',
|
||||
'Circ In' => 'circIn',
|
||||
'Circ Out' => 'circOut',
|
||||
'Circ In/Out' => 'circInOut'
|
||||
'Instant (Ignores duration)' => 'INSTANT',
|
||||
'Sine' => 'sine',
|
||||
'Quad' => 'quad',
|
||||
'Cube' => 'cube',
|
||||
'Quart' => 'quart',
|
||||
'Quint' => 'quint',
|
||||
'Expo' => 'expo',
|
||||
'Smooth Step' => 'smoothStep',
|
||||
'Smoother Step' => 'smootherStep',
|
||||
'Elastic' => 'elastic',
|
||||
'Back' => 'back',
|
||||
'Bounce' => 'bounce',
|
||||
'Circ ' => 'circ',
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'easeDir',
|
||||
title: 'Easing Direction',
|
||||
defaultValue: 'In',
|
||||
type: SongEventFieldType.ENUM,
|
||||
keys: ['In' => 'In', 'Out' => 'Out', 'In/Out' => 'InOut']
|
||||
},
|
||||
{
|
||||
name: 'strumline',
|
||||
title: 'Target Strumline',
|
||||
|
||||
@@ -9,6 +9,14 @@ import funkin.data.event.SongEventSchema;
|
||||
*/
|
||||
class SongEvent
|
||||
{
|
||||
/**
|
||||
* These variables are used in two different events (and may be in more), and in order not to create unnecessary variables, we store them here
|
||||
*/
|
||||
public static final DEFAULT_EASE:String = 'linear';
|
||||
|
||||
public static final DEFAULT_EASE_DIR:String = 'in';
|
||||
public static final EASE_TYPE_DIR_REGEX:EReg = ~/(In|Out|InOut)$/i;
|
||||
|
||||
/**
|
||||
* The internal song event ID that this handler is responsible for.
|
||||
*/
|
||||
|
||||
@@ -51,7 +51,6 @@ class ZoomCameraSongEvent extends SongEvent
|
||||
static final DEFAULT_ZOOM:Float = 1.0;
|
||||
static final DEFAULT_DURATION:Float = 4.0;
|
||||
static final DEFAULT_MODE:String = 'direct';
|
||||
static final DEFAULT_EASE:String = 'linear';
|
||||
|
||||
public override function handleEvent(data:SongEventData):Void
|
||||
{
|
||||
@@ -68,7 +67,10 @@ class ZoomCameraSongEvent extends SongEvent
|
||||
var mode:String = data.getString('mode') ?? DEFAULT_MODE;
|
||||
var isDirectMode:Bool = mode == 'direct';
|
||||
|
||||
var ease:String = data.getString('ease') ?? DEFAULT_EASE;
|
||||
var ease:String = data.getString('ease') ?? SongEvent.DEFAULT_EASE;
|
||||
var easeDir:String = data.getString('easeDir') ?? SongEvent.DEFAULT_EASE_DIR;
|
||||
|
||||
if (SongEvent.EASE_TYPE_DIR_REGEX.match(ease) || ease == "linear") easeDir = "";
|
||||
|
||||
// If it's a string, check the value.
|
||||
switch (ease)
|
||||
@@ -77,7 +79,7 @@ class ZoomCameraSongEvent extends SongEvent
|
||||
PlayState.instance.tweenCameraZoom(zoom, 0, isDirectMode);
|
||||
default:
|
||||
var durSeconds = Conductor.instance.stepLengthMs * duration / 1000;
|
||||
var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease);
|
||||
var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease + easeDir);
|
||||
if (easeFunction == null)
|
||||
{
|
||||
trace('Invalid ease function: $ease');
|
||||
@@ -100,6 +102,7 @@ class ZoomCameraSongEvent extends SongEvent
|
||||
* 'duration': FLOAT, // Duration in steps.
|
||||
* 'mode': ENUM, // Whether zoom is relative to the stage or absolute zoom.
|
||||
* 'ease': ENUM, // Easing function.
|
||||
* 'easeDir': ENUM, // Easing function direction (In, Out, InOut).
|
||||
* }
|
||||
* @return SongEventSchema
|
||||
*/
|
||||
@@ -138,44 +141,27 @@ class ZoomCameraSongEvent extends SongEvent
|
||||
type: SongEventFieldType.ENUM,
|
||||
keys: [
|
||||
'Linear' => 'linear',
|
||||
'Instant' => 'INSTANT',
|
||||
'Sine In' => 'sineIn',
|
||||
'Sine Out' => 'sineOut',
|
||||
'Sine In/Out' => 'sineInOut',
|
||||
'Quad In' => 'quadIn',
|
||||
'Quad Out' => 'quadOut',
|
||||
'Quad In/Out' => 'quadInOut',
|
||||
'Cube In' => 'cubeIn',
|
||||
'Cube Out' => 'cubeOut',
|
||||
'Cube In/Out' => 'cubeInOut',
|
||||
'Quart In' => 'quartIn',
|
||||
'Quart Out' => 'quartOut',
|
||||
'Quart In/Out' => 'quartInOut',
|
||||
'Quint In' => 'quintIn',
|
||||
'Quint Out' => 'quintOut',
|
||||
'Quint In/Out' => 'quintInOut',
|
||||
'Expo In' => 'expoIn',
|
||||
'Expo Out' => 'expoOut',
|
||||
'Expo In/Out' => 'expoInOut',
|
||||
'Smooth Step In' => 'smoothStepIn',
|
||||
'Smooth Step Out' => 'smoothStepOut',
|
||||
'Smooth Step In/Out' => 'smoothStepInOut',
|
||||
'Smoother Step In' => 'smootherStepIn',
|
||||
'Smoother Step Out' => 'smootherStepOut',
|
||||
'Smoother Step In/Out' => 'smootherStepInOut',
|
||||
'Elastic In' => 'elasticIn',
|
||||
'Elastic Out' => 'elasticOut',
|
||||
'Elastic In/Out' => 'elasticInOut',
|
||||
'Back In' => 'backIn',
|
||||
'Back Out' => 'backOut',
|
||||
'Back In/Out' => 'backInOut',
|
||||
'Bounce In' => 'bounceIn',
|
||||
'Bounce Out' => 'bounceOut',
|
||||
'Bounce In/Out' => 'bounceInOut',
|
||||
'Circ In' => 'circIn',
|
||||
'Circ Out' => 'circOut',
|
||||
'Circ In/Out' => 'circInOut'
|
||||
'Instant (Ignores duration)' => 'INSTANT',
|
||||
'Sine' => 'sine',
|
||||
'Quad' => 'quad',
|
||||
'Cube' => 'cube',
|
||||
'Quart' => 'quart',
|
||||
'Quint' => 'quint',
|
||||
'Expo' => 'expo',
|
||||
'Smooth Step' => 'smoothStep',
|
||||
'Smoother Step' => 'smootherStep',
|
||||
'Elastic' => 'elastic',
|
||||
'Back' => 'back',
|
||||
'Bounce' => 'bounce',
|
||||
'Circ ' => 'circ',
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'easeDir',
|
||||
title: 'Easing Direction',
|
||||
defaultValue: 'In',
|
||||
type: SongEventFieldType.ENUM,
|
||||
keys: ['In' => 'In', 'Out' => 'Out', 'In/Out' => 'InOut']
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user