1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-01-30 08:27:38 +00:00

animate atlas overhaul stuff

This commit is contained in:
Cameron Taylor 2021-09-01 15:34:20 -04:00
parent fad3af327f
commit 720b428bcf
7 changed files with 533 additions and 247 deletions

View file

@ -124,6 +124,7 @@
<!--haxelib name="newgrounds" unless="switch"/> -->
<haxelib name="faxe" if='switch'/>
<haxelib name="polymod"/>
<!-- <haxelib name="colyseus"/> -->
<!-- <haxelib name="colyseus-websocket" /> -->
<!-- <haxelib name="newgrounds"/> -->

View file

@ -872,7 +872,7 @@ class FlxActionInputDigitalMobileSwipeGameplay extends FlxActionInputDigital
public function new(swipeDir:Int = FlxObject.ANY, Trigger:FlxInputState, ?swipeLength:Float = 90)
{
super(MOBILE, swipeDir, Trigger);
super(OTHER, swipeDir, Trigger);
activateLength = swipeLength;
}

View file

@ -7,6 +7,7 @@ import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets.FlxGraphicAsset;
import haxe.Json;
import haxe.format.JsonParser;
import lime.math.Rectangle;
import lime.utils.Assets;
@ -88,6 +89,21 @@ class CoolUtil
return lerp * (FlxG.elapsed / (1 / 60));
}
/**
* Hashlink json encoding fix for some wacky bullshit
* https://github.com/HaxeFoundation/haxe/issues/6930#issuecomment-384570392
*/
public static function coolJSON(fileData:String)
{
var cont = fileData;
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));
}
/*
* frame dependant lerp kinda lol
*/

View file

@ -1,7 +1,7 @@
package animate;
import animate.FlxSymbol.Parsed;
import animate.FlxSymbol.Timeline;
// import animate.FlxSymbol.Parsed;
// import animate.FlxSymbol.Timeline;
import flixel.FlxCamera;
import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
@ -13,7 +13,7 @@ import lime.utils.Assets;
class AnimateTimeline extends FlxTypedGroup<FlxSprite>
{
var coolParsed:Parsed;
// var coolParsed:Parsed;
var playhead:FlxSprite;
public var curFrame(default, set):Int;
@ -31,45 +31,47 @@ class AnimateTimeline extends FlxTypedGroup<FlxSprite>
{
super();
hudCamShit = new FlxCamera();
hudCamShit.bgColor = FlxColor.TRANSPARENT;
FlxG.cameras.add(hudCamShit, false);
/* hudCamShit = new FlxCamera();
hudCamShit.bgColor = FlxColor.TRANSPARENT;
FlxG.cameras.add(hudCamShit, false);
playhead = new FlxSprite(0, -12).makeGraphic(2, 10, FlxColor.MAGENTA);
add(playhead);
playhead = new FlxSprite(0, -12).makeGraphic(2, 10, FlxColor.MAGENTA);
add(playhead);
hudCamShit.follow(playhead);
hudCamShit.setScrollBounds(0, null, -14, null);
hudCamShit.follow(playhead);
hudCamShit.setScrollBounds(0, null, -14, null);
curFrame = 0;
curFrame = 0;
coolParsed = cast Json.parse(Assets.getText(parsed));
coolParsed = cast Json.parse(Assets.getText(parsed));
var layerNum:Int = 0;
for (layer in coolParsed.AN.TL.L)
{
var frameNum:Int = 0;
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++;
}
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 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;
var layerBG:FlxSprite = new FlxSprite(0, layerNum * 12).makeGraphic(12 * 4, 12);
layerBG.scrollFactor.x = 0;
add(layerBG);
add(layerName);
add(layerBG);
add(layerName);
layerNum++;
}
layerNum++;
}
this.cameras = [hudCamShit];
this.cameras = [hudCamShit];
*/
}
}

View file

