1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-05-21 22:53:13 +00:00

char select to freeplay transition, backing card implementation, beatHit for backing cards

This commit is contained in:
FabsTheFabs 2024-08-30 01:04:30 +01:00
parent 0c809c828e
commit 60c10aae99
2 changed files with 159 additions and 39 deletions

View file

@ -391,9 +391,15 @@ class CharSelectSubState extends MusicBeatSubState
} }
} }
function testLol():Void function goToFreeplay():Void
{ {
autoFollow = false; autoFollow = false;
FlxTween.tween(cursor, {alpha: 0}, 0.8, {ease: FlxEase.expoOut});
FlxTween.tween(cursorBlue, {alpha: 0}, 0.8, {ease: FlxEase.expoOut});
FlxTween.tween(cursorDarkBlue, {alpha: 0}, 0.8, {ease: FlxEase.expoOut});
FlxTween.tween(cursorConfirmed, {alpha: 0}, 0.8, {ease: FlxEase.expoOut});
FlxTween.tween(barthing, {y: barthing.y + 80}, 0.8, {ease: FlxEase.backIn}); FlxTween.tween(barthing, {y: barthing.y + 80}, 0.8, {ease: FlxEase.backIn});
FlxTween.tween(dipshitBacking, {y: dipshitBacking.y + 210}, 0.8, {ease: FlxEase.backIn}); FlxTween.tween(dipshitBacking, {y: dipshitBacking.y + 210}, 0.8, {ease: FlxEase.backIn});
FlxTween.tween(chooseDipshit, {y: chooseDipshit.y + 200}, 0.8, {ease: FlxEase.backIn}); FlxTween.tween(chooseDipshit, {y: chooseDipshit.y + 200}, 0.8, {ease: FlxEase.backIn});
@ -413,7 +419,8 @@ class CharSelectSubState extends MusicBeatSubState
FlxG.switchState(FreeplayState.build( FlxG.switchState(FreeplayState.build(
{ {
{ {
character: curChar character: curChar,
fromCharSelect: true
} }
})); }));
} }
@ -542,7 +549,7 @@ class CharSelectSubState extends MusicBeatSubState
// character: curChar // character: curChar
// } // }
// })); // }));
testLol(); goToFreeplay();
}); });
} }

View file

