mirror of
https://github.com/4sval/FModel.git
synced 2026-09-24 09:15:51 -05:00
added some basic stats to all weapon icons excluding pickaxes
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using FModel.Methods.BackupPAKs.Parser.AccessTokenParser;
|
||||
using FModel.Methods.BackupPAKs.Parser.AccessCodeParser;
|
||||
using FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser;
|
||||
using FModel.Methods.BackupPAKs.Parser.AccessCodeParser;
|
||||
using FModel.Methods.BackupPAKs.Parser.TokenParser;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -54,7 +53,7 @@ namespace FModel
|
||||
getAccessTokenRequest.AddHeader("Authorization", "basic MzQ0NmNkNzI2OTRjNGE0NDg1ZDgxYjc3YWRiYjIxNDE6OTIwOWQ0YTVlMjVhNDU3ZmI5YjA3NDg5ZDMxM2I0MWE=");
|
||||
getAccessTokenRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
return AccessTokenParser.FromJson(getAccessTokenClient.Execute(getAccessTokenRequest).Content).AccessToken;
|
||||
return TokenParser.FromJson(getAccessTokenClient.Execute(getAccessTokenRequest).Content).AccessToken;
|
||||
}
|
||||
private static string getAccessCode(string accessToken)
|
||||
{
|
||||
@@ -77,7 +76,7 @@ namespace FModel
|
||||
getExchangeTokenRequest.AddParameter("includePerms", true);
|
||||
getExchangeTokenRequest.AddParameter("token_type", "eg1");
|
||||
|
||||
return ExchangeTokenParser.FromJson(getExchangeTokenClient.Execute(getExchangeTokenRequest).Content).AccessToken;
|
||||
return TokenParser.FromJson(getExchangeTokenClient.Execute(getExchangeTokenRequest).Content).AccessToken;
|
||||
}
|
||||
|
||||
private static IEnumerable<string> SplitGuid(string str, int chunkSize)
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
// <auto-generated />
|
||||
//
|
||||
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
|
||||
//
|
||||
// using FModel.Methods.BackupPAKs.Parser.AccessTokenParser;
|
||||
//
|
||||
// var accessTokenParser = AccessTokenParser.FromJson(jsonString);
|
||||
|
||||
namespace FModel.Methods.BackupPAKs.Parser.AccessTokenParser
|
||||
{
|
||||
using System;
|
||||
|
||||
using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
public partial class AccessTokenParser
|
||||
{
|
||||
[JsonProperty("access_token")]
|
||||
public string AccessToken { get; set; }
|
||||
|
||||
[JsonProperty("expires_in")]
|
||||
public long ExpiresIn { get; set; }
|
||||
|
||||
[JsonProperty("expires_at")]
|
||||
public DateTimeOffset ExpiresAt { get; set; }
|
||||
|
||||
[JsonProperty("token_type")]
|
||||
public string TokenType { get; set; }
|
||||
|
||||
[JsonProperty("refresh_token")]
|
||||
public string RefreshToken { get; set; }
|
||||
|
||||
[JsonProperty("refresh_expires")]
|
||||
public long RefreshExpires { get; set; }
|
||||
|
||||
[JsonProperty("refresh_expires_at")]
|
||||
public DateTimeOffset RefreshExpiresAt { get; set; }
|
||||
|
||||
[JsonProperty("account_id")]
|
||||
public string AccountId { get; set; }
|
||||
|
||||
[JsonProperty("client_id")]
|
||||
public string ClientId { get; set; }
|
||||
|
||||
[JsonProperty("internal_client")]
|
||||
public bool InternalClient { get; set; }
|
||||
|
||||
[JsonProperty("client_service")]
|
||||
public string ClientService { get; set; }
|
||||
|
||||
[JsonProperty("lastPasswordValidation")]
|
||||
public DateTimeOffset LastPasswordValidation { get; set; }
|
||||
|
||||
[JsonProperty("perms")]
|
||||
public Perm[] Perms { get; set; }
|
||||
|
||||
[JsonProperty("app")]
|
||||
public string App { get; set; }
|
||||
|
||||
[JsonProperty("in_app_id")]
|
||||
public string InAppId { get; set; }
|
||||
}
|
||||
|
||||
public partial class Perm
|
||||
{
|
||||
[JsonProperty("resource")]
|
||||
public string Resource { get; set; }
|
||||
|
||||
[JsonProperty("action")]
|
||||
public long Action { get; set; }
|
||||
}
|
||||
|
||||
public partial class AccessTokenParser
|
||||
{
|
||||
public static AccessTokenParser FromJson(string json) => JsonConvert.DeserializeObject<AccessTokenParser>(json, FModel.Methods.BackupPAKs.Parser.AccessTokenParser.Converter.Settings);
|
||||
}
|
||||
|
||||
public static class Serialize
|
||||
{
|
||||
public static string ToJson(this AccessTokenParser self) => JsonConvert.SerializeObject(self, FModel.Methods.BackupPAKs.Parser.AccessTokenParser.Converter.Settings);
|
||||
}
|
||||
|
||||
internal static class Converter
|
||||
{
|
||||
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
|
||||
{
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
||||
DateParseHandling = DateParseHandling.None,
|
||||
Converters =
|
||||
{
|
||||
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
//
|
||||
// using FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser;
|
||||
//
|
||||
// var exchangeTokenParser = ExchangeTokenParser.FromJson(jsonString);
|
||||
// var TokenParser = ExchangeTokenParser.FromJson(jsonString);
|
||||
|
||||
namespace FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser
|
||||
namespace FModel.Methods.BackupPAKs.Parser.TokenParser
|
||||
{
|
||||
using System;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
public partial class ExchangeTokenParser
|
||||
public partial class TokenParser
|
||||
{
|
||||
[JsonProperty("access_token")]
|
||||
public string AccessToken { get; set; }
|
||||
@@ -68,14 +68,14 @@ namespace FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser
|
||||
public long Action { get; set; }
|
||||
}
|
||||
|
||||
public partial class ExchangeTokenParser
|
||||
public partial class TokenParser
|
||||
{
|
||||
public static ExchangeTokenParser FromJson(string json) => JsonConvert.DeserializeObject<ExchangeTokenParser>(json, FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser.Converter.Settings);
|
||||
public static TokenParser FromJson(string json) => JsonConvert.DeserializeObject<TokenParser>(json, FModel.Methods.BackupPAKs.Parser.TokenParser.Converter.Settings);
|
||||
}
|
||||
|
||||
public static class Serialize
|
||||
{
|
||||
public static string ToJson(this ExchangeTokenParser self) => JsonConvert.SerializeObject(self, FModel.Methods.BackupPAKs.Parser.ExchangeTokenParser.Converter.Settings);
|
||||
public static string ToJson(this TokenParser self) => JsonConvert.SerializeObject(self, FModel.Methods.BackupPAKs.Parser.TokenParser.Converter.Settings);
|
||||
}
|
||||
|
||||
internal static class Converter
|
||||
326
FModel/Methods/IconGenerator/DrawText.cs
Normal file
326
FModel/Methods/IconGenerator/DrawText.cs
Normal file
@@ -0,0 +1,326 @@
|
||||
using csharp_wick;
|
||||
using FModel.Parser.Items;
|
||||
using FModel.Properties;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace FModel
|
||||
{
|
||||
static class DrawText
|
||||
{
|
||||
private static string cosmeticSource { get; set; }
|
||||
private static string shortDescription { get; set; }
|
||||
private static string cosmeticId { get; set; }
|
||||
private static string maxStackSize { get; set; }
|
||||
private static string itemAction { get; set; }
|
||||
private static string weaponRowName { get; set; }
|
||||
private static string cosmeticUFF { get; set; }
|
||||
private static string heroType { get; set; }
|
||||
private static string defenderType { get; set; }
|
||||
private static string minToMax { get; set; }
|
||||
|
||||
public static void DrawTexts(ItemsIdParser theItem, Graphics myGraphic, string Mode)
|
||||
{
|
||||
DrawDisplayName(theItem, myGraphic);
|
||||
DrawDescription(theItem, myGraphic);
|
||||
|
||||
setTexts(theItem);
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
case "athIteDef":
|
||||
DrawToLeft(shortDescription, myGraphic);
|
||||
DrawToRight(cosmeticSource, myGraphic);
|
||||
break;
|
||||
case "consAndWeap":
|
||||
DrawToRight(itemAction, myGraphic);
|
||||
if (MainWindow.ExtractedFilePath.Contains("Items\\Consumables\\"))
|
||||
{
|
||||
DrawToLeft(maxStackSize, myGraphic);
|
||||
}
|
||||
break;
|
||||
case "variant":
|
||||
DrawToLeft(shortDescription, myGraphic);
|
||||
DrawToRight(cosmeticId, myGraphic);
|
||||
break;
|
||||
case "stwHeroes":
|
||||
DrawToRight(heroType, myGraphic);
|
||||
DrawToLeft(minToMax, myGraphic);
|
||||
break;
|
||||
case "stwDefenders":
|
||||
DrawToRight(defenderType, myGraphic);
|
||||
DrawToLeft(minToMax, myGraphic);
|
||||
break;
|
||||
}
|
||||
|
||||
if (theItem.ExportType == "AthenaItemWrapDefinition" && Checking.WasFeatured && ItemIcon.ItemIconPath.Contains("WeaponRenders"))
|
||||
{
|
||||
DrawAdditionalImage(theItem, myGraphic);
|
||||
}
|
||||
if (theItem.AmmoData != null && theItem.AmmoData.AssetPathName.Contains("Ammo")) //TO AVOID TRIGGERING CONSUMABLES, NAME SHOULD CONTAIN "AMMO"
|
||||
{
|
||||
ItemIcon.GetAmmoData(theItem.AmmoData.AssetPathName, myGraphic);
|
||||
DrawWeaponStat(weaponRowName, myGraphic);
|
||||
}
|
||||
|
||||
DrawCosmeticUFF(theItem, myGraphic);
|
||||
}
|
||||
|
||||
private static void setTexts(ItemsIdParser theItem)
|
||||
{
|
||||
cosmeticSource = "";
|
||||
shortDescription = "";
|
||||
cosmeticId = "";
|
||||
maxStackSize = "";
|
||||
itemAction = "";
|
||||
weaponRowName = "";
|
||||
cosmeticUFF = "";
|
||||
heroType = "";
|
||||
defenderType = "";
|
||||
minToMax = "";
|
||||
|
||||
try
|
||||
{
|
||||
shortDescription = theItem.ShortDescription;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
try
|
||||
{
|
||||
cosmeticSource = theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.Source."))].Substring(17);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
try
|
||||
{
|
||||
cosmeticId = theItem.CosmeticItem;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
try
|
||||
{
|
||||
maxStackSize = "Max Stack Size: " + theItem.MaxStackSize;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
try
|
||||
{
|
||||
itemAction = theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Athena.ItemAction."))].Substring(18);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
try
|
||||
{
|
||||
if (theItem.WeaponStatHandle.RowName != "Harvest_Pickaxe_Athena_C_T01")
|
||||
{
|
||||
weaponRowName = theItem.WeaponStatHandle.RowName;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
try
|
||||
{
|
||||
cosmeticUFF = theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("Cosmetics.UserFacingFlags."))];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
try
|
||||
{
|
||||
heroType = theItem.AttributeInitKey.AttributeInitCategory;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
try
|
||||
{
|
||||
defenderType = theItem.GameplayTags.GameplayTagsGameplayTags[Array.FindIndex(theItem.GameplayTags.GameplayTagsGameplayTags, x => x.StartsWith("NPC.CharacterType.Survivor.Defender."))].Substring(36);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
try
|
||||
{
|
||||
minToMax = "Power " + theItem.MinLevel + " to " + theItem.MaxLevel;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//avoid generator to stop when a string isn't found
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// search for a known Cosmetics.UserFacingFlags, if found draw the uff icon
|
||||
/// Cosmetics.UserFacingFlags icons are basically the style icon or the animated/reactive/traversal icon
|
||||
/// </summary>
|
||||
/// <param name="theItem"></param>
|
||||
/// <param name="myGraphic"></param>
|
||||
private static void DrawCosmeticUFF(ItemsIdParser theItem, Graphics myGraphic)
|
||||
{
|
||||
if (cosmeticUFF != null)
|
||||
{
|
||||
if (cosmeticUFF.Contains("Animated"))
|
||||
{
|
||||
Image animatedLogo = Resources.T_Icon_Animated_64;
|
||||
myGraphic.DrawImage(ImageUtilities.ResizeImage(animatedLogo, 32, 32), new Point(6, -2));
|
||||
}
|
||||
else if (cosmeticUFF.Contains("HasUpgradeQuests") && theItem.ExportType != "AthenaPetCarrierItemDefinition")
|
||||
{
|
||||
Image questLogo = Resources.T_Icon_Quests_64;
|
||||
myGraphic.DrawImage(ImageUtilities.ResizeImage(questLogo, 32, 32), new Point(6, 6));
|
||||
}
|
||||
else if (cosmeticUFF.Contains("HasUpgradeQuests") && theItem.ExportType == "AthenaPetCarrierItemDefinition")
|
||||
{
|
||||
Image petLogo = Resources.T_Icon_Pets_64;
|
||||
myGraphic.DrawImage(ImageUtilities.ResizeImage(petLogo, 32, 32), new Point(6, 6));
|
||||
}
|
||||
else if (cosmeticUFF.Contains("HasVariants"))
|
||||
{
|
||||
Image variantsLogo = Resources.T_Icon_Variant_64;
|
||||
myGraphic.DrawImage(ImageUtilities.ResizeImage(variantsLogo, 32, 32), new Point(6, 6));
|
||||
}
|
||||
else if (cosmeticUFF.Contains("Reactive"))
|
||||
{
|
||||
Image reactiveLogo = Resources.T_Icon_Adaptive_64;
|
||||
myGraphic.DrawImage(ImageUtilities.ResizeImage(reactiveLogo, 32, 32), new Point(7, 7));
|
||||
}
|
||||
else if (cosmeticUFF.Contains("Traversal"))
|
||||
{
|
||||
Image traversalLogo = Resources.T_Icon_Traversal_64;
|
||||
myGraphic.DrawImage(ImageUtilities.ResizeImage(traversalLogo, 32, 32), new Point(6, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw item name if exist
|
||||
/// </summary>
|
||||
/// <param name="theItem"></param>
|
||||
/// <param name="myGraphic"></param>
|
||||
private static void DrawDisplayName(ItemsIdParser theItem, Graphics myGraphic)
|
||||
{
|
||||
if (theItem.DisplayName != null)
|
||||
{
|
||||
myGraphic.DrawString(theItem.DisplayName, new Font(FontUtilities.pfc.Families[0], 35), new SolidBrush(Color.White), new Point(522 / 2, 395), FontUtilities.centeredString);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw item description if exist
|
||||
/// </summary>
|
||||
/// <param name="theItem"></param>
|
||||
/// <param name="myGraphic"></param>
|
||||
private static void DrawDescription(ItemsIdParser theItem, Graphics myGraphic)
|
||||
{
|
||||
if (theItem.Description != null)
|
||||
{
|
||||
myGraphic.DrawString(theItem.Description, new Font("Arial", 10), new SolidBrush(Color.White), new RectangleF(5, 441, 512, 49), FontUtilities.centeredStringLine);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw text at bottom right
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="myGraphic"></param>
|
||||
private static void DrawToRight(string text, Graphics myGraphic)
|
||||
{
|
||||
myGraphic.DrawString(text, new Font(FontUtilities.pfc.Families[0], 13), new SolidBrush(Color.White), new Point(522 - 5, 500), FontUtilities.rightString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// draw text at bottom left
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="myGraphic"></param>
|
||||
private static void DrawToLeft(string text, Graphics myGraphic)
|
||||
{
|
||||
myGraphic.DrawString(text, new Font(FontUtilities.pfc.Families[0], 13), new SolidBrush(Color.White), new Point(5, 500));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// this is only triggered for wraps, in case the featured (weapon render) image is drawn
|
||||
/// also draw the non featured image to make it clear it's a wrap, not a weapon
|
||||
/// </summary>
|
||||
/// <param name="theItem"></param>
|
||||
/// <param name="myGraphic"></param>
|
||||
private static void DrawAdditionalImage(ItemsIdParser theItem, Graphics myGraphic)
|
||||
{
|
||||
string wrapAddImg = theItem.LargePreviewImage.AssetPathName.Substring(theItem.LargePreviewImage.AssetPathName.LastIndexOf(".", StringComparison.Ordinal) + 1);
|
||||
|
||||
ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(wrapAddImg);
|
||||
|
||||
if (File.Exists(ItemIcon.ItemIconPath))
|
||||
{
|
||||
Image itemIcon;
|
||||
using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath))
|
||||
{
|
||||
itemIcon = new Bitmap(bmpTemp);
|
||||
}
|
||||
myGraphic.DrawImage(ImageUtilities.ResizeImage(itemIcon, 122, 122), new Point(395, 282));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// this is only triggered for weapons
|
||||
/// draw the damage per bullet as well as the reload time
|
||||
/// </summary>
|
||||
/// <param name="weaponName"></param>
|
||||
/// <param name="myGraphic"></param>
|
||||
public static void DrawWeaponStat(string weaponName, Graphics myGraphic)
|
||||
{
|
||||
ItemIcon.ItemIconPath = string.Empty;
|
||||
string extractedWeaponsStatPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["AthenaRangedWeapons"], "AthenaRangedWeapons");
|
||||
if (extractedWeaponsStatPath != null)
|
||||
{
|
||||
if (extractedWeaponsStatPath.Contains(".uasset") || extractedWeaponsStatPath.Contains(".uexp") || extractedWeaponsStatPath.Contains(".ubulk"))
|
||||
{
|
||||
JohnWick.MyAsset = new PakAsset(extractedWeaponsStatPath.Substring(0, extractedWeaponsStatPath.LastIndexOf('.')));
|
||||
try
|
||||
{
|
||||
if (JohnWick.MyAsset.GetSerialized() != null)
|
||||
{
|
||||
string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString().TrimStart('[').TrimEnd(']');
|
||||
JObject jo = JObject.Parse(parsedJson);
|
||||
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));
|
||||
|
||||
if (statParsed.DmgPb != 0 && statParsed.ClipSize != 0)
|
||||
{
|
||||
DrawToRight("Reload Time: " + statParsed.ReloadTime + " seconds", myGraphic);
|
||||
DrawToLeft(" " + statParsed.DmgPb, myGraphic); //damage per bullet
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JsonSerializationException)
|
||||
{
|
||||
//do not crash when JsonSerialization does weird stuff
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user