@ -2,17 +2,19 @@ package animate;
// import animateAtlasPlayer.assets.AssetManager;
// import animateAtlasPlayer.core.Animation;
import animate.FlxSymbol.Parsed;
import animate.ParseAnimate.AnimJson;
import animate.ParseAnimate.Sprite;
import 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.math.FlxMatrix;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets.FlxGraphicAsset;
import haxe.Json;
import haxe.Utf8;
import haxe.format.JsonParser;
import lime.text.UTF8String;
import openfl.Assets;
import openfl.display.BitmapData;
import openfl.geom.Rectangle;
@ -25,16 +27,30 @@ class FlxAnimate extends FlxSymbol
var swagFrames:Array<BitmapData> = [];
var jsonAnim:AnimJson;
public function new(x:Float, y:Float)
{
var folder:String = 'tightBarsLol';
coolParse = cast Json.parse(Assets.getText(Paths.file('images/' + folder + '/Animation.json')));
super(x, y);
// reverses the layers, for proper rendering!
coolParse.AN.TL.L.reverse();
super(x, y, coolParse);
var folder:String = "tightBarsLol";
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.parseTimeline(jsonAnim.AN.TL, 0, 0);
/* 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 = FlxAnimate.fromAnimate(Paths.file('images/' + folder + '/spritemap1.png'), Paths.file('images/' + folder + '/spritemap1.json'));
// frames
}
@ -43,27 +59,48 @@ class FlxAnimate extends FlxSymbol
// having this commented out fixes some wacky scaling bullshit?
// super.draw();
if (FlxG.keys.justPressed.ONE)
{
trace("-------------------------------------");
trace('CUR FRAME: ' + daFrame);
trace('--------------');
}
// renderFrame(coolParse.AN.TL, coolParse, true);
renderFrame(coolParse.AN.TL, coolParse, true);
actualFrameRender();
}
if (FlxG.keys.justPressed.E)
function actualFrameRender()
{
for (i in ParseAnimate.frameList)
{
for (shit in FlxSymbol.nestedShit.keys())
var spr:FlxSymbol = new FlxSymbol(0, 0); // redo this to recycle from a list later
spr.frames = frames;
spr.frame = spr.frames.getByName(i);
if (FlxG.keys.justPressed.I)
{
for (spr in FlxSymbol.nestedShit.get(shit))
trace('\n\n\nSPR OLD: ' + spr._matrix);
}
ParseAnimate.matrixMap.get(i).reverse();
for (swagMatrix in ParseAnimate.matrixMap.get(i))
{
var alsoSwag:FlxMatrix = new FlxMatrix(swagMatrix[0], swagMatrix[1], swagMatrix[4], swagMatrix[5], swagMatrix[12], swagMatrix[13]);
spr.matrixExposed = true;
spr.transformMatrix.concat(alsoSwag);
if (FlxG.keys.justPressed.I)
{
trace(shit);
spr.draw();
trace(i + ": " + swagMatrix);
}
}
FlxSymbol.nestedShit.clear();
if (FlxG.keys.justPressed.I)
{
trace('SPR NEW: ' + spr._matrix);
}
// trace('MATRIX ' + spr._matrix);
// spr
spr.draw();
}
}
@ -73,6 +110,8 @@ class FlxAnimate extends FlxSymbol
var frameTickTypeShit:Float = 0;
var animFrameRate:Int = 24;
// redo all the matrix animation stuff
override function update(elapsed:Float)
{
super.update(elapsed);
@ -89,16 +128,22 @@ class FlxAnimate extends FlxSymbol
{
changeFrame(1);
frameTickTypeShit = 0;
ParseAnimate.resetFrameList();
ParseAnimate.parseTimeline(jsonAnim.AN.TL, 0, daFrame);
}
}
if (FlxG.keys.justPressed.RIGHT)
{
changeFrame(1);
ParseAnimate.resetFrameList();
ParseAnimate.parseTimeline(jsonAnim.AN.TL, 0, daFrame);
}
if (FlxG.keys.justPressed.LEFT)
changeFrame(-1);
}
// This stuff is u
public static function fromAnimate(Source:FlxGraphicAsset, Description:String):FlxAtlasFrames
{
var graphic:FlxGraphic = FlxG.bitmap.add(Source);
@ -114,11 +159,11 @@ class FlxAnimate extends FlxSymbol
frames = new FlxAtlasFrames(graphic);
var data:AnimateObject;
var data:Spritemap;
var json:String = Description;
trace(json);
// trace(json);
var funnyJson:Dynamic = {};
if (Assets.exists(json))
@ -126,12 +171,14 @@ class FlxAnimate extends FlxSymbol
// trace(json);
data = cast funnyJson.ATLAS;
// data = c
for (sprite in data.SPRITES)
data = cast funnyJson;
for (sprite in data.ATLAS.SPRITES)
{
// probably nicer way to do this? Oh well
var swagSprite:AnimateSprite = sprite.SPRITE;
var swagSprite:Sprite = sprite.SPRITE;
var rect = FlxRect.get(swagSprite.x, swagSprite.y, swagSprite.w, swagSprite.h);
@ -147,10 +194,6 @@ class FlxAnimate extends FlxSymbol
}
}
/**
* HL json encoding fix for some wacky bullshit
* https://github.com/HaxeFoundation/haxe/issues/6930#issuecomment-384570392
*/
class JaySon
{
public static function parseFile(name:String)
@ -164,18 +207,3 @@ class JaySon
0));
}
}
typedef AnimateObject =
{
SPRITES:Array<Dynamic>
}
typedef AnimateSprite =
{
var name:String;
var x:Int;
var y:Int;
var w:Int;
var h:Int;
var rotated:Bool;
}

