diff --git a/PKHeX.Core/PKM/Util/FormConverter.cs b/PKHeX.Core/PKM/Util/FormConverter.cs index cf14eb432..f5d85c078 100644 --- a/PKHeX.Core/PKM/Util/FormConverter.cs +++ b/PKHeX.Core/PKM/Util/FormConverter.cs @@ -945,28 +945,31 @@ public static string[] GetAlcremieFormList(IReadOnlyList forms) return result; } - public static string[] GetFormArgumentStrings(int species, int form, int generation) + public static uint GetFormArgumentMax(int species, int form, int generation) { if (generation <= 5) - return EMPTY; + return 0; 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 => FormArg9999.Value, - (int) Runerigus when form == 0 => FormArg9999.Value, - (int) Alcremie => Enum.GetNames(typeof(AlcremieDecoration)), - _ => EMPTY + (int)Furfrou when form != 0 => 5, + (int)Hoopa when form == 1 => 3, + (int)Yamask when form == 1 => 9999, + (int)Runerigus when form == 0 => 9999, + (int)Alcremie => (uint)AlcremieDecoration.Ribbon, + _ => 0, }; } - private static readonly Lazy FormArg9999 = new(() => + public static bool GetFormArgumentIsNamedIndex(int species) => species == (int)Alcremie; + + public static string[] GetFormArgumentStrings(int species) { - var result = new string[10_000]; - for (int i = 0; i < result.Length; i++) - result[i] = i.ToString(); - return result; - }, true); + return species switch + { + (int)Alcremie => Enum.GetNames(typeof(AlcremieDecoration)), + _ => EMPTY + }; + } } } diff --git a/PKHeX.WinForms/Controls/PKM Editor/FormArgument.Designer.cs b/PKHeX.WinForms/Controls/PKM Editor/FormArgument.Designer.cs new file mode 100644 index 000000000..3336294b2 --- /dev/null +++ b/PKHeX.WinForms/Controls/PKM Editor/FormArgument.Designer.cs @@ -0,0 +1,95 @@ +namespace PKHeX.WinForms.Controls +{ + partial class FormArgument + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.NUD_FormArg = new System.Windows.Forms.NumericUpDown(); + this.CB_FormArg = new System.Windows.Forms.ComboBox(); + this.flowLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_FormArg)).BeginInit(); + this.SuspendLayout(); + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Controls.Add(this.NUD_FormArg); + this.flowLayoutPanel1.Controls.Add(this.CB_FormArg); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(162, 22); + this.flowLayoutPanel1.TabIndex = 1; + // + // NUD_FormArg + // + this.NUD_FormArg.Location = new System.Drawing.Point(0, 0); + this.NUD_FormArg.Margin = new System.Windows.Forms.Padding(0); + this.NUD_FormArg.Maximum = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUD_FormArg.Name = "NUD_FormArg"; + this.NUD_FormArg.Size = new System.Drawing.Size(44, 20); + this.NUD_FormArg.TabIndex = 0; + this.NUD_FormArg.Value = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + // + // CB_FormArg + // + this.CB_FormArg.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_FormArg.FormattingEnabled = true; + this.CB_FormArg.Items.AddRange(new object[] {""}); + this.CB_FormArg.Location = new System.Drawing.Point(44, 0); + this.CB_FormArg.Margin = new System.Windows.Forms.Padding(0); + this.CB_FormArg.Name = "CB_FormArg"; + this.CB_FormArg.Size = new System.Drawing.Size(66, 21); + this.CB_FormArg.TabIndex = 1; + // + // FormArgument + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; + this.Controls.Add(this.flowLayoutPanel1); + this.Name = "FormArgument"; + this.Size = new System.Drawing.Size(162, 22); + this.flowLayoutPanel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.NUD_FormArg)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.NumericUpDown NUD_FormArg; + private System.Windows.Forms.ComboBox CB_FormArg; + } +} diff --git a/PKHeX.WinForms/Controls/PKM Editor/FormArgument.cs b/PKHeX.WinForms/Controls/PKM Editor/FormArgument.cs new file mode 100644 index 000000000..5f34a21b2 --- /dev/null +++ b/PKHeX.WinForms/Controls/PKM Editor/FormArgument.cs @@ -0,0 +1,69 @@ +using System; +using System.Windows.Forms; +using PKHeX.Core; + +namespace PKHeX.WinForms.Controls +{ + public partial class FormArgument : UserControl + { + private bool IsRawMode; + private int CurrentSpecies; + private int CurrentForm; + + public FormArgument() => InitializeComponent(); + + public void LoadArgument(IFormArgument f, int species, int form, int generation) + { + var max = FormConverter.GetFormArgumentMax(species, form, generation); + if (max == 0) + { + CB_FormArg.SelectedIndex = 0; + CB_FormArg.Visible = false; + NUD_FormArg.Visible = false; + return; + } + + bool named = FormConverter.GetFormArgumentIsNamedIndex(species); + if (named) + { + if (CurrentSpecies == species && CurrentForm == form) + { + CurrentValue = f.FormArgument; + return; + } + IsRawMode = false; + + NUD_FormArg.Visible = false; + CB_FormArg.Items.Clear(); + var args = FormConverter.GetFormArgumentStrings(species); + CB_FormArg.Items.AddRange(args); + CB_FormArg.Visible = true; + } + else + { + IsRawMode = true; + + CB_FormArg.Visible = false; + NUD_FormArg.Maximum = max; + NUD_FormArg.Visible = true; + } + CurrentSpecies = species; + CurrentForm = form; + CurrentValue = f.FormArgument; + } + + public uint CurrentValue + { + get => IsRawMode ? (uint) NUD_FormArg.Value : (uint) CB_FormArg.SelectedIndex; + set + { + if (IsRawMode) + NUD_FormArg.Value = Math.Min(NUD_FormArg.Maximum, value); + else + CB_FormArg.SelectedIndex = Math.Min(CB_FormArg.SelectedIndex, (int)value); + } + } + + public void SaveArgument(IFormArgument f) => f.FormArgument = CurrentValue; + } +} diff --git a/PKHeX.WinForms/Controls/PKM Editor/LoadSave.cs b/PKHeX.WinForms/Controls/PKM Editor/LoadSave.cs index 0ba34daf9..3f64cd304 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/LoadSave.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/LoadSave.cs @@ -172,7 +172,7 @@ private void LoadMisc2(PKM pk) CB_HeldItem.SelectedValue = pk.HeldItem; CB_Form.SelectedIndex = CB_Form.Items.Count > pk.Form ? pk.Form : CB_Form.Items.Count - 1; if (pk is IFormArgument f) - CB_FormArgument.SelectedIndex = CB_FormArgument.Items.Count > f.FormArgument ? (int)f.FormArgument : CB_FormArgument.Items.Count - 1; + FA_Form.LoadArgument(f, pk.Species, pk.Form, pk.Format); TB_Friendship.Text = pk.CurrentFriendship.ToString(); @@ -187,7 +187,7 @@ private void SaveMisc2(PKM pk) pk.HeldItem = WinFormsUtil.GetIndex(CB_HeldItem); pk.Form = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F; if (Entity is IFormArgument f) - f.FormArgument = (uint)Math.Max(0, CB_FormArgument.SelectedIndex); + f.FormArgument = FA_Form.CurrentValue; pk.CurrentFriendship = Util.ToInt32(TB_Friendship.Text); } diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs index b13918f27..3528875f5 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs @@ -68,7 +68,6 @@ private void InitializeComponent() this.FLP_FormRight = new System.Windows.Forms.FlowLayoutPanel(); this.CB_Form = new System.Windows.Forms.ComboBox(); this.MT_Form = new System.Windows.Forms.MaskedTextBox(); - this.CB_FormArgument = new System.Windows.Forms.ComboBox(); this.FLP_HeldItem = new System.Windows.Forms.FlowLayoutPanel(); this.Label_HeldItem = new System.Windows.Forms.Label(); this.CB_HeldItem = new System.Windows.Forms.ComboBox(); @@ -120,12 +119,9 @@ private void InitializeComponent() this.CHK_Shadow = new System.Windows.Forms.CheckBox(); this.FLP_ShinyLeaf = new System.Windows.Forms.FlowLayoutPanel(); this.L_ShinyLeaf = new System.Windows.Forms.Label(); - this.ShinyLeaf = new PKHeX.WinForms.Controls.ShinyLeaf(); this.FLP_CatchRate = new System.Windows.Forms.FlowLayoutPanel(); this.L_CatchRate = new System.Windows.Forms.Label(); - this.CR_PK1 = new PKHeX.WinForms.Controls.CatchRate(); this.FLP_SizeCP = new System.Windows.Forms.FlowLayoutPanel(); - this.SizeCP = new PKHeX.WinForms.Controls.SizeCP(); this.Tab_Met = new System.Windows.Forms.TabPage(); this.TB_HomeTracker = new System.Windows.Forms.TextBox(); this.L_HomeTracker = new System.Windows.Forms.Label(); @@ -166,8 +162,6 @@ private void InitializeComponent() this.L_MetTimeOfDay = new System.Windows.Forms.Label(); this.CB_MetTimeOfDay = new System.Windows.Forms.ComboBox(); this.Tab_Stats = new System.Windows.Forms.TabPage(); - this.Stats = new PKHeX.WinForms.Controls.StatEditor(); - this.Contest = new PKHeX.WinForms.Controls.ContestStat(); this.Tab_Attacks = new System.Windows.Forms.TabPage(); this.B_Records = new System.Windows.Forms.Button(); this.PB_WarnMove4 = new System.Windows.Forms.PictureBox(); @@ -226,7 +220,6 @@ private void InitializeComponent() this.TB_ExtraByte = new System.Windows.Forms.MaskedTextBox(); this.CB_ExtraBytes = new System.Windows.Forms.ComboBox(); this.GB_OT = new System.Windows.Forms.GroupBox(); - this.TID_Trainer = new PKHeX.WinForms.Controls.TrainerID(); this.Label_OTGender = new System.Windows.Forms.Label(); this.TB_OT = new System.Windows.Forms.TextBox(); this.Label_OT = new System.Windows.Forms.Label(); @@ -234,6 +227,13 @@ private void InitializeComponent() this.SpeciesIDTip = new System.Windows.Forms.ToolTip(this.components); this.NatureTip = new System.Windows.Forms.ToolTip(this.components); this.Tip3 = new System.Windows.Forms.ToolTip(this.components); + this.FA_Form = new PKHeX.WinForms.Controls.FormArgument(); + this.ShinyLeaf = new PKHeX.WinForms.Controls.ShinyLeaf(); + this.CR_PK1 = new PKHeX.WinForms.Controls.CatchRate(); + this.SizeCP = new PKHeX.WinForms.Controls.SizeCP(); + this.Stats = new PKHeX.WinForms.Controls.StatEditor(); + this.Contest = new PKHeX.WinForms.Controls.ContestStat(); + this.TID_Trainer = new PKHeX.WinForms.Controls.TrainerID(); this.tabMain.SuspendLayout(); this.Tab_Main.SuspendLayout(); this.FLP_Main.SuspendLayout(); @@ -782,7 +782,7 @@ private void InitializeComponent() this.FLP_FormRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.FLP_FormRight.Controls.Add(this.CB_Form); this.FLP_FormRight.Controls.Add(this.MT_Form); - this.FLP_FormRight.Controls.Add(this.CB_FormArgument); + this.FLP_FormRight.Controls.Add(this.FA_Form); this.FLP_FormRight.Location = new System.Drawing.Point(110, 0); this.FLP_FormRight.Margin = new System.Windows.Forms.Padding(0); this.FLP_FormRight.Name = "FLP_FormRight"; @@ -815,18 +815,6 @@ private void InitializeComponent() this.MT_Form.Visible = false; this.MT_Form.TextChanged += new System.EventHandler(this.UpdateHaXForm); // - // CB_FormArgument - // - this.CB_FormArgument.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.CB_FormArgument.DropDownWidth = 90; - this.CB_FormArgument.FormattingEnabled = true; - this.CB_FormArgument.Location = new System.Drawing.Point(90, 0); - this.CB_FormArgument.Margin = new System.Windows.Forms.Padding(0); - this.CB_FormArgument.Name = "CB_FormArgument"; - this.CB_FormArgument.Size = new System.Drawing.Size(50, 21); - this.CB_FormArgument.TabIndex = 19; - this.CB_FormArgument.SelectedIndexChanged += new System.EventHandler(this.UpdateFormArgument); - // // FLP_HeldItem // this.FLP_HeldItem.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); @@ -1434,14 +1422,6 @@ private void InitializeComponent() this.L_ShinyLeaf.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.L_ShinyLeaf.Click += new System.EventHandler(this.ClickShinyLeaf); // - // ShinyLeaf - // - this.ShinyLeaf.Location = new System.Drawing.Point(110, 0); - this.ShinyLeaf.Margin = new System.Windows.Forms.Padding(0); - this.ShinyLeaf.Name = "ShinyLeaf"; - this.ShinyLeaf.Size = new System.Drawing.Size(140, 56); - this.ShinyLeaf.TabIndex = 116; - // // FLP_CatchRate // this.FLP_CatchRate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); @@ -1463,14 +1443,6 @@ private void InitializeComponent() this.L_CatchRate.Text = "Catch Rate:"; this.L_CatchRate.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // CR_PK1 - // - this.CR_PK1.Location = new System.Drawing.Point(110, 0); - this.CR_PK1.Margin = new System.Windows.Forms.Padding(0); - this.CR_PK1.Name = "CR_PK1"; - this.CR_PK1.Size = new System.Drawing.Size(162, 25); - this.CR_PK1.TabIndex = 10; - // // FLP_SizeCP // this.FLP_SizeCP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); @@ -1481,15 +1453,6 @@ private void InitializeComponent() this.FLP_SizeCP.Size = new System.Drawing.Size(272, 72); this.FLP_SizeCP.TabIndex = 21; // - // SizeCP - // - this.SizeCP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.SizeCP.Location = new System.Drawing.Point(50, 0); - this.SizeCP.Margin = new System.Windows.Forms.Padding(50, 0, 0, 0); - this.SizeCP.Name = "SizeCP"; - this.SizeCP.Size = new System.Drawing.Size(204, 68); - this.SizeCP.TabIndex = 0; - // // Tab_Met // this.Tab_Met.AllowDrop = true; @@ -1501,7 +1464,7 @@ private void InitializeComponent() this.Tab_Met.Location = new System.Drawing.Point(4, 22); this.Tab_Met.Name = "Tab_Met"; this.Tab_Met.Padding = new System.Windows.Forms.Padding(3); - this.Tab_Met.Size = new System.Drawing.Size(192, 74); + this.Tab_Met.Size = new System.Drawing.Size(307, 539); this.Tab_Met.TabIndex = 1; this.Tab_Met.Text = "Met"; this.Tab_Met.UseVisualStyleBackColor = true; @@ -1947,38 +1910,11 @@ private void InitializeComponent() this.Tab_Stats.Location = new System.Drawing.Point(4, 22); this.Tab_Stats.Name = "Tab_Stats"; this.Tab_Stats.Padding = new System.Windows.Forms.Padding(3); - this.Tab_Stats.Size = new System.Drawing.Size(192, 74); + this.Tab_Stats.Size = new System.Drawing.Size(307, 539); this.Tab_Stats.TabIndex = 2; this.Tab_Stats.Text = "Stats"; this.Tab_Stats.UseVisualStyleBackColor = true; // - // Stats - // - this.Stats.EVsFishy = System.Drawing.Color.LightYellow; - this.Stats.EVsInvalid = System.Drawing.Color.Red; - this.Stats.EVsMaxed = System.Drawing.Color.Honeydew; - this.Stats.Location = new System.Drawing.Point(0, 0); - this.Stats.Name = "Stats"; - this.Stats.Size = new System.Drawing.Size(270, 264); - this.Stats.StatDecreased = System.Drawing.Color.Blue; - this.Stats.StatHyperTrained = System.Drawing.Color.LightGreen; - this.Stats.StatIncreased = System.Drawing.Color.Red; - this.Stats.TabIndex = 1; - // - // Contest - // - this.Contest.CNT_Beauty = 0; - this.Contest.CNT_Cool = 0; - this.Contest.CNT_Cute = 0; - this.Contest.CNT_Sheen = 0; - this.Contest.CNT_Smart = 0; - this.Contest.CNT_Tough = 0; - this.Contest.Location = new System.Drawing.Point(21, 265); - this.Contest.Margin = new System.Windows.Forms.Padding(0); - this.Contest.Name = "Contest"; - this.Contest.Size = new System.Drawing.Size(230, 50); - this.Contest.TabIndex = 2; - // // Tab_Attacks // this.Tab_Attacks.AllowDrop = true; @@ -1992,7 +1928,7 @@ private void InitializeComponent() this.Tab_Attacks.Location = new System.Drawing.Point(4, 22); this.Tab_Attacks.Name = "Tab_Attacks"; this.Tab_Attacks.Padding = new System.Windows.Forms.Padding(3); - this.Tab_Attacks.Size = new System.Drawing.Size(192, 74); + this.Tab_Attacks.Size = new System.Drawing.Size(307, 539); this.Tab_Attacks.TabIndex = 3; this.Tab_Attacks.Text = "Attacks"; this.Tab_Attacks.UseVisualStyleBackColor = true; @@ -2735,13 +2671,6 @@ private void InitializeComponent() this.GB_OT.TabStop = false; this.GB_OT.Text = "Trainer Information"; // - // TID_Trainer - // - this.TID_Trainer.Location = new System.Drawing.Point(13, 18); - this.TID_Trainer.Name = "TID_Trainer"; - this.TID_Trainer.Size = new System.Drawing.Size(178, 27); - this.TID_Trainer.TabIndex = 57; - // // Label_OTGender // this.Label_OTGender.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); @@ -2782,6 +2711,74 @@ private void InitializeComponent() this.Label_EncryptionConstant.Text = "Encryption Constant:"; this.Label_EncryptionConstant.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // + // FA_Form + // + this.FA_Form.CurrentValue = ((uint)(4294967295u)); + this.FA_Form.Location = new System.Drawing.Point(90, 0); + this.FA_Form.Margin = new System.Windows.Forms.Padding(0); + this.FA_Form.Name = "FA_Form"; + this.FA_Form.Size = new System.Drawing.Size(70, 20); + this.FA_Form.TabIndex = 19; + // + // ShinyLeaf + // + this.ShinyLeaf.Location = new System.Drawing.Point(110, 0); + this.ShinyLeaf.Margin = new System.Windows.Forms.Padding(0); + this.ShinyLeaf.Name = "ShinyLeaf"; + this.ShinyLeaf.Size = new System.Drawing.Size(140, 56); + this.ShinyLeaf.TabIndex = 116; + // + // CR_PK1 + // + this.CR_PK1.Location = new System.Drawing.Point(110, 0); + this.CR_PK1.Margin = new System.Windows.Forms.Padding(0); + this.CR_PK1.Name = "CR_PK1"; + this.CR_PK1.Size = new System.Drawing.Size(162, 25); + this.CR_PK1.TabIndex = 10; + // + // SizeCP + // + this.SizeCP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.SizeCP.Location = new System.Drawing.Point(50, 0); + this.SizeCP.Margin = new System.Windows.Forms.Padding(50, 0, 0, 0); + this.SizeCP.Name = "SizeCP"; + this.SizeCP.Size = new System.Drawing.Size(204, 68); + this.SizeCP.TabIndex = 0; + // + // Stats + // + this.Stats.EVsFishy = System.Drawing.Color.LightYellow; + this.Stats.EVsInvalid = System.Drawing.Color.Red; + this.Stats.EVsMaxed = System.Drawing.Color.Honeydew; + this.Stats.Location = new System.Drawing.Point(0, 0); + this.Stats.Name = "Stats"; + this.Stats.Size = new System.Drawing.Size(270, 264); + this.Stats.StatDecreased = System.Drawing.Color.Blue; + this.Stats.StatHyperTrained = System.Drawing.Color.LightGreen; + this.Stats.StatIncreased = System.Drawing.Color.Red; + this.Stats.TabIndex = 1; + // + // Contest + // + this.Contest.CNT_Beauty = 0; + this.Contest.CNT_Cool = 0; + this.Contest.CNT_Cute = 0; + this.Contest.CNT_Sheen = 0; + this.Contest.CNT_Smart = 0; + this.Contest.CNT_Tough = 0; + this.Contest.Location = new System.Drawing.Point(21, 265); + this.Contest.Margin = new System.Windows.Forms.Padding(0); + this.Contest.Name = "Contest"; + this.Contest.Size = new System.Drawing.Size(230, 50); + this.Contest.TabIndex = 2; + // + // TID_Trainer + // + this.TID_Trainer.Location = new System.Drawing.Point(13, 18); + this.TID_Trainer.Name = "TID_Trainer"; + this.TID_Trainer.Size = new System.Drawing.Size(178, 27); + this.TID_Trainer.TabIndex = 57; + // // PKMEditor // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; @@ -3098,12 +3095,12 @@ private void InitializeComponent() private System.Windows.Forms.FlowLayoutPanel FLP_FormRight; private System.Windows.Forms.ComboBox CB_Form; private System.Windows.Forms.MaskedTextBox MT_Form; - private System.Windows.Forms.ComboBox CB_FormArgument; private System.Windows.Forms.TextBox TB_HomeTracker; private System.Windows.Forms.Label L_HomeTracker; private System.Windows.Forms.FlowLayoutPanel FLP_BattleVersion; private System.Windows.Forms.Label L_BattleVersion; private System.Windows.Forms.ComboBox CB_BattleVersion; private System.Windows.Forms.PictureBox PB_BattleVersion; + private FormArgument FA_Form; } } diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index ebed159f5..7c5c6af46 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -434,7 +434,12 @@ private void SetForms() Label_Form.Visible = true; // show with value entry textbox if (!hasForms) + { + if (HaX) + return; + Entity.Form = CB_Form.SelectedIndex = 0; return; + } var ds = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, gendersymbols, Entity.Format); if (ds.Length == 1 && string.IsNullOrEmpty(ds[0])) // empty (Alolan Totems) @@ -1006,14 +1011,14 @@ private void UpdateForm(object sender, EventArgs e) private void RefreshFormArguments() { - int index = CB_FormArgument.SelectedIndex; - var items = FormConverter.GetFormArgumentStrings(Entity.Species, Entity.Form, Entity.Format); - CB_FormArgument.Items.Clear(); - CB_FormArgument.Items.AddRange(items); - CB_FormArgument.Visible = !string.IsNullOrWhiteSpace(items[0]); + if (Entity is not IFormArgument f) + return; + + var index = FA_Form.CurrentValue; + FA_Form.LoadArgument(f, Entity.Species, Entity.Form, Entity.Format); if (ChangingFields) return; - CB_FormArgument.SelectedIndex = index < items.Length ? index : 0; + FA_Form.CurrentValue = index; } private void UpdateHaXForm(object sender, EventArgs e)