fixed dynamic keys not being deleted if they doesn't exist in the api

This commit is contained in:
Asval 2019-07-16 01:39:44 +02:00
parent f8ab09dcd6
commit c103b461e8
15 changed files with 236 additions and 224 deletions

View File

@ -142,22 +142,23 @@
<DependentUpon>TweetForm.cs</DependentUpon>
</Compile>
<Compile Include="Methods\AESManager\DynamicKeysManager.cs" />
<Compile Include="Methods\DynamicKeys\AddToUI.cs" />
<Compile Include="Methods\DynamicKeys\Keychain.cs" />
<Compile Include="Methods\ChallengeGenerator\BundleDesign.cs" />
<Compile Include="Methods\ChallengeGenerator\BundleInfos.cs" />
<Compile Include="Methods\ChallengeGenerator\DrawingRewards.cs" />
<Compile Include="Methods\AESManager\DynamicKeys\AddToUI.cs" />
<Compile Include="Methods\AESManager\DynamicKeys\Keychain.cs" />
<Compile Include="Methods\IconGenerator\ChallengeGenerator\BundleDesign.cs" />
<Compile Include="Methods\IconGenerator\ChallengeGenerator\BundleInfos.cs" />
<Compile Include="Methods\IconGenerator\ChallengeGenerator\DrawingRewards.cs" />
<Compile Include="Methods\DLLImport.cs" />
<Compile Include="Methods\IconGenerator\DrawText.cs" />
<Compile Include="Methods\IconGenerator\ItemGenerator\DrawText.cs" />
<Compile Include="Methods\IconGenerator\Translations\LoadLocRes.cs" />
<Compile Include="Methods\IconGenerator\Translations\SearchResource.cs" />
<Compile Include="Methods\ImagesMerger\ImagesMerger.cs" />
<Compile Include="Methods\PakHelper\PakHelper.cs" />
<Compile Include="Methods\Serializer\AssetReader.cs" />
<Compile Include="Methods\Serializer\LocRes\LocResSerializer.cs" />
<Compile Include="Methods\Scintilla\MyScintilla.cs" />
<Compile Include="Methods\Utilities\FontUtilities.cs" />
<Compile Include="Methods\IconGenerator\ItemIcon.cs" />
<Compile Include="Methods\IconGenerator\Rarity.cs" />
<Compile Include="Methods\IconGenerator\ItemGenerator\ItemIcon.cs" />
<Compile Include="Methods\IconGenerator\ItemGenerator\Rarity.cs" />
<Compile Include="Forms\About.cs">
<SubType>Form</SubType>
</Compile>

View File

