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

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