Exemplo n.º 1
0
        private static void PopulateDict(string folder, string fileName, string lang)
        {
            string path = $"{folder}{fileName}/{lang}/{fileName}.locres";

            DebugHelper.WriteLine(".PAKs: Loading " + path + " as the translation file");

            if (HotfixLocResDict == null)
            {
                SetHotfixedLocResDict();
            }                                                          //once, no need to do more

            Dictionary <string, Dictionary <string, string> > brFinalDict  = new Dictionary <string, Dictionary <string, string> >();
            Dictionary <string, Dictionary <string, string> > stwFinalDict = new Dictionary <string, Dictionary <string, string> >();

            foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values)
            {
                IEnumerable <string> locresFilesPath = PAKsFileInfos.Where(x => x.Name.StartsWith(folder + fileName) && x.Name.Contains($"/{lang}/") && x.Name.EndsWith(".locres")).Select(x => x.Name);
                if (locresFilesPath.Any())
                {
                    foreach (string file in locresFilesPath)
                    {
                        var dict = GetLocResDict(file);
                        foreach (var namespac in dict)
                        {
                            if (!brFinalDict.ContainsKey(namespac.Key))
                            {
                                brFinalDict.Add(namespac.Key, new Dictionary <string, string>());
                            }

                            foreach (var key in namespac.Value)
                            {
                                brFinalDict[namespac.Key].Add(key.Key, key.Value);
                            }
                        }
                    }
                }
                locresFilesPath = PAKsFileInfos.Where(x => x.Name.StartsWith(folder + "Game_StW") && x.Name.Contains($"/{lang}/") && x.Name.EndsWith(".locres")).Select(x => x.Name);
                if (locresFilesPath.Any())
                {
                    foreach (string file in locresFilesPath)
                    {
                        var dict = GetLocResDict(file);
                        foreach (var namespac in dict)
                        {
                            if (!stwFinalDict.ContainsKey(namespac.Key))
                            {
                                stwFinalDict.Add(namespac.Key, new Dictionary <string, string>());
                            }

                            foreach (var key in namespac.Value)
                            {
                                stwFinalDict[namespac.Key].Add(key.Key, key.Value);
                            }
                        }
                    }
                }
            }
            BRLocResDict  = brFinalDict;
            STWLocResDict = stwFinalDict;
        }
Exemplo n.º 2
0
        public static async Task PopulateListBox(TreeViewItem sItem)
        {
            FilesListWithoutPath = null;
            FWindow.FMain.ListBox_Main.Items.Clear();
            FWindow.FMain.FilterTextBox_Main.Text = string.Empty;

            string path = TreeViewUtility.GetFullPath(sItem);

            FilesListWithoutPath = new List <IEnumerable <string> >();
            if (!string.IsNullOrEmpty(FWindow.FCurrentPAK))
            {
                IEnumerable <string> filesWithoutPath = PAKEntries.PAKToDisplay[FWindow.FCurrentPAK]
                                                        .Where(x => x.Name.Contains(path + "/" + Path.GetFileName(x.Name)))
                                                        .Select(x => Path.GetFileName(x.Name));

                if (filesWithoutPath != null)
                {
                    FilesListWithoutPath.Add(filesWithoutPath);
                }
            }
            else
            {
                foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values)
                {
                    IEnumerable <string> filesWithoutPath = PAKsFileInfos
                                                            .Where(x => x.Name.Contains(path + "/" + Path.GetFileName(x.Name)))
                                                            .Select(x => Path.GetFileName(x.Name));

                    if (filesWithoutPath != null)
                    {
                        FilesListWithoutPath.Add(filesWithoutPath);
                    }
                }
            }

            if (FilesListWithoutPath != null && FilesListWithoutPath.Any())
            {
                await Task.Run(() =>
                {
                    FillMeThisPls();
                }).ContinueWith(TheTask =>
                {
                    TasksUtility.TaskCompleted(TheTask.Exception);
                });
            }

            FWindow.FMain.Button_Extract.IsEnabled = FWindow.FMain.ListBox_Main.SelectedIndex >= 0;
        }
