finished logging tasks

This commit is contained in:
Asval
2019-12-01 20:00:58 +01:00
parent 44a246ce04
commit 05e7b0a6da
22 changed files with 207 additions and 20 deletions

View File

@@ -49,6 +49,8 @@ namespace FModel
DebugHelper.WriteLine("User settings copied from previous version");
}
DebugHelper.WriteUserSettings();
await Task.Run(() =>
{
FoldersUtility.LoadFolders();
@@ -68,6 +70,7 @@ namespace FModel
#region BUTTON EVENTS
private void Button_AESManager_Click(object sender, RoutedEventArgs e)
{
DebugHelper.WriteLine("FWindow: AES Manager");
if (!FormsUtility.IsWindowOpen<Window>("AES Manager"))
{
new AESManager().Show();
@@ -78,6 +81,7 @@ namespace FModel
{
if (ImageBox_Main.Source != null)
{
DebugHelper.WriteLine("FWindow: Opening image of " + FWindow.FCurrentAsset);
if (!FormsUtility.IsWindowOpen<Window>(FWindow.FCurrentAsset))
{
Window win = new Window();
@@ -112,6 +116,7 @@ namespace FModel
{
if (TasksUtility.CancellableTaskTokenSource != null)
{
DebugHelper.WriteLine("Thread canceled by user");
TasksUtility.CancellableTaskTokenSource.Cancel();
if (TasksUtility.CancellableTaskTokenSource.IsCancellationRequested)
{
@@ -124,7 +129,6 @@ namespace FModel
{
if (ListBox_Main.SelectedIndex >= 0)
{
//FWindow.FCurrentAsset = ListBox_Main.SelectedItem.ToString(); <-- already in the 'Load' loop
await AssetsLoader.LoadSelectedAsset();
}
}
@@ -178,6 +182,7 @@ namespace FModel
}
private void MI_Search_Click(object sender, RoutedEventArgs e)
{
DebugHelper.WriteLine("FWindow: Search Files");
if (!FormsUtility.IsWindowOpen<Window>("Search"))
{
new FModel_SearchFiles().Show();
@@ -186,6 +191,7 @@ namespace FModel
}
private void MI_HexViewer_Click(object sender, RoutedEventArgs e)
{
DebugHelper.WriteLine("FWindow: Hex Viewer");
if (!FormsUtility.IsWindowOpen<Window>("Hex Viewer"))
{
new HexViewer().Show();
@@ -217,6 +223,7 @@ namespace FModel
}
private void MI_MergeImages_Click(object sender, RoutedEventArgs e)
{
DebugHelper.WriteLine("FWindow: Images Merger");
if (!FormsUtility.IsWindowOpen<Window>("Images Merger"))
{
new FModel_ImagesMerger().Show();
@@ -225,6 +232,7 @@ namespace FModel
}
private void MI_About_Click(object sender, RoutedEventArgs e)
{
DebugHelper.WriteLine("FWindow: About");
if (!FormsUtility.IsWindowOpen<Window>("About"))
{
new FModel_About().Show();
@@ -308,7 +316,6 @@ namespace FModel
{
if (!AssetsLoader.isRunning && ListBox_Main.SelectedIndex >= 0)
{
//FWindow.FCurrentAsset = ListBox_Main.SelectedItem.ToString(); <-- already in the 'Load' loop
await AssetsLoader.LoadSelectedAsset();
}
}
@@ -320,7 +327,6 @@ namespace FModel
{
if (ListBox_Main.SelectedIndex >= 0)
{
//FWindow.FCurrentAsset = ListBox_Main.SelectedItem.ToString(); <-- already in the 'Load' loop
await AssetsLoader.LoadSelectedAsset();
}
}

View File

@@ -69,15 +69,18 @@ namespace FModel.Forms
PakTextBox.Foreground = new SolidColorBrush(Color.FromRgb(239, 239, 239));
PakTextBox.Name = $"TxtBox_{Regex.Match(Path.GetFileNameWithoutExtension(Pak.ThePAKPath), @"\d+").Value}";
string PAKKeyFromXML = string.Empty;
if (AESEntries.AESEntriesList != null && AESEntries.AESEntriesList.Any())
{
string PAKKeyFromXML = AESEntries.AESEntriesList.Where(x => string.Equals(x.ThePAKName, Path.GetFileNameWithoutExtension(Pak.ThePAKPath))).Select(x => x.ThePAKKey).FirstOrDefault();
PAKKeyFromXML = AESEntries.AESEntriesList.Where(x => string.Equals(x.ThePAKName, Path.GetFileNameWithoutExtension(Pak.ThePAKPath))).Select(x => x.ThePAKKey).FirstOrDefault();
PakTextBox.Text = $"0x{PAKKeyFromXML}";
}
yPos += 28;
Grid_DynamicKeys.Children.Add(PakLabel);
Grid_DynamicKeys.Children.Add(PakTextBox);
DebugHelper.WriteLine($"AESManager GET: {Pak.ThePAKPath} with key: {PAKKeyFromXML}");
}
}
}
@@ -85,6 +88,7 @@ namespace FModel.Forms
private void GetUserSettings()
{
MAesTextBox.Text = $"0x{FProp.Default.FPak_MainAES}";
DebugHelper.WriteLine($"AESManager GET: Main PAKs with key: {FProp.Default.FPak_MainAES}");
}
private void SetUserSettings()
@@ -99,6 +103,7 @@ namespace FModel.Forms
else { FProp.Default.FPak_MainAES = Regex.Replace(MAesTextBox.Text.ToUpper(), @"\s+", string.Empty); }
}
else { FProp.Default.FPak_MainAES = string.Empty; }
DebugHelper.WriteLine($"AESManager SET: Main PAKs with key: {MAesTextBox.Text}");
//DYNAMIC AESs
AESEntries.AESEntriesList = new List<AESInfosEntry>();
@@ -116,6 +121,7 @@ namespace FModel.Forms
else { KeysManager.Serialize(Path.GetFileNameWithoutExtension(Pak.ThePAKPath), Regex.Replace(PakTextBox.Text.ToUpper(), @"\s+", string.Empty)); }
}
else { KeysManager.Serialize(Path.GetFileNameWithoutExtension(Pak.ThePAKPath), string.Empty); }
DebugHelper.WriteLine($"AESManager SET: {Pak.ThePAKPath} with key: {PakTextBox.Text}");
}
Directory.CreateDirectory(Path.GetDirectoryName(AESManager_PATH));
@@ -127,6 +133,7 @@ namespace FModel.Forms
//SAVE
FProp.Default.Save();
DebugHelper.WriteLine($"AESManager: Saved");
}

View File

@@ -41,6 +41,8 @@ namespace FModel.Forms
private async Task UpdateMergerPreview()
{
DebugHelper.WriteLine("Merger: Merging images of the listbox");
AddImages_Button.IsEnabled = false;
RemoveImage_Button.IsEnabled = false;
ClearImages_Button.IsEnabled = false;
@@ -134,6 +136,8 @@ namespace FModel.Forms
ImagesPerRow_Slider.IsEnabled = true;
OpenImage_Button.IsEnabled = true;
SaveImage_Button.IsEnabled = true;
DebugHelper.WriteLine("Merger: Images of the listbox merged successfully");
}
private async void AddImages_Button_Click(object sender, RoutedEventArgs e)
@@ -161,6 +165,7 @@ namespace FModel.Forms
itm.Content = Path.GetFileNameWithoutExtension(file);
ImagesListBox.Items.Add(itm);
DebugHelper.WriteLine($"Merger: {file} added to the listbox");
}
}
}
@@ -188,6 +193,7 @@ namespace FModel.Forms
{
if (MergerPreview_Image.Source != null)
{
DebugHelper.WriteLine("Merger: Opening preview of the merged image");
if (!FormsUtility.IsWindowOpen<Window>("Merged Image"))
{
Window win = new Window();
@@ -223,6 +229,8 @@ namespace FModel.Forms
{
if (MergerPreview_Image.Source != null)
{
DebugHelper.WriteLine("Merger: Saving image...");
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "Save Image";
saveFileDialog.FileName = "Merger";
@@ -239,13 +247,17 @@ namespace FModel.Forms
if (File.Exists(path))
{
new UpdateMyConsole(System.IO.Path.GetFileNameWithoutExtension(path), CColors.Blue).Append();
DebugHelper.WriteLine("Merger: Image saved at " + path);
new UpdateMyConsole(Path.GetFileNameWithoutExtension(path), CColors.Blue).Append();
new UpdateMyConsole(" successfully saved", CColors.White, true).Append();
}
else //just in case
{
DebugHelper.WriteLine("Merger: Image couldn't be saved at " + path);
new UpdateMyConsole("Bruh moment\nCouldn't save ", CColors.White).Append();
new UpdateMyConsole(System.IO.Path.GetFileNameWithoutExtension(path), CColors.Blue, true).Append();
new UpdateMyConsole(Path.GetFileNameWithoutExtension(path), CColors.Blue, true).Append();
}
}
}

View File

@@ -50,11 +50,15 @@ namespace FModel.Forms
{
if (PAKEntries.PAKToDisplay != null)
{
DebugHelper.WriteLine("SearchFiles: Populating DataGrid...");
FilterTextBox_Search.IsReadOnly = true;
FileNames = new List<FileInfo>();
await PopulateDataGrid();
DataGrid_Search.ItemsSource = FileNames;
FilterTextBox_Search.IsReadOnly = false;
DebugHelper.WriteLine("SearchFiles: Populated DataGrid");
}
}
@@ -85,7 +89,9 @@ namespace FModel.Forms
});
//max = million
FoundNumber_Label.Content = $"Found {i.ToString("# ### ###", new NumberFormatInfo{ NumberGroupSeparator = " " }).Trim()} assets";
string number = i.ToString("# ### ###", new NumberFormatInfo { NumberGroupSeparator = " " }).Trim();
DebugHelper.WriteLine($"SearchFiles: Loaded {number} assets");
FoundNumber_Label.Content = $"Found {number} assets";
}
private static void FillList(FPakEntry[] EntryArray, Dictionary<string, string> ExistChecker)

View File

@@ -100,6 +100,7 @@ namespace FModel.Forms
private void Button_Click(object sender, RoutedEventArgs e)
{
SetUserSettings();
DebugHelper.WriteUserSettings();
Close();
}

View File

@@ -268,14 +268,17 @@ namespace FModel.Forms
AssetsEntriesDict[a.Name] = new Dictionary<string, string>();
AssetsEntriesDict[a.Name]["Path"] = a.Path;
AssetsEntriesDict[a.Name]["isChecked"] = a.IsChecked.ToString();
if (a.IsChecked)
DebugHelper.WriteLine("UpdateMode: User is about to extract everything in " + a.Path);
}
if (AssetEntries.AssetEntriesDict != null && !string.Equals(FProp.Default.FLanguage, ((ComboBoxItem)ComboBox_Language.SelectedItem).Content.ToString()))
string selectedLang = ((ComboBoxItem)ComboBox_Language.SelectedItem).Content.ToString();
if (AssetEntries.AssetEntriesDict != null && !string.Equals(FProp.Default.FLanguage, selectedLang))
{
AssetTranslations.SetAssetTranslation(((ComboBoxItem)ComboBox_Language.SelectedItem).Content.ToString());
AssetTranslations.SetAssetTranslation(selectedLang);
}
FProp.Default.FLanguage = ((ComboBoxItem)ComboBox_Language.SelectedItem).Content.ToString();
FProp.Default.FLanguage = selectedLang;
FProp.Default.FRarity_Design = ((ComboBoxItem)ComboBox_Design.SelectedItem).Content.ToString();
FProp.Default.FIsFeatured = (bool)bFeaturedIcon.IsChecked;
@@ -284,6 +287,23 @@ namespace FModel.Forms
FProp.Default.FWatermarkOpacity = Convert.ToInt32(Opacity_Slider.Value);
FProp.Default.FUM_AssetsType = JsonConvert.SerializeObject(AssetsEntriesDict, Formatting.Indented);
FProp.Default.Save();
DebugHelper.WriteLine("=============== UPDATE MODE ===============");
DebugHelper.WriteLine("FRarity_Design > " + FProp.Default.FRarity_Design);
DebugHelper.WriteLine("FLanguage > " + FProp.Default.FLanguage);
DebugHelper.WriteLine("FIsFeatured > " + FProp.Default.FIsFeatured);
DebugHelper.WriteLine("FUseWatermark > " + FProp.Default.FUseWatermark);
DebugHelper.WriteLine("FWatermarkFilePath > " + FProp.Default.FWatermarkFilePath);
DebugHelper.WriteLine("FWatermarkOpacity > " + FProp.Default.FWatermarkOpacity);
DebugHelper.WriteLine("FWatermarkScale > " + FProp.Default.FWatermarkScale);
DebugHelper.WriteLine("FWatermarkXPos > " + FProp.Default.FWatermarkXPos);
DebugHelper.WriteLine("FWatermarkYPos > " + FProp.Default.FWatermarkYPos);
DebugHelper.WriteLine("FOpenSounds > " + FProp.Default.FOpenSounds);
DebugHelper.WriteLine("FAutoExtractRaw > " + FProp.Default.FAutoExtractRaw);
DebugHelper.WriteLine("FAutoSaveJson > " + FProp.Default.FAutoSaveJson);
DebugHelper.WriteLine("FAutoSaveImg > " + FProp.Default.FAutoSaveImg);
DebugHelper.WriteLine("=============================================");
Close();
}
@@ -297,6 +317,7 @@ namespace FModel.Forms
{
if (AssetsListBox.Items.Count > 0 && AssetsListBox.SelectedItems.Count > 0)
{
DebugHelper.WriteLine("UpdateMode: Removing " + (AssetsListBox.SelectedItem as AssetProperties).Path + " to the list of assets type");
Assets.Remove(AssetsListBox.SelectedItem as AssetProperties);
}
}
@@ -309,6 +330,7 @@ namespace FModel.Forms
if (!path.EndsWith("/"))
path += "/";
DebugHelper.WriteLine("UpdateMode: Adding " + path + " to the list of assets type");
Assets.Add(new AssetProperties
{
Name = NameTextBox.Text,

View File

@@ -78,7 +78,7 @@ namespace FModel.Methods.AESManager
}
else
{
DebugHelper.WriteLine("AES keys not loaded, this isn't an error");
DebugHelper.WriteLine("AES keys not loaded, user doesn't wanna check for new keys on startup");
KeysManager.Deserialize();
}

View File

@@ -27,6 +27,7 @@ namespace FModel.Methods.Assets
StringBuilder sb = new StringBuilder();
string fullPath = isFromDataGrid ? FWindow.FCurrentAsset : TreeViewUtility.GetFullPath(FWindow.TVItem) + "/" + FWindow.FCurrentAsset;
DebugHelper.WriteLine("Assets: Gathering info about {0}", fullPath);
PakReader.PakReader reader = AssetsUtility.GetPakReader(fullPath);
if (reader != null)
{

View File

@@ -96,6 +96,8 @@ namespace FModel.Methods.Assets
private static void PopulateDict(string LocResPath)
{
DebugHelper.WriteLine(".PAKs: Loading " + LocResPath + " as the translation file");
if (HotfixLocResDict == null) { SetHotfixedLocResDict(); } //once, no need to do more
BRLocResDict = GetLocResDict(LocResPath);
STWLocResDict = GetLocResDict(LocResPath.Replace("Game_BR", "Game_StW"));
@@ -124,6 +126,7 @@ namespace FModel.Methods.Assets
string pdd = Path.GetFullPath(Path.Combine(FProp.Default.FPak_Path, @"..\..\PersistentDownloadDir\EMS\"));
if (File.Exists(pdd + "a22d837b6a2b46349421259c0a5411bf"))
{
DebugHelper.WriteLine(".PAKs: Populating hotfixed string dictionary at " + pdd + "a22d837b6a2b46349421259c0a5411bf");
HotfixLocResDict = new Dictionary<string, Dictionary<string, Dictionary<string, string>>> ();
using (StreamReader sr = new StreamReader(File.Open(pdd + "a22d837b6a2b46349421259c0a5411bf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
{
@@ -160,7 +163,10 @@ namespace FModel.Methods.Assets
}
}
}
DebugHelper.WriteLine(".PAKs: Populated hotfixed string dictionary");
}
else
DebugHelper.WriteLine(".PAKs: No such file or directory " + pdd + "a22d837b6a2b46349421259c0a5411bf");
}
private static string GetValueFromParam(string fullLine, string startWith, string endWith)

View File

@@ -1,6 +1,5 @@
using FModel.Methods.SyntaxHighlighter;
using FModel.Methods.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PakReader;
using System.Collections.Generic;
@@ -37,6 +36,8 @@ namespace FModel.Methods.Assets
isRunning = true;
foreach (string item in selectedItems)
{
DebugHelper.WriteLine("Assets: User selected " + item);
cToken.ThrowIfCancellationRequested(); //if clicked on 'Stop' it breaks at the following item
FWindow.FMain.Dispatcher.InvokeAsync(() => //ui thread because if not, FCurrentAsset isn't updated in time to Auto Save a JSON Data for example
{
@@ -91,6 +92,7 @@ namespace FModel.Methods.Assets
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))

View File

@@ -28,8 +28,14 @@ namespace FModel.Methods.Assets.IconCreator
ICDrawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 515)));
Rarity.DrawRarityBackground(AssetProperties);
DebugHelper.WriteLine("DefaultIconCreation: Icon rarity done for {0}", FWindow.FCurrentAsset);
IconImage.DrawIconImage(AssetProperties, FProp.Default.FIsFeatured);
DebugHelper.WriteLine("DefaultIconCreation: Icon image done for {0}", FWindow.FCurrentAsset);
IconText.DrawIconText(AssetProperties);
DebugHelper.WriteLine("DefaultIconCreation: Icon text done for {0}", FWindow.FCurrentAsset);
IconWatermark.DrawIconWatermark();
}
@@ -53,9 +59,11 @@ namespace FModel.Methods.Assets.IconCreator
ICDrawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(1024, 300)));
ChallengeBundleInfos.GetBundleData(AssetProperties);
DebugHelper.WriteLine("BChallengesIconCreation: Bundle data has been gathered for {0}", FWindow.FCurrentAsset);
new UpdateMyProcessEvents("Drawing Quests Informations...", "Waiting").Update();
ChallengeIconDesign.DrawChallenge(AssetProperties, new DirectoryInfo(path).Parent.Name.ToUpperInvariant());
DebugHelper.WriteLine("BChallengesIconCreation: Bundle image has been drawn for {0}", FWindow.FCurrentAsset);
}
new UpdateMyProcessEvents("Done", "Success").Update();

View File

@@ -26,6 +26,8 @@ namespace FModel.Methods.Assets.IconCreator
IconCreator.ICDrawingContext.DrawImage(ImagesUtility.CreateTransparency(bmp, FProp.Default.FWatermarkOpacity), new Rect(FProp.Default.FWatermarkXPos, FProp.Default.FWatermarkYPos, FProp.Default.FWatermarkScale, FProp.Default.FWatermarkScale));
}
}
DebugHelper.WriteLine("DefaultIconCreation: Icon watermark has been applied on {0}", FWindow.FCurrentAsset);
}
}
}

