From baac63221838b768beb904a4b7320227b49a5e8e Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 14 Jul 2018 10:56:11 -0700 Subject: [PATCH] Enable editing gen1/2 hidden power type --- PKHeX.Core/Editing/ShowdownSet.cs | 2 +- PKHeX.Core/PKM/Util/PKX.cs | 9 ++++++++- PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs | 4 +--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/PKHeX.Core/Editing/ShowdownSet.cs b/PKHeX.Core/Editing/ShowdownSet.cs index 0b2123de1..496520efd 100644 --- a/PKHeX.Core/Editing/ShowdownSet.cs +++ b/PKHeX.Core/Editing/ShowdownSet.cs @@ -484,7 +484,7 @@ namespace PKHeX.Core InvalidLines.Add($"Invalid IVs for Hidden Power Type: {type}"); } else if (hpVal >= 0) - IVs = PKX.SetHPIVs(hpVal, IVs); // Get IVs + IVs = PKX.SetHPIVs(hpVal, IVs, Format); // Get IVs else InvalidLines.Add($"Invalid Hidden Power Type: {type}"); } diff --git a/PKHeX.Core/PKM/Util/PKX.cs b/PKHeX.Core/PKM/Util/PKX.cs index 7cdcd34b7..0244693e1 100644 --- a/PKHeX.Core/PKM/Util/PKX.cs +++ b/PKHeX.Core/PKM/Util/PKX.cs @@ -634,9 +634,16 @@ namespace PKHeX.Core /// Calculate the Hidden Power Type of the entered IVs. /// Hidden Power Type /// Individual Values (H/A/B/S/C/D) + /// Generation specific format /// Hidden Power Type - public static int[] SetHPIVs(int type, int[] ivs) + public static int[] SetHPIVs(int type, int[] ivs, int format = Generation) { + if (format <= 2) + { + ivs[1] = (ivs[1] & ~3) | (type >> 2); + ivs[2] = (ivs[2] & ~3) | (type & 3); + return ivs; + } for (int i = 0; i < 6; i++) ivs[i] = (ivs[i] & 0x1E) + hpivs[type, i]; return ivs; diff --git a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs index 274a3c370..2d2665bb3 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/StatEditor.cs @@ -186,7 +186,7 @@ namespace PKHeX.WinForms.Controls // Change IVs to match the new Hidden Power int hpower = WinFormsUtil.GetIndex(CB_HPType); - int[] newIVs = PKX.SetHPIVs(hpower, pkm.IVs); + int[] newIVs = PKX.SetHPIVs(hpower, pkm.IVs, pkm.Format); LoadIVs(newIVs); } private void ClickStatLabel(object sender, MouseEventArgs e) @@ -378,8 +378,6 @@ namespace PKHeX.WinForms.Controls { FLP_StatsTotal.Visible = gen >= 3; FLP_Characteristic.Visible = gen >= 3; - CB_HPType.Enabled = gen >= 3; - FLP_HPType.Visible = gen >= 2; switch (gen) {