From ab7fac0368e5d60c372fce602c51218598c7d2aa Mon Sep 17 00:00:00 2001 From: Asval Date: Wed, 19 Jun 2019 16:43:05 +0200 Subject: [PATCH] fixed null exceptions on some challenges + fixed loading dynamic paks + new icon for weapon reload time + temporary reverted isFileLocked() --- FModel/FModel.csproj | 1 + FModel/Forms/About.Designer.cs | 4 +-- FModel/MainWindow.cs | 28 +++++++++++++++--- .../Methods/AESManager/DynamicKeysManager.cs | 4 +-- .../Methods/ChallengeGenerator/BundleInfos.cs | 13 ++++++-- FModel/Methods/IconGenerator/DrawText.cs | 14 +++++---- .../IconGenerator/Translations/LoadLocRes.cs | 2 ++ .../Translations/SearchResource.cs | 12 ++++++-- FModel/Properties/Resources.Designer.cs | 10 +++++++ FModel/Properties/Resources.resx | 3 ++ FModel/Resources/reload64.png | Bin 0 -> 1311 bytes README.md | 7 ++--- 12 files changed, 75 insertions(+), 23 deletions(-) create mode 100644 FModel/Resources/reload64.png diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index 9c5804a3..d93e65b7 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -250,6 +250,7 @@ + diff --git a/FModel/Forms/About.Designer.cs b/FModel/Forms/About.Designer.cs index 32286cbf..a92c7b02 100644 --- a/FModel/Forms/About.Designer.cs +++ b/FModel/Forms/About.Designer.cs @@ -110,9 +110,9 @@ this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Location = new System.Drawing.Point(53, 124); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(277, 13); + this.label4.Size = new System.Drawing.Size(241, 13); this.label4.TabIndex = 11; - this.label4.Text = "• Asval • Waddlesworth • AyeTSG • FireMonkey • Maiky M"; + this.label4.Text = "• Waddlesworth • Maiky M • AyeTSG • FireMonkey"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // About diff --git a/FModel/MainWindow.cs b/FModel/MainWindow.cs index 5bdeb555..e2451ba2 100644 --- a/FModel/MainWindow.cs +++ b/FModel/MainWindow.cs @@ -120,7 +120,22 @@ namespace FModel for (int i = 0; i < yourPaKs.Count(); i++) { string arCurrentUsedPak = yourPaKs.ElementAt(i); //SET CURRENT PAK - if (!Utilities.IsFileLocked(new System.IO.FileInfo(arCurrentUsedPak))) + string arCurrentUsedPakGuid = ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + Path.GetFileName(arCurrentUsedPak)); //SET CURRENT PAK GUID + + if (arCurrentUsedPakGuid == "0-0-0-0") + { + ThePak.mainPaksList.Add(new PaksEntry(Path.GetFileName(arCurrentUsedPak), arCurrentUsedPakGuid)); + AddPaKs(Path.GetFileName(arCurrentUsedPak)); //add to toolstrip + } + if (arCurrentUsedPakGuid != "0-0-0-0") + { + ThePak.dynamicPaksList.Add(new PaksEntry(Path.GetFileName(arCurrentUsedPak), arCurrentUsedPakGuid)); + AddPaKs(Path.GetFileName(arCurrentUsedPak)); //add to toolstrip + } + + //IT'S TRIGGERED WHEN FORTNITE IS RUNNING BUT FILES CAN BE READ AND I WANT IT TO BE TRIGGERED WHEN FILE IS FULLY LOCKED AND CAN'T BE USED AT ALL + //aka while you're updating the game + /*if (!Utilities.IsFileLocked(new System.IO.FileInfo(arCurrentUsedPak))) { string arCurrentUsedPakGuid = ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + Path.GetFileName(arCurrentUsedPak)); //SET CURRENT PAK GUID @@ -135,7 +150,7 @@ namespace FModel AddPaKs(Path.GetFileName(arCurrentUsedPak)); //add to toolstrip } } - else { AppendText(Path.GetFileName(arCurrentUsedPak) + " is locked by another process.", Color.Red, true); } + else { AppendText(Path.GetFileName(arCurrentUsedPak) + " is locked by another process.", Color.Red, true); }*/ } } } @@ -473,6 +488,12 @@ namespace FModel })); } } + else + { + AppendText("Canceled! ", Color.Red); + AppendText("All pak files loaded...", Color.Black, true); + return; + } if (File.Exists(App.DefaultOutputPath + "\\Result.txt")) { @@ -543,7 +564,7 @@ namespace FModel //ADD TO DICTIONNARY RegisterPaKsinDict(null, true); - if (!File.Exists(App.DefaultOutputPath + "\\FortnitePAKs.txt")) + if (new System.IO.FileInfo(App.DefaultOutputPath + "\\FortnitePAKs.txt").Length <= 0) { UpdateConsole("Can't read .PAK files with this key", Color.FromArgb(255, 244, 66, 66), "Error"); } @@ -1285,7 +1306,6 @@ namespace FModel DrawText.DrawTexts(theItem, g, specialMode); - UpdateConsole(theItem.DisplayName.SourceString, Color.FromArgb(255, 66, 244, 66), "Success"); if (autoSaveImagesToolStripMenuItem.Checked || updateModeToolStripMenuItem.Checked) { bmp.Save(App.DefaultOutputPath + "\\Icons\\" + ThePak.CurrentUsedItem + ".png", ImageFormat.Png); diff --git a/FModel/Methods/AESManager/DynamicKeysManager.cs b/FModel/Methods/AESManager/DynamicKeysManager.cs index db2773f9..a6fb4300 100644 --- a/FModel/Methods/AESManager/DynamicKeysManager.cs +++ b/FModel/Methods/AESManager/DynamicKeysManager.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Configuration; +using System.Collections.Generic; using System.IO; using System.Xml.Serialization; diff --git a/FModel/Methods/ChallengeGenerator/BundleInfos.cs b/FModel/Methods/ChallengeGenerator/BundleInfos.cs index 5f3e2863..e9a67d4e 100644 --- a/FModel/Methods/ChallengeGenerator/BundleInfos.cs +++ b/FModel/Methods/ChallengeGenerator/BundleInfos.cs @@ -113,10 +113,17 @@ namespace FModel if (questParser[x].ObjectiveCompletionCount > 0) newCount = questParser[x].ObjectiveCompletionCount; + //fortbyte check bool isFortbyte = false; - var assetTypeToken = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name == "Token").FirstOrDefault(); - if (assetTypeToken != null) - isFortbyte = assetTypeToken.ItemPrimaryAssetId.PrimaryAssetName == "AthenaFortbyte"; + Parser.Quests.Reward assetTypeToken = null; + if (questParser[x].Rewards != null) //this caused a null exception for some challenges (most of them in the Styles folder) + { + assetTypeToken = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name == "Token").FirstOrDefault(); + if (assetTypeToken != null) + { + isFortbyte = assetTypeToken.ItemPrimaryAssetId.PrimaryAssetName == "AthenaFortbyte"; + } + } if (newQuest != oldQuest && newCount != oldCount) { diff --git a/FModel/Methods/IconGenerator/DrawText.cs b/FModel/Methods/IconGenerator/DrawText.cs index 2e19d009..b0f5cfd3 100644 --- a/FModel/Methods/IconGenerator/DrawText.cs +++ b/FModel/Methods/IconGenerator/DrawText.cs @@ -71,7 +71,7 @@ namespace FModel } /// - /// find a better way to handle errors + /// todo: find a better way to handle errors /// /// private static void SetTexts(ItemsIdParser theItem) @@ -366,17 +366,21 @@ namespace FModel { foreach (JToken token in jo.FindTokens(weaponName)) { - var statParsed = Parser.Weapons.WeaponStatParser.FromJson(token.ToString()); + Parser.Weapons.WeaponStatParser statParsed = Parser.Weapons.WeaponStatParser.FromJson(token.ToString()); Image bulletImage = Resources.dmg64; myGraphic.DrawImage(ImageUtilities.ResizeImage(bulletImage, 15, 15), new Point(5, 500)); + DrawToLeft(" " + statParsed.DmgPb, myGraphic); //damage per bullet Image clipSizeImage = Resources.clipSize64; myGraphic.DrawImage(ImageUtilities.ResizeImage(clipSizeImage, 15, 15), new Point(52, 500)); - - DrawToRight("Reload Time: " + statParsed.ReloadTime + " seconds", myGraphic); - DrawToLeft(" " + statParsed.DmgPb, myGraphic); //damage per bullet myGraphic.DrawString(" " + statParsed.ClipSize, new Font(FontUtilities.pfc.Families[0], 13), new SolidBrush(Color.White), new Point(50, 500)); + + Image reload = Resources.reload64; + myGraphic.DrawImage(ImageUtilities.ResizeImage(reload, 15, 15), new Point(50 + (statParsed.ClipSize.ToString().Length * 7) + 47, 500)); //50=clipsize text position | for each clipsize letter we add 7 to x | 47=difference between 2 icons + myGraphic.DrawString(statParsed.ReloadTime + " seconds", new Font(FontUtilities.pfc.Families[0], 13), new SolidBrush(Color.White), new Point(64 + (statParsed.ClipSize.ToString().Length * 7) + 47, 500)); //64=50+icon size (-1 because that wasn't perfectly at the position i wanted) + + DrawToRight(weaponName, myGraphic); } } diff --git a/FModel/Methods/IconGenerator/Translations/LoadLocRes.cs b/FModel/Methods/IconGenerator/Translations/LoadLocRes.cs index 12f0bad5..b8c2c81e 100644 --- a/FModel/Methods/IconGenerator/Translations/LoadLocRes.cs +++ b/FModel/Methods/IconGenerator/Translations/LoadLocRes.cs @@ -41,6 +41,7 @@ namespace FModel if (ThePak.AllpaksDictionary != null && ThePak.AllpaksDictionary["Game_BR.locres"] != null) { string oldKey = JohnWick.MyKey; //get the old key + string oldGuid = ThePak.CurrentUsedPakGuid; //get the old guid JohnWick.MyKey = Properties.Settings.Default.AESKey; //set the main key to extract ThePak.CurrentUsedPakGuid = "0-0-0-0"; //fake the guid -> writeFile need this guid to get the mountPoint, otherwise it crashes @@ -48,6 +49,7 @@ namespace FModel string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres"); JohnWick.MyKey = oldKey; //set the old key + ThePak.CurrentUsedPakGuid = oldGuid; //set the old guid return LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage)); } diff --git a/FModel/Methods/IconGenerator/Translations/SearchResource.cs b/FModel/Methods/IconGenerator/Translations/SearchResource.cs index 4818606a..0d2f976c 100644 --- a/FModel/Methods/IconGenerator/Translations/SearchResource.cs +++ b/FModel/Methods/IconGenerator/Translations/SearchResource.cs @@ -9,7 +9,14 @@ namespace FModel private static JObject jo { get; set; } private static string oldLanguage = Properties.Settings.Default.IconLanguage; - public static string getTranslatedText(string theNamespace) + /// + /// for most (if not all) of our translations there's no namespace so we just have to find the key in the string + /// once found, we only take the part between this key and we parse to get out LocResText + /// To improve speed, we check if the language has change or if JObject has never been loaded + /// + /// + /// + public static string getTranslatedText(string theKey) { string toReturn = string.Empty; string newLanguage = Properties.Settings.Default.IconLanguage; @@ -19,7 +26,8 @@ namespace FModel parsedJsonToCheck = JToken.Parse(LoadLocRes.myLocRes).ToString().TrimStart('[').TrimEnd(']'); jo = JObject.Parse(parsedJsonToCheck); } - foreach (JToken token in jo.FindTokens(theNamespace)) + + foreach (JToken token in jo.FindTokens(theKey)) { LocResParser LocResParse = LocResParser.FromJson(token.ToString()); if (LocResParse.LocResText != null) diff --git a/FModel/Properties/Resources.Designer.cs b/FModel/Properties/Resources.Designer.cs index 0629a9b4..597c3dfb 100644 --- a/FModel/Properties/Resources.Designer.cs +++ b/FModel/Properties/Resources.Designer.cs @@ -240,6 +240,16 @@ namespace FModel.Properties { } } + /// + /// Recherche une ressource localisée de type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap reload64 { + get { + object obj = ResourceManager.GetObject("reload64", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// diff --git a/FModel/Properties/Resources.resx b/FModel/Properties/Resources.resx index 3061a705..c04b08ba 100644 --- a/FModel/Properties/Resources.resx +++ b/FModel/Properties/Resources.resx @@ -217,4 +217,7 @@ ..\Resources\clipSize64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\reload64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/FModel/Resources/reload64.png b/FModel/Resources/reload64.png new file mode 100644 index 0000000000000000000000000000000000000000..1420f33d4c05a106352905393b3e29df8dbb009a GIT binary patch literal 1311 zcmV+)1>pLLP)z8$z3 z=*Stvn9&Qo0(@SSkj(%qi~$A8a!FfNKKdlxU4&aOa(1vl()K0@Z^Uj%H?@)hXG(f4 zg78MXC#k)t0Y%>d3xJn_i^A!5P5oz^YQC2HZ{$ zS8&Vw&=czsSP87o>Fr=LwjTiclkwl+6yR*2JsC1j%^80!@Sv-*jA3v^&a3mTq|U&X z*13|FN!paNuSc3S3UuTkvq92T1;*~nB|Vd)-$l(Z;7|qvI|>SKEYl@@kfHxSB#kfA zfSwGUza*(vqWJos*y- z26P4l-vYefe4S401J(z$b6%vhPhpdRndb>?vOc@=FfS1kfFquZxzl`NXPFI-17>+R z?rj0_1_QuWPn+4mg|-Tp0rQgyN*Z1*M7vyU42ZVScF<+O+<<_aBZ&(^Z$O(XYzJKi zT;d64GBIBjrd=KmCojY_ST(r}@MU>+1HV_Vdl+_l>NC9qCV7H=myKH#9P)HB!FJGP zK$|DnFRh_@7>;@Bty!kLNzo$7)Mmk#?;6Y^IA4bYwu3GMd}HdkfO$epObZygt(sg0Y!4uROUuZI zr2%cM%j>S$;8@`2WCMc>=9xMl__GM}lJEs^r6<%mwOZ}R#)Gaq;6%XgjETUdF;zM+ zH9-7lzzFdMY2*2uDRmo?PWR+xT_T1;q;5$wD$D^kmKy>S zqqFiRMK?=2A?eY?kXXV_4s6#SApX-LS>ef&rbQG!Q_{v{yN$2yi-A}FzgT$;h*`Sp zNYC^1yDm_CU;TNlYQSBR_B0UhNNL~g5NpG=t!%(TN!uL6=UCdGCaE`r_z|mBtzy7b zNzZ!7&uuuzY>V5ULHt2m-&GqhR?_2=20i3W{g~vO8#C?;7=m@EuF`-dlD-WjZ#Flq zDX`nL)5W6-1Fo0!VMYPIJ0uPFrSXYrzu%7^LB}?(&7bO(ymzl=0H07J$ zg)T{LCG)VG;xeEKFfYj`0@fW#@{I#!Qz-j~iLB@WrUUDMzdh$piA5^*BB#mBK9CrZ zmUNAVs#baTCoe~{pz%#b9R5Ys%iNoikD0E9XFeLQR$1qNE_p0oNLHjqF^U)f{sBwH V&ykw8@#6ph002ovPDHLkV1k;4YAFB! literal 0 HcmV?d00001 diff --git a/README.md b/README.md index bc93da00..de64b781 100644 --- a/README.md +++ b/README.md @@ -74,10 +74,10 @@ Also if you find this project useful, feel free to give it a :star: thank you :k - [Find & Replace for ScintillaNET](https://www.nuget.org/packages/snt.ScintillaNet.FindReplaceDialog/) - [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) ### Contributors -| **Waddlesworth** | **AyeTSG** | **FireMonkey** | **Maiky M** | +| **Waddlesworth** | **Maiky M** | **AyeTSG** | **FireMonkey** | | :---: | :---: | :---: | :---: | -| [![Waddlesworth](https://avatars1.githubusercontent.com/u/769399?s=200&v=4)](https://github.com/SirWaddles) | [![AyeTSG](https://avatars1.githubusercontent.com/u/49595354?s=200&v=4)](https://github.com/AyeTSG) | [![FireMonkey](https://avatars2.githubusercontent.com/u/38590471?s=200&v=4)](https://github.com/ItsFireMonkey) | [![Maiky M](https://avatars3.githubusercontent.com/u/51415805?s=200&v=4)](https://github.com/MaikyM) | -| `https://github.com/SirWaddles` | `https://twitter.com/AyeTSG` | `https://twitter.com/FireMonkeyFN` |`https://twitter.com/MaikyMOficial` | +| [![Waddlesworth](https://avatars1.githubusercontent.com/u/769399?s=200&v=4)](https://github.com/SirWaddles) | [![Maiky M](https://avatars3.githubusercontent.com/u/51415805?s=200&v=4)](https://github.com/MaikyM) | [![AyeTSG](https://avatars1.githubusercontent.com/u/49595354?s=200&v=4)](https://github.com/AyeTSG) | [![FireMonkey](https://avatars2.githubusercontent.com/u/38590471?s=200&v=4)](https://github.com/ItsFireMonkey) | +| `https://github.com/SirWaddles` | `https://twitter.com/MaikyMOficial` | `https://twitter.com/AyeTSG` | `https://twitter.com/FireMonkeyFN` | ### Why FModel This project is mainly based on what [UModel](https://github.com/gildor2/UModel) can do, in a personalized way, in case UModel doesn't work, as a temporary rescue solution. I'd highly suggest you to use [UModel](https://github.com/gildor2/UModel) instead if you wanna use something made professionnaly. @@ -86,7 +86,6 @@ I'd highly suggest you to use [UModel](https://github.com/gildor2/UModel) instea - [ ] Code refactoring - [ ] 2FA support - [ ] Export Queue - - [ ] Nintendo Switch sound files - [x] Translation support - [x] AES Manager - [x] Display support for .locres files