diff --git a/source/flixel/system/ui/FlxSoundTray.hx b/source/flixel/system/ui/FlxSoundTray.hx index ea2956c7a0..fd59875d5d 100644 --- a/source/flixel/system/ui/FlxSoundTray.hx +++ b/source/flixel/system/ui/FlxSoundTray.hx @@ -21,9 +21,16 @@ import funkin.util.MathUtil; import flixel.system.FlxAssets.FlxSoundAsset; import funkin.Paths; + import openfl.display.animation.AnimatedSprite; +/* W.I.P +import flixel.FlxCamera; +import flixel.FlxSprite; +*/ + + /** * The flixel sound tray, the little volume meter that pops down sometimes. * Accessed via `FlxG.game.soundTray` or `FlxG.sound.soundTray`. @@ -48,6 +55,11 @@ class FlxSoundTray extends Sprite var splashSprite:AnimatedSprite; var _volumeSprite:Bitmap; + /* + var renderCamera:FlxCamera; + var splashSprite:FlxSprite; + */ + @:keep public function new() { @@ -79,6 +91,24 @@ class FlxSoundTray extends Sprite addChild(_volumeSprite); addChild(splashSprite); + + /* + splashSprite = new FlxSprite(); + splashSprite.frames = Paths.getSparrowAtlas("soundtray/volume"); + splashSprite.animation.addByPrefix("splash", "volume back", 1, true); //false + splashSprite.animation.play("splash", true); + trace(splashSprite.frames == null); + trace(splashSprite.animation == null); + + renderCamera = new FlxCamera(0, 0, Std.int(splashSprite.width), Std.int(splashSprite.height)); + renderCamera.bgColor = FlxColor.TRANSPARENT; + splashSprite.camera = renderCamera; + _width = renderCamera.width; + addChild(renderCamera.flashSprite); + + FlxG.signals.gameResized.add((w, h) -> renderCamera.onResize()); + */ + _requestedY = y = -height; //_requestedY = y = 0; visible = false; @@ -87,8 +117,10 @@ class FlxSoundTray extends Sprite public function update(MS:Float):Void { if (active) { - _volumeSprite.width = MathUtil.fpsLerp(_volumeSprite.width, FlxG.sound.muted ? 0 : (237 * FlxG.sound.volume), MathUtil.getFPSRatio(.65)); //.15 + //renderSelf(); + _volumeSprite.width = MathUtil.fpsLerp(_volumeSprite.width, FlxG.sound.muted ? 0 : (237 * FlxG.sound.volume), MathUtil.getFPSRatio(.65)); //.15 + if (_localTimer >= timeToExist) _requestedY = -height; y = MathUtil.fpsLerp(y, _requestedY, MathUtil.getFPSRatio(.25)); //.15 @@ -97,6 +129,36 @@ class FlxSoundTray extends Sprite } } + /* + @:access(flixel.FlxCamera) + public function renderSelf():Void + { + splashSprite.update(FlxG.elapsed); + renderCamera.update(FlxG.elapsed); + + // CAM LOCK + renderCamera.clearDrawStack(); + renderCamera.canvas.graphics.clear(); + // Clearing camera's debug sprite + #if FLX_DEBUG + renderCamera.debugLayer.graphics.clear(); + #end + + renderCamera.fill(renderCamera.bgColor.to24Bit(), renderCamera.useBgAlphaBlending, renderCamera.bgColor.alphaFloat); + // CAM LOCK + + // DRAW + splashSprite.draw(); + renderCamera.render(); + // DRAW + + // CAM UNLOCK + renderCamera.canvas.graphics.overrideBlendMode(null); + renderCamera.drawFX(); + // CAM UNLOCK + } + */ + public function show(up:Bool = false, ?forceSound:Bool = true):Void { var globalVolume:Int = Math.round(FlxG.sound.volume * 20); @@ -118,9 +180,12 @@ class FlxSoundTray extends Sprite if (shouldShow) { visible = true; active = true; + splashSprite.animation.curAnim.finished = false; splashSprite.animation.curAnim.looped = false; splashSprite.animation.curAnim.play(true); + + //splashSprite.animation.play("splash", true); _localTimer = _requestedY = 0; } diff --git a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx index a686fe41c0..0ad201ba17 100644 --- a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx +++ b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx @@ -47,7 +47,7 @@ class FlxAtlasSprite extends FlxAnimate if (this.anim.curInstance == null) throw 'FlxAtlasSprite not initialized properly. Are you sure the path (${path}) exists?'; - anim.onComplete = () -> onAnimationFinish.dispatch(currentAnimation); + anim.onComplete.add(() -> onAnimationFinish.dispatch(currentAnimation)); onAnimationFinish.add(cleanupAnimation); // This defaults the sprite to play the first animation in the atlas, @@ -62,7 +62,7 @@ class FlxAtlasSprite extends FlxAnimate public function listAnimations():Array { if (this.anim == null) return []; - return this.anim.getFrameLabels(); + return this.anim.getFrameLabelNames(); // return [""]; } diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 033950c447..01407be103 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -2665,10 +2665,10 @@ class PlayState extends MusicBeatSubState //#if (debug || FORCE_DEBUG_VERSION) // PAGEUP: Skip forward two sections. // SHIFT+PAGEUP: Skip forward twenty sections. - if (FlxG.keys.justPressed.PAGEUP) changeSection(FlxG.keys.pressed.SHIFT ? 20 : 2); + if (FlxG.keys.justPressed.PAGEUP) changeSection(FlxG.keys.pressed.SHIFT ? 8 : 2); // PAGEDOWN: Skip backward two section. Doesn't replace notes. // SHIFT+PAGEDOWN: Skip backward twenty sections. - if (FlxG.keys.justPressed.PAGEDOWN) changeSection(FlxG.keys.pressed.SHIFT ? -20 : -2); + if (FlxG.keys.justPressed.PAGEDOWN) changeSection(FlxG.keys.pressed.SHIFT ? -8 : -2); //#end if (FlxG.keys.justPressed.B) trace(inputSpitter.join('\n')); diff --git a/source/funkin/play/ResultState.hx b/source/funkin/play/ResultState.hx index dbad973bae..2c820a58d8 100644 --- a/source/funkin/play/ResultState.hx +++ b/source/funkin/play/ResultState.hx @@ -165,20 +165,22 @@ class ResultState extends MusicBeatSubState heartsPerfect.zIndex = 501; add(heartsPerfect); - heartsPerfect.anim.onComplete = () -> { + heartsPerfect.anim.onComplete.removeAll(); + heartsPerfect.anim.onComplete.add(() -> { if (heartsPerfect != null) heartsPerfect.anim.play("hearts full anim", true, false, 43); // unpauses this anim, since it's on PlayOnce! - }; + }); bfPerfect = new FlxAtlasSprite(1342, 370, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT", "shared")); bfPerfect.visible = false; bfPerfect.zIndex = 500; add(bfPerfect); - bfPerfect.anim.onComplete = () -> { + bfPerfect.anim.onComplete.removeAll(); + bfPerfect.anim.onComplete.add(() -> { if (bfPerfect != null) bfPerfect.anim.play("boyfriend perfect rank", true, false, 137); // unpauses this anim, since it's on PlayOnce! - }; + }); case EXCELLENT: bfExcellent = new FlxAtlasSprite(1329, 429, Paths.animateAtlas("resultScreen/results-bf/resultsEXCELLENT", "shared")); @@ -186,10 +188,11 @@ class ResultState extends MusicBeatSubState bfExcellent.zIndex = 500; add(bfExcellent); - bfExcellent.anim.onComplete = () -> { + bfExcellent.anim.onComplete.removeAll(); + bfExcellent.anim.onComplete.addOnce(() -> { if (bfExcellent != null) bfExcellent.anim.play("bf results excellent", true, false, 28); // unpauses this anim, since it's on PlayOnce! - }; + }); case GREAT: gfGreat = new FlxAtlasSprite(802, 331, Paths.animateAtlas("resultScreen/results-bf/resultsGREAT/gf", "shared")); @@ -199,10 +202,11 @@ class ResultState extends MusicBeatSubState gfGreat.scale.set(0.93, 0.93); - gfGreat.anim.onComplete = () -> { + gfGreat.anim.onComplete.removeAll(); + gfGreat.anim.onComplete.addOnce(() -> { if (gfGreat != null) gfGreat.anim.play("gf jumping", true, false, 9); // unpauses this anim, since it's on PlayOnce! - }; + }); bfGreat = new FlxAtlasSprite(929, 363, Paths.animateAtlas("resultScreen/results-bf/resultsGREAT/bf", "shared")); bfGreat.visible = false; @@ -211,17 +215,18 @@ class ResultState extends MusicBeatSubState bfGreat.scale.set(0.93, 0.93); - bfGreat.anim.onComplete = () -> { + bfGreat.anim.onComplete.removeAll(); + bfGreat.anim.onComplete.addOnce(() -> { if (bfGreat != null) bfGreat.anim.play("bf jumping ", true, false, 15); // unpauses this anim, since it's on PlayOnce! - }; + }); case GOOD: gfGood = FunkinSprite.createSparrow(625, 325, 'resultScreen/results-bf/resultsGOOD/resultGirlfriendGOOD'); gfGood.animation.addByPrefix("clap", "Girlfriend Good Anim", 24, false); gfGood.visible = false; gfGood.zIndex = 500; - gfGood.animation.finishCallback = _ -> { + gfGood.animation.finishCallback = (_) -> { if (gfGood != null) { gfGood.animation.play('clap', true, false, 9); @@ -235,9 +240,7 @@ class ResultState extends MusicBeatSubState bfGood.zIndex = 501; bfGood.animation.finishCallback = function(_) { if (bfGood != null) - { bfGood.animation.play('fall', true, false, 14); - } }; add(bfGood); @@ -246,11 +249,11 @@ class ResultState extends MusicBeatSubState bfShit.visible = false; bfShit.zIndex = 500; add(bfShit); - bfShit.onAnimationFinish.add((animName) -> { + + bfShit.anim.onComplete.removeAll(); + bfShit.anim.onComplete.addOnce(() -> { if (bfShit != null) - { bfShit.playAnimation('Loop Start'); - } }); } diff --git a/source/funkin/play/stage/Bopper.hx b/source/funkin/play/stage/Bopper.hx index 35672d3807..4c5ae1fbd7 100644 --- a/source/funkin/play/stage/Bopper.hx +++ b/source/funkin/play/stage/Bopper.hx @@ -23,6 +23,31 @@ class Bopper extends StageProp implements IPlayStateScriptedClass */ public var danceEvery:Int = 1; + /** + * This fixes the bopper desyncing from each other, imitating the `if(curBeat % 2 == 0) dad.dance();` from the 0.3.X of the game + */ + public var danceCalc(get, never):Int; + + function get_danceCalc():Int + { + return danceEvery; + + /*if (danceEvery <= 0 || shouldAlternate || this.animation.getByName('idle') == null) return danceEvery; + else if (this.animation.curAnim.name == 'idle' && !this.animation.curAnim.finished) return 1; + + var daIdle = this.animation.getByName('idle'); + var calc:Float = (daIdle.numFrames / daIdle.frameRate) / (Conductor.instance.beatLengthMs / 1000); + var danceEveryNumBeats:Int = Math.ceil(calc); + var numeratorTweak:Int = (Conductor.instance.timeSignatureNumerator % 2 == 0) ? 2 : 3; + if (danceEveryNumBeats > numeratorTweak) + { + while (danceEveryNumBeats % numeratorTweak != 0) + danceEveryNumBeats++; + } + return Std.int(Math.max(danceEvery, danceEveryNumBeats));*/ + } + + /** * Whether the bopper should dance left and right. * - If true, alternate playing `danceLeft` and `danceRight`. @@ -156,7 +181,7 @@ class Bopper extends StageProp implements IPlayStateScriptedClass */ public function onBeatHit(event:SongTimeScriptEvent):Void { - if (danceEvery > 0 && event.beat % danceEvery == 0) + if (danceEvery > 0 && event.beat % danceCalc == 0) dance(shouldBop); } diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index cd6b7ca263..4fcc4b71e2 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -598,7 +598,7 @@ class DebugBoundingState extends FlxState _file.addEventListener(Event.COMPLETE, onSaveComplete); _file.addEventListener(Event.CANCEL, onSaveCancel); _file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError); - _file.save(saveString,); + _file.save(saveString, fileName); } } diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 776595d657..79c6f6c284 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4255,8 +4255,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } else { - // Minimum of 0. - return 0; + // Minimum of -1. + return -1; } }); diff --git a/source/funkin/ui/freeplay/DJBoyfriend.hx b/source/funkin/ui/freeplay/DJBoyfriend.hx index a2bc97e192..a7170f4d7e 100644 --- a/source/funkin/ui/freeplay/DJBoyfriend.hx +++ b/source/funkin/ui/freeplay/DJBoyfriend.hx @@ -39,7 +39,7 @@ class DJBoyfriend extends FlxAtlasSprite animOffsets = new Map>(); - anim.callback = function(name, number) { + anim.onFrame.add((name, number) -> { switch (name) { case "Boyfriend DJ watchin tv OG": @@ -53,15 +53,14 @@ class DJBoyfriend extends FlxAtlasSprite } default: } - }; + }); setupAnimations(); FlxG.debugger.track(this); FlxG.console.registerObject("dj", this); - anim.onComplete = () -> onFinishAnim(); - + anim.onComplete.add(() -> onFinishAnim()); FlxG.console.registerFunction("tv", function() { currentState = TV; @@ -145,7 +144,7 @@ class DJBoyfriend extends FlxAtlasSprite function onFinishAnim():Void { var name = anim.curSymbol.name; - onAnimationFinish.dispatch(name); + //onAnimationFinish.dispatch(name); trace(name); switch (name) {