Skip to content

Commit 0c8b766

Browse files
I BROKE THE OFFSETS FUCK
.
1 parent 246014a commit 0c8b766

File tree

17 files changed

+97
-532
lines changed

17 files changed

+97
-532
lines changed

project.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
<haxelib name="away3d" if="THREE_D_SUPPORT" />
132132
<haxelib name="format" />
133133
<haxelib name="flxanimate" />
134+
<haxelib name="flixel-animate" />
134135
<haxelib name="nape-haxe4" if="NAPE_ENABLED"/>
135136

136137
<haxelib name="hscript-improved" />

source/funkin/backend/FlxAnimate.hx

Lines changed: 0 additions & 92 deletions
This file was deleted.

source/funkin/backend/FunkinSprite.hx

Lines changed: 27 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package funkin.backend;
22

3+
import animate.FlxAnimate;
4+
import animate.FlxAnimateController.FlxAnimateAnimation;
35
import flixel.addons.effects.FlxSkewedSprite;
46
import flixel.animation.FlxAnimation;
57
import flixel.math.FlxMatrix;
@@ -43,7 +45,7 @@ enum abstract XMLAnimType(Int)
4345
}
4446
}
4547

46-
class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements IOffsetCompatible implements IXMLEvents
48+
class FunkinSprite extends FlxAnimate implements IBeatReceiver implements IOffsetCompatible implements IXMLEvents
4749
{
4850
public var extra:Map<String, Dynamic> = [];
4951

@@ -66,10 +68,6 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
6668
public var beatOffset:Int = 0;
6769
public var skipNegativeBeats:Bool = false;
6870

69-
public var animateAtlas:FlxAnimate;
70-
@:noCompletion public var atlasPlayingAnim:String;
71-
@:noCompletion public var atlasPath:String;
72-
7371
var _rect2:FlxRect;
7472

7573
public function new(?X:Float = 0, ?Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset)
@@ -85,6 +83,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
8583
}
8684

8785
moves = false;
86+
applyStageMatrix = true;
8887
}
8988

