Skip to content

Commit 4e51376

Browse files
AbnormalPoofNotHyper-474MaybeMarutrayfellow
authored andcommitted
Replace FlxAnimate with flixel-animate
Co-authored-by: Hyper_ <40342021+NotHyper-474@users.noreply.github.com> Co-authored-by: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com> Co-authored-by: Trayfellow <48515908+trayfellow@users.noreply.github.com>
1 parent 2ad5933 commit 4e51376

51 files changed

Lines changed: 2056 additions & 2434 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets

hmm.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@
5656
"url": "https://github.com/FunkinCrew/flixel-addons"
5757
},
5858
{
59-
"name": "flxanimate",
59+
"name": "flixel-animate",
6060
"type": "git",
6161
"dir": null,
62-
"ref": "49214278b9124823582cdcecd94f4a1de9a4b36b",
63-
"url": "https://github.com/FunkinCrew/flxanimate"
62+
"ref": "1ed39626306b3cfb75df40890295069d1cd02698",
63+
"url": "https://github.com/MaybeMaru/flixel-animate"
6464
},
6565
{
6666
"name": "format",

project.hxp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ class Project extends HXProject
12921292
}
12931293

12941294
addHaxelib('polymod'); // Modding framework
1295-
addHaxelib('flxanimate'); // Texture atlas rendering
1295+
addHaxelib('flixel-animate'); // Texture atlas rendering
12961296

12971297
addHaxelib('json2object'); // JSON parsing
12981298
addHaxelib('jsonpath'); // JSON parsing

source/funkin/Assets.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package funkin;
22

33
import openfl.utils.Future;
4+
import funkin.util.macro.ConsoleMacro;
45

56
/**
67
* A wrapper around `openfl.utils.Assets` which disallows access to the harmful functions.
78
* Later we'll add Funkin-specific caching to this.
89
*/
910
@:nullSafety
10-
class Assets
11+
class Assets implements ConsoleClass
1112
{
1213
/**
1314
* The assets cache.

source/funkin/FunkinMemory.hx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ class FunkinMemory
111111

112112
///// TEXTURES /////
113113

114+
/**
115+
* Determine whether the texture with the given key is cached.
116+
* @param key The key of the texture to check.
117+
* @return Whether the texture is cached.
118+
*/
119+
public static function isTextureCached(key:String):Bool
120+
{
121+
return FlxG.bitmap.get(key) != null;
122+
}
123+
114124
/**
115125
* Ensures a texture with the given key is cached.
116126
* @param key The key of the texture to cache.

source/funkin/Paths.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package funkin;
22

33
import flixel.graphics.frames.FlxAtlasFrames;
44
import openfl.utils.AssetType;
5+
import funkin.util.macro.ConsoleMacro;
56
import haxe.io.Path;
67

78
/**
89
* A core class which handles determining asset paths.
910
*/
1011
@:nullSafety
11-
class Paths
12+
class Paths implements ConsoleClass
1213
{
1314
static var currentLevel:Null<String> = null;
1415

source/funkin/data/animation/AnimationData.hx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ typedef UnnamedAnimationData =
8383

8484
/**
8585
* Optionally specify an asset path to use for this specific animation.
86-
* ONLY for use by MultiSparrow characters.
86+
* ONLY for use by MultiSparrow and MultiAnimateAtlas characters.
8787
* @default The assetPath of the parent sprite
8888
*/
8989
@:optional
@@ -138,4 +138,13 @@ typedef UnnamedAnimationData =
138138
@:default([])
139139
@:optional
140140
var frameIndices:Null<Array<Int>>;
141+
142+
/**
143+
* The type of animation to use.
144+
* Only available for texture atlases.
145+
* Options: "framelabel", "symbol"
146+
*/
147+
@:default("framelabel")
148+
@:optional
149+
var animType:String;
141150
}

source/funkin/data/character/CharacterData.hx

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import funkin.modding.events.ScriptEventDispatcher;
66
import funkin.play.character.ScriptedCharacter.ScriptedAnimateAtlasCharacter;
77
import funkin.play.character.ScriptedCharacter.ScriptedBaseCharacter;
88
import funkin.play.character.ScriptedCharacter.ScriptedMultiSparrowCharacter;
9+
import funkin.play.character.ScriptedCharacter.ScriptedMultiAnimateAtlasCharacter;
910
import funkin.play.character.ScriptedCharacter.ScriptedPackerCharacter;
1011
import funkin.play.character.ScriptedCharacter.ScriptedSparrowCharacter;
1112
import funkin.play.character.AnimateAtlasCharacter;
1213
import funkin.play.character.BaseCharacter;
1314
import funkin.play.character.SparrowCharacter;
1415
import funkin.play.character.MultiSparrowCharacter;
16+
import funkin.play.character.MultiAnimateAtlasCharacter;
1517
import funkin.play.character.PackerCharacter;
1618
import funkin.util.assets.DataAssets;
1719
import funkin.util.VersionUtil;
@@ -160,14 +162,34 @@ class CharacterDataParser
160162
}
161163
}
162164

