diff --git a/FModel/Forms/AESManager.cs b/FModel/Forms/AESManager.cs index 0d8a36ce..d54a64be 100644 --- a/FModel/Forms/AESManager.cs +++ b/FModel/Forms/AESManager.cs @@ -12,9 +12,12 @@ namespace FModel.Forms { public partial class AESManager : Form { + public static bool isClosed { get; set; } + public AESManager() { InitializeComponent(); + isClosed = false; textBox2.Text = @"0x" + Properties.Settings.Default.AESKey; @@ -81,6 +84,7 @@ namespace FModel.Forms } Properties.Settings.Default.Save(); + isClosed = true; Close(); } diff --git a/FModel/Forms/Settings.Designer.cs b/FModel/Forms/Settings.Designer.cs index 7b7e87b0..5c225aeb 100644 --- a/FModel/Forms/Settings.Designer.cs +++ b/FModel/Forms/Settings.Designer.cs @@ -51,6 +51,7 @@ namespace FModel.Forms this.button1 = new System.Windows.Forms.Button(); this.wPictureBox = new System.Windows.Forms.PictureBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.checkBoxSaveAsMergeImages = new System.Windows.Forms.CheckBox(); this.imgsPerRow = new System.Windows.Forms.NumericUpDown(); this.label5 = new System.Windows.Forms.Label(); this.textBox3 = new System.Windows.Forms.TextBox(); @@ -66,7 +67,6 @@ namespace FModel.Forms this.checkBox2 = new System.Windows.Forms.CheckBox(); this.textBox6 = new System.Windows.Forms.TextBox(); this.label12 = new System.Windows.Forms.Label(); - this.checkBoxSaveAsMergeImages = new System.Windows.Forms.CheckBox(); this.groupBox3.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox4.SuspendLayout(); @@ -150,7 +150,7 @@ namespace FModel.Forms // this.OKButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.OKButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.OKButton.Location = new System.Drawing.Point(475, 546); + this.OKButton.Location = new System.Drawing.Point(475, 532); this.OKButton.Name = "OKButton"; this.OKButton.Size = new System.Drawing.Size(97, 21); this.OKButton.TabIndex = 15; @@ -325,14 +325,24 @@ namespace FModel.Forms this.groupBox1.Controls.Add(this.label4); this.groupBox1.Location = new System.Drawing.Point(12, 473); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(560, 67); + this.groupBox1.Size = new System.Drawing.Size(560, 49); this.groupBox1.TabIndex = 17; this.groupBox1.TabStop = false; this.groupBox1.Text = "Merger"; // + // checkBoxSaveAsMergeImages + // + this.checkBoxSaveAsMergeImages.AutoSize = true; + this.checkBoxSaveAsMergeImages.Location = new System.Drawing.Point(434, 21); + this.checkBoxSaveAsMergeImages.Name = "checkBoxSaveAsMergeImages"; + this.checkBoxSaveAsMergeImages.Size = new System.Drawing.Size(120, 17); + this.checkBoxSaveAsMergeImages.TabIndex = 13; + this.checkBoxSaveAsMergeImages.Text = "Enable \"Save as...\""; + this.checkBoxSaveAsMergeImages.UseVisualStyleBackColor = true; + // // imgsPerRow // - this.imgsPerRow.Location = new System.Drawing.Point(509, 41); + this.imgsPerRow.Location = new System.Drawing.Point(375, 19); this.imgsPerRow.Maximum = new decimal(new int[] { 20, 0, @@ -348,7 +358,7 @@ namespace FModel.Forms // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(415, 44); + this.label5.Location = new System.Drawing.Point(281, 22); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(88, 13); this.label5.TabIndex = 10; @@ -358,7 +368,7 @@ namespace FModel.Forms // this.textBox3.Location = new System.Drawing.Point(69, 19); this.textBox3.Name = "textBox3"; - this.textBox3.Size = new System.Drawing.Size(337, 20); + this.textBox3.Size = new System.Drawing.Size(206, 20); this.textBox3.TabIndex = 8; // // label4 @@ -480,21 +490,11 @@ namespace FModel.Forms this.label12.TabIndex = 9; this.label12.Text = "Watermark:"; // - // checkBoxSaveAsMergeImages - // - this.checkBoxSaveAsMergeImages.AutoSize = true; - this.checkBoxSaveAsMergeImages.Location = new System.Drawing.Point(418, 18); - this.checkBoxSaveAsMergeImages.Name = "checkBoxSaveAsMergeImages"; - this.checkBoxSaveAsMergeImages.Size = new System.Drawing.Size(120, 17); - this.checkBoxSaveAsMergeImages.TabIndex = 13; - this.checkBoxSaveAsMergeImages.Text = "Enable \"Save as...\""; - this.checkBoxSaveAsMergeImages.UseVisualStyleBackColor = true; - // // Settings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(584, 579); + this.ClientSize = new System.Drawing.Size(584, 565); this.Controls.Add(this.groupBox6); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox1); diff --git a/FModel/MainWindow.cs b/FModel/MainWindow.cs index 89a9b468..8e116ffb 100644 --- a/FModel/MainWindow.cs +++ b/FModel/MainWindow.cs @@ -144,8 +144,6 @@ namespace FModel DLLImport.SetTreeViewTheme(treeView1.Handle); - DynamicKeysManager.deserialize(); - Checking.BackupFileName = "\\FortniteGame_" + DateTime.Now.ToString("MMddyyyy") + ".txt"; ThePak.dynamicPaksList = new List(); ThePak.mainPaksList = new List(); @@ -157,9 +155,11 @@ namespace FModel Settings.Default.UpdateSettings = false; Settings.Default.Save(); } + DynamicKeysManager.deserialize(); await Task.Run(() => { FillWithPaKs(); + Utilities.colorMyPaks(loadOneToolStripMenuItem); Utilities.SetOutputFolder(); Utilities.SetFolderPermission(App.DefaultOutputPath); Utilities.JohnWickCheck(); @@ -251,6 +251,13 @@ namespace FModel { Application.OpenForms[aesForms.Name].Focus(); } + aesForms.FormClosing += (o, c) => + { + if (AESManager.isClosed) + { + Utilities.colorMyPaks(loadOneToolStripMenuItem); + } + }; } #endregion @@ -271,10 +278,11 @@ namespace FModel { JohnWick.MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey); } - else { break; } + else { JohnWick.MyExtractor.Dispose(); break; } } catch (Exception) { + JohnWick.MyExtractor.Dispose(); break; } @@ -316,6 +324,7 @@ namespace FModel if (loadAllPaKs) { UpdateConsole(".PAK mount point: " + mountPoint.Substring(9), Color.FromArgb(255, 244, 132, 66), "Waiting"); } if (theSinglePak != null && ThePak.mainPaksList[i].thePak == theSinglePak.ClickedItem.Text) { PakAsTxt = CurrentUsedPakLines; } } + JohnWick.MyExtractor.Dispose(); } if (bMainKeyWorking) { LoadLocRes.LoadMySelectedLocRes(Settings.Default.IconLanguage); } @@ -348,9 +357,11 @@ namespace FModel PakAsTxt[i] = mountPoint.Substring(6) + PakAsTxt[i]; } } + JohnWick.MyExtractor.Dispose(); } catch (Exception) { + JohnWick.MyExtractor.Dispose(); return; } } @@ -1084,39 +1095,39 @@ namespace FModel { if (Settings.Default.createIconForCosmetics && itemId[i].ExportType.Contains("Athena") && itemId[i].ExportType.Contains("Item") && itemId[i].ExportType.Contains("Definition")) { - pictureBox1.Image = CreateItemIcon(itemId[i], "athIteDef"); + CreateItemIcon(itemId[i], "athIteDef"); } else if (Settings.Default.createIconForConsumablesWeapons && (itemId[i].ExportType == "FortWeaponRangedItemDefinition" || itemId[i].ExportType == "FortWeaponMeleeItemDefinition")) { - pictureBox1.Image = CreateItemIcon(itemId[i], "consAndWeap"); + CreateItemIcon(itemId[i], "consAndWeap"); } else if (Settings.Default.createIconForTraps && (itemId[i].ExportType == "FortTrapItemDefinition" || itemId[i].ExportType == "FortContextTrapItemDefinition")) { - pictureBox1.Image = CreateItemIcon(itemId[i]); + CreateItemIcon(itemId[i]); } else if (Settings.Default.createIconForVariants && (itemId[i].ExportType == "FortVariantTokenType")) { - pictureBox1.Image = CreateItemIcon(itemId[i], "variant"); + CreateItemIcon(itemId[i], "variant"); } else if (Settings.Default.createIconForAmmo && (itemId[i].ExportType == "FortAmmoItemDefinition")) { - pictureBox1.Image = CreateItemIcon(itemId[i], "ammo"); + CreateItemIcon(itemId[i], "ammo"); } else if (questJson != null && (Settings.Default.createIconForSTWHeroes && (itemId[i].ExportType == "FortHeroType" && (questJson.Contains("ItemDefinition") || questJson.Contains("TestDefsSkydive") || questJson.Contains("GameplayPrototypes"))))) //Contains x not to trigger HID from BR { - pictureBox1.Image = CreateItemIcon(itemId[i], "stwHeroes"); + CreateItemIcon(itemId[i], "stwHeroes"); } else if (Settings.Default.createIconForSTWDefenders && (itemId[i].ExportType == "FortDefenderItemDefinition")) { - pictureBox1.Image = CreateItemIcon(itemId[i], "stwDefenders"); + CreateItemIcon(itemId[i], "stwDefenders"); } else if (Settings.Default.createIconForSTWCardPacks && (itemId[i].ExportType == "FortCardPackItemDefinition")) { - pictureBox1.Image = CreateItemIcon(itemId[i]); + CreateItemIcon(itemId[i]); } else if (Settings.Default.createIconForCreativeGalleries && (itemId[i].ExportType == "FortPlaysetGrenadeItemDefinition")) { - pictureBox1.Image = CreateItemIcon(itemId[i]); + CreateItemIcon(itemId[i]); } else if (itemId[i].ExportType == "FortChallengeBundleItemDefinition") { @@ -1132,7 +1143,7 @@ namespace FModel throw new ArgumentException(ex.Message); } } - private Bitmap CreateItemIcon(ItemsIdParser theItem, string specialMode = null) + private void CreateItemIcon(ItemsIdParser theItem, string specialMode = null) { UpdateConsole(ThePak.CurrentUsedItem + " is an Item Definition", Color.FromArgb(255, 66, 244, 66), "Success"); @@ -1176,8 +1187,9 @@ namespace FModel AppendText(" successfully saved", Color.Black, true); } } + + pictureBox1.Image = bmp; g.Dispose(); - return bmp; } diff --git a/FModel/Methods/Utilities/Utilities.cs b/FModel/Methods/Utilities/Utilities.cs index 2c689118..aad85e62 100644 --- a/FModel/Methods/Utilities/Utilities.cs +++ b/FModel/Methods/Utilities/Utilities.cs @@ -1,9 +1,13 @@ using FModel.Properties; using System; +using System.Linq; using System.Diagnostics; +using System.Drawing; using System.IO; using System.Security.AccessControl; using System.Security.Principal; +using System.Windows.Forms; +using System.Collections.Generic; namespace FModel { @@ -138,5 +142,38 @@ namespace FModel { return text.IndexOf(value, stringComparison) >= 0; } + + /// + /// in the ToolStripMenuItem, color the paks that have a key (working or not working) + /// result: improve readability when there's a lot of paks + /// + /// + public static void colorMyPaks(ToolStripMenuItem myToolStrip) + { + foreach (ToolStripItem toolstripmenuitem in myToolStrip.DropDownItems) + { + toolstripmenuitem.BackColor = Color.FromArgb(255, 255, 255, 255); + + if (!string.IsNullOrEmpty(Settings.Default.AESKey)) + { + string pak = ThePak.mainPaksList.Where(i => i.thePak == toolstripmenuitem.Text).Select(i => i.thePak).FirstOrDefault(); + + if (pak == toolstripmenuitem.Text) + { + toolstripmenuitem.BackColor = Color.FromArgb(50, 50, 92, 219); + } + } + if (DynamicKeysManager.AESEntries != null) + { + string pak = DynamicKeysManager.AESEntries.Where(i => i.thePak == toolstripmenuitem.Text).Select(i => i.thePak).FirstOrDefault(); + string key = DynamicKeysManager.AESEntries.Where(i => i.thePak == toolstripmenuitem.Text).Select(i => i.theKey).FirstOrDefault(); + + if (!string.IsNullOrEmpty(key) && pak == toolstripmenuitem.Text) + { + toolstripmenuitem.BackColor = Color.FromArgb(50, 50, 92, 219); + } + } + } + } } }