From 44c0b538524809259f11c5cf477b1e01606333ed Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 30 Sep 2017 20:57:32 -0700 Subject: [PATCH] Provide map for Z Crystals KeyItem->HeldItem allows for loading sprites for the key items (they're smaller than the key item but better than missingno sprite) Closes #1504 --- PKHeX.Core/Legality/Tables7.cs | 3 +++ PKHeX.WinForms/Util/PKMUtil.cs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Legality/Tables7.cs b/PKHeX.Core/Legality/Tables7.cs index d2444ce89..97826d169 100644 --- a/PKHeX.Core/Legality/Tables7.cs +++ b/PKHeX.Core/Legality/Tables7.cs @@ -102,6 +102,9 @@ namespace PKHeX.Core internal static readonly ushort[] Pouch_ZCrystalHeld_SM = { // Piece 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 798, 799, 800, 801, 802, 803, 804, 805, 806, 836 }; + public static readonly Dictionary ZCrystalDictionary = Pouch_ZCrystal_SM + .Zip(Pouch_ZCrystalHeld_SM, (k, v) => new { Key = (int)k, Value = (int)v }) + .ToDictionary(x => x.Key, x => x.Value); internal static readonly ushort[] HeldItems_SM = new ushort[1].Concat(Pouch_Items_SM).Concat(Pouch_Berries_SM).Concat(Pouch_Medicine_SM).Concat(Pouch_ZCrystalHeld_SM).ToArray(); private static readonly HashSet WildPokeballs7 = new HashSet { diff --git a/PKHeX.WinForms/Util/PKMUtil.cs b/PKHeX.WinForms/Util/PKMUtil.cs index 6ae4d9447..6ec74d0f2 100644 --- a/PKHeX.WinForms/Util/PKMUtil.cs +++ b/PKHeX.WinForms/Util/PKMUtil.cs @@ -101,7 +101,12 @@ namespace PKHeX.WinForms else if (gift.IsPokémon) img = GetSprite(gift.ConvertToPKM(SAV)); else if (gift.IsItem) - img = (Image)(Resources.ResourceManager.GetObject("item_" + gift.ItemID) ?? Resources.unknown); + { + int item = gift.ItemID; + if (Legal.ZCrystalDictionary.TryGetValue(item, out int value)) + item = value; + img = (Image)(Resources.ResourceManager.GetObject("item_" + item) ?? Resources.unknown); + } else img = Resources.unknown;