From 8ade9b21c73385f90e7644cfec8f1d5cbe5ab2ec Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 11 Nov 2016 02:00:47 -0800 Subject: [PATCH] Initial Hyper Training Support --- PKHeX/MainWindow/Main.Designer.cs | 28 +- PKHeX/MainWindow/Main.cs | 38 +- PKHeX/MainWindow/Main.resx | 786 ------------------------------ PKHeX/PKM/PK7.cs | 8 +- PKHeX/PKM/PKM.cs | 20 +- 5 files changed, 72 insertions(+), 808 deletions(-) diff --git a/PKHeX/MainWindow/Main.Designer.cs b/PKHeX/MainWindow/Main.Designer.cs index 4cf05774a..c4c4f86a1 100644 --- a/PKHeX/MainWindow/Main.Designer.cs +++ b/PKHeX/MainWindow/Main.Designer.cs @@ -260,6 +260,7 @@ public void InitializeComponent() this.Label_PrevOT = new System.Windows.Forms.Label(); this.BTN_RerollEC = new System.Windows.Forms.Button(); this.GB_Markings = new System.Windows.Forms.GroupBox(); + this.PB_MarkAlola = new System.Windows.Forms.PictureBox(); this.PB_Mark6 = new System.Windows.Forms.PictureBox(); this.PB_MarkPentagon = new System.Windows.Forms.PictureBox(); this.PB_Mark3 = new System.Windows.Forms.PictureBox(); @@ -438,7 +439,6 @@ public void InitializeComponent() this.mnuLSave = new System.Windows.Forms.ToolStripMenuItem(); this.PB_Legal = new System.Windows.Forms.PictureBox(); this.L_UpdateAvailable = new System.Windows.Forms.LinkLabel(); - this.PB_MarkAlola = new System.Windows.Forms.PictureBox(); this.tabMain.SuspendLayout(); this.Tab_Main.SuspendLayout(); this.FLP_Main.SuspendLayout(); @@ -521,6 +521,7 @@ public void InitializeComponent() this.FLP_PKMEditors.SuspendLayout(); this.GB_nOT.SuspendLayout(); this.GB_Markings.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.PB_MarkAlola)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_Mark6)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_MarkPentagon)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_Mark3)).BeginInit(); @@ -602,7 +603,6 @@ public void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.dragout)).BeginInit(); this.mnuL.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.PB_Legal)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.PB_MarkAlola)).BeginInit(); this.SuspendLayout(); // // tabMain @@ -3377,6 +3377,17 @@ public void InitializeComponent() this.GB_Markings.TabStop = false; this.GB_Markings.Text = "Markings"; // + // PB_MarkAlola + // + this.PB_MarkAlola.Image = global::PKHeX.Properties.Resources.sanchi; + this.PB_MarkAlola.InitialImage = global::PKHeX.Properties.Resources.sanchi; + this.PB_MarkAlola.Location = new System.Drawing.Point(96, 15); + this.PB_MarkAlola.Name = "PB_MarkAlola"; + this.PB_MarkAlola.Size = new System.Drawing.Size(20, 20); + this.PB_MarkAlola.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.PB_MarkAlola.TabIndex = 9; + this.PB_MarkAlola.TabStop = false; + // // PB_Mark6 // this.PB_Mark6.Image = ((System.Drawing.Image)(resources.GetObject("PB_Mark6.Image"))); @@ -5630,17 +5641,6 @@ public void InitializeComponent() this.L_UpdateAvailable.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.L_UpdateAvailable.Visible = false; // - // PB_MarkAlola - // - this.PB_MarkAlola.Image = global::PKHeX.Properties.Resources.sanchi; - this.PB_MarkAlola.InitialImage = global::PKHeX.Properties.Resources.sanchi; - this.PB_MarkAlola.Location = new System.Drawing.Point(96, 15); - this.PB_MarkAlola.Name = "PB_MarkAlola"; - this.PB_MarkAlola.Size = new System.Drawing.Size(20, 20); - this.PB_MarkAlola.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; - this.PB_MarkAlola.TabIndex = 9; - this.PB_MarkAlola.TabStop = false; - // // Main // this.AllowDrop = true; @@ -5773,6 +5773,7 @@ public void InitializeComponent() this.GB_nOT.ResumeLayout(false); this.GB_nOT.PerformLayout(); this.GB_Markings.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.PB_MarkAlola)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_Mark6)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_MarkPentagon)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_Mark3)).EndInit(); @@ -5865,7 +5866,6 @@ public void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.dragout)).EndInit(); this.mnuL.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.PB_Legal)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.PB_MarkAlola)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 9735bcf34..5f944f915 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -1626,7 +1626,34 @@ private void clickStatLabel(object sender, MouseEventArgs e) private void clickIV(object sender, EventArgs e) { if (ModifierKeys == Keys.Control) - ((MaskedTextBox) sender).Text = SAV.MaxIV.ToString(); + if (SAV.Generation < 7) + ((MaskedTextBox) sender).Text = SAV.MaxIV.ToString(); + else + { + var index = Array.IndexOf(new[] {TB_HPIV, TB_ATKIV, TB_DEFIV, TB_SPAIV, TB_SPDIV, TB_SPEIV}, sender); + switch (index) + { + case 0: + pkm.HT_HP ^= true; + break; + case 1: + pkm.HT_ATK ^= true; + break; + case 2: + pkm.HT_DEF ^= true; + break; + case 3: + pkm.HT_SPA ^= true; + break; + case 4: + pkm.HT_SPD ^= true; + break; + case 5: + pkm.HT_SPE ^= true; + break; + } + updateIVs(sender, e); + } else if (ModifierKeys == Keys.Alt) ((MaskedTextBox) sender).Text = 0.ToString(); } @@ -1790,6 +1817,14 @@ private void updateIVs(object sender, EventArgs e) pkm.IV_SPA = Util.ToInt32(TB_SPAIV.Text); pkm.IV_SPD = Util.ToInt32(TB_SPDIV.Text); + var IV_Boxes = new[] {TB_HPIV, TB_ATKIV, TB_DEFIV, TB_SPAIV, TB_SPDIV, TB_SPEIV}; + var HT_Vals = new[] {pkm.HT_HP, pkm.HT_ATK, pkm.HT_DEF, pkm.HT_SPA, pkm.HT_SPD, pkm.HT_SPE}; + for (int i = 0; i < IV_Boxes.Length; i++) + if (HT_Vals[i]) + IV_Boxes[i].BackColor = Color.LightGreen; + else + IV_Boxes[i].ResetBackColor(); + if (SAV.Generation < 3) { TB_HPIV.Text = pkm.IV_HP.ToString(); @@ -3758,6 +3793,7 @@ private void pbBoxSlot_MouseClick(object sender, MouseEventArgs e) clickSlot(sender, e); } + private void pbBoxSlot_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) diff --git a/PKHeX/MainWindow/Main.resx b/PKHeX/MainWindow/Main.resx index cbcdb103b..6be55f293 100644 --- a/PKHeX/MainWindow/Main.resx +++ b/PKHeX/MainWindow/Main.resx @@ -129,15 +129,6 @@ True - - True - - - True - - - True - @@ -164,33 +155,12 @@ True - - True - - - True - - - True - True True - - True - - - True - - - True - - - True - True @@ -200,21 +170,6 @@ True - - True - - - True - - - True - - - True - - - True - True @@ -233,30 +188,12 @@ True - - True - - - True - True True - - True - - - True - - - True - - - True - True @@ -275,33 +212,9 @@ True - - True - - - True - - - True - - - True - True - - True - - - True - - - True - - - True - True @@ -317,15 +230,6 @@ True - - True - - - True - - - True - True @@ -335,27 +239,9 @@ True - - True - - - True - True - - True - - - True - - - True - - - True - True @@ -371,30 +257,12 @@ True - - True - - - True - True True - - True - - - True - - - True - - - True - True @@ -407,15 +275,6 @@ True - - True - - - True - - - True - True @@ -425,18 +284,6 @@ True - - True - - - True - - - True - - - True - True @@ -455,36 +302,12 @@ True - - True - - - True - - - True - - - True - True True - - True - - - True - - - True - - - True - True @@ -497,18 +320,6 @@ True - - True - - - True - - - True - - - True - True @@ -521,15 +332,6 @@ True - - True - - - True - - - True - True @@ -539,57 +341,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -632,9 +383,6 @@ True - - True - True @@ -644,18 +392,6 @@ True - - True - - - True - - - True - - - True - True @@ -668,30 +404,9 @@ True - - True - - - True - - - True - True - - True - - - True - - - True - - - True - True @@ -704,9 +419,6 @@ True - - True - True @@ -716,18 +428,6 @@ True - - True - - - True - - - True - - - True - True @@ -740,30 +440,9 @@ True - - True - - - True - - - True - True - - True - - - True - - - True - - - True - True @@ -776,18 +455,6 @@ True - - True - - - True - - - True - - - True - True @@ -800,18 +467,6 @@ True - - True - - - True - - - True - - - True - True @@ -827,18 +482,6 @@ True - - True - - - True - - - True - - - True - True @@ -854,24 +497,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAeZJREFUOE+1 @@ -943,30 +568,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAeZJREFUOE+1 @@ -1089,57 +690,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -1152,27 +702,9 @@ True - - True - - - True - - - True - True - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO @@ -1330,33 +862,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -1393,108 +898,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -1600,42 +1003,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAAG8AAACgCAYAAAACezIBAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO @@ -1749,24 +1116,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAAG8AAACgCAYAAAACezIBAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO @@ -1837,54 +1186,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -1924,18 +1225,12 @@ True - - True - True True - - True - True @@ -1945,36 +1240,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -2008,57 +1273,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True diff --git a/PKHeX/PKM/PK7.cs b/PKHeX/PKM/PK7.cs index 64ee50408..2799b08bb 100644 --- a/PKHeX/PKM/PK7.cs +++ b/PKHeX/PKM/PK7.cs @@ -389,7 +389,13 @@ public override string OT_Name public override int Ball { get { return Data[0xDC]; } set { Data[0xDC] = (byte)value; } } public override int Met_Level { get { return Data[0xDD] & ~0x80; } set { Data[0xDD] = (byte)((Data[0xDD] & 0x80) | value); } } public override int OT_Gender { get { return Data[0xDD] >> 7; } set { Data[0xDD] = (byte)((Data[0xDD] & ~0x80) | (value << 7)); } } - public override int EncounterType { get { return Data[0xDE]; } set { Data[0xDE] = (byte)value; } } + public override int HyperTrainFlags { get { return Data[0xDE]; } set { Data[0xDE] = (byte)value; } } + public override bool HT_HP { get { return ((HyperTrainFlags >> 0) & 1) == 1; } set { HyperTrainFlags = (HyperTrainFlags & ~(1 << 0)) | ((value ? 1 : 0) << 0); } } + public override bool HT_ATK { get { return ((HyperTrainFlags >> 1) & 1) == 1; } set { HyperTrainFlags = (HyperTrainFlags & ~(1 << 1)) | ((value ? 1 : 0) << 1); } } + public override bool HT_DEF { get { return ((HyperTrainFlags >> 2) & 1) == 1; } set { HyperTrainFlags = (HyperTrainFlags & ~(1 << 2)) | ((value ? 1 : 0) << 2); } } + public override bool HT_SPA { get { return ((HyperTrainFlags >> 3) & 1) == 1; } set { HyperTrainFlags = (HyperTrainFlags & ~(1 << 3)) | ((value ? 1 : 0) << 3); } } + public override bool HT_SPD { get { return ((HyperTrainFlags >> 4) & 1) == 1; } set { HyperTrainFlags = (HyperTrainFlags & ~(1 << 4)) | ((value ? 1 : 0) << 4); } } + public override bool HT_SPE { get { return ((HyperTrainFlags >> 5) & 1) == 1; } set { HyperTrainFlags = (HyperTrainFlags & ~(1 << 5)) | ((value ? 1 : 0) << 5); } } public override int Version { get { return Data[0xDF]; } set { Data[0xDF] = (byte)value; } } public override int Country { get { return Data[0xE0]; } set { Data[0xE0] = (byte)value; } } public override int Region { get { return Data[0xE1]; } set { Data[0xE1] = (byte)value; } } diff --git a/PKHeX/PKM/PKM.cs b/PKHeX/PKM/PKM.cs index 7571b80ea..19355a331 100644 --- a/PKHeX/PKM/PKM.cs +++ b/PKHeX/PKM/PKM.cs @@ -394,6 +394,14 @@ public virtual int HPType public virtual bool SecretSuperTrainingUnlocked { get { return false; } set { } } public virtual bool SecretSuperTrainingComplete { get { return false; } set { } } + public virtual int HyperTrainFlags { get { return 0; } set { } } + public virtual bool HT_HP { get { return false; } set { } } + public virtual bool HT_ATK { get { return false; } set { } } + public virtual bool HT_DEF { get { return false; } set { } } + public virtual bool HT_SPA { get { return false; } set { } } + public virtual bool HT_SPD { get { return false; } set { } } + public virtual bool HT_SPE { get { return false; } set { } } + public bool InhabitedGeneration(int Generation) { if (Format < Generation) @@ -472,12 +480,12 @@ public virtual ushort[] getStats(PersonalInfo p) { int level = CurrentLevel; ushort[] Stats = new ushort[6]; - Stats[0] = (ushort)(p.HP == 1 ? 1 : (IV_HP + 2 * p.HP + EV_HP / 4 + 100) * level / 100 + 10); - Stats[1] = (ushort)((IV_ATK + 2 * p.ATK + EV_ATK / 4) * level / 100 + 5); - Stats[2] = (ushort)((IV_DEF + 2 * p.DEF + EV_DEF / 4) * level / 100 + 5); - Stats[4] = (ushort)((IV_SPA + 2 * p.SPA + EV_SPA / 4) * level / 100 + 5); - Stats[5] = (ushort)((IV_SPD + 2 * p.SPD + EV_SPD / 4) * level / 100 + 5); - Stats[3] = (ushort)((IV_SPE + 2 * p.SPE + EV_SPE / 4) * level / 100 + 5); + Stats[0] = (ushort)(p.HP == 1 ? 1 : (((HT_HP ? 31 : IV_HP) + 2 * p.HP + EV_HP / 4 + 100) * level / 100 + 10)); + Stats[1] = (ushort)(((HT_ATK ? 31 : IV_ATK) + 2 * p.ATK + EV_ATK / 4) * level / 100 + 5); + Stats[2] = (ushort)(((HT_DEF ? 31 : IV_DEF) + 2 * p.DEF + EV_DEF / 4) * level / 100 + 5); + Stats[4] = (ushort)(((HT_SPA ? 31 : IV_SPA) + 2 * p.SPA + EV_SPA / 4) * level / 100 + 5); + Stats[5] = (ushort)(((HT_SPD ? 31 : IV_SPD) + 2 * p.SPD + EV_SPD / 4) * level / 100 + 5); + Stats[3] = (ushort)(((HT_SPE ? 31 : IV_SPE) + 2 * p.SPE + EV_SPE / 4) * level / 100 + 5); // Account for nature int incr = Nature / 5 + 1;