9089
/**
@@ -100,8 +99,6 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
10099
@:privateAccess {
101100
spr.setPosition(source.x, source.y);
102101
spr.frames = source.frames;
103-
if (casted != null && casted.animateAtlas != null && casted.atlasPath != null)
104-
spr.loadSprite(casted.atlasPath);
105102
spr.animation.copyFrom(source.animation);
106103
spr.visible = source.visible;
107104
spr.alpha = source.alpha;
@@ -111,8 +108,6 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
111108

112109
if (casted != null) {
113110
spr.skew.set(casted.skew.x, casted.skew.y);
114-
spr.transformMatrix = casted.transformMatrix;
115-
spr.matrixExposed = casted.matrixExposed;
116111
spr.animOffsets = casted.animOffsets.copy();
117112
spr.zoomFactor = casted.zoomFactor;
118113
}
@@ -123,8 +118,6 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
123118
public override function update(elapsed:Float)
124119
{
125120
super.update(elapsed);
126-
if (animateAtlas != null)
127-
animateAtlas.update(elapsed);
128121

129122
// hate how it looks like but hey at least its optimized and fast - Nex
130123
if (!debugMode && isAnimFinished()) {
@@ -142,15 +135,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
142135
public function loadSprite(path:String, Unique:Bool = false, Key:String = null)
143136
{
144137
var noExt = Path.withoutExtension(path);
145-
if (Assets.exists('$noExt/Animation.json'))
146-
{
147-
atlasPath = noExt;
148-
animateAtlas = new FlxAnimate(x, y, noExt);
149-
}
150-
else
151-
{
152-
frames = Paths.getFrames(path, true);
153-
}
138+
frames = Paths.getFrames(path, true);
154139
return this;
155140
}
156141

@@ -182,48 +167,9 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
182167

183168
// ANIMATE ATLAS DRAWING
184169
#if REGION
185-
public override function draw()
186-
{
187-
if (animateAtlas != null)
188-
{
189-
copyAtlasValues();
190-
animateAtlas.draw();
191-
}
192-
else
193-
{
194-
super.draw();
195-
}
196-
}
197-
198-
public function copyAtlasValues()
199-
{
200-
@:privateAccess {
201-
animateAtlas.cameras = cameras; // investigate if we can use _cameras
202-
animateAtlas.scrollFactor = scrollFactor;
203-
animateAtlas.scale = scale;
204-
animateAtlas.offset = offset;
205-
animateAtlas.frameOffset = frameOffset;
206-
animateAtlas.x = x;
207-
animateAtlas.y = y;
208-
animateAtlas.angle = angle;
209-
animateAtlas.alpha = alpha;
210-
animateAtlas.visible = visible;
211-
animateAtlas.flipX = flipX;
212-
animateAtlas.flipY = flipY;
213-
animateAtlas.shader = shader;
214-
animateAtlas.shaderEnabled = shaderEnabled;
215-
animateAtlas.antialiasing = antialiasing;
216-
animateAtlas.skew = skew;
217-
animateAtlas.transformMatrix = transformMatrix;
218-
animateAtlas.matrixExposed = matrixExposed;
219-
animateAtlas.colorTransform = colorTransform;
220-
}
221-
}
222170

223171
public override function destroy()
224172
{
225-
animateAtlas = FlxDestroyUtil.destroy(animateAtlas);
226-
227173
if (animOffsets != null) {
228174
for (key in animOffsets.keys()) {
229175
final point = animOffsets[key];
@@ -340,13 +286,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
340286
Force = anim != null && anim.forced;
341287
}
342288

343-
if (animateAtlas != null)
344-
{
345-
@:privateAccess
346-
animateAtlas.anim.play(AnimName, Force, Reversed, Frame);
347-
atlasPlayingAnim = AnimName;
348-
}
349-
else animation.play(AnimName, Force, Reversed, Frame);
289+
animation.play(AnimName, Force, Reversed, Frame);
350290

351291
var daOffset = getAnimOffset(AnimName);
352292
frameOffset.set(daOffset.x, daOffset.y);
@@ -370,18 +310,11 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
370310
});
371311
}
372312

373-
public inline function removeAnim(name:String)
374-
{
375-
if (animateAtlas != null)
376-
@:privateAccess animateAtlas.anim.animsMap.remove(name);
377-
else
378-
animation.remove(name);
313+
public inline function removeAnim(name:String) {
314+
animation.remove(name);
379315
}
380316

381-
public function getAnim(name:String):OneOfTwo<FlxAnimation, FlxSymbolAnimation>
382-
{
383-
if(animateAtlas != null)
384-
return animateAtlas.anim.getByName(name);
317+
public function getAnim(name:String):OneOfTwo<FlxAnimation, FlxAnimateAnimation> {
385318
return animation.getByName(name);
386319
}
387320

@@ -392,40 +325,26 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
392325
return FlxPoint.weak(0, 0);
393326
}
394327

395-
public inline function hasAnim(AnimName:String):Bool @:privateAccess
396-
return animateAtlas != null ? (animateAtlas.anim.animsMap.exists(AnimName)
397-
|| animateAtlas.anim.symbolDictionary.exists(AnimName)) : animation.exists(AnimName);
328+
public inline function hasAnim(AnimName:String):Bool
329+
return animation.exists(AnimName);
398330

399-
public inline function getAnimName() {
400-
return (animateAtlas != null) ? atlasPlayingAnim : animation.name;
401-
}
331+
public inline function getAnimName()
332+
return animation.name;
402333

403-
public inline function isAnimReversed():Bool {
404-
return animateAtlas != null ? animateAtlas.anim.reversed : animation.curAnim != null ? animation.curAnim.reversed : false;
405-
}
334+
public inline function isAnimReversed():Bool
335+
return animation.curAnim?.reversed ?? false;
406336

407-
public inline function getNameList():Array<String> {
408-
if (animateAtlas != null)
409-
return [for (name in @:privateAccess animateAtlas.anim.animsMap.keys()) name];
410-
else
411-
return animation.getNameList();
412-
}
337+
public inline function getNameList():Array<String>
338+
return animation.getNameList();
413339

414340
public inline function stopAnim()
415-
{
416-
if (animateAtlas != null)
417-
animateAtlas.anim.pause();
418-
else
419-
animation.stop();
420-
}
341+
animation.stop();
421342

422-
public inline function isAnimFinished() {
423-
return animateAtlas != null ? animateAtlas.anim.finished : (animation.curAnim != null ? animation.curAnim.finished : true);
424-
}
343+
public inline function isAnimFinished()
344+
return animation.curAnim?.finished ?? true;
425345

426-
public inline function isAnimAtEnd() {
427-
return animateAtlas != null ? animateAtlas.anim.isAtEnd : (animation.curAnim != null ? animation.curAnim.isAtEnd : false);
428-
}
346+
public inline function isAnimAtEnd()
347+
return animation.curAnim?.isAtEnd ?? false;
429348

430349
override function updateAnimation(elapsed:Float) {
431350
if (animEnabled)
@@ -447,10 +366,9 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
447366
return beatInterval = v;
448367
}
449368

450-
@:noCompletion private inline function get_globalCurFrame() {
451-
return animateAtlas != null ? (animateAtlas.anim.curFrame) : (animation.curAnim != null ? animation.curAnim.curFrame : 0);
452-
}
453-
@:noCompletion private inline function set_globalCurFrame(val:Int) {
454-
return animateAtlas != null ? (animateAtlas.anim.curFrame = val) : (animation.curAnim != null ? animation.curAnim.curFrame = val : val);
455-
}
369+
@:noCompletion private inline function get_globalCurFrame()
370+
return animation.curAnim?.curFrame ?? 0;
371+
372+
@:noCompletion private inline function set_globalCurFrame(val:Int)
373+
return animation.curAnim?.curFrame ?? 0;
456374
}

source/funkin/backend/MusicBeatTransition.hx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,8 @@ class MusicBeatTransition extends MusicBeatSubstate {
114114
}
115115

116116
if (transitionSprite != null) {
117-
if (transitionSprite.animateAtlas == null) {
118-
transitionSprite.setGraphicSize(transitionCamera.width, transitionCamera.height);
119-
transitionSprite.updateHitbox();
120-
} else {
121-
transitionSprite.screenCenter();
122-
}
117+
transitionSprite.setGraphicSize(transitionCamera.width, transitionCamera.height);
118+
transitionSprite.updateHitbox();
123119
}
124120
}
125121

source/funkin/backend/assets/Paths.hx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import funkin.backend.scripting.Script;
88
import haxe.io.Path;
99
import lime.utils.AssetLibrary;
1010
import openfl.utils.Assets as OpenFlAssets;
11+
import animate.FlxAnimateFrames;
1112

1213
using StringTools;
1314

@@ -174,6 +175,9 @@ class Paths
174175
inline static public function getSparrowAtlas(key:String, ?library:String, ?ext:String)
175176
return FlxAtlasFrames.fromSparrow(image(key, library, ext), file('images/$key.xml', library));
176177

178+
inline static public function getAnimateAtlasAlt(key:String)
179+
return FlxAnimateFrames.fromAnimate(key);
180+
177181
inline static public function getSparrowAtlasAlt(key:String, ?ext:String)
178182
return FlxAtlasFrames.fromSparrow('$key.${ext != null ? ext : Flags.IMAGE_EXT}', '$key.xml');
179183

@@ -263,6 +267,8 @@ class Paths
263267
cur++;
264268
}
265269
return finalFrames;
270+
} else if (Assets.exists('$noExt/Animation.json')) {
271+
return Paths.getAnimateAtlasAlt(noExt);
266272
} else if (Assets.exists('$noExt.xml')) {
267273
return Paths.getSparrowAtlasAlt(noExt, ext);
268274
} else if (Assets.exists('$noExt.txt')) {

source/funkin/backend/scripting/Script.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Script extends FlxBasic implements IFlxDestroyable {
9191
"FunkinShader" => funkin.backend.shaders.FunkinShader,
9292
"CustomShader" => funkin.backend.shaders.CustomShader,
9393
"FunkinText" => funkin.backend.FunkinText,
94-
"FlxAnimate" => funkin.backend.FlxAnimate,
94+
"FlxAnimate" => animate.FlxAnimate,
9595
"FunkinSprite" => funkin.backend.FunkinSprite,
9696
"Alphabet" => funkin.menus.ui.Alphabet,
9797
"Flags" => funkin.backend.system.Flags,

source/funkin/backend/system/macros/Macros.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Macros {
2323
#if VIDEO_CUTSCENES "hxvlc.flixel", "hxvlc.openfl", #end
2424
#if NAPE_ENABLED "nape", "flixel.addons.nape", #end
2525
// BASE HAXE
26-
"DateTools", "EReg", "Lambda", "StringBuf", "haxe.crypto", "haxe.display", "haxe.exceptions", "haxe.extern", "scripting"
26+
"DateTools", "EReg", "Lambda", "StringBuf", "haxe.crypto", "haxe.display", "haxe.exceptions", "haxe.extern", "scripting", "animate"
2727
])
2828
Compiler.include(inc);
2929

0 commit comments

Comments
 (0)