@ -34,35 +34,35 @@ namespace FModel.Forms
FilesToSearch = false;
_myInfosDict = new Dictionary<string, string>();
if (MainWindow.PakAsTxt != null)
if (PakHelper.PakAsTxt != null)
{
for (int i = 0; i < MainWindow.PakAsTxt.Length; i++)
for (int i = 0; i < PakHelper.PakAsTxt.Length; i++)
{
if (MainWindow.PakAsTxt[i].Contains(".uasset") || MainWindow.PakAsTxt[i].Contains(".uexp") || MainWindow.PakAsTxt[i].Contains(".ubulk"))
if (PakHelper.PakAsTxt[i].Contains(".uasset") || PakHelper.PakAsTxt[i].Contains(".uexp") || PakHelper.PakAsTxt[i].Contains(".ubulk"))
{
if (!_myInfosDict.ContainsKey(MainWindow.PakAsTxt[i].Substring(0, MainWindow.PakAsTxt[i].LastIndexOf(".", StringComparison.Ordinal))))
if (!_myInfosDict.ContainsKey(PakHelper.PakAsTxt[i].Substring(0, PakHelper.PakAsTxt[i].LastIndexOf(".", StringComparison.Ordinal))))
{
_myInfosDict.Add(MainWindow.PakAsTxt[i].Substring(0, MainWindow.PakAsTxt[i].LastIndexOf(".", StringComparison.Ordinal)), ThePak.AllpaksDictionary[Path.GetFileNameWithoutExtension(MainWindow.PakAsTxt[i])]);
_myInfosDict.Add(PakHelper.PakAsTxt[i].Substring(0, PakHelper.PakAsTxt[i].LastIndexOf(".", StringComparison.Ordinal)), ThePak.AllpaksDictionary[Path.GetFileNameWithoutExtension(PakHelper.PakAsTxt[i])]);
_fileName = MainWindow.PakAsTxt[i].Substring(0, MainWindow.PakAsTxt[i].LastIndexOf(".", StringComparison.Ordinal));
_fileName = PakHelper.PakAsTxt[i].Substring(0, PakHelper.PakAsTxt[i].LastIndexOf(".", StringComparison.Ordinal));
_myInfos.Add(new FileInfo
{
FileName = _fileName,
PakFile = ThePak.AllpaksDictionary[Path.GetFileNameWithoutExtension(MainWindow.PakAsTxt[i])],
PakFile = ThePak.AllpaksDictionary[Path.GetFileNameWithoutExtension(PakHelper.PakAsTxt[i])],
});
}
}
else
{
if (!_myInfosDict.ContainsKey(MainWindow.PakAsTxt[i]))
if (!_myInfosDict.ContainsKey(PakHelper.PakAsTxt[i]))
{
_myInfosDict.Add(MainWindow.PakAsTxt[i], ThePak.AllpaksDictionary[Path.GetFileName(MainWindow.PakAsTxt[i])]);
_myInfosDict.Add(PakHelper.PakAsTxt[i], ThePak.AllpaksDictionary[Path.GetFileName(PakHelper.PakAsTxt[i])]);
_fileName = MainWindow.PakAsTxt[i];
_fileName = PakHelper.PakAsTxt[i];
_myInfos.Add(new FileInfo
{
FileName = _fileName,
PakFile = ThePak.AllpaksDictionary[Path.GetFileName(MainWindow.PakAsTxt[i])],
PakFile = ThePak.AllpaksDictionary[Path.GetFileName(PakHelper.PakAsTxt[i])],
});
}
}
@ -121,7 +121,7 @@ namespace FModel.Forms
listView1.VirtualListSize = 0;
listView1.Invalidate();
if (MainWindow.PakAsTxt != null)
if (PakHelper.PakAsTxt != null)
{
if (!string.IsNullOrEmpty(textBox1.Text) && textBox1.Text.Length > 2)
{

View File

@ -29,7 +29,6 @@ namespace FModel
{
#region to refactor
private static Stopwatch StopWatch { get; set; }
public static string[] PakAsTxt { get; set; }
private static Dictionary<string, string> _diffToExtract { get; set; }
private static List<string> _itemsToDisplay { get; set; }
public static string[] SelectedItemsArray { get; set; }
@ -274,139 +273,6 @@ namespace FModel
#region PAKLIST & FILL TREE
//METHODS
private void RegisterPaKsinDict(ToolStripItemClickedEventArgs theSinglePak = null, bool loadAllPaKs = false)
{
PakExtractor extractor = null;
StringBuilder sb = new StringBuilder();
bool bMainKeyWorking = false;
for (int i = 0; i < ThePak.mainPaksList.Count; i++)
{
try
{
if (!string.IsNullOrWhiteSpace(Settings.Default.AESKey))
{
extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey);
}
else { extractor.Dispose(); break; }
}
catch (Exception)
{
extractor.Dispose();
break;
}
string[] CurrentUsedPakLines = extractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
bMainKeyWorking = true;
string mountPoint = extractor.GetMountPoint();
ThePak.PaksMountPoint.Add(ThePak.mainPaksList[i].thePak, mountPoint.Substring(9));
for (int ii = 0; ii < CurrentUsedPakLines.Length; 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"))
{
if (!ThePak.AllpaksDictionary.ContainsKey(CurrentUsedPakFileName.Substring(0, CurrentUsedPakFileName.LastIndexOf(".", StringComparison.Ordinal))))
{
ThePak.AllpaksDictionary.Add(CurrentUsedPakFileName.Substring(0, CurrentUsedPakFileName.LastIndexOf(".", StringComparison.Ordinal)), ThePak.mainPaksList[i].thePak);
}
}
else
{
if (!ThePak.AllpaksDictionary.ContainsKey(CurrentUsedPakFileName))
{
ThePak.AllpaksDictionary.Add(CurrentUsedPakFileName, ThePak.mainPaksList[i].thePak);
}
}
if (loadAllPaKs)
{
sb.Append(CurrentUsedPakLines[ii] + "\n");
}
}
if (loadAllPaKs) { new UpdateMyState(".PAK mount point: " + mountPoint.Substring(9), "Waiting").ChangeProcessState(); }
if (theSinglePak != null && ThePak.mainPaksList[i].thePak == theSinglePak.ClickedItem.Text) { PakAsTxt = CurrentUsedPakLines; }
}
extractor.Dispose();
}
if (bMainKeyWorking) { LoadLocRes.LoadMySelectedLocRes(Settings.Default.IconLanguage); }
for (int i = 0; i < ThePak.dynamicPaksList.Count; i++)
{
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();
if (!string.IsNullOrEmpty(pakName) && !string.IsNullOrEmpty(pakKey))
{
try
{
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();
extractor.Dispose();
continue;
}
string[] CurrentUsedPakLines = extractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
string mountPoint = extractor.GetMountPoint();
ThePak.PaksMountPoint.Add(ThePak.dynamicPaksList[i].thePak, mountPoint.Substring(9));
for (int ii = 0; ii < CurrentUsedPakLines.Length; 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"))
{
if (!ThePak.AllpaksDictionary.ContainsKey(CurrentUsedPakFileName.Substring(0, CurrentUsedPakFileName.LastIndexOf(".", StringComparison.Ordinal))))
{
ThePak.AllpaksDictionary.Add(CurrentUsedPakFileName.Substring(0, CurrentUsedPakFileName.LastIndexOf(".", StringComparison.Ordinal)), ThePak.dynamicPaksList[i].thePak);
}
}
else
{
if (!ThePak.AllpaksDictionary.ContainsKey(CurrentUsedPakFileName))
{
ThePak.AllpaksDictionary.Add(CurrentUsedPakFileName, ThePak.dynamicPaksList[i].thePak);
}
}
if (loadAllPaKs)
{
sb.Append(CurrentUsedPakLines[ii] + "\n");
}
}
if (loadAllPaKs) { new UpdateMyState(".PAK mount point: " + mountPoint.Substring(9), "Waiting").ChangeProcessState(); }
if (theSinglePak != null && ThePak.dynamicPaksList[i].thePak == theSinglePak.ClickedItem.Text) { PakAsTxt = CurrentUsedPakLines; }
}
extractor.Dispose();
}
}
if (loadAllPaKs)
{
File.WriteAllText(App.DefaultOutputPath + "\\FortnitePAKs.txt", sb.ToString()); //File will always exist
}
new UpdateMyState("Building tree, please wait...", "Loading").ChangeProcessState();
}
/// <summary>
/// https://social.msdn.microsoft.com/Forums/en-US/c75c1804-6933-40ba-b17a-0e36ae8bcbb5/how-to-create-a-tree-view-with-full-paths?forum=csharplanguage
/// </summary>
/// <param name="nodeList"></param>
/// <param name="path"></param>
private void TreeParsePath(TreeNodeCollection nodeList, string path)
{
TreeNode node;
@ -447,7 +313,7 @@ namespace FModel
}
private void ComparePaKs()
{
PakAsTxt = File.ReadAllLines(App.DefaultOutputPath + "\\FortnitePAKs.txt");
PakHelper.PakAsTxt = File.ReadAllLines(App.DefaultOutputPath + "\\FortnitePAKs.txt");
File.Delete(App.DefaultOutputPath + "\\FortnitePAKs.txt");
//ASK DIFFERENCE FILE AND COMPARE
@ -465,8 +331,8 @@ namespace FModel
if (!linesA[i].StartsWith("../"))
linesA[i] = "../" + linesA[i];
IEnumerable<String> onlyB = PakAsTxt.Except(linesA);
IEnumerable<String> removed = linesA.Except(PakAsTxt);
IEnumerable<String> onlyB = PakHelper.PakAsTxt.Except(linesA);
IEnumerable<String> removed = linesA.Except(PakHelper.PakAsTxt);
File.WriteAllLines(App.DefaultOutputPath + "\\Result.txt", onlyB);
File.WriteAllLines(App.DefaultOutputPath + "\\Removed.txt", removed);
@ -505,7 +371,7 @@ namespace FModel
if (File.Exists(App.DefaultOutputPath + "\\Result.txt"))
{
PakAsTxt = File.ReadAllLines(App.DefaultOutputPath + "\\Result.txt");
PakHelper.PakAsTxt = File.ReadAllLines(App.DefaultOutputPath + "\\Result.txt");
File.Delete(App.DefaultOutputPath + "\\Result.txt");
Checking.DifferenceFileExists = true;
}
@ -515,23 +381,23 @@ namespace FModel
ThePak.AllpaksDictionary = new Dictionary<string, string>();
_diffToExtract = new Dictionary<string, string>();
ThePak.PaksMountPoint = new Dictionary<string, string>();
PakAsTxt = null;
PakHelper.PakAsTxt = null;
if (selectedPak != null)
{
new UpdateMyState(Settings.Default.PAKsPath + "\\" + selectedPak.ClickedItem.Text, "Loading").ChangeProcessState();
//ADD TO DICTIONNARY
RegisterPaKsinDict(selectedPak);
PakHelper.RegisterPaKsinDict(selectedPak);
if (PakAsTxt != null)
if (PakHelper.PakAsTxt != null)
{
Invoke(new Action(() =>
{
treeView1.BeginUpdate();
for (int i = 0; i < PakAsTxt.Length; i++)
for (int i = 0; i < PakHelper.PakAsTxt.Length; i++)
{
TreeParsePath(treeView1.Nodes, PakAsTxt[i].Replace(PakAsTxt[i].Split('/').Last(), ""));
TreeParsePath(treeView1.Nodes, PakHelper.PakAsTxt[i].Replace(PakHelper.PakAsTxt[i].Split('/').Last(), ""));
}
Utilities.ExpandToLevel(treeView1.Nodes, 2);
treeView1.EndUpdate();
@ -544,7 +410,7 @@ namespace FModel
if (loadAllPaKs)
{
//ADD TO DICTIONNARY
RegisterPaKsinDict(null, true);
PakHelper.RegisterPaKsinDict(null, true);
if (new System.IO.FileInfo(App.DefaultOutputPath + "\\FortnitePAKs.txt").Length <= 0) //File will always exist so we check the file size instead
{
@ -553,15 +419,15 @@ namespace FModel
}
else
{
PakAsTxt = File.ReadAllLines(App.DefaultOutputPath + "\\FortnitePAKs.txt");
PakHelper.PakAsTxt = File.ReadAllLines(App.DefaultOutputPath + "\\FortnitePAKs.txt");
File.Delete(App.DefaultOutputPath + "\\FortnitePAKs.txt");
Invoke(new Action(() =>
{
treeView1.BeginUpdate();
for (int i = 0; i < PakAsTxt.Length; i++)
for (int i = 0; i < PakHelper.PakAsTxt.Length; i++)
{
TreeParsePath(treeView1.Nodes, PakAsTxt[i].Replace(PakAsTxt[i].Split('/').Last(), ""));
TreeParsePath(treeView1.Nodes, PakHelper.PakAsTxt[i].Replace(PakHelper.PakAsTxt[i].Split('/').Last(), ""));
}
Utilities.ExpandToLevel(treeView1.Nodes, 2);
treeView1.EndUpdate();
@ -572,7 +438,7 @@ namespace FModel
if (getDiff)
{
//ADD TO DICTIONNARY
RegisterPaKsinDict(null, true);
PakHelper.RegisterPaKsinDict(null, true);
if (new System.IO.FileInfo(App.DefaultOutputPath + "\\FortnitePAKs.txt").Length <= 0)
{
@ -584,16 +450,16 @@ namespace FModel
ComparePaKs();
if (updateMode && Checking.DifferenceFileExists)
{
UmFilter(PakAsTxt, _diffToExtract);
UmFilter(PakHelper.PakAsTxt, _diffToExtract);
Checking.UmWorking = true;
}
Invoke(new Action(() =>
{
treeView1.BeginUpdate();
for (int i = 0; i < PakAsTxt.Length; i++)
for (int i = 0; i < PakHelper.PakAsTxt.Length; i++)
{
TreeParsePath(treeView1.Nodes, PakAsTxt[i].Replace(PakAsTxt[i].Split('/').Last(), ""));
TreeParsePath(treeView1.Nodes, PakHelper.PakAsTxt[i].Replace(PakHelper.PakAsTxt[i].Split('/').Last(), ""));
}
Utilities.ExpandToLevel(treeView1.Nodes, 2);
treeView1.EndUpdate();
@ -900,7 +766,7 @@ namespace FModel
return;
}
var dirfiles = PakAsTxt.Where(x => x.StartsWith(full) && !x.Replace(full, "").Contains("/"));
var dirfiles = PakHelper.PakAsTxt.Where(x => x.StartsWith(full) && !x.Replace(full, "").Contains("/"));
var enumerable = dirfiles as string[] ?? dirfiles.ToArray();
if (!enumerable.Any())
{
@ -1598,7 +1464,7 @@ namespace FModel
return;
}
var dirfiles = PakAsTxt.Where(x => x.StartsWith(full) && !x.Replace(full, "").Contains("/"));
var dirfiles = PakHelper.PakAsTxt.Where(x => x.StartsWith(full) && !x.Replace(full, "").Contains("/"));
var enumerable = dirfiles as string[] ?? dirfiles.ToArray();
if (!enumerable.Any())
{
@ -1775,15 +1641,15 @@ namespace FModel
{
_diffToExtract = new Dictionary<string, string>();
for (int i = 0; i < PakAsTxt.Length; i++)
for (int i = 0; i < PakHelper.PakAsTxt.Length; i++)
{
if (PakAsTxt[i].Contains(Checking.currentSelectedNodePartialPath.Replace("\\", "/")))
if (PakHelper.PakAsTxt[i].Contains(Checking.currentSelectedNodePartialPath.Replace("\\", "/")))
{
string filename = Path.GetFileName(PakAsTxt[i]);
string filename = Path.GetFileName(PakHelper.PakAsTxt[i]);
if (filename.Contains(".uasset") || filename.Contains(".uexp") || filename.Contains(".ubulk"))
{
if (!_diffToExtract.ContainsKey(filename.Substring(0, filename.LastIndexOf(".", StringComparison.Ordinal))))
_diffToExtract.Add(filename.Substring(0, filename.LastIndexOf(".", StringComparison.Ordinal)), PakAsTxt[i]);
_diffToExtract.Add(filename.Substring(0, filename.LastIndexOf(".", StringComparison.Ordinal)), PakHelper.PakAsTxt[i]);
}
}
}

View File

@ -1,5 +1,4 @@
using FModel.Properties;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Drawing;
@ -13,8 +12,8 @@ namespace FModel
private static List<AESEntry> _oldKeysList = null;
/// <summary>
/// ask the keychain api for all dynamic keys and their guids
/// if an API guid match a local guid, the key is saved and the pak can be opened with this key
/// ask the keychain api for all dynamic keys
/// if an API pak name match a local pak name, the key is saved and the pak can be opened with this key
/// </summary>
public static void checkAndAddDynamicKeys()
{
@ -29,44 +28,55 @@ namespace FModel
_oldKeysList = DynamicKeysManager.AESEntries;
}
JObject myObject = JObject.Parse(GetKeysFromKeychain());
if (myObject != null)
string data = GetKeysFromKeychain();
if (!string.IsNullOrEmpty(data))
{
DynamicKeysManager.AESEntries = new List<AESEntry>();
foreach (PaksEntry item in ThePak.dynamicPaksList)
JObject myObject = JObject.Parse(data);
if (myObject != null)
{
if (myObject.ToString().Contains(item.thePak))
DynamicKeysManager.AESEntries = new List<AESEntry>();
foreach (PaksEntry item in ThePak.dynamicPaksList)
{
JToken token = myObject.FindTokens(item.thePak).FirstOrDefault();
bool pakAlreadyExist = DynamicKeysManager.AESEntries.Where(i => i.thePak == item.thePak).Any();
if (!pakAlreadyExist)
if (myObject.ToString().Contains(item.thePak))
{
JToken token = myObject.FindTokens(item.thePak).FirstOrDefault();
DynamicKeysManager.serialize(token.ToString().ToUpper().Substring(2), item.thePak);
displayNewPaks(item.thePak);
}
}
new UpdateMyConsole("", Color.Green, true).AppendToConsole();
}
new UpdateMyConsole("", Color.Green, true).AppendToConsole();
}
DynamicKeysManager.deserialize();
}
/// <summary>
/// just set the array to be the keys from the api
/// return the dynamic keys part from Ben API
/// </summary>
/// <returns></returns>
private static string GetKeysFromKeychain()
{
if (DLLImport.IsInternetAvailable())
try
{
JToken dynamicPaks = JObject.Parse(Keychain.GetEndpoint("http://benbotfn.tk:8080/api/aes")).FindTokens("additionalKeys").FirstOrDefault();
return JToken.Parse(dynamicPaks.ToString()).ToString().TrimStart('[').TrimEnd(']');
if (DLLImport.IsInternetAvailable())
{
JToken dynamicPaks = JObject.Parse(Keychain.GetEndpoint("http://benbotfn.tk:8080/api/aes")).FindTokens("additionalKeys").FirstOrDefault();
return JToken.Parse(dynamicPaks.ToString()).ToString().TrimStart('[').TrimEnd(']');
}
else
{
new UpdateMyConsole("Your internet connection is currently unavailable, can't check for dynamic keys at the moment.", Color.Red, true).AppendToConsole();
return null;
}
}
catch (Exception)
{
new UpdateMyConsole("Error while checking for dynamic keys", Color.Red, true).AppendToConsole();
return null;
}
else { return null; }
}
/// <summary>

View File

@ -256,16 +256,20 @@ namespace FModel
string text = SearchResource.getTextByKey(theItem.DisplayName.Key, theItem.DisplayName.SourceString);
if (Settings.Default.rarityNew)
{
Font goodFont = FontUtilities.FindFont(myGraphic, text, new Rectangle(5, 405, 512, 55).Size, new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[0], 35));
myGraphic.DrawString(text, goodFont, new SolidBrush(Color.White), new Point(522, 405), FontUtilities.rightString);
}
else
{
Font goodFont = FontUtilities.FindFont(myGraphic, text, new Rectangle(5, 395, 512, 49).Size, new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[0], 35));
myGraphic.DrawString(text, goodFont, new SolidBrush(Color.White), new Point(522 / 2, 395), FontUtilities.centeredString);
}
Font goodFont = FontUtilities.FindFont(
myGraphic,
text,
Settings.Default.rarityNew ? new Rectangle(5, 405, 512, 55).Size : new Rectangle(5, 395, 512, 49).Size,
new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[0], 35)
);
myGraphic.DrawString(
text,
goodFont,
new SolidBrush(Color.White),
Settings.Default.rarityNew ? new Point(522, 405) : new Point(522 / 2, 395),
Settings.Default.rarityNew ? FontUtilities.rightString : FontUtilities.centeredString
);
}
}
@ -290,14 +294,13 @@ namespace FModel
}
}
if (Settings.Default.rarityNew)
{
myGraphic.DrawString(text, new Font("Arial", 9), new SolidBrush(Color.White), new RectangleF(5, 455, 512, 42), FontUtilities.rightString);
}
else
{
myGraphic.DrawString(text, new Font("Arial", 10), new SolidBrush(Color.White), new RectangleF(5, 441, 512, 49), FontUtilities.centeredStringLine);
}
myGraphic.DrawString(
text,
new Font("Arial", Settings.Default.rarityNew ? 9 : 10),
new SolidBrush(Color.White),
new RectangleF(5, Settings.Default.rarityNew ? 455 : 441, 512, Settings.Default.rarityNew ? 42 : 49),
Settings.Default.rarityNew ? FontUtilities.rightString : FontUtilities.centeredStringLine
);
}
}

View File

@ -303,12 +303,12 @@ namespace FModel
/// <summary>
/// Draw a watermark on an Item Icon
/// Keep in mind the update mode use different settings than the normal mode, hence there's 2 if statement
/// Keep in mind the update mode use different settings than the normal mode, hence there's 2 if statements
/// </summary>
/// <param name="toDrawOn"></param>
public static void DrawWatermark(Graphics toDrawOn)
{
if (Checking.UmWorking == false && (Settings.Default.isWatermark && !string.IsNullOrEmpty(Settings.Default.wFilename)))
if (!Checking.UmWorking && (Settings.Default.isWatermark && !string.IsNullOrEmpty(Settings.Default.wFilename)))
{
Image watermark = Image.FromFile(Settings.Default.wFilename);
if (watermark != null)

View File

@ -62,7 +62,7 @@ namespace FModel
{
if (specialMode == "ammo")
{
return Resources.C512;
return Settings.Default.rarityNew ? Resources.C512 : Resources.C512v1;
}
else
{

View File

@ -58,8 +58,7 @@ namespace FModel
}
/// <summary>
/// 1. if loading a dynamic pak we have to switch between keys because the translation file is the main paks hence string oldKey is there
/// 2. smh if loading a dynamic pak, the guid isn't reset when registering, the temp solution is to fake the guid
///
/// </summary>
/// <param name="selectedLanguage"></param>
/// <returns></returns>

View File

@ -18,10 +18,8 @@ namespace FModel
/// <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
/// Dynamic pak file: It's made so we already know the name of the pak, so we just use PaksMountPoint to get the mount point
/// </summary>
/// <param name="currentItem"></param>
/// <param name="DynamicPak"></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)
{

View File

@ -0,0 +1,135 @@
using csharp_wick;
using FModel.Properties;
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FModel
{
static class PakHelper
{
public static string[] PakAsTxt { get; set; }
private static PakExtractor _extractor { get; set; }
private static StringBuilder _sb { get; set; }
/// <summary>
/// for each main paks we generate a file list
/// if the main key used to generate the file list for each pak is working, we also load the localization file to get the translated version of all strings
/// for the dynamic paks we check if the key exist in the AES Manager, if so, we do the same steps as a main pak
/// </summary>
/// <param name="theSinglePak"></param>
/// <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++)
{
try
{
if (!string.IsNullOrWhiteSpace(Settings.Default.AESKey))
{
_extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey);
}
else { _extractor.Dispose(); break; }
}
catch (Exception)
{
_extractor.Dispose();
break;
}
string[] CurrentUsedPakLines = _extractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
bMainKeyWorking = true;
RegisterInDict(ThePak.mainPaksList[i].thePak, CurrentUsedPakLines, theSinglePak, loadAllPaKs);
}
_extractor.Dispose();
}
if (bMainKeyWorking) { LoadLocRes.LoadMySelectedLocRes(Settings.Default.IconLanguage); }
for (int i = 0; i < ThePak.dynamicPaksList.Count; i++)
{
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();
if (!string.IsNullOrEmpty(pakName) && !string.IsNullOrEmpty(pakKey))
{
try
{
_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();
_extractor.Dispose();
continue;
}
string[] CurrentUsedPakLines = _extractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
RegisterInDict(ThePak.dynamicPaksList[i].thePak, CurrentUsedPakLines, theSinglePak, loadAllPaKs);
}
_extractor.Dispose();
}
}
if (loadAllPaKs)
{
File.WriteAllText(App.DefaultOutputPath + "\\FortnitePAKs.txt", _sb.ToString()); //File will always exist
}
new UpdateMyState("Building tree, please wait...", "Loading").ChangeProcessState();
}
/// <summary>
/// 1. we get the pak mount point and add it to the PaksMountPoint dictionary
/// 2. for each file in a pak, we add the file name as the key and its pak name as the value (used later by SearchFiles form)
/// </summary>
/// <param name="thePakName"></param>
/// <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)
{
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];
string CurrentUsedPakFileName = thePakLines[i].Substring(thePakLines[i].LastIndexOf("/", StringComparison.Ordinal) + 1);
if (CurrentUsedPakFileName.Contains(".uasset") || CurrentUsedPakFileName.Contains(".uexp") || CurrentUsedPakFileName.Contains(".ubulk"))
{
if (!ThePak.AllpaksDictionary.ContainsKey(CurrentUsedPakFileName.Substring(0, CurrentUsedPakFileName.LastIndexOf(".", StringComparison.Ordinal))))
{
ThePak.AllpaksDictionary.Add(CurrentUsedPakFileName.Substring(0, CurrentUsedPakFileName.LastIndexOf(".", StringComparison.Ordinal)), thePakName);
}
}
else
{
if (!ThePak.AllpaksDictionary.ContainsKey(CurrentUsedPakFileName))
{
ThePak.AllpaksDictionary.Add(CurrentUsedPakFileName, thePakName);
}
}
if (weLoadAll)
{
_sb.Append(thePakLines[i] + "\n");
}
}
if (weLoadAll) { new UpdateMyState(".PAK mount point: " + mountPoint.Substring(9), "Waiting").ChangeProcessState(); }
if (theSinglePak != null && thePakName == theSinglePak.ClickedItem.Text) { PakAsTxt = thePakLines; }
}
}
}

View File

@ -14,7 +14,7 @@
[![](https://img.shields.io/badge/Release-2.4.2.1-orange.svg?logo=github)](https://github.com/iAmAsval/FModel/releases/latest)
### How To Use
**1.** Once you start the executable, you'll be asked to set your path to your Fortnite .PAK files. Meanwhile a `FModel` subfolder will be created in your `Documents` folder.
![](https://i.imgur.com/OvjYMyX.gif)
![](https://i.imgur.com/9AUVUVU.gif)
**2.** Restart the executable, go to the AES Manager and add your AES Keys, click **Load** and select your .PAK file
- It will parse all Assets contained in the selected .PAK file with their respective path
@ -40,7 +40,7 @@
**3.** Click `Load Difference`
![](https://i.imgur.com/khTcpJG.gif)
![](https://i.imgur.com/36icHam.gif)
### Update Mode
**1.** Enable Difference Mode, then Update Mode