View File

@@ -33,6 +33,7 @@ namespace FModel.Methods.PAKs
using (FileStream fileStream = new FileStream(BACKUP_FILE_PATH, FileMode.Create))
using (BinaryWriter writer = new BinaryWriter(fileStream))
{
DebugHelper.WriteLine("Backup: Gathering info about local .PAK files");
foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList)
{
byte[] AESKey = null;
@@ -54,6 +55,8 @@ namespace FModel.Methods.PAKs
if (AESKey != null)
{
DebugHelper.WriteLine($".PAKs: Backing up {Pak.ThePAKPath} with key: {BitConverter.ToString(AESKey).Replace("-", string.Empty)}");
PakReader.PakReader reader = new PakReader.PakReader(Pak.ThePAKPath, AESKey);
if (reader != null)
{
@@ -71,15 +74,20 @@ namespace FModel.Methods.PAKs
}
}
}
else
DebugHelper.WriteLine($".PAKs: Not backing up {Pak.ThePAKPath} because its key is empty");
}
}
if (new FileInfo(BACKUP_FILE_PATH).Length > 0) //HENCE WE CHECK THE LENGTH
{
DebugHelper.WriteLine($".PAKs: \\Backups\\{Path.GetFileName(BACKUP_FILE_PATH)} successfully created");
new UpdateMyProcessEvents($"\\Backups\\{Path.GetFileName(BACKUP_FILE_PATH)} successfully created", "Success").Update();
}
else
{
DebugHelper.WriteLine("Backup: File created is empty");
File.Delete(BACKUP_FILE_PATH); //WE DELETE THE EMPTY FILE CREATED
new UpdateMyProcessEvents($"Error while creating {Path.GetFileName(BACKUP_FILE_PATH)}", "Error").Update();
}

