From fdc52e2c1947a29c5a42a2358b3c14ac559fee28 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 29 Nov 2017 20:04:01 -0800 Subject: [PATCH] Add pkm league starter EC for gen7 Closes #1671 --- PKHeX.Core/Saves/SAV7.cs | 5 ++++ .../Save Editors/Gen6/SAV_HallOfFame.cs | 2 +- .../Gen7/SAV_HallOfFame7.Designer.cs | 26 +++++++++++++++++++ .../Save Editors/Gen7/SAV_HallOfFame7.cs | 9 +++++++ .../Save Editors/Gen7/SAV_Trainer7.cs | 1 + .../Save Editors/Gen7/SAV_ZygardeCell.cs | 2 ++ 6 files changed, 44 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Saves/SAV7.cs b/PKHeX.Core/Saves/SAV7.cs index 380b6929c..c8bd1e14f 100644 --- a/PKHeX.Core/Saves/SAV7.cs +++ b/PKHeX.Core/Saves/SAV7.cs @@ -612,6 +612,11 @@ public int Vivillon get => Data[Misc + 0x130] & 0x1F; set => Data[Misc + 0x130] = (byte)((Data[Misc + 0x130] & ~0x1F) | (value & 0x1F)); } + public uint StarterEncryptionConstant + { + get => BitConverter.ToUInt32(Data, Misc + 0x148); + set => SetData(BitConverter.GetBytes(value), Misc + 0x148); + } public int DaysFromRefreshed { get => Data[Misc + 0x123]; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs index 8087f8215..5c8db57f0 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_HallOfFame.cs @@ -252,7 +252,7 @@ private void Write_Entry(object sender, EventArgs e) BitConverter.GetBytes(Convert.ToUInt16(CB_Move2.SelectedValue)).CopyTo(data, offset + 0x06); BitConverter.GetBytes(Convert.ToUInt16(CB_Move3.SelectedValue)).CopyTo(data, offset + 0x08); BitConverter.GetBytes(Convert.ToUInt16(CB_Move4.SelectedValue)).CopyTo(data, offset + 0x0A); - BitConverter.GetBytes(Convert.ToUInt32(TB_EC.Text,16)).CopyTo(data, offset + 0x0C); + BitConverter.GetBytes(Util.GetHexValue(TB_EC.Text)).CopyTo(data, offset + 0x0C); BitConverter.GetBytes(Convert.ToUInt16(TB_TID.Text)).CopyTo(data, offset + 0x10); BitConverter.GetBytes(Convert.ToUInt16(TB_SID.Text)).CopyTo(data, offset + 0x12); diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.Designer.cs index 30a8e14bd..1882907a9 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.Designer.cs @@ -60,6 +60,8 @@ private void InitializeComponent() this.L_C1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); + this.TB_EC = new System.Windows.Forms.TextBox(); + this.L_EC = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Count)).BeginInit(); this.SuspendLayout(); // @@ -373,11 +375,33 @@ private void InitializeComponent() this.label2.Text = "Current"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // TB_EC + // + this.TB_EC.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.TB_EC.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.TB_EC.Location = new System.Drawing.Point(220, 4); + this.TB_EC.MaxLength = 8; + this.TB_EC.Name = "TB_EC"; + this.TB_EC.Size = new System.Drawing.Size(60, 20); + this.TB_EC.TabIndex = 65; + this.TB_EC.Text = "12345678"; + // + // Label_EncryptionConstant + // + this.L_EC.Location = new System.Drawing.Point(143, 5); + this.L_EC.Name = "L_EC"; + this.L_EC.Size = new System.Drawing.Size(75, 15); + this.L_EC.TabIndex = 64; + this.L_EC.Text = "Starter EC:"; + this.L_EC.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // // SAV_HallOfFame7 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(394, 201); + this.Controls.Add(this.TB_EC); + this.Controls.Add(this.L_EC); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.CB_C6); @@ -454,5 +478,7 @@ private void InitializeComponent() private System.Windows.Forms.Label L_C1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox TB_EC; + private System.Windows.Forms.Label L_EC; } } \ No newline at end of file diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.cs index 4ba4eaa7f..effaa0526 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_HallOfFame7.cs @@ -43,6 +43,11 @@ private void Setup() cb.SelectedValue = (int)BitConverter.ToUInt16(SAV.Data, o); } + + if (SAV.USUM) + TB_EC.Text = SAV.StarterEncryptionConstant.ToString("X8"); + else + TB_EC.Visible = L_EC.Visible = false; } private void B_Cancel_Click(object sender, EventArgs e) @@ -63,6 +68,10 @@ private void B_Close_Click(object sender, EventArgs e) var val = WinFormsUtil.GetIndex(cb); BitConverter.GetBytes((ushort)val).CopyTo(SAV.Data, o); } + + if (SAV.USUM) + SAV.StarterEncryptionConstant = Util.GetHexValue(TB_EC.Text); + Origin.SetData(SAV.Data, 0); Close(); } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs index b53df8fe0..be73130b4 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_Trainer7.cs @@ -747,6 +747,7 @@ private void B_GenTID_Click(object sender, EventArgs e) {069, "Items Reeled In"}, // USUM {070, "Roto Lotos"}, + {072, "Stickers Collected"}, {073, "Mantine Surf BP Earned"}, {074, "Battle Agency Wins"}, diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_ZygardeCell.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_ZygardeCell.cs index 3cbdeb3ba..d7e0b9212 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_ZygardeCell.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_ZygardeCell.cs @@ -67,6 +67,8 @@ private void B_Save_Click(object sender, EventArgs e) constants[cellstotal] = (ushort)NUD_Cells.Value; constants[cellscollected] = (ushort)NUD_Collected.Value; + if (SAV.USUM) + SAV.SetRecord(72, (int)NUD_Collected.Value); SAV.EventConsts = constants; Origin.SetData(SAV.Data, 0);