//build base item data templates from base_items.min.json and item_classes.min.json, also builds core currencies and catalyst data public static int LoadBaseItems(string basesfile, string classesfile) { Dictionary <string, Dictionary <string, string> > classesdata = JsonSerializer.Deserialize <Dictionary <string, Dictionary <string, string> > >(File.ReadAllText(classesfile)); AllBaseItems = JsonSerializer.Deserialize <Dictionary <string, PoEBaseItemData> >(File.ReadAllText(basesfile)); CoreBaseItems = new Dictionary <string, PoEBaseItemData>(); Currencies = new Dictionary <string, PoECurrencyData>(); foreach (string k in AllBaseItems.Keys) { //set item_class_properties field with a lookup AllBaseItems[k].item_class_properties = classesdata[AllBaseItems[k].item_class]; //set key field AllBaseItems[k].key = k; //flag relevant items to move to core dictionary, "misc" domain only contains regular jewels as of 3.9 if (AllBaseItems[k].domain == "item" || AllBaseItems[k].domain == "misc" || AllBaseItems[k].domain == "abyss_jewel" || AllBaseItems[k].domain == "affliction_jewel") { CoreBaseItems.Add(k, AllBaseItems[k]); } //make currency or catalyst data if it's in the list of relevant currencies if (CurrencyIndex.Contains(AllBaseItems[k].name)) { PoECurrencyData currency = new PoECurrencyData() { key = k, name = AllBaseItems[k].name, tooltip = AllBaseItems[k].name }; string imgpath = "Icons/currency/" + AllBaseItems[k].name.Replace(" ", "").Replace("'", "") + ".png"; Uri imguri = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, imgpath)); try { BitmapImage img = new BitmapImage(imguri); currency.icon = img; } catch (Exception) { Debug.WriteLine("Can't find image " + imguri); currency.icon = null; } Currencies.Add(k, currency); } } AppendCurrencies(); Debug.WriteLine(CoreBaseItems.Count + " core, " + AllBaseItems.Count + " total base items loaded"); return(CoreBaseItems.Count); }
//Add special "currency" options private static void AppendCurrencies() { PoECurrencyData extra = new PoECurrencyData() { key = "RemoveCraftedMods", name = "Remove Crafted Mods", tooltip = "Remove Crafted Mods" }; string extrapath = "Icons/currency/RemoveCraftedMods.png"; Uri extrauri = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, extrapath)); try { BitmapImage extraimg = new BitmapImage(extrauri); extra.icon = extraimg; } catch (Exception) { Debug.WriteLine("Can't find image " + extrauri); extra.icon = null; } Currencies.Add("RemoveCraftedMods", extra); extra = new PoECurrencyData() { key = "DoNothing", name = "Do Nothing", tooltip = "Skip to Post-Craft Actions" }; extrapath = "Icons/currency/DoNothing.png"; extrauri = new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, extrapath)); try { BitmapImage extraimg = new BitmapImage(extrauri); extra.icon = extraimg; } catch (Exception) { Debug.WriteLine("Can't find image " + extrauri); extra.icon = null; } Currencies.Add("DoNothing", extra); }