165+
var scriptedCharClassNames5:Array<String> = ScriptedMultiAnimateAtlasCharacter.listScriptClasses();
166+
if (scriptedCharClassNames5.length > 0)
167+
{
168+
trace(' Instantiating ${scriptedCharClassNames5.length} (Multi-Animate Atlas) scripted characters...');
169+
for (charCls in scriptedCharClassNames5)
170+
{
171+
try
172+
{
173+
var character:MultiAnimateAtlasCharacter = ScriptedMultiAnimateAtlasCharacter.init(charCls, DEFAULT_CHAR_ID);
174+
characterScriptedClass.set(character.characterId, charCls);
175+
}
176+
catch (e)
177+
{
178+
trace(' FAILED to instantiate scripted Multi-Animate Atlas character: ${charCls}');
179+
trace(e);
180+
}
181+
}
182+
}
183+
163184
// NOTE: Only instantiate the ones not populated above.
164185
// ScriptedBaseCharacter.listScriptClasses() will pick up scripts extending the other classes.
165186
var scriptedCharClassNames:Array<String> = ScriptedBaseCharacter.listScriptClasses();
166187
scriptedCharClassNames = scriptedCharClassNames.filter(function(charCls:String):Bool {
167188
return !(scriptedCharClassNames1.contains(charCls)
168189
|| scriptedCharClassNames2.contains(charCls)
169190
|| scriptedCharClassNames3.contains(charCls)
170-
|| scriptedCharClassNames4.contains(charCls));
191+
|| scriptedCharClassNames4.contains(charCls)
192+
|| scriptedCharClassNames5.contains(charCls));
171193
});
172194

173195
if (scriptedCharClassNames.length > 0)
@@ -226,6 +248,8 @@ class CharacterDataParser
226248
char = ScriptedSparrowCharacter.init(charScriptClass, charId);
227249
case CharacterRenderType.Packer:
228250
char = ScriptedPackerCharacter.init(charScriptClass, charId);
251+
case CharacterRenderType.MultiAnimateAtlas:
252+
char = ScriptedMultiAnimateAtlasCharacter.init(charScriptClass, charId);
229253
default:
230254
// We're going to assume that the script class does the rendering.
231255
char = ScriptedBaseCharacter.init(charScriptClass, charId, CharacterRenderType.Custom);
@@ -243,6 +267,8 @@ class CharacterDataParser
243267
char = new SparrowCharacter(charId);
244268
case CharacterRenderType.Packer:
245269
char = new PackerCharacter(charId);
270+
case CharacterRenderType.MultiAnimateAtlas:
271+
char = new MultiAnimateAtlasCharacter(charId);
246272
default:
247273
trace('[WARN] Creating character with undefined renderType ${charData.renderType}');
248274
char = new BaseCharacter(charId, CharacterRenderType.Custom);
@@ -431,6 +457,15 @@ class CharacterDataParser
431457
public static final DEFAULT_SCALE:Float = 1;
432458
public static final DEFAULT_SCROLL:Array<Float> = [0, 0];
433459
public static final DEFAULT_STARTINGANIM:String = 'idle';
460+
public static final DEFAULT_APPLYSTAGEMATRIX:Bool = false;
461+
public static final DEFAULT_ANIMTYPE:String = "framelabel";
462+
public static final DEFAULT_ATLASSETTINGS:funkin.data.stage.StageData.TextureAtlasData =
463+
{
464+
swfMode: true,
465+
cacheOnLoad: false,
466+
filterQuality: 1,
467+
applyStageMatrix: false
468+
};
434469

435470
/**
436471
* Set unspecified parameters to their defaults.
@@ -559,6 +594,16 @@ class CharacterDataParser
559594
input.flipX = DEFAULT_FLIPX;
560595
}
561596

597+
if (input.applyStageMatrix == null)
598+
{
599+
input.applyStageMatrix = DEFAULT_APPLYSTAGEMATRIX;
600+
}
601+
602+
if (input.atlasSettings == null)
603+
{
604+
input.atlasSettings = DEFAULT_ATLASSETTINGS;
605+
}
606+
562607
if (input.animations.length == 0 && input.startingAnimation != null)
563608
{
564609
return null;
@@ -596,6 +641,11 @@ class CharacterDataParser
596641
{
597642
inputAnimation.flipY = DEFAULT_FLIPY;
598643
}
644+
645+
if (inputAnimation.animType == null)
646+
{
647+
inputAnimation.animType = DEFAULT_ANIMTYPE;
648+
}
599649
}
600650

601651
// All good!
@@ -624,10 +674,15 @@ enum abstract CharacterRenderType(String) from String to String
624674
public var MultiSparrow = 'multisparrow';
625675

626676
/**
627-
* Renders the character using a spritesheet of symbols and JSON data.
677+
* Renders the character using a single spritesheet of symbols and JSON data.
628678
*/
629679
public var AnimateAtlas = 'animateatlas';
630680