View File

@@ -34,6 +34,7 @@ namespace FModel.Methods.PAKs
await Task.Run(() =>
{
PAKEntries.PAKToDisplay = new Dictionary<string, FPakEntry[]>();
DebugHelper.WriteLine($".PAKs: User is loading {PAK_PATH}\\{FWindow.FCurrentPAK}");
new UpdateMyProcessEvents($"{PAK_PATH}\\{FWindow.FCurrentPAK}", "Loading").Update();
LoadPAKFiles();
@@ -42,6 +43,7 @@ namespace FModel.Methods.PAKs
}).ContinueWith(TheTask =>
{
TasksUtility.TaskCompleted(TheTask.Exception);
DebugHelper.WriteLine($".PAKs: Loaded {PAK_PATH}\\{FWindow.FCurrentPAK}");
});
FWindow.FMain.MI_LoadOnePAK.IsEnabled = true;
@@ -65,6 +67,7 @@ namespace FModel.Methods.PAKs
await Task.Run(() =>
{
PAKEntries.PAKToDisplay = new Dictionary<string, FPakEntry[]>();
DebugHelper.WriteLine($".PAKs: User is loading all .PAK files at {PAK_PATH}\\");
LoadPAKFiles(true);
FillTreeView(true);
@@ -72,6 +75,7 @@ namespace FModel.Methods.PAKs
}).ContinueWith(TheTask =>
{
TasksUtility.TaskCompleted(TheTask.Exception);
DebugHelper.WriteLine($".PAKs: Loaded all .PAK files at {PAK_PATH}\\");
});
FWindow.FMain.MI_LoadOnePAK.IsEnabled = true;
@@ -97,6 +101,7 @@ namespace FModel.Methods.PAKs
await Task.Run(async () =>
{
PAKEntries.PAKToDisplay = new Dictionary<string, FPakEntry[]>();
DebugHelper.WriteLine($".PAKs: User is loading difference at {PAK_PATH}\\");
LoadPAKFiles(true);
await LoadBackupFile(updateMode);
@@ -104,6 +109,7 @@ namespace FModel.Methods.PAKs
}).ContinueWith(TheTask =>
{
TasksUtility.TaskCompleted(TheTask.Exception);
DebugHelper.WriteLine($".PAKs: Loaded difference at {PAK_PATH}\\");
});
}
@@ -120,6 +126,8 @@ namespace FModel.Methods.PAKs
{
if (!string.IsNullOrEmpty(FProp.Default.FPak_MainAES))
{
DebugHelper.WriteLine($".PAKs: Loading {Pak.ThePAKPath} with key: {FProp.Default.FPak_MainAES}");
byte[] AESKey = AESUtility.StringToByteArray(FProp.Default.FPak_MainAES);
PakReader.PakReader reader = null;
try
@@ -128,6 +136,8 @@ namespace FModel.Methods.PAKs
}
catch (Exception ex)
{
DebugHelper.WriteException(ex, Pak.ThePAKPath);
if (string.Equals(ex.Message, "The AES key is invalid")) { UIHelper.DisplayError(); }
else { new UpdateMyConsole(ex.Message, CColors.Red, true).Append(); return; }
break;
@@ -159,6 +169,7 @@ namespace FModel.Methods.PAKs
AESFromManager = AESEntries.AESEntriesList.Where(x => string.Equals(x.ThePAKName, Path.GetFileNameWithoutExtension(Pak.ThePAKPath))).Select(x => x.ThePAKKey).FirstOrDefault();
if (!string.IsNullOrEmpty(AESFromManager))
{
DebugHelper.WriteLine($".PAKs: Loading {Pak.ThePAKPath} with key: {AESFromManager}");
AESKey = AESUtility.StringToByteArray(AESFromManager);
}
}
@@ -172,6 +183,8 @@ namespace FModel.Methods.PAKs
}
catch (Exception ex)
{
DebugHelper.WriteException(ex, Pak.ThePAKPath);
if (string.Equals(ex.Message, "The AES key is invalid")) { UIHelper.DisplayError(Path.GetFileNameWithoutExtension(Pak.ThePAKPath), AESFromManager); }
else { new UpdateMyConsole(ex.Message, CColors.Red, true).Append(); return; }
continue;
@@ -189,6 +202,8 @@ namespace FModel.Methods.PAKs
}
}
}
else
DebugHelper.WriteLine($".PAKs: No key found for {Pak.ThePAKPath}");
}
}
}
@@ -198,8 +213,13 @@ namespace FModel.Methods.PAKs
if (!bAllPAKs)
{
FPakEntry[] PAKFileInfos = PAKEntries.PAKToDisplay.Where(x => x.Key == FWindow.FCurrentPAK).Select(x => x.Value).FirstOrDefault();
if (PAKFileInfos == null) { throw new ArgumentException($"Please, provide a working key in the AES Manager for {FWindow.FCurrentPAK}"); }
if (PAKFileInfos == null)
{
DebugHelper.WriteLine($".PAKs: Wrong key provided for {FWindow.FCurrentPAK}");
throw new ArgumentException($"Please, provide a working key in the AES Manager for {FWindow.FCurrentPAK}");
}
DebugHelper.WriteLine($".PAKs: Filling Treeview with {FWindow.FCurrentPAK}'s assets");
FWindow.FMain.Dispatcher.InvokeAsync(() =>
{
foreach (FPakEntry entry in PAKFileInfos)
@@ -211,6 +231,7 @@ namespace FModel.Methods.PAKs
}
else
{
DebugHelper.WriteLine(".PAKs: Filling Treeview with all PAK's assets");
foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values)
{
FWindow.FMain.Dispatcher.InvokeAsync(() =>
@@ -228,6 +249,7 @@ namespace FModel.Methods.PAKs
{
FWindow.FMain.ViewModel = srt;
});
DebugHelper.WriteLine(".PAKs: Treeview filled");
new UpdateMyProcessEvents(!bAllPAKs ? PAK_PATH + "\\" + FWindow.FCurrentPAK : PAK_PATH, "Success").Update();
}
@@ -240,12 +262,15 @@ namespace FModel.Methods.PAKs
openFiledialog.Filter = "FBKP Files (*.fbkp)|*.fbkp|All Files (*.*)|*.*";
if (openFiledialog.ShowDialog() == true)
{
DebugHelper.WriteLine($".PAKs: Loading {openFiledialog.FileName} as the backup file");
new UpdateMyProcessEvents("Comparing Files", "Waiting").Update();
FPakEntry[] BackupEntries;
using (FileStream fileStream = new FileStream(openFiledialog.FileName, FileMode.Open))
using (BinaryReader reader = new BinaryReader(fileStream))
{
DebugHelper.WriteLine(".PAKs: Populating FPakEntry[] for the backup file");
List<FPakEntry> entries = new List<FPakEntry>();
while (reader.BaseStream.Position < reader.BaseStream.Length)
{
@@ -264,17 +289,23 @@ namespace FModel.Methods.PAKs
if (BackupEntries.Any())
{
DebugHelper.WriteLine(".PAKs: FPakEntry[] for the backup file is populated");
List<FPakEntry> LocalEntries = new List<FPakEntry>();
foreach (FPakEntry[] PAKsFileInfos in PAKEntries.PAKToDisplay.Values)
{
PAKsFileInfos.ToList().ForEach(x => LocalEntries.Add(x));
}
PAKEntries.PAKToDisplay.Clear();
DebugHelper.WriteLine(".PAKs: FPakEntry[] for the local .PAKs is populated");
//FILTER WITH THE OVERRIDED EQUALS METHOD (CHECKING FILE NAME AND FILE UNCOMPRESSED SIZE)
DebugHelper.WriteLine($".PAKs: Comparing...\t File Size Check: {FProp.Default.FDiffFileSize}");
IEnumerable<FPakEntry> newAssets = LocalEntries.ToArray().Except(BackupEntries);
DebugHelper.WriteLine(".PAKs: Compared");
//ADD TO TREE
DebugHelper.WriteLine(".PAKs: Filling Treeview with differentiated assets");
foreach (FPakEntry entry in newAssets)
{
string onlyFolders = entry.Name.Substring(0, entry.Name.LastIndexOf('/'));
@@ -291,6 +322,7 @@ namespace FModel.Methods.PAKs
{
FWindow.FMain.ViewModel = srt;
});
DebugHelper.WriteLine(".PAKs: Treeview filled");
await FWindow.FMain.Dispatcher.InvokeAsync(() =>
{
@@ -304,6 +336,7 @@ namespace FModel.Methods.PAKs
//PRINT REMOVED IF NO FILE SIZE CHECK
if (!FProp.Default.FDiffFileSize)
{
DebugHelper.WriteLine(".PAKs: Checking deleted items");
new UpdateMyProcessEvents("Checking deleted items", "Waiting").Update();
IEnumerable<FPakEntry> removedAssets = BackupEntries.Except(LocalEntries.ToArray());
@@ -316,17 +349,26 @@ namespace FModel.Methods.PAKs
if (removedItems.Count > 0)
{
DebugHelper.WriteLine(".PAKs: Items Removed/Renamed:");
new UpdateMyConsole("Items Removed/Renamed:", CColors.Red, true).Append();
removedItems.Distinct().ToList().ForEach(e => new UpdateMyConsole($" - {e.Substring(1)}", CColors.White, true).Append());
removedItems.Distinct().ToList().ForEach(e => {
new UpdateMyConsole($" - {e.Substring(1)}", CColors.White, true).Append();
DebugHelper.WriteLine($" - {e.Substring(1)}");
});
}
}
DebugHelper.WriteLine(".PAKs: PAK files have been compared successfully");
new UpdateMyProcessEvents("All PAK files have been compared successfully", "Success").Update();
umIsOk = true;
}
else
DebugHelper.WriteLine(".PAKs: FPakEntry[] for the backup file is empty");
}
else
{
DebugHelper.WriteLine(".PAKs: User canceled when he got asked to select a backup file");
new UpdateMyConsole("You change your mind pretty fast but it's fine ", CColors.White).Append();
new UpdateMyConsole("all paks have been loaded instead", CColors.Blue, true).Append();
FillTreeView(true);

View File

@@ -42,7 +42,7 @@ namespace FModel.Methods.PAKs
if (pVersion == 8)
{
string PAKGuid = PAKsUtility.GetPAKGuid(Pak);
DebugHelper.WriteLine("Registering " + Pak + " with GUID " + PAKGuid);
DebugHelper.WriteLine("Registering " + Pak + " with GUID " + PAKGuid + " (" + PAKsUtility.GetEpicGuid(PAKGuid) + ")");
PAKEntries.PAKEntriesList.Add(new PAKInfosEntry(Pak, PAKGuid, string.Equals(PAKGuid, "0-0-0-0") ? false : true));
FWindow.FMain.Dispatcher.InvokeAsync(() =>

View File

@@ -1,4 +1,5 @@
using System;
using FModel.Methods.Utilities;
using System;
using System.IO;
using System.Linq;
using System.Text;
@@ -90,13 +91,13 @@ namespace PakReader
}
catch (Exception e)
{
DebugHelper.WriteException(e, "thrown in AssetReader.cs by AssetReader");
if (!ignoreErrors)
throw e;
}
long valid_pos = position + v.serial_size;
if (reader.BaseStream.Position != valid_pos)
{
Console.WriteLine($"Did not read {export_type} correctly. Current Position: {reader.BaseStream.Position}, Bytes Remaining: {valid_pos - reader.BaseStream.Position}");
reader.BaseStream.Seek(valid_pos, SeekOrigin.Begin);
}
ind++;

View File

@@ -11,7 +11,11 @@ namespace FModel.Methods.Utilities
public static byte[] StringToByteArray(string hex)
{
if (IsOdd(hex.Length)) { throw new ArgumentException("The binary key cannot have an odd number of digits"); }
if (IsOdd(hex.Length))
{
DebugHelper.WriteLine($".PAKs: The binary key cannot have an odd number of digits, Key {hex}");
throw new ArgumentException("The binary key cannot have an odd number of digits");
}
byte[] arr = new byte[hex.Length >> 1];
for (int i = 0; i < hex.Length >> 1; ++i)

View File

@@ -118,6 +118,8 @@ namespace FModel.Methods.Utilities
public static string GetAssetJsonData(PakReader.PakReader reader, IEnumerable<FPakEntry> entriesList, bool loadImageInBox = false)
{
DebugHelper.WriteLine("Assets: Gathering info about {0}", entriesList.ElementAt(0).Name);
Stream[] AssetStreamArray = new Stream[3];
foreach (FPakEntry entry in entriesList)
@@ -139,11 +141,15 @@ namespace FModel.Methods.Utilities
if (File.Exists(path))
{
DebugHelper.WriteLine("Assets: Successfully extracted data of {0}", entry.Name);
new UpdateMyConsole(Path.GetFileName(path), CColors.Blue).Append();
new UpdateMyConsole(" successfully exported", CColors.White, true).Append();
}
else //just in case
{
DebugHelper.WriteLine("Assets: Couldn't extract data of {0}", entry.Name);
new UpdateMyConsole("Bruh moment\nCouldn't export ", CColors.White).Append();
new UpdateMyConsole(Path.GetFileName(path), CColors.Blue, true).Append();
}
@@ -259,11 +265,15 @@ namespace FModel.Methods.Utilities
File.WriteAllText(path, stringData);
if (File.Exists(path))
{
DebugHelper.WriteLine("Assets: Successfully saved serialized data of {0}", entriesList.ElementAt(0).Name);
new UpdateMyConsole(name, CColors.Blue).Append();
new UpdateMyConsole("'s Json data successfully saved", CColors.White, true).Append();
}
else //just in case
{
DebugHelper.WriteLine("Assets: Couldn't save serialized data of {0}", entriesList.ElementAt(0).Name);
new UpdateMyConsole("Bruh moment\nCouldn't export ", CColors.White).Append();
new UpdateMyConsole(name, CColors.Blue, true).Append();
}
@@ -286,7 +296,11 @@ namespace FModel.Methods.Utilities
List<FPakEntry> entriesList = GetPakEntries(pathEntries != null ? pathEntries : path);
if (entriesList != null)
jsonData = GetAssetJsonData(reader, entriesList, loadImageInBox);
else
DebugHelper.WriteLine("Assets: GetAssetJsonDataByPath -> entriesList -> is empty for {0}", path);
}
else
DebugHelper.WriteLine("Assets: No PakReader found for {0}", path);
return jsonData;
}
@@ -393,11 +407,15 @@ namespace FModel.Methods.Utilities
if (File.Exists(path))
{
DebugHelper.WriteLine("ExportAssetData: Successfully extracted data of {0}", entry.Name);
new UpdateMyConsole(Path.GetFileName(path), CColors.Blue).Append();
new UpdateMyConsole(" successfully exported", CColors.White, true).Append();
}
else //just in case
{
DebugHelper.WriteLine("ExportAssetData: Couldn't extract data of {0}", entry.Name);
new UpdateMyConsole("Bruh moment\nCouldn't export ", CColors.White).Append();
new UpdateMyConsole(Path.GetFileName(path), CColors.Blue, true).Append();
}
@@ -421,11 +439,15 @@ namespace FModel.Methods.Utilities
File.WriteAllText(path, prop);
if (File.Exists(path))
{
DebugHelper.WriteLine("SaveAssetProperties: Successfully saved serialized data of {0}", FWindow.FCurrentAsset);
new UpdateMyConsole(FWindow.FCurrentAsset, CColors.Blue).Append();
new UpdateMyConsole("'s Json data successfully saved", CColors.White, true).Append();
}
else //just in case
{
DebugHelper.WriteLine("SaveAssetProperties: Couldn't save serialized data of {0}", FWindow.FCurrentAsset);
new UpdateMyConsole("Bruh moment\nCouldn't export ", CColors.White).Append();
new UpdateMyConsole(FWindow.FCurrentAsset, CColors.Blue, true).Append();
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using FProp = FModel.Properties.Settings;
namespace FModel.Methods.Utilities
{
@@ -45,5 +46,36 @@ namespace FModel.Methods.Utilities
{
WriteException(exception.ToString(), message);
}
public static void WriteUserSettings()
{
DebugHelper.WriteLine("=============== USER SETTINGS ===============");
DebugHelper.WriteLine("FPak_Path > " + FProp.Default.FPak_Path);
DebugHelper.WriteLine("FOutput_Path > " + FProp.Default.FOutput_Path);
DebugHelper.WriteLine("FPak_MainAES > " + FProp.Default.FPak_MainAES);
DebugHelper.WriteLine("FRarity_Design > " + FProp.Default.FRarity_Design);
DebugHelper.WriteLine("FLanguage > " + FProp.Default.FLanguage);
DebugHelper.WriteLine("FIsFeatured > " + FProp.Default.FIsFeatured);
DebugHelper.WriteLine("FUseWatermark > " + FProp.Default.FUseWatermark);
DebugHelper.WriteLine("FWatermarkFilePath > " + FProp.Default.FWatermarkFilePath);
DebugHelper.WriteLine("FWatermarkOpacity > " + FProp.Default.FWatermarkOpacity);
DebugHelper.WriteLine("FWatermarkScale > " + FProp.Default.FWatermarkScale);
DebugHelper.WriteLine("FWatermarkXPos > " + FProp.Default.FWatermarkXPos);
DebugHelper.WriteLine("FWatermarkYPos > " + FProp.Default.FWatermarkYPos);
DebugHelper.WriteLine("FChallengeWatermark > " + FProp.Default.FChallengeWatermark);
DebugHelper.WriteLine("FUseChallengeWatermark > " + FProp.Default.FUseChallengeWatermark);
DebugHelper.WriteLine("FBannerFilePath > " + FProp.Default.FBannerFilePath);
DebugHelper.WriteLine("FBannerOpacity > " + FProp.Default.FBannerOpacity);
DebugHelper.WriteLine("FPrimaryColor > " + FProp.Default.FPrimaryColor);
DebugHelper.WriteLine("FSecondaryColor > " + FProp.Default.FSecondaryColor);
DebugHelper.WriteLine("FUpdateSettings > " + FProp.Default.FUpdateSettings);
DebugHelper.WriteLine("FDiffFileSize > " + FProp.Default.FDiffFileSize);
DebugHelper.WriteLine("ReloadAES > " + FProp.Default.ReloadAES);
DebugHelper.WriteLine("FOpenSounds > " + FProp.Default.FOpenSounds);
DebugHelper.WriteLine("FAutoExtractRaw > " + FProp.Default.FAutoExtractRaw);
DebugHelper.WriteLine("FAutoSaveJson > " + FProp.Default.FAutoSaveJson);
DebugHelper.WriteLine("FAutoSaveImg > " + FProp.Default.FAutoSaveImg);
DebugHelper.WriteLine("=============================================");
}
}
}

View File

@@ -52,7 +52,7 @@ namespace FModel.Methods.Utilities
//BACKUPS
foreach (JProperty prop in FData["Backups"].Value<JObject>().Properties())
{
DebugHelper.WriteLine("Dropbox: " + prop.Name + " available to download");
DebugHelper.WriteLine("Dropbox: " + prop.Name + " is available to download");
ListToReturn.Add(new BackupInfosEntry(prop.Name, prop.Value.Value<string>()));
}
return ListToReturn;

View File

@@ -119,11 +119,15 @@ namespace FModel.Methods.Utilities
if (File.Exists(path))
{
DebugHelper.WriteLine("SaveImage: Successfully saved image of {0}", FWindow.FCurrentAsset);
new UpdateMyConsole(Path.GetFileNameWithoutExtension(path), CColors.Blue).Append();
new UpdateMyConsole(" successfully saved", CColors.White, true).Append();
}
else //just in case
{
DebugHelper.WriteLine("SaveImage: Couldn't save image of {0}", FWindow.FCurrentAsset);
new UpdateMyConsole("Bruh moment\nCouldn't save ", CColors.White).Append();
new UpdateMyConsole(Path.GetFileNameWithoutExtension(path), CColors.Blue, true).Append();
}

View File

@@ -34,6 +34,7 @@ namespace FModel
StartTimer = Stopwatch.StartNew();
DebugHelper.Init(LogsFilePath);
DebugHelper.WriteLine("=================================================================== FModel ===================================================================");
DebugHelper.WriteLine("FModel starting.");
DebugHelper.WriteLine("Version: " + Assembly.GetExecutingAssembly().GetName().Version.ToString());
DebugHelper.WriteLine("Build: " + Build);