mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-23 16:17:53 -05:00
Merge pull request #396 from FunkinCrew/feature/focusCameraTweening
Camera easing upgrades
This commit is contained in:
commit
d481830323
10 changed files with 320 additions and 32 deletions
|
@ -706,7 +706,7 @@ abstract SongEventData(SongEventDataRaw) from SongEventDataRaw to SongEventDataR
|
||||||
this = new SongEventDataRaw(time, eventKind, value);
|
this = new SongEventDataRaw(time, eventKind, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline function valueAsStruct(?defaultKey:String = "key"):Dynamic
|
public function valueAsStruct(?defaultKey:String = "key"):Dynamic
|
||||||
{
|
{
|
||||||
if (this.value == null) return {};
|
if (this.value == null) return {};
|
||||||
if (Std.isOfType(this.value, Array))
|
if (Std.isOfType(this.value, Array))
|
||||||
|
|
|
@ -119,6 +119,8 @@ class GameOverSubState extends MusicBeatSubState
|
||||||
// Set up the visuals
|
// Set up the visuals
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var playState = PlayState.instance;
|
||||||
|
|
||||||
// Add a black background to the screen.
|
// Add a black background to the screen.
|
||||||
var bg = new FunkinSprite().makeSolidColor(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK);
|
var bg = new FunkinSprite().makeSolidColor(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK);
|
||||||
// We make this transparent so that we can see the stage underneath during debugging,
|
// We make this transparent so that we can see the stage underneath during debugging,
|
||||||
|
@ -130,13 +132,16 @@ class GameOverSubState extends MusicBeatSubState
|
||||||
|
|
||||||
// Pluck Boyfriend from the PlayState and place him (in the same position) in the GameOverSubState.
|
// Pluck Boyfriend from the PlayState and place him (in the same position) in the GameOverSubState.
|
||||||
// We can then play the character's `firstDeath` animation.
|
// We can then play the character's `firstDeath` animation.
|
||||||
boyfriend = PlayState.instance.currentStage.getBoyfriend(true);
|
boyfriend = playState.currentStage.getBoyfriend(true);
|
||||||
boyfriend.isDead = true;
|
boyfriend.isDead = true;
|
||||||
add(boyfriend);
|
add(boyfriend);
|
||||||
boyfriend.resetCharacter();
|
boyfriend.resetCharacter();
|
||||||
|
|
||||||
|
// Cancel camera tweening if it's currently active.
|
||||||
|
playState.cancelAllCameraTweens();
|
||||||
|
|
||||||
// Assign a camera follow point to the boyfriend's position.
|
// Assign a camera follow point to the boyfriend's position.
|
||||||
cameraFollowPoint = new FlxObject(PlayState.instance.cameraFollowPoint.x, PlayState.instance.cameraFollowPoint.y, 1, 1);
|
cameraFollowPoint = new FlxObject(playState.cameraFollowPoint.x, playState.cameraFollowPoint.y, 1, 1);
|
||||||
cameraFollowPoint.x = boyfriend.getGraphicMidpoint().x;
|
cameraFollowPoint.x = boyfriend.getGraphicMidpoint().x;
|
||||||
cameraFollowPoint.y = boyfriend.getGraphicMidpoint().y;
|
cameraFollowPoint.y = boyfriend.getGraphicMidpoint().y;
|
||||||
var offsets:Array<Float> = boyfriend.getDeathCameraOffsets();
|
var offsets:Array<Float> = boyfriend.getDeathCameraOffsets();
|
||||||
|
|
|
@ -237,6 +237,17 @@ class PlayState extends MusicBeatSubState
|
||||||
*/
|
*/
|
||||||
public var cameraFollowPoint:FlxObject;
|
public var cameraFollowPoint:FlxObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An FlxTween that tweens the camera to the follow point.
|
||||||
|
* Only used when tweening the camera manually, rather than tweening via follow.
|
||||||
|
*/
|
||||||
|
public var cameraFollowTween:FlxTween;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An FlxTween that zooms the camera to the desired amount.
|
||||||
|
*/
|
||||||
|
public var cameraZoomTween:FlxTween;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The camera follow point from the last stage.
|
* The camera follow point from the last stage.
|
||||||
* Used to persist the position of the `cameraFollowPosition` between levels.
|
* Used to persist the position of the `cameraFollowPosition` between levels.
|
||||||
|
@ -244,14 +255,23 @@ class PlayState extends MusicBeatSubState
|
||||||
public var previousCameraFollowPoint:FlxPoint = null;
|
public var previousCameraFollowPoint:FlxPoint = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current camera zoom level.
|
* The current camera zoom level without any modifiers applied.
|
||||||
*
|
*/
|
||||||
* The camera zoom is increased every beat, and lerped back to this value every frame, creating a smooth 'zoom-in' effect.
|
public var currentCameraZoom:Float = FlxCamera.defaultZoom * 1.05;
|
||||||
* Defaults to 1.05 but may be larger or smaller depending on the current stage,
|
|
||||||
* and may be changed by the `ZoomCamera` song event.
|
/**
|
||||||
|
* currentCameraZoom is increased every beat, and lerped back to this value every frame, creating a smooth 'zoom-in' effect.
|
||||||
|
* Defaults to 1.05, but may be larger or smaller depending on the current stage.
|
||||||
|
* Tweened via the `ZoomCamera` song event in direct mode.
|
||||||
*/
|
*/
|
||||||
public var defaultCameraZoom:Float = FlxCamera.defaultZoom * 1.05;
|
public var defaultCameraZoom:Float = FlxCamera.defaultZoom * 1.05;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Camera zoom applied on top of currentCameraZoom.
|
||||||
|
* Tweened via the `ZoomCamera` song event in additive mode.
|
||||||
|
*/
|
||||||
|
public var additiveCameraZoom:Float = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current HUD camera zoom level.
|
* The current HUD camera zoom level.
|
||||||
*
|
*
|
||||||
|
@ -397,10 +417,15 @@ class PlayState extends MusicBeatSubState
|
||||||
var startingSong:Bool = false;
|
var startingSong:Bool = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* False if `FlxG.sound.music`
|
* Track if we currently have the music paused for a Pause substate, so we can unpause it when we return.
|
||||||
*/
|
*/
|
||||||
var musicPausedBySubState:Bool = false;
|
var musicPausedBySubState:Bool = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Track any camera tweens we've paused for a Pause substate, so we can unpause them when we return.
|
||||||
|
*/
|
||||||
|
var cameraTweensPausedBySubState:List<FlxTween> = new List<FlxTween>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* False until `create()` has completed.
|
* False until `create()` has completed.
|
||||||
*/
|
*/
|
||||||
|
@ -943,7 +968,9 @@ class PlayState extends MusicBeatSubState
|
||||||
// Lerp the camera zoom towards the target level.
|
// Lerp the camera zoom towards the target level.
|
||||||
if (subState == null)
|
if (subState == null)
|
||||||
{
|
{
|
||||||
FlxG.camera.zoom = FlxMath.lerp(defaultCameraZoom, FlxG.camera.zoom, 0.95);
|
currentCameraZoom = FlxMath.lerp(defaultCameraZoom, currentCameraZoom, 0.95);
|
||||||
|
FlxG.camera.zoom = currentCameraZoom + additiveCameraZoom;
|
||||||
|
|
||||||
camHUD.zoom = FlxMath.lerp(defaultHUDCameraZoom, camHUD.zoom, 0.95);
|
camHUD.zoom = FlxMath.lerp(defaultHUDCameraZoom, camHUD.zoom, 0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1121,14 +1148,30 @@ class PlayState extends MusicBeatSubState
|
||||||
// Pause the music.
|
// Pause the music.
|
||||||
if (FlxG.sound.music != null)
|
if (FlxG.sound.music != null)
|
||||||
{
|
{
|
||||||
musicPausedBySubState = FlxG.sound.music.playing;
|
if (FlxG.sound.music.playing)
|
||||||
if (musicPausedBySubState)
|
|
||||||
{
|
{
|
||||||
FlxG.sound.music.pause();
|
FlxG.sound.music.pause();
|
||||||
|
musicPausedBySubState = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pause vocals.
|
||||||
|
// Not tracking that we've done this via a bool because vocal re-syncing involves pausing the vocals anyway.
|
||||||
if (vocals != null) vocals.pause();
|
if (vocals != null) vocals.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pause camera tweening, and keep track of which tweens we pause.
|
||||||
|
if (cameraFollowTween != null && cameraFollowTween.active)
|
||||||
|
{
|
||||||
|
cameraFollowTween.active = false;
|
||||||
|
cameraTweensPausedBySubState.add(cameraFollowTween);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cameraZoomTween != null && cameraZoomTween.active)
|
||||||
|
{
|
||||||
|
cameraZoomTween.active = false;
|
||||||
|
cameraTweensPausedBySubState.add(cameraZoomTween);
|
||||||
|
}
|
||||||
|
|
||||||
// Pause the countdown.
|
// Pause the countdown.
|
||||||
Countdown.pauseCountdown();
|
Countdown.pauseCountdown();
|
||||||
}
|
}
|
||||||
|
@ -1150,17 +1193,26 @@ class PlayState extends MusicBeatSubState
|
||||||
|
|
||||||
if (event.eventCanceled) return;
|
if (event.eventCanceled) return;
|
||||||
|
|
||||||
// Resume
|
// Resume music if we paused it.
|
||||||
if (musicPausedBySubState)
|
if (musicPausedBySubState)
|
||||||
{
|
{
|
||||||
FlxG.sound.music.play();
|
FlxG.sound.music.play();
|
||||||
|
musicPausedBySubState = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resume camera tweens if we paused any.
|
||||||
|
for (camTween in cameraTweensPausedBySubState)
|
||||||
|
{
|
||||||
|
camTween.active = true;
|
||||||
|
}
|
||||||
|
cameraTweensPausedBySubState.clear();
|
||||||
|
|
||||||
if (currentConversation != null)
|
if (currentConversation != null)
|
||||||
{
|
{
|
||||||
currentConversation.resumeMusic();
|
currentConversation.resumeMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-sync vocals.
|
||||||
if (FlxG.sound.music != null && !startingSong && !isInCutscene) resyncVocals();
|
if (FlxG.sound.music != null && !startingSong && !isInCutscene) resyncVocals();
|
||||||
|
|
||||||
// Resume the countdown.
|
// Resume the countdown.
|
||||||
|
@ -1308,7 +1360,7 @@ class PlayState extends MusicBeatSubState
|
||||||
if (FlxG.camera.zoom < (1.35 * defaultCameraZoom) && cameraZoomRate > 0 && Conductor.instance.currentBeat % cameraZoomRate == 0)
|
if (FlxG.camera.zoom < (1.35 * defaultCameraZoom) && cameraZoomRate > 0 && Conductor.instance.currentBeat % cameraZoomRate == 0)
|
||||||
{
|
{
|
||||||
// Zoom camera in (1.5%)
|
// Zoom camera in (1.5%)
|
||||||
FlxG.camera.zoom += cameraZoomIntensity * defaultCameraZoom;
|
currentCameraZoom += cameraZoomIntensity * defaultCameraZoom;
|
||||||
// Hud zooms double (3%)
|
// Hud zooms double (3%)
|
||||||
camHUD.zoom += hudCameraZoomIntensity * defaultHUDCameraZoom;
|
camHUD.zoom += hudCameraZoomIntensity * defaultHUDCameraZoom;
|
||||||
}
|
}
|
||||||
|
@ -1500,6 +1552,11 @@ class PlayState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
// Apply camera zoom level from stage data.
|
// Apply camera zoom level from stage data.
|
||||||
defaultCameraZoom = currentStage.camZoom;
|
defaultCameraZoom = currentStage.camZoom;
|
||||||
|
currentCameraZoom = defaultCameraZoom;
|
||||||
|
FlxG.camera.zoom = currentCameraZoom;
|
||||||
|
|
||||||
|
// Reset additive zoom.
|
||||||
|
additiveCameraZoom = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2847,6 +2904,9 @@ class PlayState extends MusicBeatSubState
|
||||||
*/
|
*/
|
||||||
function performCleanup():Void
|
function performCleanup():Void
|
||||||
{
|
{
|
||||||
|
// If the camera is being tweened, stop it.
|
||||||
|
cancelAllCameraTweens();
|
||||||
|
|
||||||
if (currentConversation != null)
|
if (currentConversation != null)
|
||||||
{
|
{
|
||||||
remove(currentConversation);
|
remove(currentConversation);
|
||||||
|
@ -2905,6 +2965,9 @@ class PlayState extends MusicBeatSubState
|
||||||
// Stop camera zooming on beat.
|
// Stop camera zooming on beat.
|
||||||
cameraZoomRate = 0;
|
cameraZoomRate = 0;
|
||||||
|
|
||||||
|
// Cancel camera tweening if it's active.
|
||||||
|
cancelAllCameraTweens();
|
||||||
|
|
||||||
// If the opponent is GF, zoom in on the opponent.
|
// If the opponent is GF, zoom in on the opponent.
|
||||||
// Else, if there is no GF, zoom in on BF.
|
// Else, if there is no GF, zoom in on BF.
|
||||||
// Else, zoom in on GF.
|
// Else, zoom in on GF.
|
||||||
|
@ -2991,15 +3054,119 @@ class PlayState extends MusicBeatSubState
|
||||||
/**
|
/**
|
||||||
* Resets the camera's zoom level and focus point.
|
* Resets the camera's zoom level and focus point.
|
||||||
*/
|
*/
|
||||||
public function resetCamera():Void
|
public function resetCamera(?resetZoom:Bool = true, ?cancelTweens:Bool = true):Void
|
||||||
{
|
{
|
||||||
|
// Cancel camera tweens if any are active.
|
||||||
|
if (cancelTweens)
|
||||||
|
{
|
||||||
|
cancelAllCameraTweens();
|
||||||
|
}
|
||||||
|
|
||||||
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.04);
|
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.04);
|
||||||
FlxG.camera.targetOffset.set();
|
FlxG.camera.targetOffset.set();
|
||||||
FlxG.camera.zoom = defaultCameraZoom;
|
|
||||||
|
if (resetZoom)
|
||||||
|
{
|
||||||
|
resetCameraZoom();
|
||||||
|
}
|
||||||
|
|
||||||
// Snap the camera to the follow point immediately.
|
// Snap the camera to the follow point immediately.
|
||||||
FlxG.camera.focusOn(cameraFollowPoint.getPosition());
|
FlxG.camera.focusOn(cameraFollowPoint.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables camera following and tweens the camera to the follow point manually.
|
||||||
|
*/
|
||||||
|
public function tweenCameraToFollowPoint(?duration:Float, ?ease:Null<Float->Float>):Void
|
||||||
|
{
|
||||||
|
// Cancel the current tween if it's active.
|
||||||
|
cancelCameraFollowTween();
|
||||||
|
|
||||||
|
if (duration == 0)
|
||||||
|
{
|
||||||
|
// Instant movement. Just reset the camera to force it to the follow point.
|
||||||
|
resetCamera(false, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Disable camera following for the duration of the tween.
|
||||||
|
FlxG.camera.target = null;
|
||||||
|
|
||||||
|
// Follow tween! Caching it so we can cancel/pause it later if needed.
|
||||||
|
var followPos:FlxPoint = cameraFollowPoint.getPosition() - FlxPoint.weak(FlxG.camera.width * 0.5, FlxG.camera.height * 0.5);
|
||||||
|
cameraFollowTween = FlxTween.tween(FlxG.camera.scroll, {x: followPos.x, y: followPos.y}, duration,
|
||||||
|
{
|
||||||
|
ease: ease,
|
||||||
|
onComplete: function(_) {
|
||||||
|
resetCamera(false, false); // Re-enable camera following when the tween is complete.
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cancelCameraFollowTween()
|
||||||
|
{
|
||||||
|
if (cameraFollowTween != null)
|
||||||
|
{
|
||||||
|
cameraFollowTween.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tweens the camera zoom to the desired amount.
|
||||||
|
*/
|
||||||
|
public function tweenCameraZoom(?zoom:Float, ?duration:Float, ?directMode:Bool, ?ease:Null<Float->Float>):Void
|
||||||
|
{
|
||||||
|
// Cancel the current tween if it's active.
|
||||||
|
cancelCameraZoomTween();
|
||||||
|
|
||||||
|
var targetZoom = zoom * FlxCamera.defaultZoom;
|
||||||
|
|
||||||
|
if (directMode) // Direct mode: Tween defaultCameraZoom for basic "smooth" zooms.
|
||||||
|
{
|
||||||
|
if (duration == 0)
|
||||||
|
{
|
||||||
|
// Instant zoom. No tween needed.
|
||||||
|
defaultCameraZoom = targetZoom;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Zoom tween! Caching it so we can cancel/pause it later if needed.
|
||||||
|
cameraZoomTween = FlxTween.tween(this, {defaultCameraZoom: targetZoom}, duration, {ease: ease});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Additive mode: Tween additiveCameraZoom for ease-based zooms.
|
||||||
|
{
|
||||||
|
if (duration == 0)
|
||||||
|
{
|
||||||
|
// Instant zoom. No tween needed.
|
||||||
|
additiveCameraZoom = targetZoom;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Zoom tween! Caching it so we can cancel/pause it later if needed.
|
||||||
|
cameraZoomTween = FlxTween.tween(this, {additiveCameraZoom: targetZoom}, duration, {ease: ease});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cancelCameraZoomTween()
|
||||||
|
{
|
||||||
|
if (cameraZoomTween != null)
|
||||||
|
{
|
||||||
|
cameraZoomTween.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel all active camera tweens simultaneously.
|
||||||
|
*/
|
||||||
|
public function cancelAllCameraTweens()
|
||||||
|
{
|
||||||
|
cancelCameraFollowTween();
|
||||||
|
cancelCameraZoomTween();
|
||||||
|
}
|
||||||
|
|
||||||
#if (debug || FORCE_DEBUG_VERSION)
|
#if (debug || FORCE_DEBUG_VERSION)
|
||||||
/**
|
/**
|
||||||
* Jumps forward or backward a number of sections in the song.
|
* Jumps forward or backward a number of sections in the song.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package funkin.play.event;
|
package funkin.play.event;
|
||||||
|
|
||||||
|
import flixel.tweens.FlxEase;
|
||||||
// Data from the chart
|
// Data from the chart
|
||||||
import funkin.data.song.SongData;
|
import funkin.data.song.SongData;
|
||||||
import funkin.data.song.SongData.SongEventData;
|
import funkin.data.song.SongData.SongEventData;
|
||||||
|
@ -69,6 +70,13 @@ class FocusCameraSongEvent extends SongEvent
|
||||||
|
|
||||||
if (char == null) char = cast data.value;
|
if (char == null) char = cast data.value;
|
||||||
|
|
||||||
|
var useTween:Null<Bool> = data.getBool('useTween');
|
||||||
|
if (useTween == null) useTween = false;
|
||||||
|
var duration:Null<Float> = data.getFloat('duration');
|
||||||
|
if (duration == null) duration = 4.0;
|
||||||
|
var ease:Null<String> = data.getString('ease');
|
||||||
|
if (ease == null) ease = 'linear';
|
||||||
|
|
||||||
switch (char)
|
switch (char)
|
||||||
{
|
{
|
||||||
case -1: // Position
|
case -1: // Position
|
||||||
|
@ -117,6 +125,26 @@ class FocusCameraSongEvent extends SongEvent
|
||||||
default:
|
default:
|
||||||
trace('Unknown camera focus: ' + data);
|
trace('Unknown camera focus: ' + data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (useTween)
|
||||||
|
{
|
||||||
|
switch (ease)
|
||||||
|
{
|
||||||
|
case 'INSTANT':
|
||||||
|
PlayState.instance.tweenCameraToFollowPoint(0);
|
||||||
|
default:
|
||||||
|
var durSeconds = Conductor.instance.stepLengthMs * duration / 1000;
|
||||||
|
|
||||||
|
var easeFunction:Null<Float->Float> = Reflect.field(FlxEase, ease);
|
||||||
|
if (easeFunction == null)
|
||||||
|
{
|
||||||
|
trace('Invalid ease function: $ease');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayState.instance.tweenCameraToFollowPoint(durSeconds, easeFunction);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override function getTitle():String
|
public override function getTitle():String
|
||||||
|
@ -158,6 +186,51 @@ class FocusCameraSongEvent extends SongEvent
|
||||||
step: 10.0,
|
step: 10.0,
|
||||||
type: SongEventFieldType.FLOAT,
|
type: SongEventFieldType.FLOAT,
|
||||||
units: "px"
|
units: "px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'useTween',
|
||||||
|
title: 'Use Tween',
|
||||||
|
type: SongEventFieldType.BOOL,
|
||||||
|
defaultValue: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'duration',
|
||||||
|
title: 'Duration',
|
||||||
|
defaultValue: 4.0,
|
||||||
|
step: 0.5,
|
||||||
|
type: SongEventFieldType.FLOAT,
|
||||||
|
units: 'steps'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ease',
|
||||||
|
title: 'Easing Type',
|
||||||
|
defaultValue: 'linear',
|
||||||
|
type: SongEventFieldType.ENUM,
|
||||||
|
keys: [
|
||||||
|
'Linear' => 'linear',
|
||||||
|
'Instant' => 'INSTANT',
|
||||||
|
'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',
|
||||||
|
'Smooth Step In' => 'smoothStepIn',
|
||||||
|
'Smooth Step Out' => 'smoothStepOut',
|
||||||
|
'Smooth Step In/Out' => 'smoothStepInOut',
|
||||||
|
'Sine In' => 'sineIn',
|
||||||
|
'Sine Out' => 'sineOut',
|
||||||
|
'Sine In/Out' => 'sineInOut',
|
||||||
|
'Elastic In' => 'elasticIn',
|
||||||
|
'Elastic Out' => 'elasticOut',
|
||||||
|
'Elastic In/Out' => 'elasticInOut',
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,19 +62,26 @@ class ZoomCameraSongEvent extends SongEvent
|
||||||
|
|
||||||
var zoom:Null<Float> = data.getFloat('zoom');
|
var zoom:Null<Float> = data.getFloat('zoom');
|
||||||
if (zoom == null) zoom = 1.0;
|
if (zoom == null) zoom = 1.0;
|
||||||
|
|
||||||
var duration:Null<Float> = data.getFloat('duration');
|
var duration:Null<Float> = data.getFloat('duration');
|
||||||
if (duration == null) duration = 4.0;
|
if (duration == null) duration = 4.0;
|
||||||
|
|
||||||
|
var mode:Null<String> = data.getString('mode');
|
||||||
|
if (mode == null) mode = 'additive';
|
||||||
|
|
||||||
var ease:Null<String> = data.getString('ease');
|
var ease:Null<String> = data.getString('ease');
|
||||||
if (ease == null) ease = 'linear';
|
if (ease == null) ease = 'linear';
|
||||||
|
|
||||||
|
var directMode:Bool = mode == 'direct';
|
||||||
|
|
||||||
// If it's a string, check the value.
|
// If it's a string, check the value.
|
||||||
switch (ease)
|
switch (ease)
|
||||||
{
|
{
|
||||||
case 'INSTANT':
|
case 'INSTANT':
|
||||||
// Set the zoom. Use defaultCameraZoom to prevent breaking camera bops.
|
PlayState.instance.tweenCameraZoom(zoom, 0, directMode);
|
||||||
PlayState.instance.defaultCameraZoom = zoom * FlxCamera.defaultZoom;
|
|
||||||
default:
|
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);
|
||||||
if (easeFunction == null)
|
if (easeFunction == null)
|
||||||
{
|
{
|
||||||
|
@ -82,8 +89,7 @@ class ZoomCameraSongEvent extends SongEvent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlxTween.tween(PlayState.instance, {defaultCameraZoom: zoom * FlxCamera.defaultZoom}, (Conductor.instance.stepLengthMs * duration / 1000),
|
PlayState.instance.tweenCameraZoom(zoom, durSeconds, directMode, easeFunction);
|
||||||
{ease: easeFunction});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +102,9 @@ class ZoomCameraSongEvent extends SongEvent
|
||||||
* ```
|
* ```
|
||||||
* {
|
* {
|
||||||
* 'zoom': FLOAT, // Target zoom level.
|
* 'zoom': FLOAT, // Target zoom level.
|
||||||
* 'duration': FLOAT, // Optional duration in steps
|
* 'duration': FLOAT, // Optional duration in steps.
|
||||||
* 'ease': ENUM, // Optional easing function
|
* 'mode': ENUM, // Whether to set additive zoom or direct zoom.
|
||||||
|
* 'ease': ENUM, // Optional easing function.
|
||||||
* }
|
* }
|
||||||
* @return SongEventSchema
|
* @return SongEventSchema
|
||||||
*/
|
*/
|
||||||
|
@ -120,6 +127,13 @@ class ZoomCameraSongEvent extends SongEvent
|
||||||
type: SongEventFieldType.FLOAT,
|
type: SongEventFieldType.FLOAT,
|
||||||
units: 'steps'
|
units: 'steps'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'mode',
|
||||||
|
title: 'Mode',
|
||||||
|
defaultValue: 'additive',
|
||||||
|
type: SongEventFieldType.ENUM,
|
||||||
|
keys: ['Additive' => 'additive', 'Direct' => 'direct']
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'ease',
|
name: 'ease',
|
||||||
title: 'Easing Type',
|
title: 'Easing Type',
|
||||||
|
|
|
@ -878,6 +878,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
||||||
*/
|
*/
|
||||||
var noteDisplayDirty:Bool = true;
|
var noteDisplayDirty:Bool = true;
|
||||||
|
|
||||||
|
var noteTooltipsDirty:Bool = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the selected charactesr have been modified and the health icons need to be updated.
|
* Whether the selected charactesr have been modified and the health icons need to be updated.
|
||||||
*/
|
*/
|
||||||
|
@ -1541,6 +1543,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
||||||
// Make sure view is updated when the variation changes.
|
// Make sure view is updated when the variation changes.
|
||||||
noteDisplayDirty = true;
|
noteDisplayDirty = true;
|
||||||
notePreviewDirty = true;
|
notePreviewDirty = true;
|
||||||
|
noteTooltipsDirty = true;
|
||||||
notePreviewViewportBoundsDirty = true;
|
notePreviewViewportBoundsDirty = true;
|
||||||
|
|
||||||
switchToCurrentInstrumental();
|
switchToCurrentInstrumental();
|
||||||
|
@ -1562,6 +1565,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
||||||
// Make sure view is updated when the difficulty changes.
|
// Make sure view is updated when the difficulty changes.
|
||||||
noteDisplayDirty = true;
|
noteDisplayDirty = true;
|
||||||
notePreviewDirty = true;
|
notePreviewDirty = true;
|
||||||
|
noteTooltipsDirty = true;
|
||||||
notePreviewViewportBoundsDirty = true;
|
notePreviewViewportBoundsDirty = true;
|
||||||
|
|
||||||
// Make sure the difficulty we selected is in the list of difficulties.
|
// Make sure the difficulty we selected is in the list of difficulties.
|
||||||
|
@ -3663,8 +3667,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
||||||
selectionSquare.width = eventSprite.width;
|
selectionSquare.width = eventSprite.width;
|
||||||
selectionSquare.height = eventSprite.height;
|
selectionSquare.height = eventSprite.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Additional cleanup on notes.
|
||||||
|
if (noteTooltipsDirty) eventSprite.updateTooltipText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noteTooltipsDirty = false;
|
||||||
|
|
||||||
// Sort the notes DESCENDING. This keeps the sustain behind the associated note.
|
// Sort the notes DESCENDING. This keeps the sustain behind the associated note.
|
||||||
renderedNotes.sort(FlxSort.byY, FlxSort.DESCENDING); // TODO: .group.insertionSort()
|
renderedNotes.sort(FlxSort.byY, FlxSort.DESCENDING); // TODO: .group.insertionSort()
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,12 @@ class SetItemSelectionCommand implements ChartEditorCommand
|
||||||
}
|
}
|
||||||
var eventData = eventSelected.valueAsStruct(defaultKey);
|
var eventData = eventSelected.valueAsStruct(defaultKey);
|
||||||
|
|
||||||
state.eventDataToPlace = eventData;
|
var eventDataClone = Reflect.copy(eventData);
|
||||||
|
|
||||||
|
if (eventDataClone != null)
|
||||||
|
{
|
||||||
|
state.eventDataToPlace = eventDataClone;
|
||||||
|
}
|
||||||
|
|
||||||
state.refreshToolbox(ChartEditorState.CHART_EDITOR_TOOLBOX_EVENT_DATA_LAYOUT);
|
state.refreshToolbox(ChartEditorState.CHART_EDITOR_TOOLBOX_EVENT_DATA_LAYOUT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,8 +164,7 @@ class ChartEditorEventSprite extends FlxSprite
|
||||||
this.eventData = value;
|
this.eventData = value;
|
||||||
// Update the position to match the note data.
|
// Update the position to match the note data.
|
||||||
updateEventPosition();
|
updateEventPosition();
|
||||||
// Update the tooltip text.
|
updateTooltipText();
|
||||||
this.tooltip.tipData = {text: this.eventData.buildTooltip()};
|
|
||||||
return this.eventData;
|
return this.eventData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,6 +187,13 @@ class ChartEditorEventSprite extends FlxSprite
|
||||||
this.updateTooltipPosition();
|
this.updateTooltipPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateTooltipText():Void
|
||||||
|
{
|
||||||
|
if (this.eventData == null) return;
|
||||||
|
if (this.isGhost) return;
|
||||||
|
this.tooltip.tipData = {text: this.eventData.buildTooltip()};
|
||||||
|
}
|
||||||
|
|
||||||
public function updateTooltipPosition():Void
|
public function updateTooltipPosition():Void
|
||||||
{
|
{
|
||||||
// No tooltip for ghost sprites.
|
// No tooltip for ghost sprites.
|
||||||
|
|
|
@ -237,6 +237,11 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
|
||||||
{
|
{
|
||||||
value = event.target.value.value;
|
value = event.target.value.value;
|
||||||
}
|
}
|
||||||
|
else if (field.type == BOOL)
|
||||||
|
{
|
||||||
|
var chk:CheckBox = cast event.target;
|
||||||
|
value = cast(chk.selected, Null<Bool>); // Need to cast to nullable bool or the compiler will get mad.
|
||||||
|
}
|
||||||
|
|
||||||
trace('ChartEditorToolboxHandler.buildEventDataFormFromSchema() - ${event.target.id} = ${value}');
|
trace('ChartEditorToolboxHandler.buildEventDataFormFromSchema() - ${event.target.id} = ${value}');
|
||||||
|
|
||||||
|
@ -253,14 +258,15 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
|
||||||
// Edit the event data of any existing events.
|
// Edit the event data of any existing events.
|
||||||
if (!_initializing && chartEditorState.currentEventSelection.length > 0)
|
if (!_initializing && chartEditorState.currentEventSelection.length > 0)
|
||||||
{
|
{
|
||||||
for (event in chartEditorState.currentEventSelection)
|
for (songEvent in chartEditorState.currentEventSelection)
|
||||||
{
|
{
|
||||||
event.eventKind = chartEditorState.eventKindToPlace;
|
songEvent.eventKind = chartEditorState.eventKindToPlace;
|
||||||
event.value = chartEditorState.eventDataToPlace;
|
songEvent.value = Reflect.copy(chartEditorState.eventDataToPlace);
|
||||||
}
|
}
|
||||||
chartEditorState.saveDataDirty = true;
|
chartEditorState.saveDataDirty = true;
|
||||||
chartEditorState.noteDisplayDirty = true;
|
chartEditorState.noteDisplayDirty = true;
|
||||||
chartEditorState.notePreviewDirty = true;
|
chartEditorState.notePreviewDirty = true;
|
||||||
|
chartEditorState.noteTooltipsDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,11 @@ class StageOffsetSubState extends HaxeUISubState
|
||||||
{
|
{
|
||||||
super.create();
|
super.create();
|
||||||
|
|
||||||
|
var playState = PlayState.instance;
|
||||||
|
|
||||||
FlxG.mouse.visible = true;
|
FlxG.mouse.visible = true;
|
||||||
PlayState.instance.pauseMusic();
|
playState.pauseMusic();
|
||||||
|
playState.cancelAllCameraTweens();
|
||||||
FlxG.camera.target = null;
|
FlxG.camera.target = null;
|
||||||
|
|
||||||
setupUIListeners();
|
setupUIListeners();
|
||||||
|
@ -63,8 +66,8 @@ class StageOffsetSubState extends HaxeUISubState
|
||||||
|
|
||||||
// add(uiStuff);
|
// add(uiStuff);
|
||||||
|
|
||||||
PlayState.instance.persistentUpdate = true;
|
playState.persistentUpdate = true;
|
||||||
component.cameras = [PlayState.instance.camHUD];
|
component.cameras = [playState.camHUD];
|
||||||
// uiStuff.cameras = [PlayState.instance.camHUD];
|
// uiStuff.cameras = [PlayState.instance.camHUD];
|
||||||
// btn.cameras = [PlayState.instance.camHUD];
|
// btn.cameras = [PlayState.instance.camHUD];
|
||||||
|
|
||||||
|
@ -72,7 +75,7 @@ class StageOffsetSubState extends HaxeUISubState
|
||||||
|
|
||||||
var layerList:ListView = findComponent("prop-layers");
|
var layerList:ListView = findComponent("prop-layers");
|
||||||
|
|
||||||
for (thing in PlayState.instance.currentStage)
|
for (thing in playState.currentStage)
|
||||||
{
|
{
|
||||||
var prop:StageProp = cast thing;
|
var prop:StageProp = cast thing;
|
||||||
if (prop != null && prop.name != null)
|
if (prop != null && prop.name != null)
|
||||||
|
|
Loading…
Reference in a new issue