Fix issues with Freeplay OST text and add animations.

This commit is contained in:
EliteMasterEric 2024-03-28 01:46:50 -04:00
parent 31827f30b1
commit b13c6563df
5 changed files with 71 additions and 9 deletions

2
assets

@ -1 +1 @@
Subproject commit 8013845e331015b40c4cc35230f6d02bd2148d52 Subproject commit 92bd680af3c627211656205dac85f9de5ae5abee

View file

@ -1,5 +1,7 @@
package funkin.data.freeplay; package funkin.data.freeplay;
import funkin.data.animation.AnimationData;
/** /**
* A type definition for the data for an album of songs. * A type definition for the data for an album of songs.
* It includes things like what graphics to display in Freeplay. * It includes things like what graphics to display in Freeplay.
@ -33,4 +35,11 @@ typedef AlbumData =
* The album title will be displayed below the album art in Freeplay. * The album title will be displayed below the album art in Freeplay.
*/ */
public var albumTitleAsset:String; public var albumTitleAsset:String;
/**
* An optional array of animations for the album title.
*/
@:optional
@:default([])
public var albumTitleAnimations:Array<AnimationData>;
} }

View file

@ -1,6 +1,7 @@
package funkin.ui.freeplay; package funkin.ui.freeplay;
import funkin.data.freeplay.AlbumData; import funkin.data.freeplay.AlbumData;
import funkin.data.animation.AnimationData;
import funkin.data.freeplay.AlbumRegistry; import funkin.data.freeplay.AlbumRegistry;
import funkin.data.IRegistryEntry; import funkin.data.IRegistryEntry;
import flixel.graphics.FlxGraphic; import flixel.graphics.FlxGraphic;
@ -75,6 +76,16 @@ class Album implements IRegistryEntry<AlbumData>
return _data.albumTitleAsset; return _data.albumTitleAsset;
} }
public function hasAlbumTitleAnimations()
{
return _data.albumTitleAnimations.length > 0;
}
public function getAlbumTitleAnimations():Array<AnimationData>
{
return _data.albumTitleAnimations;
}
public function toString():String public function toString():String
{ {
return 'Album($id)'; return 'Album($id)';

View file

@ -7,6 +7,7 @@ import flixel.tweens.FlxTween;
import flixel.util.FlxTimer; import flixel.util.FlxTimer;
import flixel.tweens.FlxEase; import flixel.tweens.FlxEase;
import funkin.data.freeplay.AlbumRegistry; import funkin.data.freeplay.AlbumRegistry;
import funkin.util.assets.FlxAnimationUtil;
import funkin.graphics.FunkinSprite; import funkin.graphics.FunkinSprite;
import funkin.util.SortUtil; import funkin.util.SortUtil;
import openfl.utils.Assets; import openfl.utils.Assets;
@ -21,9 +22,9 @@ class AlbumRoll extends FlxSpriteGroup
* The ID of the album to display. * The ID of the album to display.
* Modify this value to automatically update the album art and title. * Modify this value to automatically update the album art and title.
*/ */
public var albumId(default, set):String; public var albumId(default, set):Null<String>;
function set_albumId(value:String):String function set_albumId(value:Null<String>):Null<String>
{ {
if (this.albumId != value) if (this.albumId != value)
{ {
@ -65,6 +66,17 @@ class AlbumRoll extends FlxSpriteGroup
*/ */
function updateAlbum():Void function updateAlbum():Void
{ {
if (albumId == null)
{
albumArt.visible = false;
albumTitle.visible = false;
if (titleTimer != null)
{
titleTimer.cancel();
titleTimer = null;
}
}
albumData = AlbumRegistry.instance.fetchEntry(albumId); albumData = AlbumRegistry.instance.fetchEntry(albumId);
if (albumData == null) if (albumData == null)
@ -93,9 +105,17 @@ class AlbumRoll extends FlxSpriteGroup
applyExitMovers(); applyExitMovers();
if (Assets.exists(Paths.image(albumData.getAlbumTitleAssetKey()))) if (Assets.exists(Paths.image(albumData.getAlbumTitleAssetKey())))
{
if (albumData.hasAlbumTitleAnimations())
{
albumTitle.loadSparrow(albumData.getAlbumTitleAssetKey());
FlxAnimationUtil.addAtlasAnimations(albumTitle, albumData.getAlbumTitleAnimations());
}
else
{ {
albumTitle.loadGraphic(Paths.image(albumData.getAlbumTitleAssetKey())); albumTitle.loadGraphic(Paths.image(albumData.getAlbumTitleAssetKey()));
} }
}
else else
{ {
albumTitle.visible = false; albumTitle.visible = false;
@ -155,6 +175,8 @@ class AlbumRoll extends FlxSpriteGroup
}); });
} }
var titleTimer:Null<FlxTimer> = null;
/** /**
* Play the intro animation on the album art. * Play the intro animation on the album art.
*/ */
@ -164,7 +186,14 @@ class AlbumRoll extends FlxSpriteGroup
FlxTween.tween(albumArt, {x: 950, y: 320, angle: -340}, 0.5, {ease: FlxEase.elasticOut}); FlxTween.tween(albumArt, {x: 950, y: 320, angle: -340}, 0.5, {ease: FlxEase.elasticOut});
albumTitle.visible = false; albumTitle.visible = false;
new FlxTimer().start(0.75, function(_) {
if (titleTimer != null)
{
titleTimer.cancel();
titleTimer = null;
}
titleTimer = new FlxTimer().start(0.75, function(_) {
showTitle(); showTitle();
}); });
} }
@ -179,6 +208,8 @@ class AlbumRoll extends FlxSpriteGroup
public function showTitle():Void public function showTitle():Void
{ {
albumTitle.visible = true; albumTitle.visible = true;
albumTitle.animation.play('active');
albumTitle.animation.finishCallback = (_) -> albumTitle.animation.play('idle');
} }
/** /**

View file

@ -380,7 +380,7 @@ class FreeplayState extends MusicBeatSubState
} }
albumRoll = new AlbumRoll(); albumRoll = new AlbumRoll();
albumRoll.albumId = 'volume1'; albumRoll.albumId = null;
add(albumRoll); add(albumRoll);
albumRoll.applyExitMovers(exitMovers); albumRoll.applyExitMovers(exitMovers);
@ -881,6 +881,8 @@ class FreeplayState extends MusicBeatSubState
for (spr in grpSpr) for (spr in grpSpr)
{ {
if (spr == null) continue;
var funnyMoveShit:MoveData = moveData; var funnyMoveShit:MoveData = moveData;
if (moveData.x == null) funnyMoveShit.x = spr.x; if (moveData.x == null) funnyMoveShit.x = spr.x;
@ -1019,7 +1021,7 @@ class FreeplayState extends MusicBeatSubState
albumRoll.setDifficultyStars(daSong?.songRating); albumRoll.setDifficultyStars(daSong?.songRating);
// Set the album graphic and play the animation if relevant. // Set the album graphic and play the animation if relevant.
var newAlbumId:String = daSong?.albumId ?? Constants.DEFAULT_ALBUM_ID; var newAlbumId:String = daSong?.albumId;
if (albumRoll.albumId != newAlbumId) if (albumRoll.albumId != newAlbumId)
{ {
albumRoll.albumId = newAlbumId; albumRoll.albumId = newAlbumId;
@ -1162,6 +1164,7 @@ class FreeplayState extends MusicBeatSubState
intendedCompletion = 0.0; intendedCompletion = 0.0;
rememberedSongId = null; rememberedSongId = null;
rememberedDifficulty = null; rememberedDifficulty = null;
albumRoll.albumId = null;
} }
for (index => capsule in grpCapsules.members) for (index => capsule in grpCapsules.members)
@ -1311,7 +1314,7 @@ class FreeplaySongData
public var songName(default, null):String = ''; public var songName(default, null):String = '';
public var songCharacter(default, null):String = ''; public var songCharacter(default, null):String = '';
public var songRating(default, null):Int = 0; public var songRating(default, null):Int = 0;
public var albumId(default, null):String = ''; public var albumId(default, null):Null<String> = null;
public var currentDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY; public var currentDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY;
public var displayedVariations(default, null):Array<String> = [Constants.DEFAULT_VARIATION]; public var displayedVariations(default, null):Array<String> = [Constants.DEFAULT_VARIATION];
@ -1345,9 +1348,17 @@ class FreeplaySongData
this.songName = songDifficulty.songName; this.songName = songDifficulty.songName;
this.songCharacter = songDifficulty.characters.opponent; this.songCharacter = songDifficulty.characters.opponent;
this.songRating = songDifficulty.difficultyRating; this.songRating = songDifficulty.difficultyRating;
if (songDifficulty.album == null)
{
FlxG.log.warn('No album for: ${songDifficulty.songName}');
this.albumId = Constants.DEFAULT_ALBUM_ID;
}
else
{
this.albumId = songDifficulty.album; this.albumId = songDifficulty.album;
} }
} }
}
/** /**
* The map storing information about the exit movers. * The map storing information about the exit movers.