searching weapon stats improved by 1 second + locres fix again

This commit is contained in:
Asval 2019-06-18 23:48:50 +02:00
parent cd7835032c
commit 273fab7e39
2 changed files with 52 additions and 29 deletions

View File

@ -21,6 +21,7 @@ namespace FModel
private static string HeroType { get; set; }
private static string DefenderType { get; set; }
private static string MinToMax { get; set; }
private static JObject jo { get; set; }
public static void DrawTexts(ItemsIdParser theItem, Graphics myGraphic, string mode)
{
@ -69,6 +70,10 @@ namespace FModel
DrawCosmeticUff(theItem, myGraphic);
}
/// <summary>
/// find a better way to handle errors
/// </summary>
/// <param name="theItem"></param>
private static void SetTexts(ItemsIdParser theItem)
{
CosmeticSource = "";
@ -330,41 +335,49 @@ namespace FModel
/// <param name="myGraphic"></param>
private static void DrawWeaponStat(string weaponName, Graphics myGraphic)
{
ItemIcon.ItemIconPath = string.Empty;
string extractedWeaponsStatPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["AthenaRangedWeapons"], "AthenaRangedWeapons");
if (extractedWeaponsStatPath != null)
if (jo == null)
{
if (extractedWeaponsStatPath.Contains(".uasset") || extractedWeaponsStatPath.Contains(".uexp") || extractedWeaponsStatPath.Contains(".ubulk"))
ItemIcon.ItemIconPath = string.Empty;
string extractedWeaponsStatPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["AthenaRangedWeapons"], "AthenaRangedWeapons");
if (extractedWeaponsStatPath != null)
{
JohnWick.MyAsset = new PakAsset(extractedWeaponsStatPath.Substring(0, extractedWeaponsStatPath.LastIndexOf('.')));
try
if (extractedWeaponsStatPath.Contains(".uasset") || extractedWeaponsStatPath.Contains(".uexp") || extractedWeaponsStatPath.Contains(".ubulk"))
{
if (JohnWick.MyAsset.GetSerialized() != null)
JohnWick.MyAsset = new PakAsset(extractedWeaponsStatPath.Substring(0, extractedWeaponsStatPath.LastIndexOf('.')));
try
{
string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString().TrimStart('[').TrimEnd(']');
JObject jo = JObject.Parse(parsedJson);
foreach (JToken token in jo.FindTokens(weaponName))
if (JohnWick.MyAsset.GetSerialized() != null)
{
var statParsed = Parser.Weapons.WeaponStatParser.FromJson(token.ToString());
Image bulletImage = Resources.dmg64;
myGraphic.DrawImage(ImageUtilities.ResizeImage(bulletImage, 15, 15), new Point(5, 500));
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));
string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString().TrimStart('[').TrimEnd(']');
jo = JObject.Parse(parsedJson);
loopingLol(weaponName, myGraphic);
}
}
}
catch (JsonSerializationException)
{
//do not crash when JsonSerialization does weird stuff
catch (JsonSerializationException)
{
//do not crash when JsonSerialization does weird stuff
}
}
}
}
else { loopingLol(weaponName, myGraphic); }
}
private static void loopingLol(string weaponName, Graphics myGraphic)
{
foreach (JToken token in jo.FindTokens(weaponName))
{
var statParsed = Parser.Weapons.WeaponStatParser.FromJson(token.ToString());
Image bulletImage = Resources.dmg64;
myGraphic.DrawImage(ImageUtilities.ResizeImage(bulletImage, 15, 15), new Point(5, 500));
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));
}
}
/// <summary>

View File

@ -30,14 +30,24 @@ namespace FModel
}
}
/// <summary>
/// 1. if loading a dynamic pak we have to switch between keys because the translation file is the main paks hence string oldKey is there
/// 2. smh if loading a dynamic pak, the guid isn't reset when registering, the temp solution is to fake the guid
/// </summary>
/// <param name="selectedLanguage"></param>
/// <returns></returns>
private static string getMyLocRes(string selectedLanguage)
{
if (ThePak.AllpaksDictionary != null)
if (ThePak.AllpaksDictionary != null && ThePak.AllpaksDictionary["Game_BR.locres"] != null)
{
string oldKey = JohnWick.MyKey;
JohnWick.MyKey = Properties.Settings.Default.AESKey;
string oldKey = JohnWick.MyKey; //get the old key
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
string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");
JohnWick.MyKey = oldKey;
JohnWick.MyKey = oldKey; //set the old key
return LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage));
}