diff --git a/Nebula.CLI/Program.cs b/Nebula.CLI/Program.cs index 7a413bd..5e469b9 100644 --- a/Nebula.CLI/Program.cs +++ b/Nebula.CLI/Program.cs @@ -129,6 +129,7 @@ static void AutoDetectReader() case ".zip": NebulaCore.CurrentReader = new OpenFileReader(); break; + case ".xapk": case ".apk": NebulaCore.CurrentReader = new APKFileReader(); break; diff --git a/Nebula.Core/Data/Chunks/FrameChunks/Events/Action.cs b/Nebula.Core/Data/Chunks/FrameChunks/Events/Action.cs index 1fcccf0..486132c 100644 --- a/Nebula.Core/Data/Chunks/FrameChunks/Events/Action.cs +++ b/Nebula.Core/Data/Chunks/FrameChunks/Events/Action.cs @@ -75,7 +75,7 @@ public override void ReadCCN(ByteReader reader, params object[] extraInfo) ObjectInfo = ObjectInfo, Type = ObjectType }); - } + } } Fix((List)extraInfo[0], reader, endPosition); diff --git a/Nebula.Core/Data/Chunks/FrameChunks/Events/Condition.cs b/Nebula.Core/Data/Chunks/FrameChunks/Events/Condition.cs index 907a245..20afaee 100644 --- a/Nebula.Core/Data/Chunks/FrameChunks/Events/Condition.cs +++ b/Nebula.Core/Data/Chunks/FrameChunks/Events/Condition.cs @@ -79,7 +79,7 @@ public override void ReadCCN(ByteReader reader, params object[] extraInfo) ObjectInfo = ObjectInfo, Type = ObjectType }); - } + } } Fix((List)extraInfo[0], reader); diff --git a/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterExpression.cs b/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterExpression.cs index 2758f25..67c0904 100644 --- a/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterExpression.cs +++ b/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterExpression.cs @@ -553,7 +553,8 @@ public override string ToString() public ObjectInfo? GetObject() { - if (Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo).Any() == true) + // added here just because without it - any other changes with qualifiers won't do anything (will still get KeyNotFoundException, means that it won't get added) + if (Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo).Any() == true || (NebulaCore.Windows && NebulaCore.Build >= 296 && NebulaCore.Fusion >= 2.5 && (ObjectInfo & 0x8000) != 0)) return null; else if (NebulaCore.MFA && Parent?.FrameEvents?.EventObjects.Count > 0) return NebulaCore.PackageData.FrameItems.Items[(int)Parent.FrameEvents.EventObjects[ObjectInfo].ItemHandle]; @@ -614,140 +615,8 @@ public string GetObjectName() ObjectInfo? objectInfo = GetObject(); if (objectInfo != null) return objectInfo.Name; - Qualifier[] qualifier = Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo && x.Type == ObjectType).ToArray()!; - if (qualifier.Length > 0) - return GetQualifierName(qualifier.First()); - return "Unknown Object"; - } - - public string GetQualifierName(Qualifier qualifier) - { - string qualifierName = "Group." + (qualifier.ObjectInfo & 0x7FFF) switch - { - 0 => "Player", - 1 => "Good", - 2 => "Neutral", - 3 => "Bad", - 4 => "Enemies", - 5 => "Friends", - 6 => "Bullets", - 7 => "Arms", - 8 => "Bonus", - 9 => "Collectables", - 10 => "Traps", - 11 => "Doors", - 12 => "Keys", - 13 => "Texts", - 14 => "0", - 15 => "1", - 16 => "2", - 17 => "3", - 18 => "4", - 19 => "5", - 20 => "6", - 21 => "7", - 22 => "8", - 23 => "9", - 24 => "Parents", - 25 => "Children", - 26 => "Data", - 27 => "Timed", - 28 => "Engine", - 29 => "Areas", - 30 => "Reference Points", - 31 => "Radar Enemies", - 32 => "Radar Friends", - 33 => "Radar Neutrals", - 34 => "Music", - 35 => "Sound", - 36 => "Waveform", - 37 => "Background Scenery", - 38 => "Foreground Scenery", - 39 => "Decorations", - 40 => "Water", - 41 => "Clouds", - 42 => "Empty", - 43 => "Fog", - 44 => "Flowers", - 45 => "Animals", - 46 => "Bosses", - 47 => "NPC", - 48 => "Vehicles", - 49 => "Rockets", - 50 => "Balls", - 51 => "Bombs", - 52 => "Explosions", - 53 => "Particles", - 54 => "Clothes", - 55 => "Glow", - 56 => "Arrows", - 57 => "Buttons", - 58 => "Cursors", - 59 => "Drawing Tools", - 60 => "Indicator", - 61 => "Shapes", - 62 => "Shields", - 63 => "Shifting Blocks", - 64 => "Magnets", - 65 => "Negative Matter", - 66 => "Neutral Matter", - 67 => "Positive Matter", - 68 => "Breakable", - 69 => "Dissolving", - 70 => "Dialogue", - 71 => "HUD", - 72 => "Inventory", - 73 => "Inventory Item", - 74 => "Interface", - 75 => "Movable", - 76 => "Perspective", - 77 => "Calculation Objects", - 78 => "Invisible", - 79 => "Masks", - 80 => "Obstacles", - 81 => "Value Holder", - 82 => "Helpful", - 83 => "Powerups", - 84 => "Targets", - 85 => "Trapdoors", - 86 => "Dangers", - 87 => "Forbidden", - 88 => "Physical objects", - 89 => "3D Objects", - 90 => "Generic 1", - 91 => "Generic 2", - 92 => "Generic 3", - 93 => "Generic 4", - 94 => "Generic 5", - 95 => "Generic 6", - 96 => "Generic 7", - 97 => "Generic 8", - 98 => "Generic 9", - 99 => "Generic 10", - _ => string.Empty - }; - - qualifierName += "." + qualifier.Type switch - { - 2 => "Sprite", - 3 => "Text", - 4 => "Question", - 5 => "Score", - 6 => "Lives", - 7 => "Counter", - _ => string.Empty - }; - - if (qualifier.Type >= 32 && NebulaCore.PackageData.Extensions.Exts.ContainsKey(qualifier.Type - 32)) - { - Extension ext = NebulaCore.PackageData.Extensions.Exts[qualifier.Type - 32]; - qualifierName += ext.Name; - } - - if (qualifierName.StartsWith("Group..")) - return "Unknown Qualifier"; else - return qualifierName; + return ObjectCommon.TryGetQualifier(this, ObjectInfo, ObjectType); } } } diff --git a/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterObject.cs b/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterObject.cs index bf9b849..4007af4 100644 --- a/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterObject.cs +++ b/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterObject.cs @@ -1,5 +1,6 @@ using Nebula.Core.Data.Chunks.AppChunks; using Nebula.Core.Data.Chunks.ObjectChunks; +using Nebula.Core.Data.Chunks.ObjectChunks.ObjectCommon; using Nebula.Core.Memory; namespace Nebula.Core.Data.Chunks.FrameChunks.Events.Parameters @@ -37,150 +38,19 @@ public override string ToString() ObjectInfo? objectInfo = GetObject(); if (objectInfo != null) return objectInfo.Name; - Qualifier[] qualifier = Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo && x.Type == ObjectType).ToArray()!; - if (qualifier.Length > 0) - return GetQualifierName(qualifier.First()); - return "Unknown Object"; + else + return ObjectCommon.TryGetQualifier(this, ObjectInfo, ObjectType); } public ObjectInfo? GetObject() { - if (Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo).Any() == true) + // added here just because without it - any other changes with qualifiers won't do anything (will still get KeyNotFoundException, means that it won't get added) + if (Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo).Any() == true || (NebulaCore.Windows && NebulaCore.Build >= 296 && NebulaCore.Fusion >= 2.5 && (ObjectInfo & 0x8000) != 0)) return null; else if (NebulaCore.MFA && Parent?.FrameEvents?.EventObjects.Count > 0) return NebulaCore.PackageData.FrameItems.Items[(int)Parent.FrameEvents.EventObjects[ObjectInfo].ItemHandle]; else return NebulaCore.PackageData.FrameItems.Items[ObjectInfo]; } - - public string GetQualifierName(Qualifier qualifier) - { - string qualifierName = "Group." + (qualifier.ObjectInfo & 0x7FFF) switch - { - 0 => "Player", - 1 => "Good", - 2 => "Neutral", - 3 => "Bad", - 4 => "Enemies", - 5 => "Friends", - 6 => "Bullets", - 7 => "Arms", - 8 => "Bonus", - 9 => "Collectables", - 10 => "Traps", - 11 => "Doors", - 12 => "Keys", - 13 => "Texts", - 14 => "0", - 15 => "1", - 16 => "2", - 17 => "3", - 18 => "4", - 19 => "5", - 20 => "6", - 21 => "7", - 22 => "8", - 23 => "9", - 24 => "Parents", - 25 => "Children", - 26 => "Data", - 27 => "Timed", - 28 => "Engine", - 29 => "Areas", - 30 => "Reference Points", - 31 => "Radar Enemies", - 32 => "Radar Friends", - 33 => "Radar Neutrals", - 34 => "Music", - 35 => "Sound", - 36 => "Waveform", - 37 => "Background Scenery", - 38 => "Foreground Scenery", - 39 => "Decorations", - 40 => "Water", - 41 => "Clouds", - 42 => "Empty", - 43 => "Fog", - 44 => "Flowers", - 45 => "Animals", - 46 => "Bosses", - 47 => "NPC", - 48 => "Vehicles", - 49 => "Rockets", - 50 => "Balls", - 51 => "Bombs", - 52 => "Explosions", - 53 => "Particles", - 54 => "Clothes", - 55 => "Glow", - 56 => "Arrows", - 57 => "Buttons", - 58 => "Cursors", - 59 => "Drawing Tools", - 60 => "Indicator", - 61 => "Shapes", - 62 => "Shields", - 63 => "Shifting Blocks", - 64 => "Magnets", - 65 => "Negative Matter", - 66 => "Neutral Matter", - 67 => "Positive Matter", - 68 => "Breakable", - 69 => "Dissolving", - 70 => "Dialogue", - 71 => "HUD", - 72 => "Inventory", - 73 => "Inventory Item", - 74 => "Interface", - 75 => "Movable", - 76 => "Perspective", - 77 => "Calculation Objects", - 78 => "Invisible", - 79 => "Masks", - 80 => "Obstacles", - 81 => "Value Holder", - 82 => "Helpful", - 83 => "Powerups", - 84 => "Targets", - 85 => "Trapdoors", - 86 => "Dangers", - 87 => "Forbidden", - 88 => "Physical objects", - 89 => "3D Objects", - 90 => "Generic 1", - 91 => "Generic 2", - 92 => "Generic 3", - 93 => "Generic 4", - 94 => "Generic 5", - 95 => "Generic 6", - 96 => "Generic 7", - 97 => "Generic 8", - 98 => "Generic 9", - 99 => "Generic 10", - _ => string.Empty - }; - - qualifierName += "." + qualifier.Type switch - { - 2 => "Sprite", - 3 => "Text", - 4 => "Question", - 5 => "Score", - 6 => "Lives", - 7 => "Counter", - _ => string.Empty - }; - - if (qualifier.Type >= 32 && NebulaCore.PackageData.Extensions.Exts.ContainsKey(qualifier.Type - 32)) - { - Extension ext = NebulaCore.PackageData.Extensions.Exts[qualifier.Type - 32]; - qualifierName += ext.Name; - } - - if (qualifierName.StartsWith("Group..")) - return "Unknown Qualifier"; - else - return qualifierName; - } } } diff --git a/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterPosition.cs b/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterPosition.cs index b1a9ec8..5c4b279 100644 --- a/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterPosition.cs +++ b/Nebula.Core/Data/Chunks/FrameChunks/Events/Parameters/ParameterPosition.cs @@ -1,6 +1,7 @@ using ILGPU.IR.Types; using Nebula.Core.Data.Chunks.AppChunks; using Nebula.Core.Data.Chunks.ObjectChunks; +using Nebula.Core.Data.Chunks.ObjectChunks.ObjectCommon; using Nebula.Core.Memory; namespace Nebula.Core.Data.Chunks.FrameChunks.Events.Parameters @@ -96,7 +97,8 @@ public override string ToString() public ObjectInfo? GetObject() { - if (Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfoParent).Any() == true) + // added here just because without it - any other changes with qualifiers won't do anything (will still get KeyNotFoundException, means that it won't get added) + if (Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfoParent).Any() == true || (NebulaCore.Windows && NebulaCore.Build >= 296 && NebulaCore.Fusion >= 2.5 &&(ObjectInfoParent & 0x8000) != 0)) return null; else if (NebulaCore.MFA && Parent?.FrameEvents?.EventObjects.Count > 0) return NebulaCore.PackageData.FrameItems.Items[(int)Parent.FrameEvents.EventObjects[ObjectInfoParent].ItemHandle]; @@ -109,140 +111,8 @@ public string GetObjectName() ObjectInfo? objectInfo = GetObject(); if (objectInfo != null) return objectInfo.Name; - Qualifier[] qualifier = Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfoParent && x.Type == TypeParent).ToArray()!; - if (qualifier.Length > 0) - return GetQualifierName(qualifier.First()); - return "Unknown Object"; - } - - public string GetQualifierName(Qualifier qualifier) - { - string qualifierName = "Group." + (qualifier.ObjectInfo & 0x7FFF) switch - { - 0 => "Player", - 1 => "Good", - 2 => "Neutral", - 3 => "Bad", - 4 => "Enemies", - 5 => "Friends", - 6 => "Bullets", - 7 => "Arms", - 8 => "Bonus", - 9 => "Collectables", - 10 => "Traps", - 11 => "Doors", - 12 => "Keys", - 13 => "Texts", - 14 => "0", - 15 => "1", - 16 => "2", - 17 => "3", - 18 => "4", - 19 => "5", - 20 => "6", - 21 => "7", - 22 => "8", - 23 => "9", - 24 => "Parents", - 25 => "Children", - 26 => "Data", - 27 => "Timed", - 28 => "Engine", - 29 => "Areas", - 30 => "Reference Points", - 31 => "Radar Enemies", - 32 => "Radar Friends", - 33 => "Radar Neutrals", - 34 => "Music", - 35 => "Sound", - 36 => "Waveform", - 37 => "Background Scenery", - 38 => "Foreground Scenery", - 39 => "Decorations", - 40 => "Water", - 41 => "Clouds", - 42 => "Empty", - 43 => "Fog", - 44 => "Flowers", - 45 => "Animals", - 46 => "Bosses", - 47 => "NPC", - 48 => "Vehicles", - 49 => "Rockets", - 50 => "Balls", - 51 => "Bombs", - 52 => "Explosions", - 53 => "Particles", - 54 => "Clothes", - 55 => "Glow", - 56 => "Arrows", - 57 => "Buttons", - 58 => "Cursors", - 59 => "Drawing Tools", - 60 => "Indicator", - 61 => "Shapes", - 62 => "Shields", - 63 => "Shifting Blocks", - 64 => "Magnets", - 65 => "Negative Matter", - 66 => "Neutral Matter", - 67 => "Positive Matter", - 68 => "Breakable", - 69 => "Dissolving", - 70 => "Dialogue", - 71 => "HUD", - 72 => "Inventory", - 73 => "Inventory Item", - 74 => "Interface", - 75 => "Movable", - 76 => "Perspective", - 77 => "Calculation Objects", - 78 => "Invisible", - 79 => "Masks", - 80 => "Obstacles", - 81 => "Value Holder", - 82 => "Helpful", - 83 => "Powerups", - 84 => "Targets", - 85 => "Trapdoors", - 86 => "Dangers", - 87 => "Forbidden", - 88 => "Physical objects", - 89 => "3D Objects", - 90 => "Generic 1", - 91 => "Generic 2", - 92 => "Generic 3", - 93 => "Generic 4", - 94 => "Generic 5", - 95 => "Generic 6", - 96 => "Generic 7", - 97 => "Generic 8", - 98 => "Generic 9", - 99 => "Generic 10", - _ => string.Empty - }; - - qualifierName += "." + qualifier.Type switch - { - 2 => "Sprite", - 3 => "Text", - 4 => "Question", - 5 => "Score", - 6 => "Lives", - 7 => "Counter", - _ => string.Empty - }; - - if (qualifier.Type >= 32 && NebulaCore.PackageData.Extensions.Exts.ContainsKey(qualifier.Type - 32)) - { - Extension ext = NebulaCore.PackageData.Extensions.Exts[qualifier.Type - 32]; - qualifierName += ext.Name; - } - - if (qualifierName.StartsWith("Group..")) - return "Unknown Qualifier"; else - return qualifierName; + return ObjectCommon.TryGetQualifier(this, ObjectInfoParent, ObjectInfoList); } } } diff --git a/Nebula.Core/Data/Chunks/FrameChunks/FrameEvents.cs b/Nebula.Core/Data/Chunks/FrameChunks/FrameEvents.cs index 055785f..213c63e 100644 --- a/Nebula.Core/Data/Chunks/FrameChunks/FrameEvents.cs +++ b/Nebula.Core/Data/Chunks/FrameChunks/FrameEvents.cs @@ -84,10 +84,6 @@ public override void ReadCCN(ByteReader reader, params object[] extraInfo) qualifier.ReadCCN(reader); Qualifiers.Add(qualifier); } - - // Just incase, 296 shouldnt be writing qualifiers anyway - if (NebulaCore.Build >= 296 && NebulaCore.Windows && NebulaCore.Fusion >= 2.5) - Qualifiers.Clear(); } else if (identifier == "ERes") EventCount = reader.ReadInt(); diff --git a/Nebula.Core/Data/Chunks/ObjectChunks/ObjectCommon/ObjectCommon.cs b/Nebula.Core/Data/Chunks/ObjectChunks/ObjectCommon/ObjectCommon.cs index a8a8382..15b80d9 100644 --- a/Nebula.Core/Data/Chunks/ObjectChunks/ObjectCommon/ObjectCommon.cs +++ b/Nebula.Core/Data/Chunks/ObjectChunks/ObjectCommon/ObjectCommon.cs @@ -1,7 +1,10 @@ using Nebula.Core.Data.Chunks.ChunkTypes; +using Nebula.Core.Data.Chunks.FrameChunks.Events; +using Nebula.Core.Data.Chunks.FrameChunks.Events.Parameters; using Nebula.Core.Memory; using System.Diagnostics; using System.Drawing; +using Nebula.Core.Data.Chunks.AppChunks; namespace Nebula.Core.Data.Chunks.ObjectChunks.ObjectCommon { @@ -236,6 +239,150 @@ public override void WriteMFA(ByteWriter writer, params object[] extraInfo) } + // method for getting qualifiers in different places + public static string TryGetQualifier(ParameterChunk paramChunk, ushort ObjectInfo, short ObjectType) + { + if (paramChunk.Parent?.FrameEvents?.Qualifiers.Where(q => q.ObjectInfo == ObjectInfo && q.Type == ObjectType).Any() != true) + { + if ((ObjectInfo & 0x8000) != 0) + paramChunk.Parent?.FrameEvents?.Qualifiers.Add(new Qualifier() { ObjectInfo = ObjectInfo, Type = ObjectType }); + } + Qualifier[] qualifiers = paramChunk.Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo && x.Type == ObjectType).ToArray()!; + if (qualifiers.Length > 0) + return GetQualifierName(qualifiers.First()); + return "Unknown Object"; + } + + public static string GetQualifierName(Qualifier qualifier) + { + string qualifierName = "Group." + (qualifier.ObjectInfo & 0x7FFF) switch + { + 0 => "Player", + 1 => "Good", + 2 => "Neutral", + 3 => "Bad", + 4 => "Enemies", + 5 => "Friends", + 6 => "Bullets", + 7 => "Arms", + 8 => "Bonus", + 9 => "Collectables", + 10 => "Traps", + 11 => "Doors", + 12 => "Keys", + 13 => "Texts", + 14 => "0", + 15 => "1", + 16 => "2", + 17 => "3", + 18 => "4", + 19 => "5", + 20 => "6", + 21 => "7", + 22 => "8", + 23 => "9", + 24 => "Parents", + 25 => "Children", + 26 => "Data", + 27 => "Timed", + 28 => "Engine", + 29 => "Areas", + 30 => "Reference Points", + 31 => "Radar Enemies", + 32 => "Radar Friends", + 33 => "Radar Neutrals", + 34 => "Music", + 35 => "Sound", + 36 => "Waveform", + 37 => "Background Scenery", + 38 => "Foreground Scenery", + 39 => "Decorations", + 40 => "Water", + 41 => "Clouds", + 42 => "Empty", + 43 => "Fog", + 44 => "Flowers", + 45 => "Animals", + 46 => "Bosses", + 47 => "NPC", + 48 => "Vehicles", + 49 => "Rockets", + 50 => "Balls", + 51 => "Bombs", + 52 => "Explosions", + 53 => "Particles", + 54 => "Clothes", + 55 => "Glow", + 56 => "Arrows", + 57 => "Buttons", + 58 => "Cursors", + 59 => "Drawing Tools", + 60 => "Indicator", + 61 => "Shapes", + 62 => "Shields", + 63 => "Shifting Blocks", + 64 => "Magnets", + 65 => "Negative Matter", + 66 => "Neutral Matter", + 67 => "Positive Matter", + 68 => "Breakable", + 69 => "Dissolving", + 70 => "Dialogue", + 71 => "HUD", + 72 => "Inventory", + 73 => "Inventory Item", + 74 => "Interface", + 75 => "Movable", + 76 => "Perspective", + 77 => "Calculation Objects", + 78 => "Invisible", + 79 => "Masks", + 80 => "Obstacles", + 81 => "Value Holder", + 82 => "Helpful", + 83 => "Powerups", + 84 => "Targets", + 85 => "Trapdoors", + 86 => "Dangers", + 87 => "Forbidden", + 88 => "Physical objects", + 89 => "3D Objects", + 90 => "Generic 1", + 91 => "Generic 2", + 92 => "Generic 3", + 93 => "Generic 4", + 94 => "Generic 5", + 95 => "Generic 6", + 96 => "Generic 7", + 97 => "Generic 8", + 98 => "Generic 9", + 99 => "Generic 10", + _ => string.Empty + }; + + qualifierName += "." + qualifier.Type switch + { + 2 => "Sprite", + 3 => "Text", + 4 => "Question", + 5 => "Score", + 6 => "Lives", + 7 => "Counter", + _ => string.Empty + }; + + if (qualifier.Type >= 32 && NebulaCore.PackageData.Extensions.Exts.ContainsKey(qualifier.Type - 32)) + { + Extension ext = NebulaCore.PackageData.Extensions.Exts[qualifier.Type - 32]; + qualifierName += ext.Name; + } + + if (qualifierName.StartsWith("Group..")) + return "Unknown Qualifier"; + else + return qualifierName; + } + public void GetOffset(ByteReader reader, int index, bool check = false) { ushort Offset = reader.ReadUShort(); diff --git a/Nebula.Core/FileReaders/APKFileReader.cs b/Nebula.Core/FileReaders/APKFileReader.cs index a6f76e6..0712ba0 100644 --- a/Nebula.Core/FileReaders/APKFileReader.cs +++ b/Nebula.Core/FileReaders/APKFileReader.cs @@ -11,10 +11,20 @@ namespace Nebula.Core.FileReaders { public class APKFileReader : IFileReader { - public string Name => "APK"; + public string Name => "Android"; public Dictionary Icons { get { return _icons; } set { _icons = value; } } private Dictionary _icons = new Dictionary(); + private static readonly List VideoExtensions = new List + { + ".mp4", + ".mkv", + ".m4a", + ".mov", + ".webm", + ".avi" + }; + public string FilePath { get { return _filePath; } set { _filePath = value; } } public string _filePath = string.Empty; @@ -47,6 +57,21 @@ public void LoadGame(ByteReader fileReader, string filePath) entry.Open().CopyTo(ms); SoundBank.ExternalFiles[Path.GetFileNameWithoutExtension(entry.Name)] = ms.ToArray(); // saving it to dictionary } + else if (VideoExtensions.Contains(Path.GetExtension(entry.Name))) // for unpacking video files saved by Video Android extension + { + using var stream = entry.Open(); + using var memoryStream = new MemoryStream(); + stream.CopyTo(memoryStream); + byte[] fileData = memoryStream.ToArray(); + + // add videos to binary files list for dumping + BinaryFile binFile = new BinaryFile + { + FileName = entry.Name, + FileData = fileData + }; + NebulaCore.PackageData.BinaryFiles.Items.Add(binFile); + } } if (Directory.GetParent(entry.FullName)?.Name == "fonts" && Path.GetExtension(entry.Name) == ".ttf") {