fixed pak mount point bug + fixed update mode stop if error

This commit is contained in:
Asval 2019-07-28 00:44:16 +02:00
parent 447b017c4f
commit f668aab0c6
5 changed files with 64 additions and 67 deletions

View File

@ -68,29 +68,29 @@ namespace FModel.Forms
Properties.Settings.Default.UMOpacity = trackBar1.Value;
//PARAMETERS
if (checkedListBox1.GetItemCheckState(0) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Athena/Items/Cosmetics/"); }
if (checkedListBox1.GetItemCheckState(1) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Athena/Items/CosmeticVariantTokens/"); }
if (checkedListBox1.GetItemCheckState(2) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Athena/Items/BannerToken/"); }
if (checkedListBox1.GetItemCheckState(3) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Athena/Items/ChallengeBundles/"); }
if (checkedListBox1.GetItemCheckState(4) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Athena/Items/Consumables/"); }
if (checkedListBox1.GetItemCheckState(5) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Athena/Items/Gameplay/"); }
if (checkedListBox1.GetItemCheckState(6) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Athena/Items/Traps/"); }
if (checkedListBox1.GetItemCheckState(7) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Athena/Items/Weapons/"); }
if (checkedListBox1.GetItemCheckState(8) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Heroes/"); }
if (checkedListBox1.GetItemCheckState(9) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Items/Defenders/"); }
if (checkedListBox1.GetItemCheckState(10) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Items/Workers/"); }
if (checkedListBox1.GetItemCheckState(11) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Items/Traps/"); }
if (checkedListBox1.GetItemCheckState(12) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Items/Weapons/"); }
if (checkedListBox1.GetItemCheckState(13) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Items/Ingredients/"); }
if (checkedListBox1.GetItemCheckState(14) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Items/PersistentResources/"); }
if (checkedListBox1.GetItemCheckState(15) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Items/CardPacks/"); }
if (checkedListBox1.GetItemCheckState(16) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/Items/Tokens/"); }
if (checkedListBox1.GetItemCheckState(0) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Athena/Items/Cosmetics/"); }
if (checkedListBox1.GetItemCheckState(1) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Athena/Items/CosmeticVariantTokens/"); }
if (checkedListBox1.GetItemCheckState(2) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Athena/Items/BannerToken/"); }
if (checkedListBox1.GetItemCheckState(3) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Athena/Items/ChallengeBundles/"); }
if (checkedListBox1.GetItemCheckState(4) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Athena/Items/Consumables/"); }
if (checkedListBox1.GetItemCheckState(5) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Athena/Items/Gameplay/"); }
if (checkedListBox1.GetItemCheckState(6) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Athena/Items/Traps/"); }
if (checkedListBox1.GetItemCheckState(7) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Athena/Items/Weapons/"); }
if (checkedListBox1.GetItemCheckState(8) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Heroes/"); }
if (checkedListBox1.GetItemCheckState(9) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Items/Defenders/"); }
if (checkedListBox1.GetItemCheckState(10) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Items/Workers/"); }
if (checkedListBox1.GetItemCheckState(11) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Items/Traps/"); }
if (checkedListBox1.GetItemCheckState(12) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Items/Weapons/"); }
if (checkedListBox1.GetItemCheckState(13) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Items/Ingredients/"); }
if (checkedListBox1.GetItemCheckState(14) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Items/PersistentResources/"); }
if (checkedListBox1.GetItemCheckState(15) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Items/CardPacks/"); }
if (checkedListBox1.GetItemCheckState(16) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/Items/Tokens/"); }
if (checkedListBox2.GetItemCheckState(0) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/2dAssets/"); }
if (checkedListBox2.GetItemCheckState(1) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/UI/Foundation/Textures/BattleRoyale/FeaturedItems/"); }
if (checkedListBox2.GetItemCheckState(2) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/UI/Foundation/Textures/Icons/"); }
if (checkedListBox2.GetItemCheckState(3) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/UI/Foundation/Textures/Banner/"); }
if (checkedListBox2.GetItemCheckState(4) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("../FortniteGame/Content/UI/Foundation/Textures/LoadingScreens/"); }
if (checkedListBox2.GetItemCheckState(0) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/2dAssets/"); }
if (checkedListBox2.GetItemCheckState(1) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/UI/Foundation/Textures/BattleRoyale/FeaturedItems/"); }
if (checkedListBox2.GetItemCheckState(2) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/UI/Foundation/Textures/Icons/"); }
if (checkedListBox2.GetItemCheckState(3) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/UI/Foundation/Textures/Banner/"); }
if (checkedListBox2.GetItemCheckState(4) == CheckState.Checked) { RegisterSettings.updateModeListParameters.Add("FortniteGame/Content/UI/Foundation/Textures/LoadingScreens/"); }
//LOCRES
Properties.Settings.Default.IconLanguage = comboBox1.SelectedItem.ToString();

View File

@ -325,8 +325,8 @@ namespace FModel
{
String[] linesA = File.ReadAllLines(theDialog.FileName);
for (int i = 0; i < linesA.Length; i++)
if (!linesA[i].StartsWith("../"))
linesA[i] = "../" + linesA[i];
if (linesA[i].StartsWith("../"))
linesA[i] = linesA[i].Substring(3);
IEnumerable<String> onlyB = PakHelper.PakAsTxt.Except(linesA);
IEnumerable<String> removed = linesA.Except(PakHelper.PakAsTxt);
@ -376,7 +376,6 @@ namespace FModel
private void CreatePakList(ToolStripItemClickedEventArgs selectedPak = null, bool loadAllPaKs = false, bool getDiff = false, bool updateMode = false)
{
ThePak.AllpaksDictionary = new Dictionary<string, string>();
ThePak.PaksMountPoint = new Dictionary<string, string>();
ThePak.PaksExtractorDictionary = new Dictionary<string, PakExtractor>();
ThePak.PaksFileArrayDictionary = new Dictionary<PakExtractor, string[]>();
RegisterSettings.updateModeDictionary = new Dictionary<string, string>();
@ -428,7 +427,7 @@ namespace FModel
{
TreeParsePath(treeView1.Nodes, PakHelper.PakAsTxt[i].Replace(PakHelper.PakAsTxt[i].Split('/').Last(), ""));
}
Utilities.ExpandToLevel(treeView1.Nodes, 2);
Utilities.ExpandToLevel(treeView1.Nodes, 1);
treeView1.EndUpdate();
}));
new UpdateMyState(Settings.Default.PAKsPath, "Success").ChangeProcessState();
@ -460,7 +459,7 @@ namespace FModel
{
TreeParsePath(treeView1.Nodes, PakHelper.PakAsTxt[i].Replace(PakHelper.PakAsTxt[i].Split('/').Last(), ""));
}
Utilities.ExpandToLevel(treeView1.Nodes, 2);
Utilities.ExpandToLevel(treeView1.Nodes, 1);
treeView1.EndUpdate();
}));
@ -493,7 +492,7 @@ namespace FModel
string mountPoint = extractor.GetMountPoint();
for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++)
{
CurrentUsedPakLines[ii] = mountPoint.Substring(6) + CurrentUsedPakLines[ii];
CurrentUsedPakLines[ii] = mountPoint.Substring(9) + CurrentUsedPakLines[ii];
sb.Append(CurrentUsedPakLines[ii] + "\n");
}
@ -526,7 +525,7 @@ namespace FModel
string mountPoint = extractor.GetMountPoint();
for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++)
{
CurrentUsedPakLines[ii] = mountPoint.Substring(6) + CurrentUsedPakLines[ii];
CurrentUsedPakLines[ii] = mountPoint.Substring(9) + CurrentUsedPakLines[ii];
sb.Append(CurrentUsedPakLines[ii] + "\n");
}
@ -990,7 +989,14 @@ namespace FModel
}
catch (Exception ex)
{
throw new ArgumentException(ex.Message);
if (Checking.UmWorking)
{
new UpdateMyConsole(ex.Message, Color.Red, true).AppendToConsole();
}
else
{
throw new ArgumentException(ex.Message);
}
}
}
private void CreateItemIcon(JToken theItem, string specialMode = null)

View File

@ -12,29 +12,18 @@ namespace FModel
{
public static PakAsset MyAsset;
/// <summary>
/// Normal pak file: using AllpaksDictionary, it tells you the pak name depending on currentItem. Using this pak name and PaksMountPoint we get the mount point
/// </summary>
/// <param name="currentItem"></param>
/// <returns> the mount point as string, used to create subfolders when extracting or create the tree when loading all paks </returns>
private static string GetMountPointFromDict(string currentItem)
{
return ThePak.PaksMountPoint[ThePak.AllpaksDictionary[currentItem]];
}
/// <summary>
/// just the method to create subfolders using GetMountPointFromDict and write the file from myResults with its byte[] data
/// </summary>
/// <param name="currentItem"></param>
/// <param name="myResults"></param>
/// <param name="data"></param>
/// <returns> the path to this brand new created file </returns>
private static string WriteFile(string currentItem, string myResults, byte[] data)
private static string WriteFile(string myResults, byte[] data)
{
Directory.CreateDirectory(App.DefaultOutputPath + "\\Extracted\\" + GetMountPointFromDict(currentItem) + myResults.Substring(0, myResults.LastIndexOf("/", StringComparison.Ordinal)));
File.WriteAllBytes(App.DefaultOutputPath + "\\Extracted\\" + GetMountPointFromDict(currentItem) + myResults, data);
Directory.CreateDirectory(App.DefaultOutputPath + "\\Extracted\\" + myResults.Substring(0, myResults.LastIndexOf("/", StringComparison.Ordinal)));
File.WriteAllBytes(App.DefaultOutputPath + "\\Extracted\\" + myResults, data);
return App.DefaultOutputPath + "\\Extracted\\" + GetMountPointFromDict(currentItem) + myResults;
return App.DefaultOutputPath + "\\Extracted\\" + myResults;
}
/// <summary>
@ -68,7 +57,7 @@ namespace FModel
uint y = (uint)index;
byte[] b = pakExtractor.GetData(y);
AssetPath = WriteFile(currentItem, results[i], b).Replace("/", "\\");
AssetPath = WriteFile(results[i], b).Replace("/", "\\");
}
return AssetPath;

View File

@ -12,7 +12,6 @@ namespace FModel
static class PakHelper
{
public static string[] PakAsTxt { get; set; }
private static PakExtractor _extractor { get; set; }
private static StringBuilder _sb { get; set; }
/// <summary>
@ -24,39 +23,43 @@ namespace FModel
/// <param name="loadAllPaKs"></param>
public static void RegisterPaKsinDict(ToolStripItemClickedEventArgs theSinglePak = null, bool loadAllPaKs = false)
{
_extractor = null;
_sb = new StringBuilder();
bool bMainKeyWorking = false;
for (int i = 0; i < ThePak.mainPaksList.Count; i++)
{
PakExtractor theExtractor = null;
try
{
if (!string.IsNullOrWhiteSpace(Settings.Default.AESKey))
{
_extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey);
theExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey);
}
else { if (_extractor != null) { _extractor.Dispose(); } break; }
else { if (theExtractor != null) { theExtractor.Dispose(); } break; }
}
catch (Exception)
{
if (_extractor != null) { _extractor.Dispose(); }
if (theExtractor != null) { theExtractor.Dispose(); }
break;
}
string[] CurrentUsedPakLines = _extractor.GetFileList().ToArray();
string[] CurrentUsedPakLines = theExtractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
bMainKeyWorking = true;
ThePak.PaksExtractorDictionary.Add(ThePak.mainPaksList[i].thePak, _extractor);
ThePak.PaksFileArrayDictionary.Add(_extractor, CurrentUsedPakLines);
RegisterInDict(ThePak.mainPaksList[i].thePak, CurrentUsedPakLines, theSinglePak, loadAllPaKs);
string mountPoint = theExtractor.GetMountPoint();
ThePak.PaksExtractorDictionary.Add(ThePak.mainPaksList[i].thePak, theExtractor);
ThePak.PaksFileArrayDictionary.Add(theExtractor, CurrentUsedPakLines); //in RegisterInDict we add the mount point to CurrentUsedPakLines
RegisterInDict(ThePak.mainPaksList[i].thePak, CurrentUsedPakLines, mountPoint, theSinglePak, loadAllPaKs);
}
}
if (bMainKeyWorking) { LoadLocRes.LoadMySelectedLocRes(Settings.Default.IconLanguage); }
for (int i = 0; i < ThePak.dynamicPaksList.Count; i++)
{
PakExtractor theExtractor = null;
string pakName = DynamicKeysManager.AESEntries.Where(x => x.thePak == ThePak.dynamicPaksList[i].thePak).Select(x => x.thePak).FirstOrDefault();
string pakKey = DynamicKeysManager.AESEntries.Where(x => x.thePak == ThePak.dynamicPaksList[i].thePak).Select(x => x.theKey).FirstOrDefault();
@ -64,21 +67,24 @@ namespace FModel
{
try
{
_extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + pakName, pakKey);
theExtractor = 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();
if (_extractor != null) { _extractor.Dispose(); }
if (theExtractor != null) { theExtractor.Dispose(); }
continue;
}
string[] CurrentUsedPakLines = _extractor.GetFileList().ToArray();
string[] CurrentUsedPakLines = theExtractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
ThePak.PaksExtractorDictionary.Add(ThePak.dynamicPaksList[i].thePak, _extractor);
ThePak.PaksFileArrayDictionary.Add(_extractor, CurrentUsedPakLines);
RegisterInDict(ThePak.dynamicPaksList[i].thePak, CurrentUsedPakLines, theSinglePak, loadAllPaKs);
string mountPoint = theExtractor.GetMountPoint();
ThePak.PaksExtractorDictionary.Add(ThePak.dynamicPaksList[i].thePak, theExtractor);
ThePak.PaksFileArrayDictionary.Add(theExtractor, CurrentUsedPakLines); //in RegisterInDict we add the mount point to CurrentUsedPakLines
RegisterInDict(ThePak.dynamicPaksList[i].thePak, CurrentUsedPakLines, mountPoint, theSinglePak, loadAllPaKs);
}
}
}
@ -99,14 +105,11 @@ namespace FModel
/// <param name="thePakLines"></param>
/// <param name="theSinglePak"></param>
/// <param name="weLoadAll"></param>
private static void RegisterInDict(string thePakName, string[] thePakLines, ToolStripItemClickedEventArgs theSinglePak = null, bool weLoadAll = false)
private static void RegisterInDict(string thePakName, string[] thePakLines, string mountPoint, ToolStripItemClickedEventArgs theSinglePak = null, bool weLoadAll = false)
{
string mountPoint = _extractor.GetMountPoint();
ThePak.PaksMountPoint.Add(thePakName, mountPoint.Substring(9));
for (int i = 0; i < thePakLines.Length; i++)
{
thePakLines[i] = mountPoint.Substring(6) + thePakLines[i];
thePakLines[i] = mountPoint.Substring(9) + thePakLines[i];
string CurrentUsedPakFileName = thePakLines[i].Substring(thePakLines[i].LastIndexOf("/", StringComparison.Ordinal) + 1);
if (CurrentUsedPakFileName.Contains(".uasset") || CurrentUsedPakFileName.Contains(".uexp") || CurrentUsedPakFileName.Contains(".ubulk"))

View File

@ -52,7 +52,6 @@ namespace FModel
public static Dictionary<string, string> AllpaksDictionary { get; set; }
public static Dictionary<string, PakExtractor> PaksExtractorDictionary { get; set; }
public static Dictionary<PakExtractor, string[]> PaksFileArrayDictionary { get; set; }
public static Dictionary<string, string> PaksMountPoint { get; set; }
/// <summary>
/// read the GUID of a the param, it's basically just reading some bytes at the end of a pak file, but it's useful to tell if the pak is dynamically encrypted