Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Nebula.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static void AutoDetectReader()
case ".zip":
NebulaCore.CurrentReader = new OpenFileReader();
break;
case ".xapk":
case ".apk":
NebulaCore.CurrentReader = new APKFileReader();
break;
Expand Down
7 changes: 1 addition & 6 deletions Nebula.Core/Data/Chunks/FrameChunks/Events/ACEventBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ public override void WriteMFA(ByteWriter writer, params object[] extraInfo)

public ObjectInfo? GetObject()
{
if (Parent?.Parent.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo).Any() == true)
return null;
else if (NebulaCore.MFA && Parent?.Parent.EventObjects.Count > 0)
return NebulaCore.PackageData.FrameItems.Items[(int)Parent.Parent.EventObjects[ObjectInfo].ItemHandle];
else
return NebulaCore.PackageData.FrameItems.Items[ObjectInfo];
return ObjectCommon.GetObject(ObjectInfo, ObjectType, this, null);
}

public string GetGlobalValueName(ParameterChunk param)
Expand Down
2 changes: 1 addition & 1 deletion Nebula.Core/Data/Chunks/FrameChunks/Events/Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override void ReadCCN(ByteReader reader, params object[] extraInfo)
ObjectInfo = ObjectInfo,
Type = ObjectType
});
}
}
}

Fix((List<Action>)extraInfo[0], reader, endPosition);
Expand Down
2 changes: 1 addition & 1 deletion Nebula.Core/Data/Chunks/FrameChunks/Events/Condition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public override void ReadCCN(ByteReader reader, params object[] extraInfo)
ObjectInfo = ObjectInfo,
Type = ObjectType
});
}
}
}

Fix((List<Condition>)extraInfo[0], reader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,7 @@ public override string ToString()

public ObjectInfo? GetObject()
{
if (Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo).Any() == true)
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];
return ObjectCommon.GetObject(ObjectInfo, ObjectType, null, this);
}

public string GetGlobalValueName()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -45,12 +46,7 @@ public override string ToString()

public ObjectInfo? GetObject()
{
if (Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo).Any() == true)
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];
return ObjectCommon.GetObject(ObjectInfo, ObjectType, null, this);
}

public string GetQualifierName(Qualifier qualifier)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -96,12 +97,7 @@ public override string ToString()

public ObjectInfo? GetObject()
{
if (Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfoParent).Any() == true)
return null;
else if (NebulaCore.MFA && Parent?.FrameEvents?.EventObjects.Count > 0)
return NebulaCore.PackageData.FrameItems.Items[(int)Parent.FrameEvents.EventObjects[ObjectInfoParent].ItemHandle];
else
return NebulaCore.PackageData.FrameItems.Items[ObjectInfoParent];
return ObjectCommon.GetObject(ObjectInfoParent, TypeParent, null, this);
}

public string GetObjectName()
Expand Down
4 changes: 0 additions & 4 deletions Nebula.Core/Data/Chunks/FrameChunks/FrameEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
36 changes: 36 additions & 0 deletions Nebula.Core/Data/Chunks/ObjectChunks/ObjectCommon/ObjectCommon.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
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;
Expand Down Expand Up @@ -236,6 +238,40 @@ public override void WriteMFA(ByteWriter writer, params object[] extraInfo)

}

// method for getting objects/qualifiers to prevent copy paste
public static ObjectInfo? GetObject(ushort ObjectInfo, short ObjectType, ACEventBase ace, ParameterChunk paramChunk)
{
if (ace != null)
{
if (NebulaCore.Windows && NebulaCore.Build >= 296 && NebulaCore.Fusion >= 2.5 && (ObjectInfo & 0x8000) != 0)
{
if (ace.Parent?.Parent.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo && x.Type == ObjectType).Any() != true)
ace.Parent?.Parent.Qualifiers.Add(new Qualifier() { ObjectInfo = ObjectInfo, Type = ObjectType });
}
if (ace.Parent?.Parent.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo).Any() == true)
return null;
else if (NebulaCore.MFA && ace.Parent?.Parent.EventObjects.Count > 0)
return NebulaCore.PackageData.FrameItems.Items[(int)ace.Parent.Parent.EventObjects[ObjectInfo].ItemHandle];
else
return NebulaCore.PackageData.FrameItems.Items[ObjectInfo];
}
else if (paramChunk != null)
{
if (NebulaCore.Windows && NebulaCore.Build >= 296 && NebulaCore.Fusion >= 2.5 && (ObjectInfo & 0x8000) != 0)
{
if (paramChunk.Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo && x.Type == ObjectType).Any() != true)
paramChunk.Parent?.FrameEvents?.Qualifiers.Add(new Qualifier() { ObjectInfo = ObjectInfo, Type = ObjectType });
}
if (paramChunk.Parent?.FrameEvents?.Qualifiers.Where(x => x.ObjectInfo == ObjectInfo).Any() == true)
return null;
else if (NebulaCore.MFA && paramChunk.Parent?.FrameEvents?.EventObjects.Count > 0)
return NebulaCore.PackageData.FrameItems.Items[(int)paramChunk.Parent.FrameEvents.EventObjects[ObjectInfo].ItemHandle];
else
return NebulaCore.PackageData.FrameItems.Items[ObjectInfo];
}
return null;
}

public void GetOffset(ByteReader reader, int index, bool check = false)
{
ushort Offset = reader.ReadUShort();
Expand Down
27 changes: 26 additions & 1 deletion Nebula.Core/FileReaders/APKFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ namespace Nebula.Core.FileReaders
{
public class APKFileReader : IFileReader
{
public string Name => "APK";
public string Name => "Android";
public Dictionary<int, Bitmap> Icons { get { return _icons; } set { _icons = value; } }
private Dictionary<int, Bitmap> _icons = new Dictionary<int, Bitmap>();

private static readonly List<string> VideoExtensions = new List<string>
{
".mp4",
".mkv",
".m4a",
".mov",
".webm",
".avi"
};

public string FilePath { get { return _filePath; } set { _filePath = value; } }
public string _filePath = string.Empty;

Expand Down Expand Up @@ -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")
{
Expand Down