681+
/**
682+
* Renders the character using multiple spritesheets of symbols and JSON data.
683+
*/
684+
public var MultiAnimateAtlas = 'multianimateatlas';
685+
631686
/**
632687
* Renders the character using a custom method.
633688
*/
@@ -674,6 +729,9 @@ typedef CharacterData =
674729
*/
675730
var healthIcon:Null<HealthIconData>;
676731

732+
/**
733+
* Optional data about the death animation for the character.
734+
*/
677735
var death:Null<DeathData>;
678736

679737
/**
@@ -734,6 +792,23 @@ typedef CharacterData =
734792
* @default false
735793
*/
736794
var flipX:Null<Bool>;
795+
796+
/**
797+
* NOTE: This only applies to animate atlas characters.
798+
*
799+
* Whether to apply the stage matrix, if it was exported from a symbol instance.
800+
* Also positions the Texture Atlas as it displays in Animate.
801+
* Turning this on is only recommended if you prepositioned the character in Animate.
802+
* For other cases, it should be turned off to act similarly to a normal FlxSprite.
803+
*/
804+
var applyStageMatrix:Null<Bool>;
805+
806+
/**
807+
* Various settings for the prop.
808+
* Only available for texture atlases.
809+
*/
810+
@:optional
811+
var atlasSettings:funkin.data.stage.StageData.TextureAtlasData;
737812
};
738813

739814
/**

source/funkin/data/freeplay/player/PlayerData.hx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ class PlayerFreeplayDJData
103103
var assetPath:String;
104104
var animations:Array<AnimationData>;
105105

106+
@:optional
107+
@:default(false)
108+
var applyStageMatrix:Bool;
109+
106110
@:optional
107111
@:default("BOYFRIEND")
108112
var text1:String;
@@ -158,11 +162,16 @@ class PlayerFreeplayDJData
158162
}
159163

160164
public inline function getAssetPath():String
161-
return assetPath; // return Paths.animateAtlas(assetPath);
165+
return assetPath; // return assetPath;
162166

163167
public inline function getAnimationsList():Array<AnimationData>
164168
return animations;
165169

170+
public function useApplyStageMatrix():Bool
171+
{
172+
return applyStageMatrix;
173+
}
174+
166175
public function getFreeplayDJText(index:Int):String
167176
{
168177
switch (index)
@@ -343,6 +352,10 @@ typedef PlayerResultsAnimationData =
343352
*/
344353
var renderType:String;
345354

355+
@:optional
356+
@:default(false)
357+
var applyStageMatrix:Bool;
358+
346359
@:optional
347360
var assetPath:Null<String>;
348361

source/funkin/data/stage/StageData.hx

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ typedef StageDataProp =
196196

197197
/**
198198
* The animation type to use.
199-
* Options: "sparrow", "packer"
199+
* Options: "sparrow", "packer", "animateatlas"
200200
* @default "sparrow"
201201
*/
202202
@:default("sparrow")
@@ -228,6 +228,52 @@ typedef StageDataProp =
228228
@:default("#FFFFFF")
229229
@:optional
230230
var color:String;
231+
232+
/**
233+
* Various settings for the prop.
234+
* Only available for texture atlases.
235+
*/
236+
@:optional
237+
var atlasSettings:TextureAtlasData;
238+
};
239+
240+
typedef TextureAtlasData =
241+
{
242+
/**
243+
* If true, the texture atlas will behave as if it was exported as an SWF file.
244+
* Notably, this allows MovieClip symbols to play.
245+
*/
246+
@:optional
247+
var swfMode:Bool;
248+
249+
/**
250+
* If true, filters and masks will be cached when the atlas is loaded, instead of during runtime.
251+
*/
252+
@:optional
253+
var cacheOnLoad:Bool;
254+
255+
/**
256+
* The filter quality.
257+
* Available values are: HIGH, MEDIUM, LOW, and RUDY.
258+
*
259+
* If you're making an atlas sprite in HScript, you pass an Int instead:
260+
*
261+
* HIGH - 0
262+
* MEDIUM - 1
263+
* LOW - 2
264+
* RUDY - 3
265+
*/
266+
@:optional
267+
var filterQuality:Int;
268+
269+
/**
270+
* Whether to apply the stage matrix, if it was exported from a symbol instance.
271+
* Also positions the Texture Atlas as it displays in Animate.
272+
* Turning this on is only recommended if you prepositioned the character in Animate.
273+
* For other cases, it should be turned off to act similarly to a normal FlxSprite.
274+
*/
275+
@:optional
276+
var applyStageMatrix:Bool;
231277
};
232278

233279
typedef StageDataCharacter =

0 commit comments

Comments
 (0)