Skip to content

Commit

Permalink
FlxAnimate redar13 dev branch & inst variations fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PurSnake committed Aug 11, 2024
1 parent 10bf8a2 commit 8850622
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 77 deletions.
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.addOnce((instName:String, symName:String) -> 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
75 changes: 37 additions & 38 deletions source/funkin/graphics/shaders/ScreenWipeShader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,68 @@ import flixel.system.FlxAssets.FlxShader;

class ScreenWipeShader extends FlxShader
{
public var daAlphaShit(default, set):Float = 0;
public var daAlphaShit(default, set):Float = 0;

function set_daAlphaShit(alpha:Float):Float
{
alphaShit.value[0] = alpha;
function set_daAlphaShit(alpha:Float):Float
{
alphaShit.value[0] = alpha;

return alpha;
}
return alpha;
}

@:glFragmentSource('
#pragma header
@:glFragmentSource('
#pragma header

uniform float alphaShit;
uniform float alphaShit;
uniform float yPos;
uniform float xPos;

uniform sampler2D funnyShit;


vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));

float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}

void main()
{
void main()
{
vec2 funnyUv = openfl_TextureCoordv;
vec4 color = flixel_texture2D(bitmap, funnyUv);
vec4 color = flixel_texture2D(bitmap, funnyUv);

vec2 reallyFunnyUv = vec2(vec2(0.0, 0.0) - gl_FragCoord.xy / openfl_TextureSize.xy);

vec4 gf = flixel_texture2D(funnyShit, openfl_TextureCoordv);


vec3 hsvTypeBeat = rgb2hsv(vec3(gf.r, gf.g, gf.b));
vec3 hsvTypeBeat = rgb2hsv(vec3(gf.r, gf.g, gf.b));

vec4 output = color;

// .b here actually means value?
// .b here actually means value?
if (hsvTypeBeat.b <= alphaShit)
color = vec4(0.0, 0.0, 0.0, 0.0);


gl_FragColor = color;
}
')
public function new()
{
super();
gl_FragColor = color;
}
')
public function new()
{
super();

alphaShit.value = [0];
}
alphaShit.value = [0];
}
}
40 changes: 16 additions & 24 deletions source/funkin/play/ResultState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ class ResultState extends MusicBeatSubState
soundSystem.zIndex = 1100;
add(soundSystem);


@:nullSafety(Off)
{
switch (rank)
{
case PERFECT | PERFECT_GOLD:
Expand All @@ -165,31 +168,25 @@ class ResultState extends MusicBeatSubState
heartsPerfect.zIndex = 501;
add(heartsPerfect);

heartsPerfect.anim.onComplete = () -> {
if (heartsPerfect != null)
heartsPerfect.anim.play("hearts full anim", true, false, 43); // unpauses this anim, since it's on PlayOnce!
};
heartsPerfect.anim.onComplete.removeAll();
heartsPerfect.anim.onComplete.addOnce((a,b) -> heartsPerfect.anim.play("hearts full anim", true, false, 43));

bfPerfect = new FlxAtlasSprite(1342, 370, Paths.animateAtlas("resultScreen/results-bf/resultsPERFECT", "shared"));
bfPerfect.visible = false;
bfPerfect.zIndex = 500;
add(bfPerfect);

bfPerfect.anim.onComplete = () -> {
if (bfPerfect != null)
bfPerfect.anim.play("boyfriend perfect rank", true, false, 137); // unpauses this anim, since it's on PlayOnce!
};
bfPerfect.anim.onComplete.removeAll();
bfPerfect.anim.onComplete.addOnce((a,b) -> bfPerfect.anim.play("boyfriend perfect rank", true, false, 137));

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 = () -> {
if (bfExcellent != null)
bfExcellent.anim.play("bf results excellent", true, false, 28); // unpauses this anim, since it's on PlayOnce!
};
bfExcellent.anim.onComplete.removeAll();
bfExcellent.anim.onComplete.addOnce((a,b) -> bfExcellent.anim.play("bf results excellent", true, false, 28));

case GREAT:
gfGreat = new FlxAtlasSprite(802, 331, Paths.animateAtlas("resultScreen/results-bf/resultsGREAT/gf", "shared"));
Expand All @@ -199,10 +196,8 @@ class ResultState extends MusicBeatSubState

gfGreat.scale.set(0.93, 0.93);

gfGreat.anim.onComplete = () -> {
if (gfGreat != null)
gfGreat.anim.play("gf jumping", true, false, 9); // unpauses this anim, since it's on PlayOnce!
};
gfGreat.anim.onComplete.removeAll();
gfGreat.anim.onComplete.addOnce((a, b) -> gfGreat.anim.play("gf jumping", true, false, 9));

bfGreat = new FlxAtlasSprite(929, 363, Paths.animateAtlas("resultScreen/results-bf/resultsGREAT/bf", "shared"));
bfGreat.visible = false;
Expand All @@ -211,10 +206,8 @@ class ResultState extends MusicBeatSubState

bfGreat.scale.set(0.93, 0.93);

bfGreat.anim.onComplete = () -> {
if (bfGreat != null)
bfGreat.anim.play("bf jumping ", true, false, 15); // unpauses this anim, since it's on PlayOnce!
};
bfGreat.anim.onComplete.removeAll();
bfGreat.anim.onComplete.addOnce((a, b) -> bfGreat.anim.play("bf jumping ", true, false, 15));

case GOOD:
gfGood = FunkinSprite.createSparrow(625, 325, 'resultScreen/results-bf/resultsGOOD/resultGirlfriendGOOD');
Expand Down Expand Up @@ -245,10 +238,9 @@ class ResultState extends MusicBeatSubState
bfShit.zIndex = 500;
add(bfShit);

bfShit.onAnimationFinish.add((animName) -> {
if (bfShit != null)
bfShit.playAnimation('Loop Start');
});
bfShit.anim.onComplete.removeAll();
bfShit.anim.onComplete.add((anim:String, name:String) -> bfShit.playAnimation('Loop Start', true));
}
}

