From 771086a2224778bef0cc4f7fe693195f7f2dd76c Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 24 Nov 2020 12:40:56 -0800 Subject: [PATCH] Show all valid yamask-1 formarg values from 319 (max HP-1) to 9999 (max saved value). Causes a little bit of GUI lag when loading 10k items to the combobox; could be a number entry but meh. Lazily allocate the 10k strings; wait until it's requested. --- PKHeX.Core/Legality/Verifiers/FormVerifier.cs | 4 ++++ PKHeX.Core/PKM/Util/FormConverter.cs | 20 +++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs index 7370b4047..41c577e27 100644 --- a/PKHeX.Core/Legality/Verifiers/FormVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/FormVerifier.cs @@ -303,6 +303,8 @@ private CheckResult VerifyFormArgument(LegalityAnalysis data, in uint arg) if (arg != 0) return GetInvalid(LFormArgumentNotAllowed); } + if (arg > 9_999) + return GetInvalid(LFormArgumentHigh); break; } case (int)Species.Runerigus: @@ -316,6 +318,8 @@ private CheckResult VerifyFormArgument(LegalityAnalysis data, in uint arg) { if (arg < 49) return GetInvalid(LFormArgumentLow); + if (arg > 9_999) + return GetInvalid(LFormArgumentHigh); } break; } diff --git a/PKHeX.Core/PKM/Util/FormConverter.cs b/PKHeX.Core/PKM/Util/FormConverter.cs index 4f3375f58..92c986709 100644 --- a/PKHeX.Core/PKM/Util/FormConverter.cs +++ b/PKHeX.Core/PKM/Util/FormConverter.cs @@ -1029,23 +1029,23 @@ public static string[] GetFormArgumentStrings(int species, int form, int generat if (generation <= 5) return EMPTY; - static string[] GetBlank(int count) - { - var result = new string[count]; - for (int i = 0; i < result.Length; i++) - result[i] = i.ToString(); - return result; - } - return species switch { (int) Furfrou when form != 0 => new[] {"0", "1", "2", "3", "4", "5"}, (int) Hoopa when form == 1 => new[] {"0", "1", "2", "3"}, - (int) Yamask when form == 1 => GetBlank(320), - (int) Runerigus when form == 0 => GetBlank(320), // max Runerigus HP + (int) Yamask when form == 1 => FormArg9999.Value, + (int) Runerigus when form == 0 => FormArg9999.Value, (int) Alcremie => Enum.GetNames(typeof(AlcremieDecoration)), _ => EMPTY }; } + + private static readonly Lazy FormArg9999 = new Lazy(() => + { + var result = new string[9_999]; + for (int i = 0; i < result.Length; i++) + result[i] = i.ToString(); + return result; + }, true); } }