WIP on Animate

This commit is contained in:
EliteMasterEric 2023-02-01 16:18:41 -05:00
parent dad252dfdc
commit 39585f9794
9 changed files with 131 additions and 1172 deletions

View file

@ -13,7 +13,7 @@ Code Quality is handled by the `vshaxe.haxe-checkstyle` extension, which include
* Checks can be disabled by setting the severity to `IGNORE`.
* `IndentationCharacter` checks what is used to indent, `Indentation` checks how deep the intentation is.
* `CommentedOutCode` check is in place because old code should be retrieved via Git history.
* TODO items:
* TODO items: Enable these one-by-one and fix them to improve the overall code quality.
- Reconfigure `MethodLength`
- Reconfigure `CyclomaticComplexity`
- Re-enable `MagicNumber`

View file

@ -41,7 +41,9 @@
"type": "AvoidStarImport"
},
{
"props": {},
"props": {
"severity": "IGNORE"
},
"type": "AvoidTernaryOperator"
},
{
@ -229,7 +231,8 @@
},
{
"props": {
"ignoreReturnAssignments": false
"ignoreReturnAssignments": false,
"severity": "WARNING"
},
"type": "InnerAssignment"
},
@ -275,11 +278,18 @@
},
"type": "MagicNumber"
},
{
"props": {
"format": "^[A-Z][a-zA-Z0-9]*$",
"tokens": ["ENUM"]
},
"type": "MemberName"
},
{
"props": {
"ignoreExtern": true,
"format": "^[a-z][a-zA-Z0-9]*$",
"tokens": []
"tokens": ["PUBLIC", "PRIVATE", "CLASS", "ABSTRACT", "TYPEDEF"]
},
"type": "MemberName"
},
@ -310,10 +320,10 @@
{
"props": {
"modifiers": [
"MACRO",
"OVERRIDE",
"PUBLIC_PRIVATE",
"STATIC",
"MACRO",
"OVERRIDE",
"INLINE",
"DYNAMIC",
"FINAL"
@ -342,13 +352,15 @@
},
{
"props": {
"max": 3
"max": 3,
"severity": "IGNORE"
},
"type": "NestedControlFlow"
},
{
"props": {
"max": 1
"max": 1,
"severity": "IGNORE"
},
"type": "NestedForDepth"
},
@ -366,7 +378,7 @@
},
{
"props": {
"option": "questionMark"
"option": "nullDefault"
},
"type": "NullableParameter"
},
@ -426,7 +438,7 @@
"++",
"--"
],
"option": "eol"
"option": "nl"
},
"type": "OperatorWrap"
},
@ -446,7 +458,9 @@
"type": "ParameterNumber"
},
{
"props": {},
"props": {
"severity": "WARNING"
},
"type": "PublicAccessor"
},
{

View file

@ -1,5 +1,6 @@
{
"dependencies": [{
"dependencies": [
{
"name": "discord_rpc",
"type": "git",
"dir": null,
@ -10,15 +11,15 @@
"name": "flixel",
"type": "git",
"dir": null,
"ref": "a629f9a5",
"url": "https://github.com/MasterEric/flixel"
"ref": "ec5d0f2",
"url": "https://github.com/EliteMasterEric/flixel"
},
{
"name": "flixel-addons",
"type": "git",
"dir": null,
"ref": "752c3d7",
"url": "https://github.com/MasterEric/flixel-addons"
"url": "https://github.com/EliteMasterEric/flixel-addons"
},
{
"name": "flixel-ui",
@ -29,7 +30,7 @@
"name": "flxanimate",
"type": "git",
"dir": null,
"ref": "18b2060",
"ref": "master",
"url": "https://github.com/Dot-Stuff/flxanimate"
},
{
@ -88,7 +89,7 @@
"type": "git",
"dir": null,
"ref": "3fd5763c1",
"url": "https://github.com/MasterEric/openfl"
"url": "https://github.com/EliteMasterEric/openfl"
},
{
"name": "polymod",

View file

@ -1,36 +0,0 @@
package funkin.animate;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.addons.display.FlxGridOverlay;
class AnimTestStage extends FlxState
{
var tl:AnimateTimeline;
var swag:FlxAnimate;
override function create()
{
var bg:FlxSprite = FlxGridOverlay.create(32, 32);
add(bg);
bg.scrollFactor.set();
swag = new FlxAnimate(200, 200);
add(swag);
tl = new AnimateTimeline(Paths.file('images/tightBarsLol/Animation.json'));
add(tl);
super.create();
}
override function update(elapsed:Float)
{
tl.curFrame = swag.daFrame;
CoolUtil.mouseWheelZoom();
CoolUtil.mouseCamDrag();
super.update(elapsed);
}
}

View file

@ -1,74 +0,0 @@
package funkin.animate;
import flixel.FlxCamera;
import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxGroup;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import haxe.Json;
import lime.utils.Assets;
class AnimateTimeline extends FlxTypedGroup<FlxSprite>
{
// var coolParsed:Parsed;
var playhead:FlxSprite;
public var curFrame(default, set):Int;
function set_curFrame(frm:Int):Int
{
if (playhead != null) playhead.x = 5 + (frm * 12) + (12 * 5);
return frm;
}
var hudCamShit:FlxCamera;
public function new(parsed:String)
{
super();
/* hudCamShit = new FlxCamera();
hudCamShit.bgColor = FlxColor.TRANSPARENT;
FlxG.cameras.add(hudCamShit, false);
playhead = new FlxSprite(0, -12).makeGraphic(2, 10, FlxColor.MAGENTA);
add(playhead);
hudCamShit.follow(playhead);
hudCamShit.setScrollBounds(0, null, -14, null);
curFrame = 0;
coolParsed = cast Json.parse(Assets.getText(parsed));
var layerNum:Int = 0;
for (layer in coolParsed.AN.TL.L)
{
var frameNum:Int = 0;
for (frame in layer.FR)
{
var coolFrame:TimelineFrame = new TimelineFrame((frame.I * 12) + 12 * 5, layerNum * 12, frame.DU, frame);
add(coolFrame);
frameNum++;
}
var layerName:FlxText = new FlxText(0, layerNum * 12, 0, layer.LN, 10);
layerName.color = FlxColor.PURPLE;
layerName.scrollFactor.x = 0;
var layerBG:FlxSprite = new FlxSprite(0, layerNum * 12).makeGraphic(12 * 4, 12);
layerBG.scrollFactor.x = 0;
add(layerBG);
add(layerName);
layerNum++;
}
this.cameras = [hudCamShit];
*/
}
}

View file

@ -1,285 +0,0 @@
package funkin.animate;
import funkin.animate.ParseAnimate.AnimJson;
import funkin.animate.ParseAnimate.Sprite;
import funkin.animate.ParseAnimate.Spritemap;
import flixel.FlxCamera;
import flixel.FlxSprite;
import flixel.graphics.FlxGraphic;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.graphics.frames.FlxFrame.FlxFrameAngle;
import flixel.group.FlxGroup;
import flixel.math.FlxMatrix;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets.FlxGraphicAsset;
import haxe.format.JsonParser;
import openfl.Assets;
import openfl.display.BitmapData;
import openfl.geom.Matrix;
import openfl.geom.Rectangle;
class FlxAnimate extends FlxSymbol
{
// var myAnim:Animation;
// var animBitmap:BitmapData;
var jsonAnim:AnimJson;
var sprGrp:FlxTypedGroup<FlxSymbol>;
public function new(x:Float, y:Float)
{
super(x, y);
sprGrp = new FlxTypedGroup<FlxSymbol>();
var tests:Array<String> = ['tightBarsLol', 'tightestBars'];
var folder:String = tests[1];
frames = FlxAnimate.fromAnimate(Paths.file('images/' + folder + "/spritemap1.png"), Paths.file('images/$folder/spritemap1.json'));
jsonAnim = cast CoolUtil.coolJSON(Assets.getText(Paths.file('images/$folder/Animation.json')));
ParseAnimate.generateSymbolmap(jsonAnim.SD.S);
ParseAnimate.resetFrameList();
ParseAnimate.parseTimeline(jsonAnim.AN.TL, 0, 0);
generateSpriteShit();
/* var folder:String = 'tightestBars';
coolParse = cast Json.parse(Assets.getText(Paths.file('images/' + folder + '/Animation.json')));
// reverses the layers, for proper rendering!
coolParse.AN.TL.L.reverse();
super(x, y, coolParse);
frames = FlxAnimate.fromAnimate(Paths.file('images/' + folder + '/spritemap1.png'), Paths.file('images/' + folder + '/spritemap1.json'));
*/
// frames
}
override function draw()
{
// having this commented out fixes some wacky scaling bullshit?
// or fixes drawing it twice?
// super.draw();
// renderFrame(coolParse.AN.TL, coolParse, true);
actualFrameRender();
}
/**
* Puts all the needed sprites into a FlxTypedGroup, and properly recycles them?
**/
function generateSpriteShit()
{
sprGrp.kill(); // kills group, maybe dont need to do this one so broadly? ehh whatev
for (frameSorted in ParseAnimate.frameList)
{
for (i in frameSorted)
{
// instead of making them every frame, regenerate when needed?
var spr:FlxSymbol = sprGrp.recycle(FlxSymbol); // redo this to recycle from a list later
spr.frames = frames;
spr.frame = spr.frames.getByName(i.frameName); // this one is fine
spr.updateHitbox();
// move this? wont work here!
if (FlxG.keys.justPressed.I)
{
trace(i.frameName);
trace(i.depthString);
// trace("random lol: " + i.randomLol);
}
// cuz its in group, gets a lil fuckie when animated, need to go thru and properly reset each thing for shit like matrix!
// merely resets the matrix to normal ass one!
spr.transformMatrix.identity();
spr.setPosition();
/* for (swagMatrix in i.matrixArray)
{
var alsoSwag:FlxMatrix = new FlxMatrix(swagMatrix[0], swagMatrix[1], swagMatrix[4], swagMatrix[5], swagMatrix[12], swagMatrix[13]);
spr.matrixExposed = true;
spr.transformMatrix.concat(alsoSwag);
}*/
// i.fullMatrix.concat
spr.matrixExposed = true;
// trace(i.fullMatrix);
if (i.fullMatrix.a < 0)
{
trace('negative?');
trace(i.fullMatrix);
}
spr.transformMatrix.concat(i.fullMatrix);
if (i.fullMatrix.a < 0)
{
trace('negative?');
trace(i.fullMatrix);
trace(spr.transformMatrix);
}
// trace(spr.transformMatrix);
spr.origin.set();
/* for (trpShit in i.trpArray)
{
spr.origin.x -= trpShit[0];
spr.origin.y -= trpShit[1];
}
*/
// spr.alpha = 0.3;
spr.antialiasing = true;
sprGrp.add(spr);
spr.alpha = 0.5;
/* if (i == "0225")
{
trace('FUNNY MATRIX!');
trace(spr._matrix);
trace("\n\n MATRIX MAP");
for (m in ParseAnimate.matrixMap.get("0225"))
{
trace(m);
}
trace('\n\n');
}*/
}
}
// trace(sprGrp.length);
}
// fix render order of ALL layers!
// seperate frameList into layers
// go thru animate file to see how it should all be ordered
// per frame symbol stuff to fix lip sync (in ParseAnimate?)
// definitely need to dig through Animate.json stuff
// something with TRP stuff, look through tighterBars (GF scene)
// redo map stuff incase there's multiple assets
// ONE CENTRAL THING FOR THIS DUMBASS BULLSHIT
// sorted framelist put it all in there, then make i actually mean something
function actualFrameRender()
{
sprGrp.draw();
}
// notes to self
// account for different layers
var playingAnim:Bool = false;
var frameTickTypeShit:Float = 0;
var animFrameRate:Int = 24;
// redo all the matrix animation stuff
override function update(elapsed:Float)
{
super.update(elapsed);
if (FlxG.keys.justPressed.SPACE) playingAnim = !playingAnim;
if (playingAnim)
{
frameTickTypeShit += elapsed;
// prob fix this framerate thing for higher framerates?
if (frameTickTypeShit >= 1 / 24)
{
changeFrame(1);
frameTickTypeShit = 0;
ParseAnimate.resetFrameList();
ParseAnimate.parseTimeline(jsonAnim.AN.TL, 0, daFrame);
generateSpriteShit();
}
}
if (FlxG.keys.justPressed.RIGHT)
{
changeFrame(1);
ParseAnimate.resetFrameList();
ParseAnimate.parseTimeline(jsonAnim.AN.TL, 0, daFrame);
generateSpriteShit();
}
if (FlxG.keys.justPressed.LEFT) changeFrame(-1);
}
/**
* PARSES THE 'spritemap1.png' or whatever into a FlxAtlasFrames!!!
*/
public static function fromAnimate(Source:FlxGraphicAsset, Description:String):FlxAtlasFrames
{
var graphic:FlxGraphic = FlxG.bitmap.add(Source);
if (graphic == null) return null;
var frames:FlxAtlasFrames = FlxAtlasFrames.findFrame(graphic);
if (frames != null) return frames;
if (graphic == null || Description == null) return null;
frames = new FlxAtlasFrames(graphic);
var data:Spritemap;
var json:String = Description;
// trace(json);
var funnyJson:Dynamic = {};
if (Assets.exists(json)) funnyJson = JaySon.parseFile(json);
// trace(json);
// data = c
data = cast funnyJson;
for (sprite in data.ATLAS.SPRITES)
{
// probably nicer way to do this? Oh well
var swagSprite:Sprite = sprite.SPRITE;
var rect = FlxRect.get(swagSprite.x, swagSprite.y, swagSprite.w, swagSprite.h);
var size = new Rectangle(0, 0, rect.width, rect.height);
var offset = FlxPoint.get(-size.left, -size.top);
var sourceSize = FlxPoint.get(size.width, size.height);
frames.addAtlasFrame(rect, sourceSize, offset, swagSprite.name);
}
return frames;
}
}
// handy json function that has some hashlink fix, see the thing in CoolUtils file to see the link / where i stole it from
class JaySon
{
public static function parseFile(name:String)
{
var cont = Assets.getText(name);
function is(n:Int, what:Int)
return cont.charCodeAt(n) == what;
return JsonParser.parse(cont.substr(if (is(0, 65279)) /// looks like a HL target, skipping only first character here:
1 else if (is(0, 239) && is(1, 187) && is(2, 191)) /// it seems to be Neko or PHP, start from position 3:
3 else /// all other targets, that prepare the UTF string correctly
0));
}
}

View file

@ -1,81 +0,0 @@
package funkin.animate;
import funkin.animate.ParseAnimate.AnimJson;
import funkin.animate.ParseAnimate.Animation;
import funkin.animate.ParseAnimate.Frame;
import funkin.animate.ParseAnimate.Sprite;
import funkin.animate.ParseAnimate.Spritemap;
import funkin.animate.ParseAnimate.SymbolDictionary;
import funkin.animate.ParseAnimate.Timeline;
import flixel.FlxCamera;
import flixel.FlxSprite;
import flixel.graphics.frames.FlxFrame.FlxFrameAngle;
import flixel.math.FlxAngle;
import flixel.math.FlxMath;
import flixel.math.FlxMatrix;
import flixel.math.FlxPoint;
import lime.system.System;
import openfl.Assets;
import openfl.geom.Matrix;
class FlxSymbol extends FlxSprite
{
// Loop types shit
public static inline var LOOP:String = 'LP';
public static inline var PLAY_ONCE:String = 'PO';
public static inline var SINGLE_FRAME:String = 'SF';
public var transformMatrix:Matrix = new Matrix();
public var daLoopType:String = 'LP'; // LP by default, is set below!!!
/**
* Bool flag showing whether transformMatrix is used for rendering or not.
* False by default, which means that transformMatrix isn't used for rendering
*/
public var matrixExposed:Bool = true;
public function new(x:Float, y:Float)
{
super(x, y);
}
public var daFrame:Int = 0;
function changeFrame(frameChange:Int = 0):Void
{
daFrame += frameChange;
}
/**
* custom "homemade" (nabbed from FlxSkewSprite) draw function, to make having a matrix transform slightly
* less painful
*/
override function drawComplex(camera:FlxCamera):Void
{
_frame.prepareMatrix(_matrix, FlxFrameAngle.ANGLE_0, checkFlipX(), checkFlipY());
_matrix.translate(-origin.x, -origin.y);
_matrix.scale(scale.x, scale.y);
if (matrixExposed)
{
_matrix.concat(transformMatrix);
}
if (bakedRotationAngle <= 0)
{
updateTrig();
if (angle != 0) _matrix.rotateWithTrig(_cosAngle, _sinAngle);
}
_point.addPoint(origin);
_matrix.translate(_point.x, _point.y);
if (isPixelPerfectRender(camera))
{
_matrix.tx = Math.floor(_matrix.tx);
_matrix.ty = Math.floor(_matrix.ty);
}
camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing, shader);
}
}

View file

@ -1,517 +0,0 @@
package funkin.animate;
import haxe.format.JsonParser;
import openfl.Assets;
import openfl.geom.Matrix3D;
import openfl.geom.Matrix;
#if sys
import sys.io.File;
#end
/**
* Generally designed / written in a way that can be easily taken out of FNF and used elsewhere
* I don't think it even has ties to OpenFL? Could probably just use it for ANY haxe
* project if needed, DOES NEED A LOT OF CLEANUP THOUGH!
*/
class ParseAnimate
{
// make list of frames needed to render (with ASI)
// make GIANT list of all the frames ever and have them in order?
public static var symbolMap:Map<String, Symbol> = new Map();
public static var actualSprites:Map<String, Sprite> = new Map();
var _atlas:Map<String, Sprite>;
var _symbolData:Map<String, Symbol>;
var _defaultSymbolName:String;
public function new(data:AnimJson, atlas:Spritemap)
{
// bitmap data could prob be instead
// this code is mostly nabbed from https://github.com/miltoncandelero/OpenFLAnimateAtlas/blob/master/Source/animateatlas/displayobject/SpriteAnimationLibrary.hx
parseAnimationData(data);
parseAtlasData(atlas);
}
function parseAnimationData(data:AnimJson):Void
{
_symbolData = new Map();
var symbols = data.SD.S;
for (symbol in symbols)
_symbolData[symbol.SN] = preprocessSymbolData(symbol);
var defaultSymbol:Symbol = preprocessSymbolData(data.AN);
_defaultSymbolName = defaultSymbol.SN;
_symbolData.set(_defaultSymbolName, defaultSymbol);
}
// at little redundant, does exactly the same thing as genSpritemap()
function parseAtlasData(atlas:Spritemap):Void
{
_atlas = new Map<String, Sprite>();
if (atlas.ATLAS != null && atlas.ATLAS.SPRITES != null)
{
for (s in atlas.ATLAS.SPRITES)
_atlas.set(s.SPRITE.name, s.SPRITE);
}
}
/**
* Not used, was used for testing stuff though!
*/
public static function init()
{
// Main.gids
var folder:String = 'tightestBars';
// var spritemap:Spritemap =
// var spritemap:Spritemap = genSpritemap('test/$folder/spritemap1.json');
actualSprites = genSpritemap('test/$folder/spritemap1.json');
var animation:AnimJson = cast CoolUtil.coolJSON(Assets.getText('src/$folder/Animation.json'));
generateSymbolmap(animation.SD.S);
trace("\n\nANIMATION SHIT\n");
var timelineLength:Int = 0;
for (lyr in animation.AN.TL.L)
timelineLength = Std.int(Math.max(lyr.FR.length, timelineLength));
var content:String = animation.AN.TL.L[0].LN;
content += "TOTAL FRAMES NEEDED: " + timelineLength + "\n";
for (frm in 0...timelineLength)
{
trace('FRAME NUMBER ' + frm);
try
{
parseTimeline(animation.AN.TL, 1, frm);
content += 'Good write on frame: ' + frm + "\n";
}
catch (e)
{
content += "BAD WRITE : " + frm + "\n";
content += "\t" + e + "\n";
trace(e);
}
// File.saveContent("output.txt", content);
}
parseTimeline(animation.AN.TL, 1, 0);
trace(actualSprites);
}
/**
* a MAP of SPRITES, not to be confused with Spritemap... lol
*/
public static function genSpritemap(json:String):Map<String, Sprite>
{
var sprShitty:Spritemap = cast CoolUtil.coolJSON(json);
var sprMap:Map<String, Sprite> = new Map();
for (spr in sprShitty.ATLAS.SPRITES)
sprMap.set(spr.SPRITE.name, spr.SPRITE);
return sprMap;
}
// should change dis to all private?
public static function generateSymbolmap(symbols:Array<Symbol>)
{
for (symbol in symbols)
{
// trace(symbol.SN + "has: " + symbol.TL.L.length + " LAYERS");
symbolMap.set(symbol.SN, symbol);
// parseTimeline(symbol.TL);
}
}
public static function preprocessSymbolData(anim:Symbol):Symbol
{
var timelineData:Timeline = anim.TL;
var layerData:Array<Layer> = timelineData.L;
if (!timelineData.sortedForRender)
{
timelineData.sortedForRender = true;
layerData.reverse();
}
for (layerStuff in layerData)
{
var frames:Array<Frame> = layerStuff.FR;
for (frame in frames)
{
var elements:Array<Element> = frame.E;
for (e in 0...elements.length)
{
var element:Element = elements[e];
if (element.ASI != null)
{
element = elements[e] =
{
SI:
{
SN: "ATLAS_SYMBOL_SPRITE",
LP: "LP",
TRP: {x: 0, y: 0},
M3D: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
FF: 0,
ST: "G",
ASI: element.ASI
}
}
}
}
}
}
return anim;
}
public static var curLoopType:String;
/**
* Stuff for debug parsing
*/
public static var depthTypeBeat:String = "";
/**
* Array of bullshit that will eventually be RENDERED by whoever wanna use it!
*/
public static var frameList:Array<Array<VALIDFRAME>> = [];
// for loop stuf
/**
* Similar to frameList, keeps track of shit according to framess?
* That amount of arrays within arrays is fuckin dumb
* but innermost array is basically just x and y value, cuz im dum
*/
public static var matrixHelp:Array<Array<Array<Float>>> = [];
public static var trpHelpIDK:Array<Array<Array<Float>>> = [];
public static var loopedFrameShit:Int = 0;
public static var funnyMatrix:Matrix = new Matrix();
public static var matrixFlipper:Array<Matrix> = [];
// clean up all the crazy ass arrays
public static function resetFrameList()
{
// funnyMatrix.identity();
frameList = [];
frameList.push([]);
matrixHelp = [];
matrixHelp.push([]);
trpHelpIDK = [];
trpHelpIDK.push([]);
}
public static var isFlipped:Bool = false;
public static function parseTimeline(TL:Timeline, tabbed:Int = 0, ?frameInput:Int)
{
var strTab:String = "";
for (i in 0...tabbed)
strTab += '\t';
for (layer in TL.L)
{
var frameArray:Array<Int> = [];
var frameMap:Map<Int, Frame> = new Map();
for (frms in layer.FR)
{
for (i in 0...frms.DU)
frameArray.push(frms.I);
frameMap.set(frms.I, frms);
}
if (frameInput == null) frameInput = 0;
var oldFrm:Int = frameInput;
/*
if (curLoopType == "SF")
{
trace(layer.LN);
trace(frameArray);
trace(frameInput);
trace(curLoopType);
}*/
if (curLoopType == "LP") frameInput = frameArray[frameInput % frameArray.length];
else if (curLoopType == "SF")
{
frameInput = frameArray[loopedFrameShit];
// see what happens when something has more than 2 layer?
// single frame stuff isn't fully implemented
}
else
frameInput = frameArray[frameInput];
// trace(frameMap.get(frameInput));
var frame:Frame = frameMap.get(frameInput);
// get somethin sorted per element list, which would essentially be per symbol things properly sorted
// seperate data types if symbol or atlassymbolinstance? would probably be maybe slightly less memory intensive? i dunno
// goes thru each layer, and then each element
// after it gets thru each element it adds to the layer frame stuff.
// make somethin that works recursively, maybe thats the symbol dictionary type shit?
for (element in frame.E)
{
if (Reflect.hasField(element, "ASI"))
{
matrixHelp[matrixHelp.length - 1].push(element.ASI.M3D);
var m3D = element.ASI.M3D;
var lilMatrix:Matrix = new Matrix(m3D[0], m3D[1], m3D[4], m3D[5], m3D[12], m3D[13]);
matrixFlipper.push(lilMatrix);
// matrixFlipper.reverse();
// funnyMatrix.identity();
// for (m in matrixFlipper)
// funnyMatrix.concat(m);
if (isFlipped)
{
trace("MORE FLIPPED SHIT");
trace("MORE FLIPPED SHIT");
trace("MORE FLIPPED SHIT");
trace(funnyMatrix);
trace(matrixFlipper);
}
// trace(funnyMatrix);
funnyMatrix.concat(lilMatrix);
// trace(funnyMatrix);
frameList[frameList.length - 1].push(
{
frameName: element.ASI.N,
depthString: depthTypeBeat,
matrixArray: matrixHelp[matrixHelp.length - 1],
trpArray: trpHelpIDK[trpHelpIDK.length - 1],
fullMatrix: funnyMatrix.clone()
});
// flips the matrix once?? I cant remember exactly why it needs to be flipped
// matrixHelp[matrixHelp.length - 1].reverse();
// trpHelpIDK = [];
// push the matrix array after each symbol?
funnyMatrix.identity();
matrixFlipper = [];
depthTypeBeat = "";
curLoopType = "";
loopedFrameShit = 0;
isFlipped = false;
}
else
{
var m3D = element.SI.M3D;
var lilMatrix:Matrix = new Matrix(m3D[0], m3D[1], m3D[4], m3D[5], m3D[12], m3D[13]);
if (lilMatrix.a == -1)
{
isFlipped = true;
trace('IS THE NEGATIVE ONE');
}
if (isFlipped) trace(lilMatrix);
funnyMatrix.concat(lilMatrix);
matrixFlipper.push(lilMatrix);
// trace(funnyMatrix);
matrixHelp[matrixHelp.length - 1].push(element.SI.M3D);
trpHelpIDK[trpHelpIDK.length - 1].push([element.SI.TRP.x, element.SI.TRP.y]); // trpHelpIDK.push();
depthTypeBeat += "->" + element.SI.SN;
curLoopType = element.SI.LP;
var inputFrame:Int = element.SI.FF;
// JANKY FIX, MAY NOT ACCOUNT FOR ALL SCENARIOS OF SINGLE FRAME ANIMATIONS!!
if (curLoopType == "SF")
{
// trace("LOOP SHIT: " + inputFrame);
loopedFrameShit = inputFrame;
}
// condense the animation code, so it automatically already fills up animation shit per symbol
parseTimeline(symbolMap.get(element.SI.SN).TL, tabbed + 1, inputFrame);
}
// idk if this should go per layer or per element / object?
matrixHelp.push([]);
trpHelpIDK.push([]);
}
if (tabbed == 0)
{
frameList[frameList.length - 1].reverse();
frameList.push([]); // new layer essentially
}
}
frameList.reverse();
}
}
typedef VALIDFRAME =
{
frameName:String,
depthString:String,
matrixArray:Array<Array<Float>>,
trpArray:Array<Array<Float>>,
fullMatrix:Matrix
}
typedef AnimJson =
{
AN:Animation,
SD:SymbolDictionary,
MD:MetaData
}
typedef Animation =
{
N:String,
SN:String,
TL:Timeline
}
typedef SymbolDictionary =
{
S:Array<Symbol>
}
typedef Symbol =
{
/**Symbol name*/
SN:String,
TL:Timeline
}
typedef Timeline =
{
?sortedForRender:Bool,
L:Array<Layer>
}
typedef Layer =
{
LN:String,
FR:Array<Frame>
}
typedef Frame =
{
E:Array<Element>,
I:Int,
DU:Int
// maybe need to implement names if it has frame labels?
}
typedef Element =
{
SI:SymbolInstance,
?ASI:AlsoSymbolInstance
// lmfao idk what ASI stands for lmfaoo, i dont think its "also"
}
typedef SymbolInstance =
{
SN:String,
ASI:AlsoSymbolInstance,
/**Symbol type, prob either G (graphic), or movie clip?*/ ST:String,
/**First frame*/ FF:Int,
/**Loop type, loop ping pong, etc.*/ LP:String,
/**3D matrix*/ M3D:Array<Float>,
TRP:
{
x:Float, y:Float
}
}
typedef AlsoSymbolInstance =
{
N:String,
M3D:Array<Float>
}
typedef MetaData =
{
/**
* Framerate
*/
FRT:Int
}
// SPRITEMAP BULLSHIT
typedef Spritemap =
{
ATLAS:
{
SPRITES:Array<SpriteBullshit>
},
meta:Meta
}
typedef SpriteBullshit =
{
SPRITE:Sprite
}
typedef Sprite =
{
name:String,
x:Int,
y:Int,
w:Int,
h:Int,
rotated:Bool
}
typedef Meta =
{
app:String,
verstion:String,
image:String,
format:String,
size:
{
w:Int, h:Float
},
resolution:Float
}

View file

@ -1,63 +0,0 @@
package funkin.animate;
import flixel.FlxSprite;
import flixel.input.mouse.FlxMouseEvent;
import flixel.util.FlxColor;
import funkin.animate.ParseAnimate.Frame;
class TimelineFrame extends FlxSprite
{
public var data:Frame;
public function new(x:Float, y:Float, length:Int = 0, data:Frame)
{
super(x, y);
this.data = data;
makeGraphic((10 * length) + (2 * (length - 1)), 10, FlxColor.RED);
FlxMouseEvent.add(this, null, null, function(spr:TimelineFrame)
{
alpha = 0.5;
}, function(spr:TimelineFrame)
{
alpha = 1;
}, false, true, true);
}
override function update(elapsed:Float)
{
// if (FlxG.mouse.overlaps(this, cameras[1]))
// alpha = 0.6;
// else
// alpha = 1;
if (FlxG.mouse.overlaps(this, cameras[0]) && FlxG.mouse.justPressed)
{
trace("\nFRAME DATA - \n\tFRAME NUM: " + data.I + "\n\tFRAME DURATION: " + data.DU);
for (e in data.E)
{
var elementOutput:String = "\n";
if (Reflect.hasField(e, 'ASI'))
{
elementOutput += "ELEMENT IS ASI!";
elementOutput += "\n\t";
elementOutput += "FRAME NAME: " + e.ASI.N;
}
else
{
elementOutput += "ELEMENT IS SYMBOL INSTANCE!";
elementOutput += "\n\tSYMBOL NAME: " + e.SI.SN;
}
trace(elementOutput);
}
}
super.update(elapsed);
}
}