From 4dcac24f347bb1f2dfcb8b62b0d9bbc7ecac5cb1 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 7 Jul 2018 21:31:07 -0700 Subject: [PATCH] Add roamer3 active/level editing --- PKHeX.Core/Saves/Substructures/Roamer3.cs | 21 +++++++++++++++- .../Save Editors/Gen3/SAV_Roamer3.Designer.cs | 25 +++++++++++++++++++ .../Subforms/Save Editors/Gen3/SAV_Roamer3.cs | 5 ++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Saves/Substructures/Roamer3.cs b/PKHeX.Core/Saves/Substructures/Roamer3.cs index 2a36b8d16..8ee8db810 100644 --- a/PKHeX.Core/Saves/Substructures/Roamer3.cs +++ b/PKHeX.Core/Saves/Substructures/Roamer3.cs @@ -2,7 +2,7 @@ namespace PKHeX.Core { - public class Roamer3 + public class Roamer3 : IContestStats { private readonly SaveFile SAV; private readonly int Offset; @@ -36,6 +36,25 @@ public int Species get => SpeciesConverter.GetG4Species(BitConverter.ToInt16(SAV.Data, Offset + 8)); set => SAV.SetData(BitConverter.GetBytes((ushort)SpeciesConverter.GetG3Species(value)), Offset + 8); } + public int HP_Current + { + get => BitConverter.ToInt16(SAV.Data, Offset + 10); + set => SAV.SetData(BitConverter.GetBytes((short)value), Offset + 10); + } + public int CurrentLevel + { + get => SAV.Data[Offset + 12]; + set => SAV.Data[Offset + 12] = (byte)value; + } + public int Status { get => SAV.Data[Offset + 0x0D]; set => SAV.Data[Offset + 0x0D] = (byte)value; } + + public int CNT_Cool { get => SAV.Data[Offset + 0x0E]; set => SAV.Data[Offset + 0x0E] = (byte)value; } + public int CNT_Beauty { get => SAV.Data[Offset + 0x0F]; set => SAV.Data[Offset + 0x0F] = (byte)value; } + public int CNT_Cute { get => SAV.Data[Offset + 0x10]; set => SAV.Data[Offset + 0x10] = (byte)value; } + public int CNT_Smart { get => SAV.Data[Offset + 0x11]; set => SAV.Data[Offset + 0x11] = (byte)value; } + public int CNT_Tough { get => SAV.Data[Offset + 0x12]; set => SAV.Data[Offset + 0x12] = (byte)value; } + public int CNT_Sheen { get => 0; set { } } + public bool Active { get => SAV.Data[Offset + 0x13] == 1; set => SAV.Data[Offset + 0x13] = (byte)(value ? 1 : 0); } // Derived Properties private int IV_HP { get => (int)(IV32 >> 00) & 0x1F; set => IV32 = (uint)((IV32 & ~(0x1F << 00)) | (uint)((value > 31 ? 31 : value) << 00)); } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.Designer.cs index aa524cc91..87b0e74d2 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.Designer.cs @@ -48,6 +48,9 @@ private void InitializeComponent() this.CB_Species = new System.Windows.Forms.ComboBox(); this.Label_Species = new System.Windows.Forms.Label(); this.CHK_Shiny = new System.Windows.Forms.CheckBox(); + this.CHK_Active = new System.Windows.Forms.CheckBox(); + this.NUD_Level = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Level)).BeginInit(); this.SuspendLayout(); // // B_Save @@ -255,11 +258,30 @@ private void InitializeComponent() this.CHK_Shiny.Text = "Shiny?"; this.CHK_Shiny.UseVisualStyleBackColor = true; // + // CHK_Active + // + this.CHK_Active.AutoSize = true; + this.CHK_Active.Location = new System.Drawing.Point(201, 61); + this.CHK_Active.Name = "CHK_Active"; + this.CHK_Active.Size = new System.Drawing.Size(68, 30); + this.CHK_Active.TabIndex = 91; + this.CHK_Active.Text = "Roaming\r\n(Active)"; + this.CHK_Active.UseVisualStyleBackColor = true; + // + // NUD_Level + // + this.NUD_Level.Location = new System.Drawing.Point(193, 12); + this.NUD_Level.Name = "NUD_Level"; + this.NUD_Level.Size = new System.Drawing.Size(45, 20); + this.NUD_Level.TabIndex = 92; + // // SAV_Roamer3 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(278, 143); + this.Controls.Add(this.NUD_Level); + this.Controls.Add(this.CHK_Active); this.Controls.Add(this.CHK_Shiny); this.Controls.Add(this.Label_Species); this.Controls.Add(this.CB_Species); @@ -287,6 +309,7 @@ private void InitializeComponent() this.Name = "SAV_Roamer3"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Roamer Editor"; + ((System.ComponentModel.ISupportInitialize)(this.NUD_Level)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -312,5 +335,7 @@ private void InitializeComponent() public System.Windows.Forms.ComboBox CB_Species; private System.Windows.Forms.Label Label_Species; private System.Windows.Forms.CheckBox CHK_Shiny; + private System.Windows.Forms.CheckBox CHK_Active; + private System.Windows.Forms.NumericUpDown NUD_Level; } } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.cs index 70522695d..dd2b3e48d 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.cs @@ -33,6 +33,9 @@ private void LoadData() var iv = new[] {TB_HPIV, TB_ATKIV, TB_DEFIV, TB_SPEIV, TB_SPAIV, TB_SPDIV}; for (int i = 0; i < iv.Length; i++) iv[i].Text = IVs[i].ToString(); + + CHK_Active.Checked = Reader.Active; + NUD_Level.Value = Math.Min(NUD_Level.Maximum, Reader.CurrentLevel); } private void SaveData() { @@ -44,6 +47,8 @@ private void SaveData() Reader.PID = Util.GetHexValue(TB_PID.Text); Reader.Species = WinFormsUtil.GetIndex(CB_Species); Reader.IVs = IVs; + Reader.Active = CHK_Active.Checked; + Reader.CurrentLevel = (int)NUD_Level.Value; } private void B_Save_Click(object sender, EventArgs e) {