bug fixes

This commit is contained in:
Asval 2019-07-14 01:17:58 +02:00
parent 327aec7a75
commit 369162abb2
8 changed files with 63 additions and 68 deletions

View File

@ -126,7 +126,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Converter\UnrealEngineDataToOGG.cs" />
<Compile Include="Methods\Converter\UnrealEngineDataToOGG.cs" />
<Compile Include="Custom\JsonExtensions.cs" />
<Compile Include="Custom\TypeAssistant.cs" />
<Compile Include="Forms\AESManager.cs">
@ -265,9 +265,6 @@
<Content Include="csharp_wick.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="oo2core_5_win64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="DLLs\csharp-wick.dll" />
<Content Include="DLLs\ScintillaNET FindReplaceDialog.dll" />
<Content Include="FModel.ico" />

View File

@ -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)],
});
}
}

View File

@ -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();
}
}

View File

@ -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
/// <returns> the path of the last created file (usually the uexp file but we don't care about the extension, so it's fine) </returns>
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("/", "\\");
}

View File

@ -169,5 +169,22 @@ namespace FModel
}
}
}
/// <summary>
/// something to expand nodes to a given level
/// </summary>
/// <param name="nodes"></param>
/// <param name="level"></param>
public static void ExpandToLevel(TreeNodeCollection nodes, int level)
{
if (level > 0)
{
foreach (TreeNode node in nodes)
{
node.Expand();
ExpandToLevel(node.Nodes, level - 1);
}
}
}
}
}

View File

@ -45,8 +45,6 @@ namespace FModel
{
public static List<PaksEntry> mainPaksList { get; set; }
public static List<PaksEntry> dynamicPaksList { get; set; }
public static string CurrentUsedPak { get; set; }
public static string CurrentUsedPakGuid { get; set; }
public static string CurrentUsedItem { get; set; }
public static Dictionary<string, string> PaksMountPoint { get; set; }

Binary file not shown.