View file

@ -1,5 +1,12 @@
package animate;
import animate.ParseAnimate.AnimJson;
import animate.ParseAnimate.Animation;
import animate.ParseAnimate.Frame;
import animate.ParseAnimate.Sprite;
import animate.ParseAnimate.Spritemap;
import animate.ParseAnimate.SymbolDictionary;
import animate.ParseAnimate.Timeline;
import flixel.FlxCamera;
import flixel.FlxSprite;
import flixel.graphics.frames.FlxFrame.FlxFrameAngle;
@ -8,11 +15,11 @@ 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
{
public var coolParse:Parsed;
public var oldMatrix:Array<Float> = [];
// Loop types shit
@ -27,21 +34,11 @@ class FlxSymbol extends FlxSprite
public var daLoopType:String = 'LP'; // LP by default, is set below!!!
public function new(x:Float, y:Float, coolParsed:Parsed)
public function new(x:Float, y:Float)
{
super(x, y);
// trace(System.deviceModel);
// trace(System.deviceVendor);
// trace(System.platformLabel);
// trace(System.platformName);
this.coolParse = coolParsed;
var hasSymbolDictionary:Bool = Reflect.hasField(coolParse, "SD");
if (hasSymbolDictionary)
symbolAtlasShit = parseSymbolDictionary(coolParse);
var spritemap:Map<String, Sprite> = ParseAnimate.genSpritemap(Assets.getText(Paths.file('images/tightestBars/spritemap1.json')));
}
var symbolAtlasShit:Map<String, String> = new Map();
@ -54,7 +51,7 @@ class FlxSymbol extends FlxSprite
public var transformMatrix:Matrix = new Matrix();
function renderFrame(TL:Timeline, coolParsed:Parsed, ?traceShit:Bool = false)
function renderFrame(TL:Timeline, ?traceShit:Bool = false)
{
for (layer in TL.L)
{
@ -142,7 +139,7 @@ class FlxSymbol extends FlxSprite
var m3d = element.ASI.M3D;
var dumbassMatrix:Matrix = new Matrix(m3d[0], m3d[1], m3d[4], m3d[5], m3d[12], m3d[13]);
var spr:FlxSymbol = new FlxSymbol(0, 0, coolParsed);
var spr:FlxSymbol = new FlxSymbol(0, 0);
spr.setPosition(x, y);
matrixExposed = true;
spr.frames = frames;
@ -160,18 +157,13 @@ class FlxSymbol extends FlxSprite
// spr.origin.x += origin.x;
// spr.origin.y += origin.y;
// spr.antialiasing = true;
spr.antialiasing = true;
spr.draw();
if (FlxG.keys.justPressed.ONE)
{
trace("ASI - " + layer.LN + ": " + element.ASI.N);
}
}
else
{
var nestedSymbol = symbolMap.get(element.SI.SN);
var nestedShit:FlxSymbol = new FlxSymbol(x, y, coolParse);
var nestedShit:FlxSymbol = new FlxSymbol(x, y);
nestedShit.frames = frames;
var swagMatrix:FlxMatrix = new FlxMatrix(element.SI.M3D[0], element.SI.M3D[1], element.SI.M3D[4], element.SI.M3D[5], element.SI.M3D[12],
@ -202,11 +194,10 @@ class FlxSymbol extends FlxSprite
nestedShit.firstFrame = element.SI.FF;
// nestedShit.daFrame += nestedShit.firstFrame;
nestedShit.daLoopType = element.SI.LP;
nestedShit.daFrame = daFrame;
nestedShit.scrollFactor.set(1, 1);
nestedShit.renderFrame(nestedSymbol.TL, coolParsed);
nestedShit.renderFrame(nestedSymbol.TL);
// renderFrame(nestedSymbol.TL, coolParsed);
}
@ -221,38 +212,25 @@ class FlxSymbol extends FlxSprite
daFrame += frameChange;
}
function parseSymbolDictionary(coolParsed:Parsed):Map<String, String>
{
var awesomeMap:Map<String, String> = new Map();
for (symbol in coolParsed.SD.S)
{
symbolMap.set(symbol.SN, symbol);
var symbolName = symbol.SN;
// one time reverse?
symbol.TL.L.reverse();
for (layer in symbol.TL.L)
{
for (frame in layer.FR)
{
for (element in frame.E)
{
if (Reflect.hasField(element, 'ASI'))
{
awesomeMap.set(symbolName, element.ASI.N);
}
}
}
}
}
return awesomeMap;
}
function getFrame() {}
/**
_frame.prepareMatrix(_matrix, FlxFrameAngle.ANGLE_0, checkFlipX(), checkFlipY());
_matrix.translate(-origin.x, -origin.y);
_matrix.scale(scale.x, scale.y);
if (bakedRotationAngle <= 0)
{
updateTrig();
if (angle != 0)
_matrix.rotateWithTrig(_cosAngle, _sinAngle);
}
_point.add(origin.x, origin.y);
camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing, shader);**/
override function drawComplex(camera:FlxCamera):Void
{
_frame.prepareMatrix(_matrix, FlxFrameAngle.ANGLE_0, checkFlipX(), checkFlipY());
@ -273,16 +251,19 @@ class FlxSymbol extends FlxSprite
_matrix.rotateWithTrig(_cosAngle, _sinAngle);
}
// updateSkewMatrix();
updateSkewMatrix();
_matrix.concat(_skewMatrix);
}
_point.addPoint(origin);
if (isPixelPerfectRender(camera))
_point.floor();
_matrix.translate(_point.x, _point.y);
camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing);
if (isPixelPerfectRender(camera))
{
_matrix.tx = Math.floor(_matrix.tx);
_matrix.ty = Math.floor(_matrix.ty);
}
camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing, shader);
}
var _skewMatrix:Matrix = new Matrix();
@ -293,7 +274,7 @@ class FlxSymbol extends FlxSprite
* 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 = false;
public var matrixExposed:Bool = true;
public var skew(default, null):FlxPoint = FlxPoint.get();
@ -308,110 +289,88 @@ class FlxSymbol extends FlxSprite
}
}
}
// TYPEDEFS FOR ANIMATION.JSON PARSING
typedef Parsed =
{
var MD:Metadata;
var AN:Animation;
var SD:SymbolDictionary; // Doesn't always have symbol dictionary!!
}
typedef Metadata =
{
/** Framerate */
var FRT:Int;
}
/** Basically treated like one big symbol*/
typedef Animation =
{
/** symbolName */
var SN:String;
var TL:Timeline;
/** IDK what STI stands for, Symbole Type Instance?
Anyways, it is NOT used in SYMBOLS, only the main AN animation
*/
var STI:Dynamic;
}
/** DISCLAIMER, MAY NOT ACTUALLY BE CALLED
SYMBOL TYPE ISNTANCE, IM JUST MAKING ASSUMPTION!! */
typedef SymbolTypeInstance =
{
// var TL:Timeline;
// var SN:String;
}
typedef SymbolDictionary =
{
var S:Array<Animation>;
}
typedef Timeline =
{
/** Layers */
var L:Array<Layer>;
}
// Singular layer, not to be confused with LAYERS
typedef Layer =
{
var LN:String;
/** Frames */
var FR:Array<Frame>;
}
typedef Frame =
{
/** Frame index*/
var I:Int;
/** Duration, in frames*/
var DU:Int;
/** Elements*/
var E:Array<Element>;
}
typedef Element =
{
var SI:SymbolInstance;
var ASI:AtlasSymbolInstance;
}
/**
Symbol instance, for SYMBOLS and refers to SYMBOLS
*/
typedef SymbolInstance =
{
var SN:String;
/** SymbolType (Graphic, Movieclip, Button)*/
var ST:String;
/** First frame*/
var FF:Int;
/** Loop type (Loop, play once, single frame)*/
var LP:String;
var TRP:TransformationPoint;
var M3D:Array<Float>;
}
typedef AtlasSymbolInstance =
{
var N:String;
var M3D:Array<Float>;
}
typedef TransformationPoint =
{
var x:Float;
var y:Float;
}
// typedef Parsed =
// {
// var MD:Metadata;
// var AN:Animation;
// var SD:SymbolDictionary; // Doesn't always have symbol dictionary!!
// }
// typedef Metadata =
// {
// /** Framerate */
// var FRT:Int;
// }
// /** Basically treated like one big symbol*/
// typedef Animation =
// {
// /** symbolName */
// var SN:String;
// var TL:Timeline;
// /** IDK what STI stands for, Symbole Type Instance?
// Anyways, it is NOT used in SYMBOLS, only the main AN animation
// */
// var STI:Dynamic;
// }
// /** DISCLAIMER, MAY NOT ACTUALLY BE CALLED
// SYMBOL TYPE ISNTANCE, IM JUST MAKING ASSUMPTION!! */
// typedef SymbolTypeInstance =
// {
// // var TL:Timeline;
// // var SN:String;
// }
// typedef SymbolDictionary =
// {
// var S:Array<Animation>;
// }
// typedef Timeline =
// {
// /** Layers */
// var L:Array<Layer>;
// }
// // Singular layer, not to be confused with LAYERS
// typedef Layer =
// {
// var LN:String;
// /** Frames */
// var FR:Array<Frame>;
// }
// typedef Frame =
// {
// /** Frame index*/
// var I:Int;
// /** Duration, in frames*/
// var DU:Int;
// /** Elements*/
// var E:Array<Element>;
// }
// typedef Element =
// {
// var SI:SymbolInstance;
// var ASI:AtlasSymbolInstance;
// }
// /**
// Symbol instance, for SYMBOLS and refers to SYMBOLS
// */
// typedef SymbolInstance =
// {
// var SN:String;
// /** SymbolType (Graphic, Movieclip, Button)*/
// var ST:String;
// /** First frame*/
// var FF:Int;
// /** Loop type (Loop, play once, single frame)*/
// var LP:String;
// var TRP:TransformationPoint;
// var M3D:Array<Float>;
// }
// typedef AtlasSymbolInstance =
// {
// var N:String;
// var M3D:Array<Float>;
// }
// typedef TransformationPoint =
// {
// var x:Float;
// var y:Float;
// }

