private static void DrawCosmeticUff(JToken theItem, Graphics myGraphic) { if (tertiaryCategoriesArray == null) { string extractedCosmeticsSetsPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["ItemCategories"], "ItemCategories"); if (extractedCosmeticsSetsPath != null) { if (extractedCosmeticsSetsPath.Contains(".uasset") || extractedCosmeticsSetsPath.Contains(".uexp") || extractedCosmeticsSetsPath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(extractedCosmeticsSetsPath.Substring(0, extractedCosmeticsSetsPath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JToken tertiaryCategories = AssetData[0]["TertiaryCategories"]; if (tertiaryCategories != null) { tertiaryCategoriesArray = tertiaryCategories.Value <JArray>(); DrawCosmeticUffFromArray(theItem, myGraphic); } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } else { DrawCosmeticUffFromArray(theItem, myGraphic); } }
/// <summary> /// JohnWick is case sensitive so that way we search the item in the dictionary with CurrentCultureIgnoreCase and if he exists, we take his name /// so the name taken will be working for JohnWick /// </summary> /// <param name="item"></param> public static void DrawRewardIcon(string item) { ItemIcon.ItemIconPath = string.Empty; var value = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, item, StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault(); if (value != null) { string extractedIconPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[value], value); if (extractedIconPath != null) { if (extractedIconPath.Contains(".uasset") || extractedIconPath.Contains(".uexp") || extractedIconPath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(extractedIconPath.Substring(0, extractedIconPath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { var itemId = ItemsIdParser.FromJson(JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString()); for (int i = 0; i < itemId.Length; i++) { ItemIcon.SearchAthIteDefIcon(itemId[i]); drawIcon(item); } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } }
/// <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> private static void DrawWeaponStat(string weaponName, Graphics myGraphic) { if (jo == null) { 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(']'); jo = JObject.Parse(parsedJson); loopingLol(weaponName, myGraphic); } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } else { loopingLol(weaponName, myGraphic); } }
/// <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> private static void DrawWeaponStat(string filename, string weaponName, Graphics myGraphic) { if (weaponsStatsArray == null || !weaponStatsFilename.Equals(filename)) { ItemIcon.ItemIconPath = string.Empty; string extractedWeaponsStatPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[filename], filename); 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) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); weaponsStatsArray = JArray.FromObject(AssetData); weaponStatsFilename = filename; loopingLol(weaponName, myGraphic); } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } else { loopingLol(weaponName, myGraphic); } }
/// <summary> /// /// </summary> /// <param name="selectedLanguage"></param> /// <returns></returns> private static void getMyLocRes(string selectedLanguage) { if (ThePak.AllpaksDictionary != null) { if (ThePak.AllpaksDictionary.ContainsKey("Game_BR.locres")) { string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres"); LocResSerializer.setLocRes(locResPath.Replace("zh-Hant", selectedLanguage)); } else { new UpdateMyConsole("Game_BR.locres ", Color.Crimson).AppendToConsole(); new UpdateMyConsole("not found", Color.Black, true).AppendToConsole(); new UpdateMyConsole("Icon language set to ", Color.Black).AppendToConsole(); new UpdateMyConsole("English", Color.CornflowerBlue, true).AppendToConsole(); Properties.Settings.Default.IconLanguage = "English"; Properties.Settings.Default.Save(); } if (ThePak.AllpaksDictionary.ContainsKey("Game_StW.locres")) { string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_StW.locres"], "Game_StW.locres"); LocResSerializer.setLocRes(locResPath.Replace("zh-Hant", selectedLanguage), true); } else { new UpdateMyConsole("Game_StW.locres ", Color.Crimson).AppendToConsole(); new UpdateMyConsole("not found", Color.Black, true).AppendToConsole(); } } }
/// <summary> /// This is only triggered if ThePak.CurrentUsedItem is a weapon id, it's to display the bullet type /// extract, serialize and parse the ammoFile, search a Large or Small icon, display this icon at the top left of the rarity image /// </summary> /// <param name="ammoFile"></param> /// <param name="toDrawOn"></param> public static void GetAmmoData(string ammoFile, Graphics toDrawOn) { string ammoFilePath; if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") { ammoFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, ammoFile.Substring(ammoFile.LastIndexOf('.') + 1)); } else { ammoFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[ammoFile.Substring(ammoFile.LastIndexOf('.') + 1)], ammoFile.Substring(ammoFile.LastIndexOf('.') + 1)); } if (ammoFilePath != null) { if (ammoFilePath.Contains(".uasset") || ammoFilePath.Contains(".uexp") || ammoFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(ammoFilePath.Substring(0, ammoFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString(); var ammoId = ItemsIdParser.FromJson(parsedJson); for (int i = 0; i < ammoId.Length; i++) { SearchLargeSmallIcon(ammoId[i]); if (File.Exists(ItemIconPath)) { Image itemIcon; using (var bmpTemp = new Bitmap(ItemIconPath)) { itemIcon = new Bitmap(bmpTemp); } toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6)); } else { Image itemIcon = Resources.unknown512; toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6)); } } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } }
/// <summary> /// "BannerIcons" contains all banners id, their image path and more /// so basically we export and serialize "BannerIcons", locate where our banner id is, with FindTokens /// after that we only have what we want with token.ToString() -> "SmallImage", "LargeImage", "asset_path_name", "CategoryRowName", "DisplayName", "DisplayDescription" /// so we can just parse token.ToString() to properly get the LargeImage's asset_path_name or SmallImage's asset_path_name and draw /// </summary> /// <param name="bannerName"></param> public static void DrawRewardBanner(string bannerName) { ItemIcon.ItemIconPath = string.Empty; string extractedBannerPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["BannerIcons"], "BannerIcons"); if (extractedBannerPath != null) { if (extractedBannerPath.Contains(".uasset") || extractedBannerPath.Contains(".uexp") || extractedBannerPath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(extractedBannerPath.Substring(0, extractedBannerPath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); JToken bannerToken = ((JObject)AssetArray[0]).GetValue(bannerName, StringComparison.InvariantCultureIgnoreCase); if (bannerToken != null) { JToken largeImage = bannerToken["LargeImage"]; JToken smallImage = bannerToken["SmallImage"]; if (largeImage != null) { JToken assetPathName = largeImage["asset_path_name"]; if (assetPathName != null) { string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.')); ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile); drawIcon(); } } else if (smallImage != null) { JToken assetPathName = smallImage["asset_path_name"]; if (assetPathName != null) { string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.')); ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile); drawIcon(); } } } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } }
public static JToken setSchematicData(JToken schematicAsset) { schematicInfoList = new List <SchematicInfoEntry>(); JToken toReturn = null; JToken craftingRecipe = schematicAsset["CraftingRecipe"]; if (craftingRecipe != null) { JToken dataTable = craftingRecipe["DataTable"]; if (dataTable != null) { string dataTableFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[dataTable.Value <string>()], dataTable.Value <string>()); if (!string.IsNullOrEmpty(dataTableFilePath)) { if (dataTableFilePath.Contains(".uasset") || dataTableFilePath.Contains(".uexp") || dataTableFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(dataTableFilePath.Substring(0, dataTableFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); JToken weaponRowName = ((JObject)AssetArray[0]).GetValue(craftingRecipe["RowName"].Value <string>(), StringComparison.OrdinalIgnoreCase); if (weaponRowName != null) { toReturn = getSchematicRecipeResult(weaponRowName); registerSchematicRecipeCosts(weaponRowName); } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } } else { throw new ArgumentException("Not enough informations to create an icon about this schematic - Missing: \"CraftingRecipe\""); } return(toReturn); }
/// <summary> /// "BannerIcons" contains all banners id, their image path and more /// so basically we export and serialize "BannerIcons", locate where our banner id is, with FindTokens /// after that we only have what we want with token.ToString() -> "SmallImage", "LargeImage", "asset_path_name", "CategoryRowName", "DisplayName", "DisplayDescription" /// so we can just parse token.ToString() to properly get the LargeImage's asset_path_name or SmallImage's asset_path_name and draw /// </summary> /// <param name="bannerName"></param> public static void DrawRewardBanner(string bannerName) { ItemIcon.ItemIconPath = string.Empty; string extractedBannerPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["BannerIcons"], "BannerIcons"); if (extractedBannerPath != null) { if (extractedBannerPath.Contains(".uasset") || extractedBannerPath.Contains(".uexp") || extractedBannerPath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(extractedBannerPath.Substring(0, extractedBannerPath.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(bannerName)) { var bannerId = Parser.Banners.BannersParser.FromJson(token.ToString()); if (bannerId.LargeImage != null) { string textureFile = Path.GetFileName(bannerId.LargeImage.AssetPathName) ?.Substring(0, Path.GetFileName(bannerId.LargeImage.AssetPathName).LastIndexOf('.')); ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } else if (bannerId.SmallImage != null) { string textureFile = Path.GetFileName(bannerId.SmallImage.AssetPathName) ?.Substring(0, Path.GetFileName(bannerId.SmallImage.AssetPathName).LastIndexOf('.')); ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } drawIcon(bannerName); } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } }
private static string DrawCosmeticSet(string setName) { if (cosmeticsSetsArray == null) { string extractedCosmeticsSetsPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["CosmeticSets"], "CosmeticSets"); if (extractedCosmeticsSetsPath != null) { if (extractedCosmeticsSetsPath.Contains(".uasset") || extractedCosmeticsSetsPath.Contains(".uexp") || extractedCosmeticsSetsPath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(extractedCosmeticsSetsPath.Substring(0, extractedCosmeticsSetsPath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); cosmeticsSetsArray = JArray.FromObject(AssetData); return(searchSetName(setName)); } else { return(""); } } catch (JsonSerializationException) { return(""); //do not crash when JsonSerialization does weird stuff } } else { return(""); } } else { return(""); } } else { return(searchSetName(setName)); } }
/// <summary> /// JohnWick is case sensitive so that way we search the item in the dictionary with CurrentCultureIgnoreCase and if he exists, we take his name /// so the name taken will be working for JohnWick /// </summary> /// <param name="item"></param> public static void DrawRewardIcon(string item) { ItemIcon.ItemIconPath = string.Empty; var value = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, item, StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault(); if (value != null) { string extractedIconPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[value], value); if (extractedIconPath != null) { if (extractedIconPath.Contains(".uasset") || extractedIconPath.Contains(".uexp") || extractedIconPath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(extractedIconPath.Substring(0, extractedIconPath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); ItemIcon.SearchAthIteDefIcon(AssetArray[0]); drawIcon(); } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } else { drawIcon(); } } else { drawIcon(); } }
/// <summary> /// This is only triggered if ThePak.CurrentUsedItem is a weapon id, it's to display the bullet type /// extract, serialize and parse the ammoFile, search a Large or Small icon, display this icon at the top left of the rarity image /// </summary> /// <param name="ammoFile"></param> /// <param name="toDrawOn"></param> public static void GetAmmoData(string ammoFile, Graphics toDrawOn) { string ammoFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[ammoFile.Substring(ammoFile.LastIndexOf('.') + 1)], ammoFile.Substring(ammoFile.LastIndexOf('.') + 1)); if (ammoFilePath != null) { if (ammoFilePath.Contains(".uasset") || ammoFilePath.Contains(".uexp") || ammoFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(ammoFilePath.Substring(0, ammoFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); SearchLargeSmallIcon(AssetArray[0]); if (File.Exists(ItemIconPath)) { Image itemIcon; using (var bmpTemp = new Bitmap(ItemIconPath)) { itemIcon = new Bitmap(bmpTemp); } toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6)); } else { Image itemIcon = Resources.unknown512; toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6)); } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } }
/// <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 && 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 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))); } else { return(""); } }
public static JToken getSchematicRecipeResult(JToken schematicDataTable) { JToken toReturn = null; JToken recipeResults = schematicDataTable["RecipeResults"]; if (recipeResults != null) { JToken primaryAssetName = recipeResults[0]["ItemPrimaryAssetId"]["PrimaryAssetName"]; if (primaryAssetName != null) { string primaryAssetNameInDict = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, primaryAssetName.Value <string>(), StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault(); string primaryAssetTableFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[primaryAssetNameInDict], primaryAssetNameInDict); if (!string.IsNullOrEmpty(primaryAssetTableFilePath)) { if (primaryAssetTableFilePath.Contains(".uasset") || primaryAssetTableFilePath.Contains(".uexp") || primaryAssetTableFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(primaryAssetTableFilePath.Substring(0, primaryAssetTableFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic primaryAssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray primaryAssetArray = JArray.FromObject(primaryAssetData); toReturn = primaryAssetArray[0]; } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } } return(toReturn); }
public static void createIngredientIcon() { for (int i = 0; i < SchematicItemInfos.schematicInfoList.Count; i++) { string ingredientsFileName = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, SchematicItemInfos.schematicInfoList[i].theIngredientItemDefinition, StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault(); if (!string.IsNullOrEmpty(ingredientsFileName)) { string extractedIconPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[ingredientsFileName], ingredientsFileName); if (extractedIconPath != null) { if (extractedIconPath.Contains(".uasset") || extractedIconPath.Contains(".uexp") || extractedIconPath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(extractedIconPath.Substring(0, extractedIconPath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { new UpdateMyState("Drawing " + ingredientsFileName + "...", "Waiting").ChangeProcessState(); dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); fillSchematicIcon(AssetData[0], i); drawIngredientIcon(AssetData[0], i); drawDisplayNameAndQuantity(AssetData[0], SchematicItemInfos.schematicInfoList[i].theIngredientQuantity, i); } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } } }
/// <summary> /// extract quest and add description, count, reward item, reward quantity to List<BundleInfoEntry> BundleData /// loop if stage exist /// </summary> /// <param name="questFile"></param> private static void getQuestData(string questFile) { try { string questFilePath; if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") { questFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, questFile); } else { questFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[questFile], questFile); } if (questFilePath != null) { if (questFilePath.Contains(".uasset") || questFilePath.Contains(".uexp") || questFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(questFilePath.Substring(0, questFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { QuestParser[] questParser = QuestParser.FromJson(JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString()); for (int x = 0; x < questParser.Length; x++) { string oldQuest = string.Empty; long oldCount = 0; for (int p = 0; p < questParser[x].Objectives.Length; p++) { long newCount = questParser[x].Objectives[p].Count; if (questParser[x].ObjectiveCompletionCount > 0) { newCount = questParser[x].ObjectiveCompletionCount; } //fortbyte check bool isFortbyte = false; 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"; } } string newQuest = SearchResource.getTextByKey(questParser[x].Objectives[p].Description.Key, questParser[x].Objectives[p].Description.SourceString); if (newQuest != oldQuest && newCount != oldCount) { if (questParser[x].Rewards != null && !isFortbyte) { try { string rewardId = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest").Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token").FirstOrDefault().ItemPrimaryAssetId.PrimaryAssetName; string rewardQuantity = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest").Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token").FirstOrDefault().Quantity.ToString(); BundleData.Add(new BundleInfoEntry(newQuest, newCount, rewardId, rewardQuantity)); } catch (NullReferenceException) { if (questParser[x].HiddenRewards != null) { string rewardId = questParser[x].HiddenRewards.FirstOrDefault().TemplateId; string rewardQuantity = questParser[x].HiddenRewards.FirstOrDefault().Quantity.ToString(); BundleData.Add(new BundleInfoEntry(newQuest, newCount, rewardId, rewardQuantity)); } } //get stage for (int k = 0; k < questParser[x].Rewards.Length; k++) { string qAssetType = questParser[x].Rewards[k].ItemPrimaryAssetId.PrimaryAssetType.Name; string qAssetName = questParser[x].Rewards[k].ItemPrimaryAssetId.PrimaryAssetName; if (qAssetType == "Quest") { getQuestData(qAssetName); } } } else if (isFortbyte && assetTypeToken != null) { BundleData.Add(new BundleInfoEntry(newQuest, newCount, assetTypeToken.ItemPrimaryAssetId.PrimaryAssetName, questParser[x].Weight > 0 ? questParser[x].Weight.ToString() : "01")); } else { BundleData.Add(new BundleInfoEntry(newQuest, newCount, "", "")); } oldQuest = newQuest; oldCount = newCount; } } } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } catch (KeyNotFoundException) { //do not stop when questFile doesn't exist //Console.WriteLine("Can't extract " + questFile); } }
/// <summary> /// extract, serialize, get Large or Small image for HeroDefinition or WeaponDefinition /// if no HeroDefinition and WeaponDefinition move to SearchLargeSmallIcon /// </summary> /// <param name="theItem"></param> public static void SearchAthIteDefIcon(ItemsIdParser theItem) { if (theItem.HeroDefinition != null) { string heroFilePath; if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") { heroFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, theItem.HeroDefinition); } else { heroFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[theItem.HeroDefinition], theItem.HeroDefinition); } if (heroFilePath != null) { if (heroFilePath.Contains(".uasset") || heroFilePath.Contains(".uexp") || heroFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(heroFilePath.Substring(0, heroFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString(); var itemId = ItemsIdParser.FromJson(parsedJson); for (int i = 0; i < itemId.Length; i++) { if (itemId[i].LargePreviewImage != null) { string textureFile = Path.GetFileName(itemId[i].LargePreviewImage.AssetPathName) ?.Substring(0, Path.GetFileName(itemId[i].LargePreviewImage.AssetPathName) .LastIndexOf('.')); ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } else if (theItem.WeaponDefinition != null) { //MANUAL FIX if (theItem.WeaponDefinition == "WID_Harvest_Pickaxe_NutCracker") { theItem.WeaponDefinition = "WID_Harvest_Pickaxe_Nutcracker"; } if (theItem.WeaponDefinition == "WID_Harvest_Pickaxe_Wukong") { theItem.WeaponDefinition = "WID_Harvest_Pickaxe_WuKong"; } string weaponFilePath; if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") { weaponFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, theItem.WeaponDefinition); } else { weaponFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[theItem.WeaponDefinition], theItem.WeaponDefinition); } if (weaponFilePath != null) { if (weaponFilePath.Contains(".uasset") || weaponFilePath.Contains(".uexp") || weaponFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(weaponFilePath.Substring(0, weaponFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString(); var itemId = ItemsIdParser.FromJson(parsedJson); for (int i = 0; i < itemId.Length; i++) { if (itemId[i].LargePreviewImage != null) { string textureFile = Path.GetFileName(itemId[i].LargePreviewImage.AssetPathName) ?.Substring(0, Path.GetFileName(itemId[i].LargePreviewImage.AssetPathName) .LastIndexOf('.')); ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } else { SearchLargeSmallIcon(theItem); } }
private static void drawRewards(string itemId, string type, string quantity) { string value = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, itemId, StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault(); if (value != null) { string extractedIconPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[value], value); if (extractedIconPath != null) { if (extractedIconPath.Contains(".uasset") || extractedIconPath.Contains(".uexp") || extractedIconPath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(extractedIconPath.Substring(0, extractedIconPath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); ItemIcon.ItemIconPath = string.Empty; ItemIcon.SearchAthIteDefIcon(AssetArray[0]); if (File.Exists(ItemIcon.ItemIconPath)) { Image itemIcon; using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath)) { itemIcon = new Bitmap(bmpTemp); } BundleDesign.toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 48, 48), new Point(947, BundleDesign.theY + 12)); } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } GraphicsPath graphicsPath = null; switch (type) { case "athenabattlestar": { graphicsPath = new GraphicsPath(); drawPathAndFill(graphicsPath, quantity, Color.FromArgb(255, 143, 74, 32), Color.FromArgb(255, 255, 219, 103)); break; } case "AthenaSeasonalXP": { graphicsPath = new GraphicsPath(); drawPathAndFill(graphicsPath, quantity, Color.FromArgb(255, 81, 131, 15), Color.FromArgb(255, 230, 253, 177)); break; } case "MtxGiveaway": { graphicsPath = new GraphicsPath(); drawPathAndFill(graphicsPath, quantity, Color.FromArgb(255, 100, 160, 175), Color.FromArgb(255, 220, 230, 255)); break; } case "AthenaFortbyte": { BundleDesign.toDrawOn.DrawString("#" + Int32.Parse(quantity).ToString("D2"), new Font(FontUtilities.pfc.Families[1], 40), new SolidBrush(Color.White), new Point(975, BundleDesign.theY + 5), FontUtilities.rightString); break; } default: break; } if (graphicsPath != null) { graphicsPath.Dispose(); } }
/// <summary> /// if the catalogFile is in AllpaksDictionary (is known) extract, serialize the catalogFile and parse to get and convert the featured file to a png image /// </summary> /// <param name="theItem"></param> /// <param name="catName"></param> private static void GetFeaturedItemIcon(ItemsIdParser theItem, string catName) { if (ThePak.AllpaksDictionary.ContainsKey(catName)) { ThePak.CurrentUsedItem = catName; string catalogFilePath; if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0") { catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName); } else { catalogFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[catName], catName); } if (catalogFilePath != null) { Checking.WasFeatured = true; if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString(); var featuredId = FeaturedParser.FromJson(parsedJson); for (int i = 0; i < featuredId.Length; i++) { switch (catName) { case "DA_Featured_Glider_ID_070_DarkViking": case "DA_Featured_CID_319_Athena_Commando_F_Nautilus": if (featuredId[i].TileImage != null) { string textureFile = featuredId[i].TileImage.ResourceObject; ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } break; default: if (featuredId[i].DetailsImage != null) { string textureFile = featuredId[i].DetailsImage.ResourceObject; ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } break; } } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } else { GetItemIcon(theItem); } }
/// <summary> /// extract, serialize, get Large or Small image for HeroDefinition or WeaponDefinition /// if no HeroDefinition and WeaponDefinition move to SearchLargeSmallIcon /// </summary> /// <param name="theItem"></param> public static void SearchAthIteDefIcon(JToken theItem) { JToken heroDefinition = theItem["HeroDefinition"]; JToken weaponDefinition = theItem["WeaponDefinition"]; if (heroDefinition != null) { string heroFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[heroDefinition.Value <string>()], heroDefinition.Value <string>()); if (heroFilePath != null) { if (heroFilePath.Contains(".uasset") || heroFilePath.Contains(".uexp") || heroFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(heroFilePath.Substring(0, heroFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); JToken largePreviewImage = AssetArray[0]["LargePreviewImage"]; if (largePreviewImage != null) { JToken assetPathName = largePreviewImage["asset_path_name"]; if (assetPathName != null) { string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.')); ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } else if (weaponDefinition != null) { //STW PICKAXES MANUAL FIX if (weaponDefinition.Value <string>().Equals("WID_Harvest_Pickaxe_STWCosmetic_Tier")) { weaponDefinition = "WID_Harvest_Pickaxe_STWCosmetic_Tier_" + ThePak.CurrentUsedItem.Substring(ThePak.CurrentUsedItem.Length - 1); } string value = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, weaponDefinition.Value <string>(), StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault(); if (value != null) { string weaponFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[value], value); if (weaponFilePath != null) { if (weaponFilePath.Contains(".uasset") || weaponFilePath.Contains(".uexp") || weaponFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(weaponFilePath.Substring(0, weaponFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); JToken largePreviewImage = AssetArray[0]["LargePreviewImage"]; if (largePreviewImage != null) { JToken assetPathName = largePreviewImage["asset_path_name"]; if (assetPathName != null) { string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.')); ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } } else { SearchLargeSmallIcon(theItem); } }
/// <summary> /// extract quest and add description, count, reward item, reward quantity to List<BundleInfoEntry> BundleData /// loop if stage exist /// </summary> /// <param name="questFile"></param> private static void getQuestData(string questFile, JToken questInfo) { try { string questFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[questFile], questFile); if (questFilePath != null) { if (questFilePath.Contains(".uasset") || questFilePath.Contains(".uexp") || questFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(questFilePath.Substring(0, questFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { new UpdateMyState("Parsing " + questFile + "...", "Waiting").ChangeProcessState(); //prestige challenge check JToken questUnlockType = questInfo["QuestUnlockType"]; string unlockType = string.Empty; if (questUnlockType != null) { unlockType = questUnlockType.Value <string>(); } dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); //fortbyte check JToken rewards = AssetArray[0]["Rewards"]; JToken assetTypeToken = null; bool isFortbyte = false; if (rewards != null) { JArray rewardsArray = rewards.Value <JArray>(); assetTypeToken = rewardsArray.Where(item => item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Token")).FirstOrDefault(); if (assetTypeToken != null) { isFortbyte = rewardsArray.Any(item => item["ItemPrimaryAssetId"]["PrimaryAssetName"].Value <string>().Equals("AthenaFortbyte")); } } JToken objectives = AssetArray[0]["Objectives"]; if (objectives != null) { long questCount = 0; string descriptionKey = string.Empty; string descriptionSource = string.Empty; JArray objectivesArray = objectives.Value <JArray>(); foreach (JToken token in objectivesArray) { //quest count JToken count = token["Count"]; if (count != null) { questCount = count.Value <long>(); JToken objectiveCompletionCount = AssetArray[0]["ObjectiveCompletionCount"]; if (objectiveCompletionCount != null && objectiveCompletionCount.Value <long>() > 0) { questCount = objectiveCompletionCount.Value <long>(); } } //quest description JToken description = token["Description"]; if (description != null) { JToken key = description["key"]; JToken sourceString = description["source_string"]; if (key != null && sourceString != null) { descriptionKey = key.Value <string>(); descriptionSource = sourceString.Value <string>(); } } JToken descriptionMain = AssetArray[0]["Description"]; if (descriptionMain != null) { JToken key = descriptionMain["key"]; JToken sourceString = descriptionMain["source_string"]; if (key != null && sourceString != null) { descriptionKey = key.Value <string>(); descriptionSource = sourceString.Value <string>(); } } } string questDescription = SearchResource.getTextByKey(descriptionKey, descriptionSource); if (string.IsNullOrEmpty(questDescription)) { questDescription = " "; } if (rewards != null && !isFortbyte) { //quest rewards JArray rewardsArray = rewards.Value <JArray>(); try { string rewardId = rewardsArray.Where(item => !item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Quest") && !item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Token")).FirstOrDefault()["ItemPrimaryAssetId"]["PrimaryAssetName"].Value <string>(); string rewardQuantity = rewardsArray.Where(item => !item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Quest") && !item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Token")).FirstOrDefault()["Quantity"].Value <string>(); BundleInfoEntry currentData = new BundleInfoEntry(questDescription, questCount, rewardId, rewardQuantity, unlockType); bool isAlreadyAdded = BundleData.Any(item => item.questDescr.Equals(currentData.questDescr, StringComparison.InvariantCultureIgnoreCase) && item.questCount == currentData.questCount); if (!isAlreadyAdded) { BundleData.Add(currentData); } } catch (NullReferenceException) { JToken hiddenRewards = AssetArray[0]["HiddenRewards"]; if (hiddenRewards != null) { string rewardId = hiddenRewards[0]["TemplateId"].Value <string>(); string rewardQuantity = hiddenRewards[0]["Quantity"].Value <string>(); BundleInfoEntry currentData = new BundleInfoEntry(questDescription, questCount, rewardId, rewardQuantity, unlockType); bool isAlreadyAdded = BundleData.Any(item => item.questDescr.Equals(currentData.questDescr, StringComparison.InvariantCultureIgnoreCase) && item.questCount == currentData.questCount); if (!isAlreadyAdded) { BundleData.Add(currentData); } } } //quest stage foreach (JToken token in rewardsArray) { string qAssetType = token["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>(); string qAssetName = token["ItemPrimaryAssetId"]["PrimaryAssetName"].Value <string>(); if (qAssetType == "Quest") { getQuestData(qAssetName, questInfo); } } } else if (isFortbyte && assetTypeToken != null) { //thank you Quest_BR_S9_Fortbyte_04 JToken weight = AssetArray[0]["Weight"]; JToken weightToUse = null; if (weight != null) { weightToUse = weight; } BundleInfoEntry currentData = new BundleInfoEntry(questDescription, questCount, assetTypeToken["ItemPrimaryAssetId"]["PrimaryAssetName"].Value <string>(), weightToUse == null ? "01" : weightToUse.Value <string>(), unlockType); bool isAlreadyAdded = BundleData.Any(item => item.questDescr.Equals(currentData.questDescr, StringComparison.InvariantCultureIgnoreCase) && item.questCount == currentData.questCount); if (!isAlreadyAdded) { BundleData.Add(currentData); } } else { BundleInfoEntry currentData = new BundleInfoEntry(questDescription, questCount, "", "", unlockType); bool isAlreadyAdded = BundleData.Any(item => item.questDescr.Equals(currentData.questDescr, StringComparison.InvariantCultureIgnoreCase) && item.questCount == currentData.questCount); if (!isAlreadyAdded) { BundleData.Add(currentData); } } } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } catch (KeyNotFoundException) { new UpdateMyConsole("Can't extract " + questFile, Color.Crimson, true).AppendToConsole(); } }
/// <summary> /// if the catalogFile is in AllpaksDictionary (is known) extract, serialize the catalogFile and parse to get and convert the featured file to a png image /// </summary> /// <param name="theItem"></param> /// <param name="catName"></param> private static void GetFeaturedItemIcon(JToken theItem, string catName) { string value = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, catName, StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault(); if (value != null) { string catalogFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[value], value); if (!string.IsNullOrEmpty(catalogFilePath)) { Checking.WasFeatured = true; if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk")) { JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.'))); try { if (JohnWick.MyAsset.GetSerialized() != null) { ThePak.CurrentUsedItem = value; dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); switch (value) { case "DA_Featured_Glider_ID_070_DarkViking": case "DA_Featured_CID_319_Athena_Commando_F_Nautilus": JToken tileImage = AssetArray[0]["TileImage"]; if (tileImage != null) { JToken resourceObject = tileImage["ResourceObject"]; if (resourceObject != null) { string textureFile = resourceObject.Value <string>(); ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } } break; default: JToken detailsImage = AssetArray[0]["DetailsImage"]; if (detailsImage != null) { JToken resourceObject = detailsImage["ResourceObject"]; if (resourceObject != null) { string textureFile = resourceObject.Value <string>(); ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } } break; } // There is no featured image (as legends pack, shadow pack...) if (string.IsNullOrEmpty(ItemIconPath) || ItemIconPath.Contains("Athena\\Prototype\\Textures\\")) { GetItemIcon(theItem); } } } catch (JsonSerializationException) { //do not crash when JsonSerialization does weird stuff } } } } else { GetItemIcon(theItem); } }