Skip to content

Commit

Permalink
[ENHANCEMENT] Add offsets support for Album titles (#3618)
Browse files Browse the repository at this point in the history
* add album title offsets

* cleanup

* cleanup

* fix inconsistency
  • Loading branch information
AbnormalPoof authored Jan 17, 2025
1 parent a17b0e8 commit 69d8570
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
7 changes: 7 additions & 0 deletions source/funkin/data/freeplay/album/AlbumData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ typedef AlbumData =
*/
public var albumTitleAsset:String;

/**
* Offsets for the album title.
*/
@:optional
@:default([0, 0])
public var albumTitleOffsets:Null<Array<Float>>;

/**
* An optional array of animations for the album title.
*/
Expand Down
8 changes: 8 additions & 0 deletions source/funkin/ui/freeplay/Album.hx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ class Album implements IRegistryEntry<AlbumData>
return _data.albumTitleAsset;
}

/**
* Get the offsets for the album title.
*/
public function getAlbumTitleOffsets():Null<Array<Float>>
{
return _data.albumTitleOffsets;
}

public function hasAlbumTitleAnimations()
{
return _data.albumTitleAnimations.length > 0;
Expand Down
12 changes: 10 additions & 2 deletions source/funkin/ui/freeplay/AlbumRoll.hx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class AlbumRoll extends FlxSpriteGroup
var albumGraphic = Paths.image(albumData.getAlbumArtAssetKey());
newAlbumArt.replaceFrameGraphic(0, albumGraphic);

buildAlbumTitle(albumData.getAlbumTitleAssetKey());
buildAlbumTitle(albumData.getAlbumTitleAssetKey(), albumData.getAlbumTitleOffsets());

applyExitMovers();

Expand Down Expand Up @@ -198,14 +198,19 @@ class AlbumRoll extends FlxSpriteGroup
albumTitle.visible = true;
}

public function buildAlbumTitle(assetKey:String):Void
public function buildAlbumTitle(assetKey:String, ?titleOffsets:Null<Array<Float>>):Void
{
if (albumTitle != null)
{
remove(albumTitle);
albumTitle = null;
}

if (titleOffsets == null)
{
titleOffsets = [0, 0];
}

albumTitle = FunkinSprite.createSparrow(925, 500, assetKey);
albumTitle.visible = albumTitle.frames != null && newAlbumArt.visible;
albumTitle.animation.addByPrefix('idle', 'idle0', 24, true);
Expand All @@ -219,6 +224,9 @@ class AlbumRoll extends FlxSpriteGroup

albumTitle.zIndex = 1000;

albumTitle.x += titleOffsets[0];
albumTitle.y += titleOffsets[1];

if (_exitMovers != null) _exitMovers.set([albumTitle],
{
x: FlxG.width,
Expand Down

0 comments on commit 69d8570

Please sign in to comment.