Skip to content

Commit

Permalink
temp signals
Browse files Browse the repository at this point in the history
  • Loading branch information
PurSnake committed Aug 7, 2024
1 parent 9f2e491 commit 6583b42
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 30 deletions.
67 changes: 66 additions & 1 deletion source/flixel/system/ui/FlxSoundTray.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -48,6 +55,11 @@ class FlxSoundTray extends Sprite
var splashSprite:AnimatedSprite;
var _volumeSprite:Bitmap;

/*
var renderCamera:FlxCamera;
var splashSprite:FlxSprite;
*/

@:keep
public function new()
{
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -62,7 +62,7 @@ class FlxAtlasSprite extends FlxAnimate
public function listAnimations():Array<String>
{
if (this.anim == null) return [];
return this.anim.getFrameLabels();
return this.anim.getFrameLabelNames();
// return [""];
}

Expand Down
4 changes: 2 additions & 2 deletions source/funkin/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
35 changes: 19 additions & 16 deletions source/funkin/play/ResultState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,34 @@ 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"));
bfExcellent.visible = false;
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"));
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);

Expand All @@ -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');
}
});
}

Expand Down
27 changes: 26 additions & 1 deletion source/funkin/play/stage/Bopper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion source/funkin/ui/debug/anim/DebugBoundingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/funkin/ui/debug/charting/ChartEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4255,8 +4255,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
}
else
{
// Minimum of 0.
return 0;
// Minimum of -1.
return -1;
}
});

Expand Down
9 changes: 4 additions & 5 deletions source/funkin/ui/freeplay/DJBoyfriend.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DJBoyfriend extends FlxAtlasSprite

animOffsets = new Map<String, Array<Dynamic>>();

anim.callback = function(name, number) {
anim.onFrame.add((name, number) -> {
switch (name)
{
case "Boyfriend DJ watchin tv OG":
Expand All @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 6583b42

Please sign in to comment.