diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index cd0e0202..bbfbf4b5 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -126,7 +126,7 @@ - + @@ -265,9 +265,6 @@ Always - - Always - diff --git a/FModel/Forms/SearchFiles.cs b/FModel/Forms/SearchFiles.cs index 15312dbc..bc1c051d 100644 --- a/FModel/Forms/SearchFiles.cs +++ b/FModel/Forms/SearchFiles.cs @@ -123,8 +123,6 @@ namespace FModel.Forms if (MainWindow.PakAsTxt != null) { - bool IsAllPaks = (ThePak.CurrentUsedPakGuid == null || ThePak.CurrentUsedPakGuid == "0-0-0-0"); - if (!string.IsNullOrEmpty(textBox1.Text) && textBox1.Text.Length > 2) { for (int i = 0; i < _myInfos.Count; i++) @@ -149,13 +147,13 @@ namespace FModel.Forms { if (!_myFilteredInfosDict.ContainsKey(_myInfos[i].FileName.Substring(0, _myInfos[i].FileName.LastIndexOf(".", StringComparison.Ordinal)))) { - _myFilteredInfosDict.Add(_myInfos[i].FileName.Substring(0, _myInfos[i].FileName.LastIndexOf(".", StringComparison.Ordinal)), !IsAllPaks ? ThePak.CurrentUsedPak : ThePak.AllpaksDictionary[Path.GetFileNameWithoutExtension(_myInfos[i].FileName)]); + _myFilteredInfosDict.Add(_myInfos[i].FileName.Substring(0, _myInfos[i].FileName.LastIndexOf(".", StringComparison.Ordinal)), ThePak.AllpaksDictionary[Path.GetFileNameWithoutExtension(_myInfos[i].FileName)]); _fileName = _myInfos[i].FileName.Substring(0, _myInfos[i].FileName.LastIndexOf(".", StringComparison.Ordinal)); _myFilteredInfos.Add(new FileInfoFilter { FileName = _fileName, - PakFile = !IsAllPaks ? ThePak.CurrentUsedPak : ThePak.AllpaksDictionary[Path.GetFileNameWithoutExtension(_myInfos[i].FileName)], + PakFile = ThePak.AllpaksDictionary[Path.GetFileNameWithoutExtension(_myInfos[i].FileName)], }); } } @@ -163,13 +161,13 @@ namespace FModel.Forms { if (!_myFilteredInfosDict.ContainsKey(_myInfos[i].FileName)) { - _myFilteredInfosDict.Add(_myInfos[i].FileName, !IsAllPaks ? ThePak.CurrentUsedPak : ThePak.AllpaksDictionary[Path.GetFileName(_myInfos[i].FileName)]); + _myFilteredInfosDict.Add(_myInfos[i].FileName, ThePak.AllpaksDictionary[Path.GetFileName(_myInfos[i].FileName)]); _fileName = _myInfos[i].FileName; _myFilteredInfos.Add(new FileInfoFilter { FileName = _fileName, - PakFile = !IsAllPaks ? ThePak.CurrentUsedPak : ThePak.AllpaksDictionary[Path.GetFileName(_myInfos[i].FileName)], + PakFile = ThePak.AllpaksDictionary[Path.GetFileName(_myInfos[i].FileName)], }); } } diff --git a/FModel/MainWindow.cs b/FModel/MainWindow.cs index 2bc75898..655bddf4 100644 --- a/FModel/MainWindow.cs +++ b/FModel/MainWindow.cs @@ -276,9 +276,8 @@ namespace FModel //METHODS private void RegisterPaKsinDict(ToolStripItemClickedEventArgs theSinglePak = null, bool loadAllPaKs = false) { + PakExtractor extractor = null; StringBuilder sb = new StringBuilder(); - ThePak.CurrentUsedPak = null; - ThePak.CurrentUsedPakGuid = null; bool bMainKeyWorking = false; for (int i = 0; i < ThePak.mainPaksList.Count; i++) @@ -287,22 +286,22 @@ namespace FModel { if (!string.IsNullOrWhiteSpace(Settings.Default.AESKey)) { - JohnWick.MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey); + extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey); } - else { JohnWick.MyExtractor.Dispose(); break; } + else { extractor.Dispose(); break; } } catch (Exception) { - JohnWick.MyExtractor.Dispose(); + extractor.Dispose(); break; } - string[] CurrentUsedPakLines = JohnWick.MyExtractor.GetFileList().ToArray(); + string[] CurrentUsedPakLines = extractor.GetFileList().ToArray(); if (CurrentUsedPakLines != null) { bMainKeyWorking = true; - string mountPoint = JohnWick.MyExtractor.GetMountPoint(); + string mountPoint = extractor.GetMountPoint(); ThePak.PaksMountPoint.Add(ThePak.mainPaksList[i].thePak, mountPoint.Substring(9)); for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++) @@ -334,7 +333,7 @@ namespace FModel if (loadAllPaKs) { new UpdateMyState(".PAK mount point: " + mountPoint.Substring(9), "Waiting").ChangeProcessState(); } if (theSinglePak != null && ThePak.mainPaksList[i].thePak == theSinglePak.ClickedItem.Text) { PakAsTxt = CurrentUsedPakLines; } } - JohnWick.MyExtractor.Dispose(); + extractor.Dispose(); } if (bMainKeyWorking) { LoadLocRes.LoadMySelectedLocRes(Settings.Default.IconLanguage); } @@ -347,24 +346,24 @@ namespace FModel { try { - JohnWick.MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + pakName, pakKey); + extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + pakName, pakKey); } catch (Exception) { new UpdateMyConsole("0x" + pakKey + " doesn't work with " + ThePak.dynamicPaksList[i].thePak, Color.Red, true).AppendToConsole(); - JohnWick.MyExtractor.Dispose(); + extractor.Dispose(); continue; } - string[] CurrentUsedPakLines = JohnWick.MyExtractor.GetFileList().ToArray(); + string[] CurrentUsedPakLines = extractor.GetFileList().ToArray(); if (CurrentUsedPakLines != null) { - string mountPoint = JohnWick.MyExtractor.GetMountPoint(); + string mountPoint = extractor.GetMountPoint(); ThePak.PaksMountPoint.Add(ThePak.dynamicPaksList[i].thePak, mountPoint.Substring(9)); for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++) { - CurrentUsedPakLines[ii] = JohnWick.MyExtractor.GetMountPoint().Substring(6) + CurrentUsedPakLines[ii]; + CurrentUsedPakLines[ii] = mountPoint.Substring(6) + CurrentUsedPakLines[ii]; string CurrentUsedPakFileName = CurrentUsedPakLines[ii].Substring(CurrentUsedPakLines[ii].LastIndexOf("/", StringComparison.Ordinal) + 1); if (CurrentUsedPakFileName.Contains(".uasset") || CurrentUsedPakFileName.Contains(".uexp") || CurrentUsedPakFileName.Contains(".ubulk")) @@ -389,15 +388,9 @@ namespace FModel } if (loadAllPaKs) { new UpdateMyState(".PAK mount point: " + mountPoint.Substring(9), "Waiting").ChangeProcessState(); } - if (theSinglePak != null && ThePak.dynamicPaksList[i].thePak == theSinglePak.ClickedItem.Text) - { - ThePak.CurrentUsedPak = pakName; - ThePak.CurrentUsedPakGuid = ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + ThePak.CurrentUsedPak); - - PakAsTxt = CurrentUsedPakLines; - } + if (theSinglePak != null && ThePak.dynamicPaksList[i].thePak == theSinglePak.ClickedItem.Text) { PakAsTxt = CurrentUsedPakLines; } } - JohnWick.MyExtractor.Dispose(); + extractor.Dispose(); } } @@ -540,6 +533,7 @@ namespace FModel { TreeParsePath(treeView1.Nodes, PakAsTxt[i].Replace(PakAsTxt[i].Split('/').Last(), "")); } + Utilities.ExpandToLevel(treeView1.Nodes, 2); treeView1.EndUpdate(); })); new UpdateMyState(Settings.Default.PAKsPath + "\\" + selectedPak.ClickedItem.Text, "Success").ChangeProcessState(); @@ -569,6 +563,7 @@ namespace FModel { TreeParsePath(treeView1.Nodes, PakAsTxt[i].Replace(PakAsTxt[i].Split('/').Last(), "")); } + Utilities.ExpandToLevel(treeView1.Nodes, 2); treeView1.EndUpdate(); })); new UpdateMyState(Settings.Default.PAKsPath, "Success").ChangeProcessState(); @@ -600,6 +595,7 @@ namespace FModel { TreeParsePath(treeView1.Nodes, PakAsTxt[i].Replace(PakAsTxt[i].Split('/').Last(), "")); } + Utilities.ExpandToLevel(treeView1.Nodes, 2); treeView1.EndUpdate(); })); @@ -610,33 +606,35 @@ namespace FModel } private void CreateBackupList() { + PakExtractor extractor = null; StringBuilder sb = new StringBuilder(); for (int i = 0; i < ThePak.mainPaksList.Count; i++) { try { - JohnWick.MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey); + extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey); } catch (Exception) { new UpdateMyConsole("0x" + Settings.Default.AESKey + " doesn't work with the main paks.", Color.Red, true).AppendToConsole(); - JohnWick.MyExtractor.Dispose(); + extractor.Dispose(); break; } - string[] CurrentUsedPakLines = JohnWick.MyExtractor.GetFileList().ToArray(); + string[] CurrentUsedPakLines = extractor.GetFileList().ToArray(); if (CurrentUsedPakLines != null) { + string mountPoint = extractor.GetMountPoint(); for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++) { - CurrentUsedPakLines[ii] = JohnWick.MyExtractor.GetMountPoint().Substring(6) + CurrentUsedPakLines[ii]; + CurrentUsedPakLines[ii] = mountPoint.Substring(6) + CurrentUsedPakLines[ii]; sb.Append(CurrentUsedPakLines[ii] + "\n"); } - new UpdateMyState(".PAK mount point: " + JohnWick.MyExtractor.GetMountPoint().Substring(9), "Waiting").ChangeProcessState(); + new UpdateMyState(".PAK mount point: " + mountPoint.Substring(9), "Waiting").ChangeProcessState(); } - JohnWick.MyExtractor.Dispose(); + extractor.Dispose(); } for (int i = 0; i < ThePak.dynamicPaksList.Count; i++) @@ -648,28 +646,29 @@ namespace FModel { try { - JohnWick.MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + pakName, pakKey); + extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + pakName, pakKey); } catch (Exception) { new UpdateMyConsole("0x" + pakKey + " doesn't work with " + ThePak.dynamicPaksList[i].thePak, Color.Red, true).AppendToConsole(); - JohnWick.MyExtractor.Dispose(); + extractor.Dispose(); continue; } - string[] CurrentUsedPakLines = JohnWick.MyExtractor.GetFileList().ToArray(); + string[] CurrentUsedPakLines = extractor.GetFileList().ToArray(); if (CurrentUsedPakLines != null) { + string mountPoint = extractor.GetMountPoint(); for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++) { - CurrentUsedPakLines[ii] = JohnWick.MyExtractor.GetMountPoint().Substring(6) + CurrentUsedPakLines[ii]; + CurrentUsedPakLines[ii] = mountPoint.Substring(6) + CurrentUsedPakLines[ii]; sb.Append(CurrentUsedPakLines[ii] + "\n"); } new UpdateMyConsole("Backing up ", Color.Black).AppendToConsole(); new UpdateMyConsole(ThePak.dynamicPaksList[i].thePak, Color.DarkRed, true).AppendToConsole(); } - JohnWick.MyExtractor.Dispose(); + extractor.Dispose(); } } diff --git a/FModel/Converter/UnrealEngineDataToOGG.cs b/FModel/Methods/Converter/UnrealEngineDataToOGG.cs similarity index 100% rename from FModel/Converter/UnrealEngineDataToOGG.cs rename to FModel/Methods/Converter/UnrealEngineDataToOGG.cs diff --git a/FModel/Methods/JohnWick/JohnWick.cs b/FModel/Methods/JohnWick/JohnWick.cs index 47a5b56d..05c87ad7 100644 --- a/FModel/Methods/JohnWick/JohnWick.cs +++ b/FModel/Methods/JohnWick/JohnWick.cs @@ -12,8 +12,7 @@ namespace FModel static class JohnWick { public static PakAsset MyAsset; - public static PakExtractor MyExtractor; - public static string MyKey; + private static PakExtractor _myExtractor; public static string[] myArray { get; set; } private static string currentPakToCheck { get; set; } @@ -54,34 +53,21 @@ namespace FModel /// the path of the last created file (usually the uexp file but we don't care about the extension, so it's fine) public static string ExtractAsset(string currentPak, string currentItem) { - ThePak.CurrentUsedPak = currentPak; - ThePak.CurrentUsedPakGuid = ThePak.dynamicPaksList.Where(x => x.thePak == currentPak).Select(x => x.thePakGuid).FirstOrDefault(); - - if (!string.IsNullOrEmpty(ThePak.CurrentUsedPakGuid) && ThePak.CurrentUsedPakGuid != "0-0-0-0") + string pakGuid = ThePak.dynamicPaksList.Where(x => x.thePak == currentPak).Select(x => x.thePakGuid).FirstOrDefault(); + string myKey = string.Empty; + if (!string.IsNullOrEmpty(pakGuid) && pakGuid != "0-0-0-0") { - MyKey = DynamicKeysManager.AESEntries.Where(x => x.thePak == currentPak).Select(x => x.theKey).FirstOrDefault(); - } - else - { - ThePak.CurrentUsedPakGuid = "0-0-0-0"; - MyKey = Settings.Default.AESKey; + myKey = DynamicKeysManager.AESEntries.Where(x => x.thePak == currentPak).Select(x => x.theKey).FirstOrDefault(); } + else { myKey = Settings.Default.AESKey; } if (currentPak != currentPakToCheck || myArray == null) { - MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + currentPak, MyKey); - myArray = MyExtractor.GetFileList().ToArray(); + _myExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + currentPak, myKey); + myArray = _myExtractor.GetFileList().ToArray(); } - string[] results; - if (currentItem.Contains(".")) - { - results = Array.FindAll(myArray, s => s.Contains("/" + currentItem)); - } - else - { - results = Array.FindAll(myArray, s => s.Contains("/" + currentItem + ".")); - } + string[] results = currentItem.Contains(".") ? Array.FindAll(myArray, s => s.Contains("/" + currentItem)) : Array.FindAll(myArray, s => s.Contains("/" + currentItem + ".")); string AssetPath = string.Empty; for (int i = 0; i < results.Length; i++) @@ -89,7 +75,7 @@ namespace FModel int index = Array.IndexOf(myArray, results[i]); uint y = (uint)index; - byte[] b = MyExtractor.GetData(y); + byte[] b = _myExtractor.GetData(y); AssetPath = WriteFile(currentItem, results[i], b).Replace("/", "\\"); } diff --git a/FModel/Methods/Utilities/Utilities.cs b/FModel/Methods/Utilities/Utilities.cs index 0a29ff11..63829e18 100644 --- a/FModel/Methods/Utilities/Utilities.cs +++ b/FModel/Methods/Utilities/Utilities.cs @@ -169,5 +169,22 @@ namespace FModel } } } + + /// + /// something to expand nodes to a given level + /// + /// + /// + public static void ExpandToLevel(TreeNodeCollection nodes, int level) + { + if (level > 0) + { + foreach (TreeNode node in nodes) + { + node.Expand(); + ExpandToLevel(node.Nodes, level - 1); + } + } + } } } diff --git a/FModel/Methods/VarApp.cs b/FModel/Methods/VarApp.cs index 7640214a..d8e12e28 100644 --- a/FModel/Methods/VarApp.cs +++ b/FModel/Methods/VarApp.cs @@ -45,8 +45,6 @@ namespace FModel { public static List mainPaksList { get; set; } public static List dynamicPaksList { get; set; } - public static string CurrentUsedPak { get; set; } - public static string CurrentUsedPakGuid { get; set; } public static string CurrentUsedItem { get; set; } public static Dictionary PaksMountPoint { get; set; } diff --git a/FModel/oo2core_5_win64.dll b/FModel/oo2core_5_win64.dll deleted file mode 100644 index a3cac456..00000000 Binary files a/FModel/oo2core_5_win64.dll and /dev/null differ