@ -1,8 +1,6 @@
package funkin.ui.freeplay; package funkin.ui.freeplay;
import funkin.ui.freeplay.backcards.BackingCard; import funkin.ui.freeplay.backcards.*;
import funkin.ui.freeplay.backcards.BoyfriendCard;
import funkin.ui.freeplay.backcards.PicoCard;
import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.ui.FlxInputText; import flixel.addons.ui.FlxInputText;
import flixel.FlxCamera; import flixel.FlxCamera;
@ -55,6 +53,8 @@ import funkin.util.MathUtil;
import funkin.util.SortUtil; import funkin.util.SortUtil;
import lime.utils.Assets; import lime.utils.Assets;
import openfl.display.BlendMode; import openfl.display.BlendMode;
import funkin.data.freeplay.style.FreeplayStyleRegistry;
import funkin.data.song.SongData.SongMusicData;
/** /**
* Parameters used to initialize the FreeplayState. * Parameters used to initialize the FreeplayState.
@ -63,6 +63,8 @@ typedef FreeplayStateParams =
{ {
?character:String, ?character:String,
?fromCharSelect:Bool,
?fromResults:FromResultsParams, ?fromResults:FromResultsParams,
}; };
@ -149,7 +151,8 @@ class FreeplayState extends MusicBeatSubState
var curSelected:Int = 0; var curSelected:Int = 0;
var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY; var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY;
var fp:FreeplayScore; public var fp:FreeplayScore;
var txtCompletion:AtlasText; var txtCompletion:AtlasText;
var lerpCompletion:Float = 0; var lerpCompletion:Float = 0;
var intendedCompletion:Float = 0; var intendedCompletion:Float = 0;
@ -201,9 +204,14 @@ class FreeplayState extends MusicBeatSubState
var prepForNewRank:Bool = false; var prepForNewRank:Bool = false;
var styleData:Null<FreeplayStyle> = null;
var fromCharSelect:Null<Bool> = null;
public function new(?params:FreeplayStateParams, ?stickers:StickerSubState) public function new(?params:FreeplayStateParams, ?stickers:StickerSubState)
{ {
currentCharacterId = params?.character ?? Constants.DEFAULT_CHARACTER; currentCharacterId = params?.character ?? Constants.DEFAULT_CHARACTER;
styleData = FreeplayStyleRegistry.instance.fetchEntry(currentCharacterId);
var fetchPlayableCharacter = function():PlayableCharacter { var fetchPlayableCharacter = function():PlayableCharacter {
var result = PlayerRegistry.instance.fetchEntry(params?.character ?? Constants.DEFAULT_CHARACTER); var result = PlayerRegistry.instance.fetchEntry(params?.character ?? Constants.DEFAULT_CHARACTER);
if (result == null) throw 'No valid playable character with id ${params?.character}'; if (result == null) throw 'No valid playable character with id ${params?.character}';
@ -211,6 +219,8 @@ class FreeplayState extends MusicBeatSubState
}; };
currentCharacter = fetchPlayableCharacter(); currentCharacter = fetchPlayableCharacter();
fromCharSelect = params?.fromCharSelect;
fromResultsParams = params?.fromResults; fromResultsParams = params?.fromResults;
if (fromResultsParams?.playRankAnim == true) if (fromResultsParams?.playRankAnim == true)
@ -228,7 +238,7 @@ class FreeplayState extends MusicBeatSubState
switch (currentCharacterId) switch (currentCharacterId)
{ {
case 'bf': case 'bf':
backingCard = new BoyfriendCard(currentCharacter); backingCard = new NewCharacterCard(currentCharacter);
case 'pico': case 'pico':
backingCard = new PicoCard(currentCharacter); backingCard = new PicoCard(currentCharacter);
default: default:
@ -237,7 +247,7 @@ class FreeplayState extends MusicBeatSubState
// We build a bunch of sprites BEFORE create() so we can guarantee they aren't null later on. // We build a bunch of sprites BEFORE create() so we can guarantee they aren't null later on.
albumRoll = new AlbumRoll(); albumRoll = new AlbumRoll();
fp = new FreeplayScore(460, 60, 7, 100); fp = new FreeplayScore(460, 60, 7, 100, styleData);
rankCamera = new FunkinCamera('rankCamera', 0, 0, FlxG.width, FlxG.height); rankCamera = new FunkinCamera('rankCamera', 0, 0, FlxG.width, FlxG.height);
funnyCam = new FunkinCamera('freeplayFunny', 0, 0, FlxG.width, FlxG.height); funnyCam = new FunkinCamera('freeplayFunny', 0, 0, FlxG.width, FlxG.height);
grpCapsules = new FlxTypedGroup<SongMenuItem>(); grpCapsules = new FlxTypedGroup<SongMenuItem>();
@ -252,11 +262,13 @@ class FreeplayState extends MusicBeatSubState
ostName = new FlxText(8, 8, FlxG.width - 8 - 8, 'OFFICIAL OST', 48); ostName = new FlxText(8, 8, FlxG.width - 8 - 8, 'OFFICIAL OST', 48);
bgDad = new FlxSprite(backingCard.pinkBack.width * 0.74, 0).loadGraphic(Paths.image('freeplay/freeplayBGdad')); bgDad = new FlxSprite(backingCard.pinkBack.width * 0.74, 0).loadGraphic(styleData == null ? 'freeplay/freeplayBGdad' : styleData.getBgAssetGraphic());
} }
var fadeShader:BlueFade = new BlueFade(); var fadeShader:BlueFade = new BlueFade();
public var angleMaskShader:AngleMask = new AngleMask();
override function create():Void override function create():Void
{ {
super.create(); super.create();
@ -350,6 +362,7 @@ class FreeplayState extends MusicBeatSubState
add(backingCard); add(backingCard);
backingCard.init(); backingCard.init();
backingCard.applyExitMovers(exitMovers, exitMoversCharSel); backingCard.applyExitMovers(exitMovers, exitMoversCharSel);
backingCard.instance = this;
} }
if (currentCharacter?.getFreeplayDJData() != null) if (currentCharacter?.getFreeplayDJData() != null)
@ -369,7 +382,7 @@ class FreeplayState extends MusicBeatSubState
}); });
} }
bgDad.shader = new AngleMask(); bgDad.shader = angleMaskShader;
bgDad.visible = false; bgDad.visible = false;
var blackOverlayBullshitLOLXD:FlxSprite = new FlxSprite(FlxG.width).makeGraphic(Std.int(bgDad.width), Std.int(bgDad.height), FlxColor.BLACK); var blackOverlayBullshitLOLXD:FlxSprite = new FlxSprite(FlxG.width).makeGraphic(Std.int(bgDad.width), Std.int(bgDad.height), FlxColor.BLACK);
@ -398,7 +411,6 @@ class FreeplayState extends MusicBeatSubState
add(bgDad); add(bgDad);
// backingCard.pinkBack.width * 0.74 // backingCard.pinkBack.width * 0.74
FlxTween.tween(blackOverlayBullshitLOLXD, {x: 387.76}, 0.7, {ease: FlxEase.quintOut});
blackOverlayBullshitLOLXD.shader = bgDad.shader; blackOverlayBullshitLOLXD.shader = bgDad.shader;
@ -445,12 +457,18 @@ class FreeplayState extends MusicBeatSubState
albumRoll.albumId = null; albumRoll.albumId = null;
add(albumRoll); add(albumRoll);
albumRoll.applyExitMovers(exitMovers, exitMoversCharSel);
var overhangStuff:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, 164, FlxColor.BLACK); var overhangStuff:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, 164, FlxColor.BLACK);
overhangStuff.y -= overhangStuff.height; overhangStuff.y -= overhangStuff.height;
FlxTween.tween(overhangStuff, {y: -100}, 0.3, {ease: FlxEase.quartOut}); if(fromCharSelect == true){
blackOverlayBullshitLOLXD.x = 387.76;
overhangStuff.y = -100;
backingCard?.skipIntroTween();
}else{
albumRoll.applyExitMovers(exitMovers, exitMoversCharSel);
FlxTween.tween(overhangStuff, {y: -100}, 0.3, {ease: FlxEase.quartOut});
FlxTween.tween(blackOverlayBullshitLOLXD, {x: 387.76}, 0.7, {ease: FlxEase.quintOut});
}
var fnfFreeplay:FlxText = new FlxText(8, 8, 0, 'FREEPLAY', 48); var fnfFreeplay:FlxText = new FlxText(8, 8, 0, 'FREEPLAY', 48);
fnfFreeplay.font = 'VCR OSD Mono'; fnfFreeplay.font = 'VCR OSD Mono';
@ -554,8 +572,8 @@ class FreeplayState extends MusicBeatSubState
wait: 0.1 wait: 0.1
}); });
var diffSelLeft:DifficultySelector = new DifficultySelector(20, grpDifficulties.y - 10, false, controls); var diffSelLeft:DifficultySelector = new DifficultySelector(20, grpDifficulties.y - 10, false, controls, styleData);
var diffSelRight:DifficultySelector = new DifficultySelector(325, grpDifficulties.y - 10, true, controls); var diffSelRight:DifficultySelector = new DifficultySelector(325, grpDifficulties.y - 10, true, controls, styleData);
diffSelLeft.visible = false; diffSelLeft.visible = false;
diffSelRight.visible = false; diffSelRight.visible = false;
add(diffSelLeft); add(diffSelLeft);
@ -573,6 +591,19 @@ class FreeplayState extends MusicBeatSubState
albumRoll.playIntro(); albumRoll.playIntro();
if (fromCharSelect == null) {
// render optimisation
if (_parentState != null) _parentState.persistentDraw = false;
FlxTween.color(bgDad, 0.6, 0xFF000000, 0xFFFFFFFF,
{
ease: FlxEase.expoOut,
onUpdate: function(_) {
angleMaskShader.extraColor = bgDad.color;
}
});
}
FlxTween.tween(grpDifficulties, {x: 90}, 0.6, {ease: FlxEase.quartOut}); FlxTween.tween(grpDifficulties, {x: 90}, 0.6, {ease: FlxEase.quartOut});
diffSelLeft.visible = true; diffSelLeft.visible = true;
@ -613,9 +644,6 @@ class FreeplayState extends MusicBeatSubState
bgDad.visible = true; bgDad.visible = true;
backingCard?.introDone(); backingCard?.introDone();
// render optimisation
if (_parentState != null) _parentState.persistentDraw = false;
if (prepForNewRank && fromResultsParams != null) if (prepForNewRank && fromResultsParams != null)
{ {
rankAnimStart(fromResultsParams); rankAnimStart(fromResultsParams);
@ -657,6 +685,12 @@ class FreeplayState extends MusicBeatSubState
{ {
rankCamera.fade(0xFF000000, 0, false, null, true); rankCamera.fade(0xFF000000, 0, false, null, true);
} }
if (fromCharSelect == true)
{
enterFromCharSel();
onDJIntroDone();
}
} }
var currentFilter:Null<SongFilter> = null; var currentFilter:Null<SongFilter> = null;
@ -715,7 +749,7 @@ class FreeplayState extends MusicBeatSubState
var hsvShader:HSVShader = new HSVShader(); var hsvShader:HSVShader = new HSVShader();
var randomCapsule:SongMenuItem = grpCapsules.recycle(SongMenuItem); var randomCapsule:SongMenuItem = grpCapsules.recycle(SongMenuItem);
randomCapsule.init(FlxG.width, 0, null); randomCapsule.init(FlxG.width, 0, null, styleData);
randomCapsule.onConfirm = function() { randomCapsule.onConfirm = function() {
capsuleOnConfirmRandom(randomCapsule); capsuleOnConfirmRandom(randomCapsule);
}; };
@ -727,7 +761,14 @@ class FreeplayState extends MusicBeatSubState
randomCapsule.favIconBlurred.visible = false; randomCapsule.favIconBlurred.visible = false;
randomCapsule.ranking.visible = false; randomCapsule.ranking.visible = false;
randomCapsule.blurredRanking.visible = false; randomCapsule.blurredRanking.visible = false;
randomCapsule.initJumpIn(0, force); if (fromCharSelect == false)
{
randomCapsule.initJumpIn(0, force);
}
else
{
randomCapsule.forcePosition();
}
randomCapsule.hsvShader = hsvShader; randomCapsule.hsvShader = hsvShader;
grpCapsules.add(randomCapsule); grpCapsules.add(randomCapsule);
@ -738,7 +779,7 @@ class FreeplayState extends MusicBeatSubState
var funnyMenu:SongMenuItem = grpCapsules.recycle(SongMenuItem); var funnyMenu:SongMenuItem = grpCapsules.recycle(SongMenuItem);
funnyMenu.init(FlxG.width, 0, tempSong); funnyMenu.init(FlxG.width, 0, tempSong, styleData);
funnyMenu.onConfirm = function() { funnyMenu.onConfirm = function() {
capsuleOnConfirmDefault(funnyMenu); capsuleOnConfirmDefault(funnyMenu);
}; };
@ -1106,6 +1147,7 @@ class FreeplayState extends MusicBeatSubState
function goToCharSelect():Void function goToCharSelect():Void
{ {
busy = true;
var transitionGradient = new FlxSprite(0, 720).loadGraphic(Paths.image('freeplay/transitionGradient')); var transitionGradient = new FlxSprite(0, 720).loadGraphic(Paths.image('freeplay/transitionGradient'));
transitionGradient.scale.set(1280, 1); transitionGradient.scale.set(1280, 1);
transitionGradient.updateHitbox(); transitionGradient.updateHitbox();
@ -1117,7 +1159,6 @@ class FreeplayState extends MusicBeatSubState
wait: 0.1 wait: 0.1
}); });
add(transitionGradient); add(transitionGradient);
// busy = true;
for (index => capsule in grpCapsules.members) for (index => capsule in grpCapsules.members)
{ {
var distFromSelected:Float = Math.abs(index - curSelected) - 1; var distFromSelected:Float = Math.abs(index - curSelected) - 1;
@ -1134,7 +1175,6 @@ class FreeplayState extends MusicBeatSubState
} }
fadeShader.fade(1.0, 0.0, 0.8, {ease: FlxEase.quadIn}); fadeShader.fade(1.0, 0.0, 0.8, {ease: FlxEase.quadIn});
FlxG.sound.music.fadeOut(0.9, 0); FlxG.sound.music.fadeOut(0.9, 0);
// FlxTween.tween(transitionGradient, {y: 0}, 1, {ease: FlxEase.expoOut, startDelay: 0.3});
new FlxTimer().start(0.9, _ -> { new FlxTimer().start(0.9, _ -> {
FlxG.switchState(new funkin.ui.charSelect.CharSelectSubState()); FlxG.switchState(new funkin.ui.charSelect.CharSelectSubState());
}); });
@ -1149,13 +1189,77 @@ class FreeplayState extends MusicBeatSubState
var funnyMoveShit:MoveData = moveData; var funnyMoveShit:MoveData = moveData;
var moveDataX = funnyMoveShit.x ?? spr.x;
var moveDataY = funnyMoveShit.y ?? spr.y; var moveDataY = funnyMoveShit.y ?? spr.y;
var moveDataSpeed = funnyMoveShit.speed ?? 0.2; var moveDataSpeed = funnyMoveShit.speed ?? 0.2;
var moveDataWait = funnyMoveShit.wait ?? 0.0; var moveDataWait = funnyMoveShit.wait ?? 0.0;
FlxTween.tween(spr, {x: moveDataX, y: moveDataY + spr.y}, moveDataSpeed, {ease: FlxEase.backIn}); FlxTween.tween(spr, {y: moveDataY + spr.y}, moveDataSpeed, {ease: FlxEase.backIn});
// longestTimer = Math.max(longestTimer, moveDataSpeed + moveDataWait); }
}
backingCard?.enterCharSel();
}
function enterFromCharSel():Void
{
busy = true;
if (_parentState != null) _parentState.persistentDraw = false;
var transitionGradient = new FlxSprite(0, 720).loadGraphic(Paths.image('freeplay/transitionGradient'));
transitionGradient.scale.set(1280, 1);
transitionGradient.updateHitbox();
transitionGradient.cameras = [rankCamera];
exitMoversCharSel.set([transitionGradient],
{
y: -720,
speed: 1.5,
wait: 0.1
});
add(transitionGradient);
// FlxTween.tween(transitionGradient, {alpha: 0}, 1, {ease: FlxEase.circIn});
// for (index => capsule in grpCapsules.members)
// {
// var distFromSelected:Float = Math.abs(index - curSelected) - 1;
// if (distFromSelected < 5)
// {
// capsule.doLerp = false;
// exitMoversCharSel.set([capsule],
// {
// y: -250,
// speed: 0.8,
// wait: 0.1
// });
// }
// }
fadeShader.fade(0.0, 1.0, 0.8, {ease: FlxEase.quadIn});
for (grpSpr in exitMoversCharSel.keys())
{
var moveData:Null<MoveData> = exitMoversCharSel.get(grpSpr);
if (moveData == null) continue;
for (spr in grpSpr)
{
if (spr == null) continue;
var funnyMoveShit:MoveData = moveData;
var moveDataY = funnyMoveShit.y ?? spr.y;
var moveDataSpeed = funnyMoveShit.speed ?? 0.2;
var moveDataWait = funnyMoveShit.wait ?? 0.0;
spr.y += moveDataY;
FlxTween.tween(spr, {y: spr.y - moveDataY}, moveDataSpeed * 1.2,
{
ease: FlxEase.expoOut,
onComplete: function(_) {
for (index => capsule in grpCapsules.members)
{
capsule.doLerp = true;
fromCharSelect = false;
busy = false;
albumRoll.applyExitMovers(exitMovers, exitMoversCharSel);
}
}
});
} }
} }
} }
@ -1185,10 +1289,7 @@ class FreeplayState extends MusicBeatSubState
{ {
super.update(elapsed); super.update(elapsed);
if (FlxG.keys.justPressed.G) Conductor.instance.update();
{
goToCharSelect();
}
if (FlxG.keys.justPressed.P) if (FlxG.keys.justPressed.P)
{ {
@ -1225,7 +1326,7 @@ class FreeplayState extends MusicBeatSubState
if (controls.FREEPLAY_CHAR_SELECT && !busy) if (controls.FREEPLAY_CHAR_SELECT && !busy)
{ {
FlxG.switchState(new funkin.ui.charSelect.CharSelectSubState()); goToCharSelect();
} }
if (controls.FREEPLAY_FAVORITE && !busy) if (controls.FREEPLAY_FAVORITE && !busy)
@ -1549,6 +1650,13 @@ class FreeplayState extends MusicBeatSubState
} }
} }
override function beatHit():Bool
{
backingCard?.beatHit();
return super.beatHit();
}
public override function destroy():Void public override function destroy():Void
{ {
super.destroy(); super.destroy();
@ -1764,7 +1872,7 @@ class FreeplayState extends MusicBeatSubState
backingCard?.confirm(); backingCard?.confirm();
new FlxTimer().start(1, function(tmr:FlxTimer) { new FlxTimer().start(styleData?.getStartDelay(), function(tmr:FlxTimer) {
FunkinSound.emptyPartialQueue(); FunkinSound.emptyPartialQueue();
Paths.setCurrentLevel(cap?.songData?.levelId); Paths.setCurrentLevel(cap?.songData?.levelId);
@ -1878,7 +1986,7 @@ class FreeplayState extends MusicBeatSubState
if (previewSongId == null) return; if (previewSongId == null) return;
var previewSong:Null<Song> = SongRegistry.instance.fetchEntry(previewSongId); var previewSong:Null<Song> = SongRegistry.instance.fetchEntry(previewSongId);
var songDifficulty = previewSong?.getDifficulty(currentDifficulty, var songDifficulty:Null<SongDifficulty> = previewSong?.getDifficulty(currentDifficulty,
previewSong?.getVariationsByCharacter(currentCharacter) ?? Constants.DEFAULT_VARIATION_LIST); previewSong?.getVariationsByCharacter(currentCharacter) ?? Constants.DEFAULT_VARIATION_LIST);
var baseInstrumentalId:String = songDifficulty?.characters?.instrumental ?? ''; var baseInstrumentalId:String = songDifficulty?.characters?.instrumental ?? '';
var altInstrumentalIds:Array<String> = songDifficulty?.characters?.altInstrumentals ?? []; var altInstrumentalIds:Array<String> = songDifficulty?.characters?.altInstrumentals ?? [];
@ -1908,13 +2016,18 @@ class FreeplayState extends MusicBeatSubState
partialParams: partialParams:
{ {
loadPartial: true, loadPartial: true,
start: 0.05, start: 0,
end: 0.25 end: 0.2
}, },
onLoad: function() { onLoad: function() {
FlxG.sound.music.fadeIn(2, 0, 0.4); FlxG.sound.music.fadeIn(2, 0, 0.4);
} }
}); });
if(songDifficulty != null) {
Conductor.instance.mapTimeChanges(songDifficulty.timeChanges);
Conductor.instance.update(FlxG.sound?.music?.time ?? 0.0);
}
} }
} }
@ -1944,13 +2057,13 @@ class DifficultySelector extends FlxSprite
var controls:Controls; var controls:Controls;
var whiteShader:PureColor; var whiteShader:PureColor;
public function new(x:Float, y:Float, flipped:Bool, controls:Controls) public function new(x:Float, y:Float, flipped:Bool, controls:Controls, ?styleData:FreeplayStyle = null)
{ {
super(x, y); super(x, y);
this.controls = controls; this.controls = controls;
frames = Paths.getSparrowAtlas('freeplay/freeplaySelector'); frames = Paths.getSparrowAtlas(styleData == null ? 'freeplay/freeplaySelector' : styleData.getSelectorAssetKey());
animation.addByPrefix('shine', 'arrow pointer loop', 24); animation.addByPrefix('shine', 'arrow pointer loop', 24);
animation.play('shine'); animation.play('shine');