Skip to content

Commit 17ed98e

Browse files
AbnormalPoofHundrec
authored andcommitted
Re-export Pico (Playable) and Pico (Dark) to texture atlases
1 parent 1b6c2d1 commit 17ed98e

File tree

6 files changed

+182
-78
lines changed

6 files changed

+182
-78
lines changed

astc-compression-data.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@
4141
"asset": "assets/shared/images/characters/sserafim/chaewon/spritemap1.png",
4242
"blocksize": "4x4"
4343
},
44+
{
45+
"asset": "assets/shared/images/characters/pico-dark/spritemap1.png",
46+
"blocksize": "4x4"
47+
},
48+
{
49+
"asset": "assets/shared/images/characters/pico/basic-animations/spritemap1.png",
50+
"blocksize": "6x6"
51+
},
52+
{
53+
"asset": "assets/shared/images/characters/pico/explosion-death/spritemap1.png",
54+
"blocksize": "8x8"
55+
},
56+
{
57+
"asset": "assets/shared/images/characters/pico/playable-animations/spritemap1.png",
58+
"blocksize": "6x6"
59+
},
4460
{
4561
"asset": "assets/shared/images/holdCoverBlue.png",
4662
"blocksize": "4x4"
@@ -109,6 +125,10 @@
109125
"asset": "assets/week1/image/erect/lights.png",
110126
"blocksize": "6x6"
111127
},
128+
{
129+
"asset": "assets/shared/images/characters/pico/death/spritemap1.png",
130+
"blocksize": "6x6"
131+
},
112132
{
113133
"asset": "assets/week1/images/erect/crowd.png",
114134
"blocksize": "8x8"

source/funkin/data/animation/AnimationData.hx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,20 @@ typedef UnnamedAnimationData =
147147
@:default("framelabel")
148148
@:optional
149149
var animType:String;
150+
151+
/**
152+
* The render type of the animation.
153+
* Only available for multi-sparrow and multi-animateatlas characters.
154+
* Options: "sparrow", "animateatlas"
155+
*/
156+
@:default("")
157+
@:optional
158+
var renderType:String;
159+
160+
/**
161+
* Various settings for the sprite.
162+
* Only available for texture atlases.
163+
*/
164+
@:optional
165+
var atlasSettings:funkin.data.stage.StageData.TextureAtlasData;
150166
}

source/funkin/play/GameOverSubState.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ class GameOverSubState extends MusicBeatSubState
253253
}
254254
else
255255
{
256-
boyfriend.playAnimation('firstDeath', true, false); // ignoreOther is set to FALSE since you WANT to be able to mash and confirm game over!
256+
boyfriend.playAnimation('firstDeath' + animationSuffix, true,
257+
false); // ignoreOther is set to FALSE since you WANT to be able to mash and confirm game over!
257258
// Play the "blue balled" sound. May play a variant if one has been assigned.
258259
playBlueBalledSFX();
259260
}

source/funkin/play/character/AnimateAtlasCharacter.hx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,9 @@ class AnimateAtlasCharacter extends BaseCharacter
2727
cpp.vm.tracy.TracyProfiler.zoneScoped('AnimateAtlasCharacter.create(${this.characterId})');
2828
#end
2929

30-
try
31-
{
32-
log('Loading assets for Animate Atlas character "${characterId}"');
33-
loadAtlas();
34-
loadAnimations();
35-
}
36-
catch (e)
37-
{
38-
throw "Exception thrown while building sprite: " + e;
39-
}
30+
log('Loading assets for Animate Atlas character "${characterId}"');
31+
loadAtlas();
32+
loadAnimations();
4033

4134
log('Successfully loaded texture atlas for ${characterId} with ${_data.animations.length} animations.');
4235
super.onCreate(event);
@@ -82,8 +75,8 @@ class AnimateAtlasCharacter extends BaseCharacter
8275
}
8376
}
8477

85-
var animNames = this.anim.getNameList();
86-
log('Successfully loaded ${animNames.length} animations for ${characterId}');
78+
var animationNames:Array<String> = this.animation.getNameList();
79+
log('[ATLASCHAR] Successfully loaded ${animationNames.length} animations for ${characterId}');
8780
}
8881

