diff --git a/PKHeX.Core/Legality/Tables6.cs b/PKHeX.Core/Legality/Tables6.cs index 8677c1e3a..8820960b1 100644 --- a/PKHeX.Core/Legality/Tables6.cs +++ b/PKHeX.Core/Legality/Tables6.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; namespace PKHeX.Core { @@ -473,6 +474,11 @@ namespace PKHeX.Core }, new[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // Region matching }; + public static readonly HashSet MemoryGeneral = new HashSet { 1, 2, 3, 4, 19, 24, 31, 32, 33, 35, 36, 37, 38, 39, 42, 52, 59 }; + public static readonly HashSet MemorySpecific = new HashSet { 6 }; + public static readonly HashSet MemoryMove = new HashSet { 12, 16, 48, 49 }; + public static readonly HashSet MemoryItem = new HashSet { 5, 15, 26, 34, 40, 51 }; + public static readonly HashSet MemorySpecies = new HashSet { 7, 9, 13, 14, 17, 21, 18, 25, 29, 44, 45, 50, 60 }; #endregion internal static readonly int[] MovePP_XY = diff --git a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs index 36fe198a8..55bf74277 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/MemoryAmie.cs @@ -222,7 +222,7 @@ namespace PKHeX.WinForms CB_OTFeel.Items.Add(GameInfo.Strings.memories[10 + i]); } } - private void GetMemoryArguments(string ARG, ComboBox sender) + private void GetMemoryArguments(MemoryType ARG, object sender) { var argvals = Util.GetCBList(new[] { "" }, null); @@ -230,19 +230,19 @@ namespace PKHeX.WinForms bool enabled = true; switch (ARG) { - case "NONE": + case MemoryType.None: enabled = false; vs = ""; break; - case "PKM": + case MemoryType.Species: argvals = Util.GetCBList(GameInfo.Strings.specieslist.Take(pkm.MaxSpeciesID+1).ToArray(), null); vs = vartypes[0]; break; - case "GENLOC": + case MemoryType.GeneralLocation: argvals = Util.GetCBList(GameInfo.Strings.genloc, null); vs = vartypes[1]; break; - case "ITEM": + case MemoryType.Item: { #region Items int[] items_allowed = @@ -271,11 +271,11 @@ namespace PKHeX.WinForms vs = vartypes[2]; } break; - case "MOVE": + case MemoryType.Move: argvals = Util.GetCBList(GameInfo.Strings.movelist.Take(622).ToArray(), null); // Hyperspace Fury vs = vartypes[3]; break; - case "LOCATION": + case MemoryType.SpecificLocation: argvals = Util.GetCBList(GameInfo.Strings.metXY_00000, Legal.Met_XY_0); vs = vartypes[4]; break; @@ -298,18 +298,20 @@ namespace PKHeX.WinForms LOTV.Visible = CB_OTVar.Visible = CB_OTVar.Enabled = enabled; } } - private string GetMemoryString(ComboBox m, ComboBox arg, ComboBox q, ComboBox f, string tr) + private string GetMemoryString(ComboBox m, Control arg, Control q, Control f, string tr) { string result; - string nn = pkm.Nickname; - string a = ((ComboItem)arg.SelectedItem).Text; + bool enabled; int mem = WinFormsUtil.GetIndex(m); - - bool enabled = false; if (mem == 0) + { result = GameInfo.Strings.memories[38]; + enabled = false; + } else { + string nn = pkm.Nickname; + string a = arg.Text; result = string.Format(GameInfo.Strings.memories[mem + 38], nn, tr, a, f.Text, q.Text); enabled = true; } @@ -329,84 +331,34 @@ namespace PKHeX.WinForms private void ChangeMemory(object sender, EventArgs e) { ComboBox m = (ComboBox)sender; - if (m == CB_CTMemory || m == CB_OTMemory) - { - int memory = WinFormsUtil.GetIndex(m); - switch (memory) // Memory Case Switchtable - { - case 0: GetMemoryArguments("NONE", m); break; - case 1: GetMemoryArguments("GENLOC", m); break; - case 2: GetMemoryArguments("GENLOC", m); break; - case 3: GetMemoryArguments("GENLOC", m); break; - case 4: GetMemoryArguments("GENLOC", m); break; - case 5: GetMemoryArguments("ITEM", m); break; - case 6: GetMemoryArguments("LOCATION", m); break; - case 7: GetMemoryArguments("PKM", m); break; - case 8: GetMemoryArguments("NONE", m); break; - case 9: GetMemoryArguments("PKM", m); break; - case 10: GetMemoryArguments("NONE", m); break; - case 11: GetMemoryArguments("NONE", m); break; - case 12: GetMemoryArguments("MOVE", m); break; - case 13: GetMemoryArguments("PKM", m); break; - case 14: GetMemoryArguments("PKM", m); break; - case 15: GetMemoryArguments("ITEM", m); break; - case 16: GetMemoryArguments("MOVE", m); break; - case 17: GetMemoryArguments("PKM", m); break; - case 18: GetMemoryArguments("PKM", m); break; - case 19: GetMemoryArguments("GENLOC", m); break; - case 20: GetMemoryArguments("NONE", m); break; - case 21: GetMemoryArguments("PKM", m); break; - case 22: GetMemoryArguments("NONE", m); break; - case 23: GetMemoryArguments("NONE", m); break; - case 24: GetMemoryArguments("GENLOC", m); break; - case 25: GetMemoryArguments("PKM", m); break; - case 26: GetMemoryArguments("ITEM", m); break; - case 27: GetMemoryArguments("NONE", m); break; - case 28: GetMemoryArguments("NONE", m); break; - case 29: GetMemoryArguments("PKM", m); break; - case 30: GetMemoryArguments("NONE", m); break; - case 31: GetMemoryArguments("GENLOC", m); break; - case 32: GetMemoryArguments("GENLOC", m); break; - case 33: GetMemoryArguments("GENLOC", m); break; - case 34: GetMemoryArguments("ITEM", m); break; - case 35: GetMemoryArguments("GENLOC", m); break; - case 36: GetMemoryArguments("GENLOC", m); break; - case 37: GetMemoryArguments("GENLOC", m); break; - case 38: GetMemoryArguments("GENLOC", m); break; - case 39: GetMemoryArguments("GENLOC", m); break; - case 40: GetMemoryArguments("ITEM", m); break; - case 41: GetMemoryArguments("NONE", m); break; - case 42: GetMemoryArguments("GENLOC", m); break; - case 43: GetMemoryArguments("NONE", m); break; - case 44: GetMemoryArguments("PKM", m); break; - case 45: GetMemoryArguments("PKM", m); break; - case 46: GetMemoryArguments("NONE", m); break; - case 47: GetMemoryArguments("NONE", m); break; - case 48: GetMemoryArguments("MOVE", m); break; - case 49: GetMemoryArguments("MOVE", m); break; - case 50: GetMemoryArguments("PKM", m); break; - case 51: GetMemoryArguments("ITEM", m); break; - case 52: GetMemoryArguments("GENLOC", m); break; - case 53: GetMemoryArguments("NONE", m); break; - case 54: GetMemoryArguments("NONE", m); break; - case 55: GetMemoryArguments("NONE", m); break; - case 56: GetMemoryArguments("NONE", m); break; - case 57: GetMemoryArguments("NONE", m); break; - case 58: GetMemoryArguments("NONE", m); break; - case 59: GetMemoryArguments("GENLOC", m); break; - case 60: GetMemoryArguments("PKM", m); break; - case 61: GetMemoryArguments("NONE", m); break; - case 62: GetMemoryArguments("NONE", m); break; - case 63: GetMemoryArguments("NONE", m); break; - case 64: GetMemoryArguments("NONE", m); break; - default: GetMemoryArguments("NONE", m); break; - } - } + if (m != CB_CTMemory && m != CB_OTMemory) + return; + + int memory = WinFormsUtil.GetIndex(m); + var t = GetMemoryType(memory); + GetMemoryArguments(t, m); if (!init) return; RTB_OT.Text = GetMemoryString(CB_OTMemory, CB_OTVar, CB_OTQual, CB_OTFeel, pkm.OT_Name); RTB_CT.Text = GetMemoryString(CB_CTMemory, CB_CTVar, CB_CTQual, CB_CTFeel, pkm.HT_Name); } + + private static MemoryType GetMemoryType(int memory) + { + if (Legal.MemoryGeneral.Contains(memory)) + return MemoryType.GeneralLocation; + if (Legal.MemorySpecific.Contains(memory)) + return MemoryType.SpecificLocation; + if (Legal.MemoryItem.Contains(memory)) + return MemoryType.Item; + if (Legal.MemoryMove.Contains(memory)) + return MemoryType.Move; + if (Legal.MemorySpecies.Contains(memory)) + return MemoryType.Species; + + return MemoryType.None; + } + private void ChangeCountryIndex(object sender, EventArgs e) { int index = Array.IndexOf(cba, sender); @@ -424,11 +376,10 @@ namespace PKHeX.WinForms } private void ChangeCountryText(object sender, EventArgs e) { - if (((ComboBox) sender).Text == "") - { - ((ComboBox) sender).SelectedValue = 0; - ChangeCountryIndex(sender, e); - } + if (!(sender is ComboBox cb) || !string.IsNullOrWhiteSpace(cb.Text)) + return; + cb.SelectedValue = 0; + ChangeCountryIndex(sender, e); } private void Update255_MTB(object sender, EventArgs e) @@ -459,5 +410,15 @@ namespace PKHeX.WinForms for (int i = 0; i < 5; i++) cba[i].SelectedValue = 0; } + + private enum MemoryType + { + None, + GeneralLocation, + SpecificLocation, + Species, + Move, + Item, + } } } \ No newline at end of file