Exemplo n.º 1
0
        public static void ExportAssetData(string fPath = null)
        {
            string fullPath = fPath;

            PakReader.PakReader reader = GetPakReader(fullPath);
            if (reader != null)
            {
                List <FPakEntry> entriesList = GetPakEntries(fullPath);
                foreach (FPakEntry entry in entriesList)
                {
                    string path       = FProp.FOutput_Path + "\\Exports\\" + entry.Name;
                    string pWExt      = FoldersUtility.GetFullPathWithoutExtension(entry.Name);
                    string subfolders = pWExt.Substring(0, pWExt.LastIndexOf("/", StringComparison.InvariantCultureIgnoreCase));

                    Directory.CreateDirectory(FProp.FOutput_Path + "\\Exports\\" + subfolders);
                    Stream stream = reader.GetPackageStream(entry);
                    using (var fStream = File.OpenWrite(path))
                        using (stream)
                        {
                            stream.CopyTo(fStream);
                        }

                    if (File.Exists(path))
                    {
                        DebugHelper.WriteLine("ExportAssetData: Successfully extracted data of {0}", entry.Name);

                        //    new UpdateMyConsole(Path.GetFileName(path), CColors.Blue).Append();
                        //  new UpdateMyConsole(" successfully exported", CColors.White, true).Append();
                    }
                    else //just in case
                    {
                        DebugHelper.WriteLine("ExportAssetData: Couldn't extract data of {0}", entry.Name);

                        //  new UpdateMyConsole("Bruh moment\nCouldn't export ", CColors.White).Append();
                        // new UpdateMyConsole(Path.GetFileName(path), CColors.Blue, true).Append();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static string GetAssetJsonData(PakReader.PakReader reader, IEnumerable <FPakEntry> entriesList, bool loadImageInBox = false)
        {
            DebugHelper.WriteLine("Assets: Gathering info about {0}", entriesList.ElementAt(0).Name);

            Stream[] AssetStreamArray = new Stream[3];

            foreach (FPakEntry entry in entriesList)
            {
                #region AUTO EXTRACT RAW
                if (FProp.Default.FAutoExtractRaw)
                {
                    string path       = FProp.Default.FOutput_Path + "\\Exports\\" + entry.Name;
                    string pWExt      = FoldersUtility.GetFullPathWithoutExtension(entry.Name);
                    string subfolders = pWExt.Substring(0, pWExt.LastIndexOf("/", StringComparison.InvariantCultureIgnoreCase));

                    Directory.CreateDirectory(FProp.Default.FOutput_Path + "\\Exports\\" + subfolders);
                    Stream stream = reader.GetPackageStream(entry);
                    using (var fStream = File.OpenWrite(path))
                        using (stream)
                        {
                            stream.CopyTo(fStream);
                        }

                    if (File.Exists(path))
                    {
                        DebugHelper.WriteLine("Assets: Successfully extracted data of {0}", entry.Name);

                        new UpdateMyConsole(Path.GetFileName(path), CColors.Blue).Append();
                        new UpdateMyConsole(" successfully exported", CColors.White, true).Append();
                    }
                    else //just in case
                    {
                        DebugHelper.WriteLine("Assets: Couldn't extract data of {0}", entry.Name);

                        new UpdateMyConsole("Bruh moment\nCouldn't export ", CColors.White).Append();
                        new UpdateMyConsole(Path.GetFileName(path), CColors.Blue, true).Append();
                    }
                }
                #endregion

                switch (Path.GetExtension(entry.Name.ToLowerInvariant()))
                {
                case ".ini":
                    FWindow.FMain.Dispatcher.InvokeAsync(() =>
                    {
                        FWindow.FMain.AssetPropertiesBox_Main.SyntaxHighlighting = ResourceLoader.LoadHighlightingDefinition("Ini.xshd");
                    });
                    using (var s = reader.GetPackageStream(entry))
                        using (var r = new StreamReader(s))
                            return(r.ReadToEnd());

                case ".uproject":
                case ".uplugin":
                case ".upluginmanifest":
                    using (var s = reader.GetPackageStream(entry))
                        using (var r = new StreamReader(s))
                            return(r.ReadToEnd());

                case ".locmeta":
                    using (var s = reader.GetPackageStream(entry))
                        return(JsonConvert.SerializeObject(new LocMetaFile(s), Formatting.Indented));

                case ".locres":
                    using (var s = reader.GetPackageStream(entry))
                        return(JsonConvert.SerializeObject(new LocResFile(s).Entries, Formatting.Indented));

                case ".udic":
                    using (var s = reader.GetPackageStream(entry))
                        using (var r = new BinaryReader(s))
                            return(JsonConvert.SerializeObject(new UDicFile(r).Header, Formatting.Indented));

                case ".bin":
                    if (string.Equals(entry.Name, "/FortniteGame/AssetRegistry.bin") || !entry.Name.Contains("AssetRegistry"))     //MEMORY ISSUE
                    {
                        break;
                    }

                    using (var s = reader.GetPackageStream(entry))
                        return(JsonConvert.SerializeObject(new AssetRegistryFile(s), Formatting.Indented));

                default:
                    if (entry.Name.EndsWith(".uasset"))
                    {
                        AssetStreamArray[0] = reader.GetPackageStream(entry);
                    }

                    if (entry.Name.EndsWith(".uexp"))
                    {
                        AssetStreamArray[1] = reader.GetPackageStream(entry);
                    }

                    if (entry.Name.EndsWith(".ubulk"))
                    {
                        AssetStreamArray[2] = reader.GetPackageStream(entry);
                    }
                    break;
                }
            }

            AssetReader ar = GetAssetReader(AssetStreamArray);
            if (ar != null)
            {
                if (loadImageInBox)
                {
                    foreach (ExportObject eo in ar.Exports)
                    {
                        switch (eo)
                        {
                        case Texture2D texture:
                            SKImage image = texture.GetImage();
                            if (image != null)
                            {
                                using (var data = image.Encode())
                                    using (var stream = data.AsStream())
                                    {
                                        ImageSource img = ImagesUtility.GetImageSource(stream);
                                        FWindow.FMain.Dispatcher.InvokeAsync(() =>
                                        {
                                            FWindow.FMain.ImageBox_Main.Source = BitmapFrame.Create((BitmapSource)img); //thread safe and fast af

                                            if (FWindow.FMain.MI_Auto_Save_Images.IsChecked)                            //auto save images
                                            {
                                                ImagesUtility.SaveImage(FProp.Default.FOutput_Path + "\\Icons\\" + FWindow.FCurrentAsset + ".png");
                                            }
                                        });
                                    }
                            }
                            return(JsonConvert.SerializeObject(texture.textures, Formatting.Indented));

                        case USoundWave sound:
                            using (sound)
                            {
                                byte[] s = readSound(sound);
                                if (s != null)
                                {
                                    string path = FProp.Default.FOutput_Path + "\\Sounds\\" + FWindow.FCurrentAsset + ".ogg";
                                    File.WriteAllBytes(path, s);

                                    //open sound
                                    if (FProp.Default.FOpenSounds)
                                    {
                                        FoldersUtility.OpenWithDefaultProgram(path);
                                    }
                                }

                                GC.Collect();
                                GC.WaitForPendingFinalizers();
                                return(JsonConvert.SerializeObject(sound.base_object, Formatting.Indented));
                            }
                        }
                    }
                }

                string stringData = JsonConvert.SerializeObject(ar.Exports, Formatting.Indented);

                #region AUTO SAVE JSON
                if (FProp.Default.FAutoSaveJson)
                {
                    string name = Path.GetFileNameWithoutExtension(entriesList.ElementAt(0).Name);
                    string path = FProp.Default.FOutput_Path + "\\JSONs\\" + name + ".json";
                    if (!string.IsNullOrEmpty(stringData))
                    {
                        File.WriteAllText(path, stringData);
                        if (File.Exists(path))
                        {
                            DebugHelper.WriteLine("Assets: Successfully saved serialized data of {0}", entriesList.ElementAt(0).Name);

                            new UpdateMyConsole(name, CColors.Blue).Append();
                            new UpdateMyConsole("'s Json data successfully saved", CColors.White, true).Append();
                        }
                        else //just in case
                        {
                            DebugHelper.WriteLine("Assets: Couldn't save serialized data of {0}", entriesList.ElementAt(0).Name);

                            new UpdateMyConsole("Bruh moment\nCouldn't export ", CColors.White).Append();
                            new UpdateMyConsole(name, CColors.Blue, true).Append();
                        }
                    }
                }
                #endregion

                return(stringData);
            }

            return(string.Empty);
        }
Exemplo n.º 3
0
        public static string GetAssetJsonData(PakReader.PakReader reader, IEnumerable <FPakEntry> entriesList, bool loadImageInBox = false)
        {
            Stream[] AssetStreamArray = new Stream[3];

            foreach (FPakEntry entry in entriesList)
            {
                switch (Path.GetExtension(entry.Name.ToLowerInvariant()))
                {
                case ".ini":
                    FWindow.FMain.Dispatcher.InvokeAsync(() =>
                    {
                        FWindow.FMain.AssetPropertiesBox_Main.SyntaxHighlighting = ResourceLoader.LoadHighlightingDefinition("Ini.xshd");
                    });
                    using (var s = reader.GetPackageStream(entry))
                        using (var r = new StreamReader(s))
                            return(r.ReadToEnd());

                case ".uproject":
                case ".uplugin":
                case ".upluginmanifest":
                    using (var s = reader.GetPackageStream(entry))
                        using (var r = new StreamReader(s))
                            return(r.ReadToEnd());

                case ".locmeta":
                    using (var s = reader.GetPackageStream(entry))
                        return(JsonConvert.SerializeObject(new LocMetaFile(s), Formatting.Indented));

                case ".locres":
                    using (var s = reader.GetPackageStream(entry))
                        return(JsonConvert.SerializeObject(new LocResFile(s).Entries, Formatting.Indented));

                case ".udic":
                    using (var s = reader.GetPackageStream(entry))
                        using (var r = new BinaryReader(s))
                            return(JsonConvert.SerializeObject(new UDicFile(r).Header, Formatting.Indented));

                case ".bin":
                    if (string.Equals(entry.Name, "/FortniteGame/AssetRegistry.bin") || !entry.Name.Contains("AssetRegistry"))     //MEMORY ISSUE
                    {
                        break;
                    }

                    using (var s = reader.GetPackageStream(entry))
                        return(JsonConvert.SerializeObject(new AssetRegistryFile(s), Formatting.Indented));

                default:
                    if (entry.Name.EndsWith(".uasset"))
                    {
                        AssetStreamArray[0] = reader.GetPackageStream(entry);
                    }

                    if (entry.Name.EndsWith(".uexp"))
                    {
                        AssetStreamArray[1] = reader.GetPackageStream(entry);
                    }

                    if (entry.Name.EndsWith(".ubulk"))
                    {
                        AssetStreamArray[2] = reader.GetPackageStream(entry);
                    }
                    break;
                }
            }

            AssetReader ar = GetAssetReader(AssetStreamArray);

            if (ar != null)
            {
                if (loadImageInBox)
                {
                    foreach (ExportObject eo in ar.Exports)
                    {
                        switch (eo)
                        {
                        case Texture2D texture:
                            SKImage image = texture.GetImage();
                            if (image != null)
                            {
                                using (var data = image.Encode())
                                    using (var stream = data.AsStream())
                                    {
                                        ImageSource img = ImagesUtility.GetImageSource(stream);
                                        FWindow.FMain.Dispatcher.InvokeAsync(() =>
                                        {
                                            FWindow.FMain.ImageBox_Main.Source = BitmapFrame.Create((BitmapSource)img); //thread safe and fast af

                                            if (FWindow.FMain.MI_Auto_Save_Images.IsChecked)                            //auto save images
                                            {
                                                ImagesUtility.SaveImage(FProp.Default.FOutput_Path + "\\Icons\\" + FWindow.FCurrentAsset + ".png");
                                            }
                                        });
                                    }
                            }
                            return(JsonConvert.SerializeObject(texture.textures, Formatting.Indented));

                        case USoundWave sound:
                            using (sound)
                            {
                                byte[] s = readSound(sound);
                                if (s != null)
                                {
                                    string path = FProp.Default.FOutput_Path + "\\Sounds\\" + FWindow.FCurrentAsset + ".ogg";
                                    File.WriteAllBytes(path, s);

                                    //open sound
                                    if (FProp.Default.FOpenSounds)
                                    {
                                        FoldersUtility.OpenWithDefaultProgram(path);
                                    }
                                }

                                GC.Collect();
                                GC.WaitForPendingFinalizers();
                                return(JsonConvert.SerializeObject(sound.base_object, Formatting.Indented));
                            }
                        }
                    }
                }

                return(JsonConvert.SerializeObject(ar.Exports, Formatting.Indented));
            }

            return(string.Empty);
        }
Exemplo n.º 4
0
        public static Stream GetChallengeBundleImage(JArray displayStyleArray)
        {
            JToken customBackgroundToken = AssetsUtility.GetPropertyTag <JToken>(displayStyleArray, "CustomBackground");
            JToken displayImageToken     = AssetsUtility.GetPropertyTag <JToken>(displayStyleArray, "DisplayImage");

            if (customBackgroundToken != null && customBackgroundToken["asset_path_name"] != null && customBackgroundToken["asset_path_name"].Value <string>().EndsWith("_Details"))
            {
                string path = FoldersUtility.FixFortnitePath(customBackgroundToken["asset_path_name"].Value <string>());
                if (!string.IsNullOrEmpty(path))
                {
                    ChallengeIconDesign.isBanner = true;
                    return(AssetsUtility.GetStreamImageFromPath(path));
                }
            }
            else if (displayImageToken != null && displayImageToken["asset_path_name"] != null)
            {
                string path = FoldersUtility.FixFortnitePath(displayImageToken["asset_path_name"].Value <string>());
                if (string.Equals(path, "/FortniteGame/Content/Athena/UI/Challenges/Art/TileImages/M_UI_ChallengeTile_PCB"))
                {
                    PakReader.PakReader reader = AssetsUtility.GetPakReader(path);
                    if (reader != null)
                    {
                        List <FPakEntry> entriesList = AssetsUtility.GetPakEntries(path);
                        string           jsonData    = AssetsUtility.GetAssetJsonData(reader, entriesList);

                        if (AssetsUtility.IsValidJson(jsonData))
                        {
                            dynamic AssetData      = JsonConvert.DeserializeObject(jsonData);
                            JToken  AssetMainToken = null;
                            if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
                            {
                                JArray AssetArray = JArray.FromObject(AssetData);
                                AssetMainToken = AssetArray[0];
                            }
                            else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
                            {
                                AssetMainToken = AssetData;
                            }

                            if (AssetMainToken != null)
                            {
                                JArray renderSwitchProperties = AssetMainToken["properties"].Value <JArray>();
                                if (renderSwitchProperties != null)
                                {
                                    JArray textureParameterArray = AssetsUtility.GetPropertyTagText <JArray>(renderSwitchProperties, "TextureParameterValues", "data")[0]["struct_type"]["properties"].Value <JArray>();
                                    if (textureParameterArray != null)
                                    {
                                        JToken parameterValueToken = AssetsUtility.GetPropertyTagOuterImport <JToken>(textureParameterArray, "ParameterValue");
                                        if (parameterValueToken != null)
                                        {
                                            string texturePath = FoldersUtility.FixFortnitePath(parameterValueToken.Value <string>());
                                            return(AssetsUtility.GetStreamImageFromPath(texturePath));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(path))
                {
                    return(AssetsUtility.GetStreamImageFromPath(path));
                }
            }
            return(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/unknown512.png")).Stream);
        }