From d7eae51c1f1145cd5246e2a86f8df85dc8caf70c Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 29 Jan 2018 17:20:12 -0800 Subject: [PATCH] Use showdown specific gender culture for formID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1793 , the form was returning -1 because it was expecting ♀ not F --- PKHeX.Core/PKM/ShowdownSet.cs | 8 +++++++- PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs | 7 +------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/PKM/ShowdownSet.cs b/PKHeX.Core/PKM/ShowdownSet.cs index fc83f03b0..1c482fb38 100644 --- a/PKHeX.Core/PKM/ShowdownSet.cs +++ b/PKHeX.Core/PKM/ShowdownSet.cs @@ -12,6 +12,7 @@ public class ShowdownSet // String to Values private static readonly string[] StatNames = { "HP", "Atk", "Def", "SpA", "SpD", "Spe" }; private static readonly string[] genders = {"M", "F", ""}; + private static readonly string[] genderForms = {"", "F", ""}; private const string Language = "en"; private static readonly string[] types = Util.GetTypesList(Language); private static readonly string[] forms = Util.GetFormsList(Language); @@ -34,6 +35,7 @@ public class ShowdownSet public bool Shiny { get; private set; } public int Friendship { get; private set; } = 255; public int Nature { get; private set; } + public int FormIndex { get; private set; } public int[] EVs { get; private set; } = {00, 00, 00, 00, 00, 00}; public int[] IVs { get; private set; } = {31, 31, 31, 31, 31, 31}; public int[] Moves { get; private set; } = {0, 0, 0, 0}; @@ -148,6 +150,9 @@ public ShowdownSet(string input = null) // Showdown Quirks Form = ConvertFormFromShowdown(Form, Species, Ability); + // Set Form + string[] formStrings = PKX.GetFormList(Species, types, forms, genderForms); + FormIndex = Math.Max(0, Array.FindIndex(formStrings, z => z.Contains(Form ?? ""))); } public string Text => GetText(); @@ -237,7 +242,7 @@ public static string GetShowdownText(PKM pkm) if (pkm.Species == 0) return string.Empty; - string[] Forms = PKX.GetFormList(pkm.Species, types, forms, new[] {"", "F", ""}, pkm.Format); + string[] Forms = PKX.GetFormList(pkm.Species, types, forms, genderForms, pkm.Format); ShowdownSet Set = new ShowdownSet { Nickname = pkm.Nickname, @@ -252,6 +257,7 @@ public static string GetShowdownText(PKM pkm) Friendship = pkm.CurrentFriendship, Level = PKX.GetLevel(pkm.Species, pkm.EXP), Shiny = pkm.IsShiny, + FormIndex = pkm.AltForm, Form = pkm.AltForm > 0 && pkm.AltForm < Forms.Length ? Forms[pkm.AltForm] : string.Empty, }; diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index e650ab0e8..25e529748 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -1973,12 +1973,7 @@ private void LoadShowdownSetDefault(ShowdownSet Set) Label_Gender.ForeColor = GetGenderColor(Gender); } - // Set Form - string[] formStrings = PKX.GetFormList(Set.Species, - Util.GetTypesList("en"), - Util.GetFormsList("en"), gendersymbols, pkm.Format); - int form = Array.FindIndex(formStrings, z => z.Contains(Set.Form ?? "")); - CB_Form.SelectedIndex = Math.Min(CB_Form.Items.Count - 1, Math.Max(0, form)); + CB_Form.SelectedIndex = Math.Min(CB_Form.Items.Count - 1, Set.FormIndex); // Set Ability and Moves int abil = Math.Max(0, Array.IndexOf(pkm.PersonalInfo.Abilities, Set.Ability));