Exemplo n.º 3
0
        public static async Task ExtractFoldersAndSub(string path)
        {
            new UpdateMyProcessEvents("", "").Update();
            FWindow.FMain.Button_Extract.IsEnabled     = false;
            FWindow.FMain.Button_Stop.IsEnabled        = true;
            FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty;
            FWindow.FMain.AssetPropertiesBox_Main.SyntaxHighlighting = ResourceLoader.LoadHighlightingDefinition("Json.xshd");
            FWindow.FMain.ImageBox_Main.Source = null;

            List <IEnumerable <string> > assetList = new List <IEnumerable <string> >();

            if (!string.IsNullOrEmpty(FWindow.FCurrentPAK))
            {
                IEnumerable <string> files = PAKEntries.PAKToDisplay[FWindow.FCurrentPAK]
                                             .Where(x => x.Name.StartsWith(path + "/"))
                                             .Select(x => x.Name);

                if (files != null)
                {
                    assetList.Add(files);
                }
            }
            else
            {
                foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values)
                {
                    IEnumerable <string> files = PAKsFileInfos
                                                 .Where(x => x.Name.StartsWith(path + "/"))
                                                 .Select(x => x.Name);

                    if (files != null)
                    {
                        assetList.Add(files);
                    }
                }
            }

            TasksUtility.CancellableTaskTokenSource = new CancellationTokenSource();
            CancellationToken cToken = TasksUtility.CancellableTaskTokenSource.Token;
            await Task.Run(() =>
            {
                isRunning = true;
                DebugHelper.WriteLine("Assets: User is extracting everything in " + path);
                foreach (IEnumerable <string> filesFromOnePak in assetList)
                {
                    foreach (string asset in filesFromOnePak.OrderBy(s => s))
                    {
                        cToken.ThrowIfCancellationRequested(); //if clicked on 'Stop' it breaks at the following item

                        string target;
                        if (asset.EndsWith(".uexp") || asset.EndsWith(".ubulk"))
                        {
                            continue;
                        }
                        else if (!asset.EndsWith(".uasset"))
                        {
                            target = asset; //ini uproject locres etc
                        }
                        else
                        {
                            target = asset.Substring(0, asset.LastIndexOf(".")); //uassets
                        }

                        while (!string.Equals(FWindow.FCurrentAsset, Path.GetFileName(target)))
                        {
                            FWindow.FCurrentAsset = Path.GetFileName(target);
                        }
                        LoadAsset(target);
                    }
                }
            }, cToken).ContinueWith(TheTask =>
            {
                TasksUtility.TaskCompleted(TheTask.Exception);
                TasksUtility.CancellableTaskTokenSource.Dispose();
                isRunning = false;
            });

            FWindow.FMain.Button_Extract.IsEnabled = true;
            FWindow.FMain.Button_Stop.IsEnabled    = false;
        }
Exemplo n.º 4
0
        public static async Task ExtractUpdateMode()
        {
            new UpdateMyProcessEvents("", "").Update();
            FWindow.FMain.Button_Extract.IsEnabled     = false;
            FWindow.FMain.Button_Stop.IsEnabled        = true;
            FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty;
            FWindow.FMain.AssetPropertiesBox_Main.SyntaxHighlighting = ResourceLoader.LoadHighlightingDefinition("Json.xshd");
            FWindow.FMain.ImageBox_Main.Source = null;
            bool sound = FProp.Default.FOpenSounds;

            FProp.Default.FOpenSounds = false;

            List <IEnumerable <string> > assetList = new List <IEnumerable <string> >();

            foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values)
            {
                IEnumerable <string> files = PAKsFileInfos
                                             .Where(x => Forms.FModel_UpdateMode.AssetsEntriesDict.Any(c => bool.Parse(c.Value["isChecked"]) && x.Name.StartsWith(c.Value["Path"])))
                                             .Select(x => x.Name);

                if (files != null)
                {
                    assetList.Add(files);
                }
            }

            TasksUtility.CancellableTaskTokenSource = new CancellationTokenSource();
            CancellationToken cToken = TasksUtility.CancellableTaskTokenSource.Token;
            await Task.Run(() =>
            {
                isRunning = true;
                foreach (IEnumerable <string> filesFromOnePak in assetList)
                {
                    foreach (string asset in filesFromOnePak.OrderBy(s => s))
                    {
                        cToken.ThrowIfCancellationRequested(); //if clicked on 'Stop' it breaks at the following item

                        string target;
                        if (asset.EndsWith(".uexp") || asset.EndsWith(".ubulk"))
                        {
                            continue;
                        }
                        else if (!asset.EndsWith(".uasset"))
                        {
                            target = asset; //ini uproject locres etc
                        }
                        else
                        {
                            target = asset.Substring(0, asset.LastIndexOf(".")); //uassets
                        }

                        while (!string.Equals(FWindow.FCurrentAsset, Path.GetFileName(target)))
                        {
                            FWindow.FCurrentAsset = Path.GetFileName(target);
                        }

                        try
                        {
                            LoadAsset(target);
                        }
                        catch (System.Exception ex)
                        {
                            new UpdateMyConsole(ex.Message, CColors.Red, true).Append();
                        }
                    }
                }
            }, cToken).ContinueWith(TheTask =>
            {
                TasksUtility.TaskCompleted(TheTask.Exception);
                TasksUtility.CancellableTaskTokenSource.Dispose();
                isRunning = false;
            });

            FWindow.FMain.MI_Auto_Save_Images.IsChecked = false;
            FWindow.FMain.Button_Extract.IsEnabled      = true;
            FWindow.FMain.Button_Stop.IsEnabled         = false;
            FWindow.FMain.MI_Auto_Save_Images.IsChecked = false;
            FProp.Default.FOpenSounds = sound;
            new UpdateMyProcessEvents("All assets have been extracted successfully", "Success").Update();
        }