var diffSpr:String = 'diff_${params?.difficultyId ?? 'Normal'}';
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/play/character/AnimateAtlasCharacter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class AnimateAtlasCharacter extends BaseCharacter
trace('[ATLASCHAR] Animation ${prefix} not found in Animate Atlas ${_data.assetPath}');
continue;
}
//mainSprite.anim.addBySymbol(anim.name, anim.prefix, 24, anim.looped);
mainSprite.anim.addBySymbol(anim.name, prefix, 24, anim.looped);
animations.set(anim.name, anim);
trace('[ATLASCHAR] - Successfully loaded animation ${anim.name} to ${characterId}');
}
Expand Down
12 changes: 7 additions & 5 deletions source/funkin/ui/freeplay/DJBoyfriend.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class DJBoyfriend extends FlxAtlasSprite

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

anim.callback = function(name, number) {
anim.onFrame.add((inName:String, name:String, number:Int) ->
{
switch (name)
{
case "Boyfriend DJ watchin tv OG":
Expand All @@ -53,14 +54,15 @@ class DJBoyfriend extends FlxAtlasSprite
}
default:
}
};
});

setupAnimations();

FlxG.debugger.track(this);
FlxG.console.registerObject("dj", this);

anim.onComplete = () -> onFinishAnim();
anim.onComplete.removeAll();
anim.onComplete.add((i:String, n:String) -> onFinishAnim(n));

FlxG.console.registerFunction("tv", function() {
currentState = TV;
Expand Down Expand Up @@ -141,9 +143,9 @@ class DJBoyfriend extends FlxAtlasSprite
}
}

function onFinishAnim():Void
function onFinishAnim(name):Void
{
var name = anim.curSymbol.name;
//var name = anim.curSymbol.name;
onAnimationFinish.dispatch(name);
trace(name);
switch (name)
Expand Down
1 change: 1 addition & 0 deletions source/funkin/ui/freeplay/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,7 @@ class FreeplayState extends MusicBeatSubState
#else
botPlayMode: false,
#end

// TODO: Make these an option! It's currently only accessible via chart editor.
// startTimestamp: 0.0,
// playbackRate: 0.5,
Expand Down
18 changes: 11 additions & 7 deletions source/funkin/ui/story/StoryMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,7 @@ class StoryMenuState extends MusicBeatState
currentLevelTitle.isFlashing = true;

for (prop in levelProps.members)
{
prop.playConfirm();
}

Paths.setCurrentLevel(currentLevel.id);

Expand All @@ -538,18 +536,24 @@ class StoryMenuState extends MusicBeatState

Highscore.talliesLevel = new funkin.Highscore.Tallies();


new FlxTimer().start(1, function(tmr:FlxTimer) {
FlxTransitionableState.skipNextTransIn = false;
FlxTransitionableState.skipNextTransOut = false;

var targetVariation:String = targetSong.getFirstValidVariation(PlayStatePlaylist.campaignDifficulty);
var targetDifficulty:SongDifficulty = targetSong.getDifficulty(PlayStatePlaylist.campaignDifficulty, targetVariation);
var targetInstId:String = targetDifficulty.characters.instrumental;

LoadingState.loadPlayState(
{
targetSong: targetSong,
targetDifficulty: PlayStatePlaylist.campaignDifficulty,
targetVariation: targetVariation
}, true);
{
targetSong: targetSong,
targetDifficulty: PlayStatePlaylist.campaignDifficulty,
targetVariation: targetVariation,
targetInstrumental: targetInstId,
practiceMode: false,
minimalMode: false
}, true);
});
}

Expand Down

0 comments on commit 8850622

Please sign in to comment.