public static void ReadAnimationFile(string filePath, ProjectManager projectManager, TimeLine timeLine) { FileInfo file = new FileInfo(filePath); // Null checking if (file == null) { return; } if (projectManager == null) { return; } if (timeLine == null) { return; } BinaryReader binaryReader = new BinaryReader(File.Open(filePath, FileMode.Open)); // Check if header is correct(basically check if this is even a valid PCAF file.) string headerString = binaryReader.ReadString(); if (headerString == headerName) { // Clear keyframes in timeline timeLine.ClearKeyframes(); // Ok cool so this file is a PCAF file. // Load version number incase this is ever useful(and because we kinda have to push the reader forward for it to read correctly) int versionNumber = binaryReader.ReadInt32(); // Load Project Info binaryReader.ReadBoolean(); binaryReader.ReadInt32(); binaryReader.ReadString(); binaryReader.ReadInt32(); int keyframeCount = binaryReader.ReadInt32(); for (int i = 0; i < keyframeCount; i++) { // Read timeline x coordinate int timelineX = binaryReader.ReadInt32(); int spriteboxCount = binaryReader.ReadInt32(); Keyframe keyframe = new Keyframe(timelineX, 0, new Dictionary <string, monogame.objects.Spritebox>(), timeLine); for (int j = 0; j < spriteboxCount; j++) { // Get name string name = binaryReader.ReadString(); // General properties double posX = binaryReader.ReadDouble(); double posY = binaryReader.ReadDouble(); int width = binaryReader.ReadInt32(); int height = binaryReader.ReadInt32(); string textureKey = binaryReader.ReadString(); float rotation = binaryReader.ReadSingle(); int sourceX = binaryReader.ReadInt32(); int sourceY = binaryReader.ReadInt32(); int sourceWidth = binaryReader.ReadInt32(); int sourceHeight = binaryReader.ReadInt32(); float layer = binaryReader.ReadSingle(); bool visible = binaryReader.ReadBoolean(); SpriteboxJson spriteBox = new SpriteboxJson(); spriteBox.posX = posX; spriteBox.posY = posY; spriteBox.width = width; spriteBox.height = height; spriteBox.textureKey = textureKey; spriteBox.rotation = rotation; spriteBox.sourceX = sourceX; spriteBox.sourceY = sourceY; spriteBox.sourceWidth = sourceWidth; spriteBox.sourceHeight = sourceHeight; spriteBox.layer = layer; spriteBox.visible = visible; keyframe.AddSpriteBox(name, Spritebox.FromJsonElement(spriteBox)); } timeLine.AddKeyframe(keyframe); } MainWindowViewModel.MonogameWindow.setSprBoxSelected("enginereserved_null"); timeLine.DisplayAtScrubber(); } binaryReader.Dispose(); }