8982
/**

source/funkin/play/character/MultiAnimateAtlasCharacter.hx

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package funkin.play.character;
33
import funkin.graphics.FunkinSprite;
44
import funkin.util.assets.FlxAnimationUtil;
55
import animate.FlxAnimateFrames;
6+
import flixel.graphics.frames.FlxAtlasFrames;
67
import funkin.modding.events.ScriptEvent;
78
import funkin.data.animation.AnimationData;
89
import funkin.data.character.CharacterData.CharacterRenderType;
@@ -29,16 +30,9 @@ class MultiAnimateAtlasCharacter extends BaseCharacter
2930
cpp.vm.tracy.TracyProfiler.zoneScoped('MultiAnimateAtlasCharacter.create(${this.characterId})');
3031
#end
3132

32-
try
33-
{
34-
log('Loading assets for Multi-Animate Atlas character "${characterId}"');
35-
loadAtlases();
36-
loadAnimations();
37-
}
38-
catch (e)
39-
{
40-
throw "Exception thrown while building sprite: " + e;
41-
}
33+
log('Loading assets for Multi-Animate Atlas character "${characterId}"');
34+
loadAtlases();
35+
loadAnimations();
4236

4337
log('Successfully loaded texture atlases for ${characterId} with ${_data.animations.length} animations.');
4438
super.onCreate(event);
@@ -48,31 +42,58 @@ class MultiAnimateAtlasCharacter extends BaseCharacter
4842
{
4943
log('Loading sprite atlases for ${characterId}.');
5044

51-
var assetList:Array<String> = [];
52-
for (anim in _data.animations)
53-
{
54-
if (anim.assetPath != null && !assetList.contains(anim.assetPath))
55-
{
56-
assetList.push(anim.assetPath);
57-
}
58-
}
45+
var textureList:Array<FlxAtlasFrames> = [];
46+
var addedAssetPaths:Array<String> = [];
5947

6048
var baseAssetLibrary:String = Paths.getLibrary(_data.assetPath);
6149
var baseAssetPath:String = Paths.stripLibrary(_data.assetPath);
6250

6351
loadTextureAtlas(baseAssetPath, baseAssetLibrary, getAtlasSettings());
6452

65-
for (asset in assetList)
66-
{
67-
var subAssetLibrary:String = Paths.getLibrary(asset);
68-
var subAssetPath:String = Paths.stripLibrary(asset);
53+
var mainTexture:FlxAtlasFrames = this.library;
54+
textureList.push(mainTexture);
6955

70-
var subTexture:FlxAnimateFrames = Paths.getAnimateAtlas(subAssetPath, subAssetLibrary, cast _data.atlasSettings);
56+
for (animation in _data.animations)
57+
{
58+
if (animation.assetPath == null) continue;
59+
if (addedAssetPaths.contains(animation.assetPath)) continue;
7160

72-
log('Concatenating texture atlas: ${asset}');
73-
subTexture.parent.destroyOnNoUse = false;
61+
switch (animation.renderType)
62+
{
63+
case "sparrow":
64+
var subTexture:FlxAtlasFrames = Paths.getSparrowAtlas(animation.assetPath);
65+
// If we don't do this, the unused textures will be removed as soon as they're loaded.
66+
67+
if (subTexture == null)
68+
{
69+
log('Multi-Animate atlas could not load subtexture: ${animation.assetPath}');
70+
FlxG.log.error('Multi-Animate atlas could not load subtexture: ${animation.assetPath}');
71+
return;
72+
}
73+
else
74+
{
75+
log('Concatenating sparrow atlas: ${animation.assetPath}');
76+
subTexture.parent.destroyOnNoUse = false;
77+
// This breaks mix-and-match for some reason.
78+
// TODO: Re-enable this line once a proper fix is found.
79+
// - Abnormal
80+
// FunkinMemory.cacheTexture(Paths.image(animation.assetPath));
81+
}
82+
83+
textureList.push(subTexture);
84+
default:
85+
var subAssetLibrary:String = Paths.getLibrary(animation.assetPath);
86+
var subAssetPath:String = Paths.stripLibrary(animation.assetPath);
87+
88+
var subTexture:FlxAnimateFrames = Paths.getAnimateAtlas(subAssetPath, subAssetLibrary, cast animation.atlasSettings ?? _data.atlasSettings);
89+
90+
log('Concatenating texture atlas: ${animation.assetPath}');
91+
subTexture.parent.destroyOnNoUse = false;
92+
93+
textureList.push(subTexture);
94+
}
7495

75-
this.library.addAtlas(subTexture);
96+
addedAssetPaths.push(animation.assetPath);
7697
}
7798

7899
if (_data.isPixel)
@@ -86,17 +107,24 @@ class MultiAnimateAtlasCharacter extends BaseCharacter
86107
this.antialiasing = true;
87108
}
88109

110+
this.frames = FlxAnimateFrames.combineAtlas(textureList);
89111
this.setScale(_data.scale);
90112
}
91113

92114
function loadAnimations():Void
93115
{
94-
log('Loading ${_data.animations.length} animations for ${characterId}');
95-
96-
FlxAnimationUtil.addTextureAtlasAnimations(this, _data.animations);
116+
log('[MULTIATLASCHAR] Loading ${_data.animations.length} animations for ${characterId}');
97117

98118
for (anim in _data.animations)
99119
{
120+
switch (anim.renderType)
121+
{
122+
case "sparrow":
123+
FlxAnimationUtil.addAtlasAnimation(this, anim);
124+
default:
125+
FlxAnimationUtil.addTextureAtlasAnimation(this, anim);
126+
}
127+
100128
if (anim.offsets == null)
101129
{
102130
setAnimationOffsets(anim.name, 0, 0);
@@ -107,8 +135,8 @@ class MultiAnimateAtlasCharacter extends BaseCharacter
107135
}
108136
}
109137

110-
var animNames = this.anim.getNameList();
111-
log('Successfully loaded ${animNames.length} animations for ${characterId}');
138+
var animationNames:Array<String> = this.animation.getNameList();
139+
log('[MULTIATLASCHAR] Successfully loaded ${animationNames.length} animations for ${characterId}');
112140
}
113141

114142
/**

0 commit comments

Comments
 (0)