fixed null exceptions on some challenges + fixed loading dynamic paks + new icon for weapon reload time + temporary reverted isFileLocked()

This commit is contained in:
Asval 2019-06-19 16:43:05 +02:00
parent d0350aeb18
commit ab7fac0368
12 changed files with 75 additions and 23 deletions

View File

@ -250,6 +250,7 @@
<Content Include="DLLs\csharp-wick.dll" />
<Content Include="DLLs\ScintillaNET FindReplaceDialog.dll" />
<Content Include="FModel.ico" />
<None Include="Resources\reload64.png" />
<None Include="Resources\clipSize64.png" />
<None Include="Resources\LBolt64.png" />
<None Include="Resources\dmg64.png" />

View File

@ -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

View File

@ -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);

View File

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;

View File

@ -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)
{

View File

@ -71,7 +71,7 @@ namespace FModel
}
/// <summary>
/// find a better way to handle errors
/// todo: find a better way to handle errors
/// </summary>
/// <param name="theItem"></param>
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);
}
}

View File

@ -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));
}

View File

@ -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)
/// <summary>
/// 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
/// </summary>
/// <param name="theKey"></param>
/// <returns></returns>
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)

View File

@ -240,6 +240,16 @@ namespace FModel.Properties {
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap reload64 {
get {
object obj = ResourceManager.GetObject("reload64", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>

View File

@ -217,4 +217,7 @@
<data name="clipSize64" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\clipSize64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="reload64" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\reload64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -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
| <a href="https://github.com/SirWaddles" target="_blank">**Waddlesworth**</a> | <a href="https://github.com/AyeTSG" target="_blank">**AyeTSG**</a> | <a href="https://github.com/ItsFireMonkey" target="_blank">**FireMonkey**</a> | <a href="https://github.com/MaikyM" target="_blank">**Maiky M**</a> |
| <a href="https://github.com/SirWaddles" target="_blank">**Waddlesworth**</a> | <a href="https://github.com/MaikyM" target="_blank">**Maiky M**</a> | <a href="https://github.com/AyeTSG" target="_blank">**AyeTSG**</a> | <a href="https://github.com/ItsFireMonkey" target="_blank">**FireMonkey**</a> |
| :---: | :---: | :---: | :---: |
| [![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) |
| <a href="https://github.com/SirWaddles" target="_blank">`https://github.com/SirWaddles`</a> | <a href="https://twitter.com/AyeTSG" target="_blank">`https://twitter.com/AyeTSG`</a> | <a href="https://twitter.com/FireMonkeyFN" target="_blank">`https://twitter.com/FireMonkeyFN`</a> |<a href="https://twitter.com/MaikyMOficial" target="_blank">`https://twitter.com/MaikyMOficial`</a> |
| [![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) |
| <a href="https://github.com/SirWaddles" target="_blank">`https://github.com/SirWaddles`</a> | <a href="https://twitter.com/MaikyMOficial" target="_blank">`https://twitter.com/MaikyMOficial`</a> | <a href="https://twitter.com/AyeTSG" target="_blank">`https://twitter.com/AyeTSG`</a> | <a href="https://twitter.com/FireMonkeyFN" target="_blank">`https://twitter.com/FireMonkeyFN`</a> |
### 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