View file

@ -0,0 +1,280 @@
package animate;
import haxe.format.JsonParser;
import openfl.Assets;
import sys.io.File;
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();
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;
}
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 var curLoopType:String;
/**
* Stuff for debug parsing
*/
public static var depthTypeBeat:String = "";
public static var frameList:Array<String> = [];
public static var matrixMap:Map<String, Array<Array<Float>>> = new Map();
// for loop stuf
public static var matrixHelp:Array<Array<Float>> = [];
public static function resetFrameList()
{
frameList = [];
matrixMap.clear();
}
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;
if (curLoopType == "LP")
frameInput = frameArray[frameInput % frameArray.length];
else
frameInput = frameArray[frameInput];
var frame:Frame = frameMap.get(frameInput);
for (element in frame.E)
{
if (Reflect.hasField(element, "ASI"))
{
frameList.push(element.ASI.N);
matrixHelp.push(element.ASI.M3D);
matrixMap.set(element.ASI.N, matrixHelp);
matrixHelp = [];
depthTypeBeat = "";
curLoopType = "";
}
else
{
matrixHelp.push(element.SI.M3D);
depthTypeBeat += "->" + element.SI.SN;
curLoopType = element.SI.LP;
parseTimeline(symbolMap.get(element.SI.SN).TL, tabbed + 1, element.SI.FF);
}
}
}
}
}
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 =
{
L:Array<Layer>
}
typedef Layer =
{
LN:String,
FR:Array<Frame>
}
typedef Frame =
{
E:Array<Element>,
I:Int,
DU:Int
}
typedef Element =
{
SI:SymbolInstance,
ASI:AlsoSymbolInstance
// lmfao idk what ASI stands for lmfaoo, i dont think its "also"
}
typedef SymbolInstance =
{
SN:String,
/**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
}