diff --git a/PKHeX/MainWindow/Main.Designer.cs b/PKHeX/MainWindow/Main.Designer.cs index aae41e99a..1e265c14d 100644 --- a/PKHeX/MainWindow/Main.Designer.cs +++ b/PKHeX/MainWindow/Main.Designer.cs @@ -105,6 +105,13 @@ public void InitializeComponent() this.FLP_NSparkle = new System.Windows.Forms.FlowLayoutPanel(); this.L_NSparkle = new System.Windows.Forms.Label(); this.CHK_NSparkle = new System.Windows.Forms.CheckBox(); + this.FLP_ShadowID = new System.Windows.Forms.FlowLayoutPanel(); + this.L_ShadowID = new System.Windows.Forms.Label(); + this.NUD_ShadowID = new System.Windows.Forms.NumericUpDown(); + this.FLP_Purification = new System.Windows.Forms.FlowLayoutPanel(); + this.L_HeartGauge = new System.Windows.Forms.Label(); + this.NUD_Purification = new System.Windows.Forms.NumericUpDown(); + this.CHK_Shadow = new System.Windows.Forms.CheckBox(); this.Tab_Met = new System.Windows.Forms.TabPage(); this.CHK_AsEgg = new System.Windows.Forms.CheckBox(); this.GB_EggConditions = new System.Windows.Forms.GroupBox(); @@ -393,6 +400,8 @@ public void InitializeComponent() this.subepkx2 = new System.Windows.Forms.PictureBox(); this.subepkx3 = new System.Windows.Forms.PictureBox(); this.Tab_SAV = new System.Windows.Forms.TabPage(); + this.CB_SaveSlot = new System.Windows.Forms.ComboBox(); + this.L_SaveSlot = new System.Windows.Forms.Label(); this.L_Secure2 = new System.Windows.Forms.Label(); this.TB_Secure2 = new System.Windows.Forms.TextBox(); this.L_Secure1 = new System.Windows.Forms.Label(); @@ -427,8 +436,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.L_SaveSlot = new System.Windows.Forms.Label(); - this.CB_SaveSlot = new System.Windows.Forms.ComboBox(); this.tabMain.SuspendLayout(); this.Tab_Main.SuspendLayout(); this.FLP_Main.SuspendLayout(); @@ -458,6 +465,10 @@ public void InitializeComponent() this.FLP_SubRegion.SuspendLayout(); this.FLP_3DSRegion.SuspendLayout(); this.FLP_NSparkle.SuspendLayout(); + this.FLP_ShadowID.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_ShadowID)).BeginInit(); + this.FLP_Purification.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Purification)).BeginInit(); this.Tab_Met.SuspendLayout(); this.GB_EggConditions.SuspendLayout(); this.FLP_Met.SuspendLayout(); @@ -593,6 +604,8 @@ public void InitializeComponent() // tabMain // this.tabMain.AllowDrop = true; + this.tabMain.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); this.tabMain.Controls.Add(this.Tab_Main); this.tabMain.Controls.Add(this.Tab_Met); this.tabMain.Controls.Add(this.Tab_Stats); @@ -635,9 +648,11 @@ public void InitializeComponent() this.FLP_Main.Controls.Add(this.FLP_SubRegion); this.FLP_Main.Controls.Add(this.FLP_3DSRegion); this.FLP_Main.Controls.Add(this.FLP_NSparkle); + this.FLP_Main.Controls.Add(this.FLP_ShadowID); + this.FLP_Main.Controls.Add(this.FLP_Purification); this.FLP_Main.Location = new System.Drawing.Point(0, 2); this.FLP_Main.Name = "FLP_Main"; - this.FLP_Main.Size = new System.Drawing.Size(272, 322); + this.FLP_Main.Size = new System.Drawing.Size(272, 391); this.FLP_Main.TabIndex = 103; // // FLP_PID @@ -1501,6 +1516,90 @@ public void InitializeComponent() this.CHK_NSparkle.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.CHK_NSparkle.UseVisualStyleBackColor = true; // + // FLP_ShadowID + // + this.FLP_ShadowID.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.FLP_ShadowID.Controls.Add(this.L_ShadowID); + this.FLP_ShadowID.Controls.Add(this.NUD_ShadowID); + this.FLP_ShadowID.Location = new System.Drawing.Point(0, 317); + this.FLP_ShadowID.Margin = new System.Windows.Forms.Padding(0); + this.FLP_ShadowID.Name = "FLP_ShadowID"; + this.FLP_ShadowID.Size = new System.Drawing.Size(272, 21); + this.FLP_ShadowID.TabIndex = 114; + // + // L_ShadowID + // + this.L_ShadowID.Location = new System.Drawing.Point(0, 0); + this.L_ShadowID.Margin = new System.Windows.Forms.Padding(0); + this.L_ShadowID.Name = "L_ShadowID"; + this.L_ShadowID.Size = new System.Drawing.Size(110, 21); + this.L_ShadowID.TabIndex = 9; + this.L_ShadowID.Text = "Shadow ID:"; + this.L_ShadowID.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // NUD_ShadowID + // + this.NUD_ShadowID.Location = new System.Drawing.Point(110, 1); + this.NUD_ShadowID.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0); + this.NUD_ShadowID.Maximum = new decimal(new int[] { + 72, + 0, + 0, + 0}); + this.NUD_ShadowID.Name = "NUD_ShadowID"; + this.NUD_ShadowID.Size = new System.Drawing.Size(51, 20); + this.NUD_ShadowID.TabIndex = 103; + this.NUD_ShadowID.ValueChanged += new System.EventHandler(this.updateShadowID); + // + // FLP_Purification + // + this.FLP_Purification.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.FLP_Purification.Controls.Add(this.L_HeartGauge); + this.FLP_Purification.Controls.Add(this.NUD_Purification); + this.FLP_Purification.Controls.Add(this.CHK_Shadow); + this.FLP_Purification.Location = new System.Drawing.Point(0, 338); + this.FLP_Purification.Margin = new System.Windows.Forms.Padding(0); + this.FLP_Purification.Name = "FLP_Purification"; + this.FLP_Purification.Size = new System.Drawing.Size(272, 21); + this.FLP_Purification.TabIndex = 113; + // + // L_HeartGauge + // + this.L_HeartGauge.Location = new System.Drawing.Point(0, 0); + this.L_HeartGauge.Margin = new System.Windows.Forms.Padding(0); + this.L_HeartGauge.Name = "L_HeartGauge"; + this.L_HeartGauge.Size = new System.Drawing.Size(110, 21); + this.L_HeartGauge.TabIndex = 9; + this.L_HeartGauge.Text = "Heart Gauge:"; + this.L_HeartGauge.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // NUD_Purification + // + this.NUD_Purification.Location = new System.Drawing.Point(110, 1); + this.NUD_Purification.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0); + this.NUD_Purification.Maximum = new decimal(new int[] { + 20000, + 0, + 0, + 0}); + this.NUD_Purification.Name = "NUD_Purification"; + this.NUD_Purification.Size = new System.Drawing.Size(51, 20); + this.NUD_Purification.TabIndex = 103; + this.NUD_Purification.ValueChanged += new System.EventHandler(this.updatePurification); + // + // CHK_Shadow + // + this.CHK_Shadow.AutoSize = true; + this.CHK_Shadow.Location = new System.Drawing.Point(161, 3); + this.CHK_Shadow.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3); + this.CHK_Shadow.Name = "CHK_Shadow"; + this.CHK_Shadow.Size = new System.Drawing.Size(65, 17); + this.CHK_Shadow.TabIndex = 16; + this.CHK_Shadow.Text = "Shadow"; + this.CHK_Shadow.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.CHK_Shadow.UseVisualStyleBackColor = true; + this.CHK_Shadow.CheckedChanged += new System.EventHandler(this.updateShadowCHK); + // // Tab_Met // this.Tab_Met.AllowDrop = true; @@ -3545,7 +3644,7 @@ public void InitializeComponent() this.Menu_Open.Name = "Menu_Open"; this.Menu_Open.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); this.Menu_Open.ShowShortcutKeys = false; - this.Menu_Open.Size = new System.Drawing.Size(152, 22); + this.Menu_Open.Size = new System.Drawing.Size(139, 22); this.Menu_Open.Text = "&Open..."; this.Menu_Open.Click += new System.EventHandler(this.mainMenuOpen); // @@ -3555,7 +3654,7 @@ public void InitializeComponent() this.Menu_Save.Name = "Menu_Save"; this.Menu_Save.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); this.Menu_Save.ShowShortcutKeys = false; - this.Menu_Save.Size = new System.Drawing.Size(152, 22); + this.Menu_Save.Size = new System.Drawing.Size(139, 22); this.Menu_Save.Text = "&Save PK6..."; this.Menu_Save.Click += new System.EventHandler(this.mainMenuSave); // @@ -3567,7 +3666,7 @@ public void InitializeComponent() this.Menu_ExportSAV.Enabled = false; this.Menu_ExportSAV.Image = global::PKHeX.Properties.Resources.saveSAV; this.Menu_ExportSAV.Name = "Menu_ExportSAV"; - this.Menu_ExportSAV.Size = new System.Drawing.Size(152, 22); + this.Menu_ExportSAV.Size = new System.Drawing.Size(139, 22); this.Menu_ExportSAV.Text = "&Export SAV..."; // // Menu_ExportMAIN @@ -3576,7 +3675,7 @@ public void InitializeComponent() this.Menu_ExportMAIN.Name = "Menu_ExportMAIN"; this.Menu_ExportMAIN.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); this.Menu_ExportMAIN.ShowShortcutKeys = false; - this.Menu_ExportMAIN.Size = new System.Drawing.Size(152, 22); + this.Menu_ExportMAIN.Size = new System.Drawing.Size(142, 22); this.Menu_ExportMAIN.Text = "&Export main"; this.Menu_ExportMAIN.Click += new System.EventHandler(this.clickExportSAV); // @@ -3586,7 +3685,7 @@ public void InitializeComponent() this.Menu_ExportBAK.Name = "Menu_ExportBAK"; this.Menu_ExportBAK.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.B))); this.Menu_ExportBAK.ShowShortcutKeys = false; - this.Menu_ExportBAK.Size = new System.Drawing.Size(152, 22); + this.Menu_ExportBAK.Size = new System.Drawing.Size(142, 22); this.Menu_ExportBAK.Text = "Export &Backup"; this.Menu_ExportBAK.Click += new System.EventHandler(this.clickExportSAVBAK); // @@ -3596,7 +3695,7 @@ public void InitializeComponent() this.Menu_Exit.Name = "Menu_Exit"; this.Menu_Exit.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q))); this.Menu_Exit.ShowShortcutKeys = false; - this.Menu_Exit.Size = new System.Drawing.Size(152, 22); + this.Menu_Exit.Size = new System.Drawing.Size(139, 22); this.Menu_Exit.Text = "&Quit"; this.Menu_Exit.Click += new System.EventHandler(this.mainMenuExit); // @@ -3861,6 +3960,7 @@ public void InitializeComponent() // // tabBoxMulti // + this.tabBoxMulti.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.tabBoxMulti.Controls.Add(this.Tab_Box); this.tabBoxMulti.Controls.Add(this.Tab_PartyBattle); this.tabBoxMulti.Controls.Add(this.Tab_Other); @@ -5121,6 +5221,25 @@ public void InitializeComponent() this.Tab_SAV.Text = "SAV"; this.Tab_SAV.UseVisualStyleBackColor = true; // + // CB_SaveSlot + // + this.CB_SaveSlot.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_SaveSlot.FormattingEnabled = true; + this.CB_SaveSlot.Location = new System.Drawing.Point(150, 148); + this.CB_SaveSlot.Name = "CB_SaveSlot"; + this.CB_SaveSlot.Size = new System.Drawing.Size(121, 21); + this.CB_SaveSlot.TabIndex = 20; + this.CB_SaveSlot.SelectedValueChanged += new System.EventHandler(this.updateSaveSlot); + // + // L_SaveSlot + // + this.L_SaveSlot.AutoSize = true; + this.L_SaveSlot.Location = new System.Drawing.Point(92, 151); + this.L_SaveSlot.Name = "L_SaveSlot"; + this.L_SaveSlot.Size = new System.Drawing.Size(56, 13); + this.L_SaveSlot.TabIndex = 19; + this.L_SaveSlot.Text = "Save Slot:"; + // // L_Secure2 // this.L_Secure2.Location = new System.Drawing.Point(33, 113); @@ -5217,6 +5336,8 @@ public void InitializeComponent() // // GB_SAVtools // + this.GB_SAVtools.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); this.GB_SAVtools.Controls.Add(this.FLP_SAVtools); this.GB_SAVtools.Location = new System.Drawing.Point(300, 252); this.GB_SAVtools.Name = "GB_SAVtools"; @@ -5482,25 +5603,6 @@ public void InitializeComponent() this.L_UpdateAvailable.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.L_UpdateAvailable.Visible = false; // - // L_SaveSlot - // - this.L_SaveSlot.AutoSize = true; - this.L_SaveSlot.Location = new System.Drawing.Point(92, 151); - this.L_SaveSlot.Name = "L_SaveSlot"; - this.L_SaveSlot.Size = new System.Drawing.Size(56, 13); - this.L_SaveSlot.TabIndex = 19; - this.L_SaveSlot.Text = "Save Slot:"; - // - // CB_SaveSlot - // - this.CB_SaveSlot.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.CB_SaveSlot.FormattingEnabled = true; - this.CB_SaveSlot.Location = new System.Drawing.Point(150, 148); - this.CB_SaveSlot.Name = "CB_SaveSlot"; - this.CB_SaveSlot.Size = new System.Drawing.Size(121, 21); - this.CB_SaveSlot.TabIndex = 20; - this.CB_SaveSlot.SelectedValueChanged += new System.EventHandler(this.updateSaveSlot); - // // Main // this.AllowDrop = true; @@ -5562,6 +5664,11 @@ public void InitializeComponent() this.FLP_3DSRegion.ResumeLayout(false); this.FLP_NSparkle.ResumeLayout(false); this.FLP_NSparkle.PerformLayout(); + this.FLP_ShadowID.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.NUD_ShadowID)).EndInit(); + this.FLP_Purification.ResumeLayout(false); + this.FLP_Purification.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Purification)).EndInit(); this.Tab_Met.ResumeLayout(false); this.Tab_Met.PerformLayout(); this.GB_EggConditions.ResumeLayout(false); @@ -6124,6 +6231,13 @@ public void InitializeComponent() private System.Windows.Forms.Label Label_IVs; private System.Windows.Forms.ComboBox CB_SaveSlot; private System.Windows.Forms.Label L_SaveSlot; + private System.Windows.Forms.FlowLayoutPanel FLP_Purification; + public System.Windows.Forms.CheckBox CHK_Shadow; + private System.Windows.Forms.Label L_HeartGauge; + private System.Windows.Forms.NumericUpDown NUD_Purification; + private System.Windows.Forms.FlowLayoutPanel FLP_ShadowID; + private System.Windows.Forms.Label L_ShadowID; + private System.Windows.Forms.NumericUpDown NUD_ShadowID; } } diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index b11062eb0..a480647d9 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -999,6 +999,9 @@ private void loadSAV(SaveFile sav, string path) } else L_SaveSlot.Visible = CB_SaveSlot.Visible = false; + + FLP_Purification.Visible = FLP_ShadowID.Visible = SAV.Version == GameVersion.COLO || SAV.Version == GameVersion.XD; + NUD_ShadowID.Maximum = SAV.MaxShadowID; // HaX override, needs to be after DEV_Ability enabled assignment. TB_AbilityNumber.Visible = SAV.Generation >= 6 && DEV_Ability.Enabled; @@ -2639,6 +2642,28 @@ private void update_ID(object sender, EventArgs e) fieldsLoaded = true; } } + private void updateShadowID(object sender, EventArgs e) + { + if (!fieldsLoaded) + return; + FLP_Purification.Visible = NUD_ShadowID.Value > 0; + } + private void updatePurification(object sender, EventArgs e) + { + if (!fieldsLoaded) + return; + fieldsLoaded = false; + CHK_Shadow.Checked = NUD_Purification.Value == 0; + fieldsLoaded = true; + } + private void updateShadowCHK(object sender, EventArgs e) + { + if (!fieldsLoaded) + return; + fieldsLoaded = false; + NUD_Purification.Value = CHK_Shadow.Checked ? NUD_Purification.Maximum : 0; + fieldsLoaded = true; + } private void validateComboBox(object sender) { if (!formInitialized) diff --git a/PKHeX/MainWindow/Main.resx b/PKHeX/MainWindow/Main.resx index 77586a336..f0c9f5ccd 100644 --- a/PKHeX/MainWindow/Main.resx +++ b/PKHeX/MainWindow/Main.resx @@ -129,15 +129,6 @@ True - - True - - - True - - - True - @@ -164,21 +155,6 @@ True - - True - - - True - - - True - - - True - - - True - True @@ -188,51 +164,9 @@ True - - True - - - True - - - True - True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -245,132 +179,18 @@ 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 - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -383,22 +203,25 @@ True - - True - - - True - True True - + True - + + True + + + True + + + True + + True @@ -407,414 +230,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 - - - 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 - - - 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 - - - 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 @@ -839,6 +254,621 @@ 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 @@ -1104,15 +1134,6 @@ True - - True - - - True - - - True - True @@ -1372,63 +1393,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -1627,6 +1591,21 @@ True + + True + + + True + + + True + + + True + + + True + True @@ -1849,6 +1828,21 @@ True + + True + + + True + + + True + + + True + + + True + True @@ -1945,6 +1939,60 @@ True + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + True diff --git a/PKHeX/MainWindow/MainCK3.cs b/PKHeX/MainWindow/MainCK3.cs index 30b5f5e1e..a3c82476e 100644 --- a/PKHeX/MainWindow/MainCK3.cs +++ b/PKHeX/MainWindow/MainCK3.cs @@ -99,6 +99,25 @@ private void populateFieldsCK3() // Load Extrabyte Value TB_ExtraByte.Text = ck3.Data[Convert.ToInt32(CB_ExtraBytes.Text, 16)].ToString(); + NUD_ShadowID.Value = ck3.ShadowID; + FLP_Purification.Visible = ck3.ShadowID > 0; + if (ck3.ShadowID > 0) + { + int puri = ck3.Purification; + if (puri > NUD_Purification.Maximum) + puri = (int)NUD_Purification.Maximum; + NUD_Purification.Value = puri; + CHK_Shadow.Checked = puri > 0; + + NUD_ShadowID.Value = Math.Max(ck3.ShadowID, 0); + } + else + { + NUD_Purification.Value = 0; + CHK_Shadow.Checked = false; + NUD_ShadowID.Value = 0; + } + updateStats(); TB_EXP.Text = ck3.EXP.ToString(); @@ -187,6 +206,11 @@ private PKM prepareCK3() ck3.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); } + // Shadow Info + ck3.ShadowID = (int)NUD_ShadowID.Value; + if (ck3.ShadowID > 0) + ck3.Purification = (int)NUD_Purification.Value; + // Fix Moves if a slot is empty ck3.FixMoves(); diff --git a/PKHeX/MainWindow/MainXK3.cs b/PKHeX/MainWindow/MainXK3.cs index 56f4f587c..67e2a75d2 100644 --- a/PKHeX/MainWindow/MainXK3.cs +++ b/PKHeX/MainWindow/MainXK3.cs @@ -96,6 +96,25 @@ private void populateFieldsXK3() // Load Extrabyte Value TB_ExtraByte.Text = xk3.Data[Convert.ToInt32(CB_ExtraBytes.Text, 16)].ToString(); + NUD_ShadowID.Value = xk3.ShadowID; + FLP_Purification.Visible = xk3.ShadowID > 0; + if (xk3.ShadowID > 0) + { + int puri = xk3.Purification; + if (puri > NUD_Purification.Maximum) + puri = (int)NUD_Purification.Maximum; + NUD_Purification.Value = puri; + CHK_Shadow.Checked = puri > 0; + + NUD_ShadowID.Value = Math.Max(xk3.ShadowID, 0); + } + else + { + NUD_Purification.Value = 0; + CHK_Shadow.Checked = false; + NUD_ShadowID.Value = 0; + } + updateStats(); TB_EXP.Text = xk3.EXP.ToString(); @@ -184,6 +203,11 @@ private PKM prepareXK3() xk3.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); } + // Shadow Info + xk3.ShadowID = (int)NUD_ShadowID.Value; + if (xk3.ShadowID > 0) + xk3.Purification = (int)NUD_Purification.Value; + // Fix Moves if a slot is empty xk3.FixMoves(); diff --git a/PKHeX/PKM/CK3.cs b/PKHeX/PKM/CK3.cs index 50e69eee2..f6adae919 100644 --- a/PKHeX/PKM/CK3.cs +++ b/PKHeX/PKM/CK3.cs @@ -170,8 +170,8 @@ public CK3(byte[] decryptedData = null, string ident = null) public override bool Valid => Data[0xCD] == 0; // 0xCE unknown public override byte MarkByte { get { return Data[0xCF]; } protected set { Data[0xCF] = value; } } - public override int PKRS_Days { get { return Data[0xD0] & 0xF; } set { Data[0xD0] = (byte)(value & 0xF); } } - public ushort ShadowID { get { return BigEndian.ToUInt16(Data, 0xD8); } set { BigEndian.GetBytes(value).CopyTo(Data, 0xD8); } } + public override int PKRS_Days { get { return Math.Max((sbyte)Data[0xD0], (sbyte)0); } set { Data[0xD0] = (byte)(value == 0 ? 0xFF : value & 0xF); } } + public int ShadowID { get { return BigEndian.ToUInt16(Data, 0xD8); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0xD8); } } public int Purification { get { return BigEndian.ToInt32(Data, 0xDC); } set { BigEndian.GetBytes(value).CopyTo(Data, 0xDC); } } public uint EXP_Shadow { get { return BigEndian.ToUInt32(Data, 0xC0); } set { BigEndian.GetBytes(value).CopyTo(Data, 0xC0); } } public override bool FatefulEncounter { get { return Data[0x11C] == 1; } set { Data[0x11C] = (byte)(value ? 1 : 0); } } diff --git a/PKHeX/PKM/XK3.cs b/PKHeX/PKM/XK3.cs index 5a5000599..7793f9936 100644 --- a/PKHeX/PKM/XK3.cs +++ b/PKHeX/PKM/XK3.cs @@ -23,7 +23,7 @@ public XK3(byte[] decryptedData = null, string ident = null) if (Data.Length != SIZE_PARTY) Array.Resize(ref Data, SIZE_PARTY); } - public override PKM Clone() { return new XK3(Data); } + public override PKM Clone() { return new XK3(Data) {Purification = Purification}; } // Future Attributes public override uint EncryptionConstant { get { return PID; } set { } } @@ -57,7 +57,7 @@ public XK3(byte[] decryptedData = null, string ident = null) public override int CNT_Sheen { get { return Data[0x12]; } set { Data[0x12] = (byte)value; } } public override int PKRS_Strain { get { return Data[0x13] & 0xF; } set { Data[0x13] = (byte)(value & 0xF); } } public override byte MarkByte { get { return Data[0x14]; } protected set { Data[0x14] = value; } } - public override int PKRS_Days { get { return Data[0x15] & 0xF; } set { Data[0x15] = (byte)(value & 0xF); } } + public override int PKRS_Days { get { return Math.Max((sbyte)Data[0x15], (sbyte)0); } set { Data[0x15] = (byte)(value == 0 ? 0xFF : value & 0xF); } } // 0x16-0x1C Battle Related private int XDPKMFLAGS { get { return Data[0x1D]; } set { Data[0x1D] = (byte)value; } } public bool UnusedFlag0 { get { return (XDPKMFLAGS & (1 << 0)) == 1 << 0; } set { XDPKMFLAGS = XDPKMFLAGS & ~(1 << 0) | (value ? 1 << 0 : 0); } } @@ -179,9 +179,10 @@ public override int EV_SPE public int RibbonCountG3Smart { get { return Data[0xB6]; } set { Data[0xB6] = (byte)value; } } public int RibbonCountG3Tough { get { return Data[0xB7]; } set { Data[0xB7] = (byte)value; } } - public ushort ShadowID { get { return BigEndian.ToUInt16(Data, 0xBA); } set { BigEndian.GetBytes(value).CopyTo(Data, 0xBA); } } + public int ShadowID { get { return BigEndian.ToUInt16(Data, 0xBA); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0xBA); } } // Purification information is stored in the save file and accessed based on the Shadow ID. + public int Purification { get; set; } // Generated Attributes public override int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 3); diff --git a/PKHeX/Saves/SAV3Colosseum.cs b/PKHeX/Saves/SAV3Colosseum.cs index e676ed9a1..e21b0d3fa 100644 --- a/PKHeX/Saves/SAV3Colosseum.cs +++ b/PKHeX/Saves/SAV3Colosseum.cs @@ -25,6 +25,7 @@ public sealed class SAV3Colosseum : SaveFile private readonly int SaveCount = -1; private readonly int SaveIndex = -1; private readonly StrategyMemo StrategyMemo; + public override int MaxShadowID => 0x30; // 48 private readonly int Memo; private readonly ushort[] LegalItems, LegalKeyItems, LegalBalls, LegalTMHMs, LegalBerries, LegalCologne; private readonly int OFS_PouchCologne; diff --git a/PKHeX/Saves/SAV3XD.cs b/PKHeX/Saves/SAV3XD.cs index 257f23ca8..1f143b4c3 100644 --- a/PKHeX/Saves/SAV3XD.cs +++ b/PKHeX/Saves/SAV3XD.cs @@ -16,8 +16,10 @@ public sealed class SAV3XD : SaveFile private readonly int SaveCount = -1; private readonly int SaveIndex = -1; - private readonly int Memo; + private readonly int Memo, Shadow; private readonly StrategyMemo StrategyMemo; + private readonly ShadowInfoTableXD ShadowInfo; + public override int MaxShadowID => ShadowInfo.Count; private readonly ushort[] LegalItems, LegalKeyItems, LegalBalls, LegalTMHMs, LegalBerries, LegalCologne, LegalDisc; private readonly int OFS_PouchCologne, OFS_PouchDisc; private readonly int[] subOffsets = new int[16]; @@ -71,10 +73,11 @@ public SAV3XD(byte[] data = null) Box = subOffsets[2] + 0xA8; Daycare = subOffsets[4] + 0xA8; Memo = subOffsets[5] + 0xA8; - // Shadow = subOffsets[7] + 0xA8; + Shadow = subOffsets[7] + 0xA8; // Purifier = subOffsets[14] + 0xA8; StrategyMemo = new StrategyMemo(Data, Memo, xd: true); + ShadowInfo = new ShadowInfoTableXD(Data.Skip(Shadow).Take(subLength[7]).ToArray()); OFS_PouchHeldItem = Trainer1 + 0x4C8; OFS_PouchKeyItem = Trainer1 + 0x540; @@ -104,6 +107,7 @@ public override byte[] Write(bool DSV) { // Set Memo Back StrategyMemo.FinalData.CopyTo(Data, Memo); + ShadowInfo.FinalData.CopyTo(Data, Shadow); setChecksums(); // Get updated save slot data @@ -244,6 +248,35 @@ public override byte[] decryptPKM(byte[] data) return data; } + public override PKM getPartySlot(int offset) + { + return getStoredSlot(offset); + } + public override PKM getStoredSlot(int offset) + { + // Get Shadow Data + var pk = getPKM(decryptPKM(getData(offset, SIZE_STORED))) as XK3; + if (pk?.ShadowID > 0 && pk.ShadowID < ShadowInfo.Count) + pk.Purification = ShadowInfo[pk.ShadowID - 1].Purification; + return pk; + } + protected override void setPKM(PKM pkm) + { + XK3 pk = pkm as XK3; + if (pk == null) + return; // shouldn't ever hit + + // Set Shadow Data back to save + if (pk.ShadowID <= 0 || pk.ShadowID >= ShadowInfo.Count) + return; + + var entry = ShadowInfo[pk.ShadowID - 1]; + entry.Purification = pk.Purification; + entry.Species = pk.Species; + entry.PID = pk.PID; + entry.IsPurified = pk.Purification == 0; + } + protected override void setDex(PKM pkm) { // Dex Related diff --git a/PKHeX/Saves/SaveFile.cs b/PKHeX/Saves/SaveFile.cs index 4431602bb..4e00d1326 100644 --- a/PKHeX/Saves/SaveFile.cs +++ b/PKHeX/Saves/SaveFile.cs @@ -109,6 +109,7 @@ public virtual byte[] Write(bool DSV) public abstract int OTLength { get; } public abstract int NickLength { get; } public virtual int MaxMoney { get; } = 9999999; + public virtual int MaxShadowID { get; } = 0; // Offsets protected virtual int Box { get; set; } = int.MinValue; @@ -342,11 +343,11 @@ public virtual MysteryGiftAlbum GiftAlbum // Storage public virtual int BoxSlotCount => 30; - public PKM getPartySlot(int offset) + public virtual PKM getPartySlot(int offset) { return getPKM(decryptPKM(getData(offset, SIZE_PARTY))); } - public PKM getStoredSlot(int offset) + public virtual PKM getStoredSlot(int offset) { return getPKM(decryptPKM(getData(offset, SIZE_STORED))); } @@ -437,6 +438,7 @@ public void sortBoxes(int BoxStart = 0, int BoxEnd = -1) .OrderBy(p => p.Species == 0) // empty slots at end .ThenBy(p => p.IsEgg) // eggs to the end .ThenBy(p => p.Species) // species sorted + .ThenBy(p => p.AltForm) // altforms sorted .ThenBy(p => p.IsNicknamed).ToArray(); Array.Copy(Sorted, 0, BD, BoxStart*BoxSlotCount, Sorted.Length); diff --git a/PKHeX/Saves/Substructures/ShadowInfo.cs b/PKHeX/Saves/Substructures/ShadowInfo.cs index ef7d6e793..4b1724904 100644 --- a/PKHeX/Saves/Substructures/ShadowInfo.cs +++ b/PKHeX/Saves/Substructures/ShadowInfo.cs @@ -1,28 +1,74 @@ -namespace PKHeX +using System; +using System.Collections.Generic; +using System.Linq; + +namespace PKHeX { - public class ShadowInfoXD + public class ShadowInfoTableXD { - private readonly byte[] Data; - private const int SIZE_ENTRY = 72; - public ShadowInfoXD(byte[] data) + private readonly List Entries; + private readonly int MaxLength; + public ShadowInfoTableXD(byte[] data) + { + Entries = new List(); + MaxLength = data.Length; + const int eSize = ShadowInfoEntryXD.SIZE_ENTRY; + int eCount = data.Length/eSize; + for (int i = 0; i < eCount; i++) + { + byte[] d = new byte[eSize]; + Array.Copy(data, i*eSize, d, 0, eSize); + + var entry = new ShadowInfoEntryXD(d); + if (entry.Species != 0) + Entries.Add(entry); + } + } + public byte[] FinalData => Entries.SelectMany(entry => entry.Data).Take(MaxLength).ToArray(); + public ShadowInfoEntryXD GetEntry(int Species, uint PID) + { + return Entries.FirstOrDefault(entry => entry.PID == PID && entry.Species == Species) ?? new ShadowInfoEntryXD(); + } + public void SetEntry(ShadowInfoEntryXD Entry) + { + var entry = GetEntry(Entry.Species, Entry.PID); + if (entry.IsEmpty) + return; + + int index = Array.FindIndex(Entries.ToArray(), ent => ent.Species == entry.Species); + if (index > 0) + Entries[index] = entry; + else + Entries.Add(entry); + } + public ShadowInfoEntryXD this[int index] { get { return Entries[index]; } set { Entries[index] = value; } } + public int Count => Entries.Count; + } + + public class ShadowInfoEntryXD + { + public byte[] Data { get; private set; } + internal const int SIZE_ENTRY = 72; + public ShadowInfoEntryXD(byte[] data = null) { Data = (byte[])(data?.Clone() ?? new byte[SIZE_ENTRY]); } public bool IsSnagged => Data[0] >> 6 != 0; public bool IsPurified { get { return Data[0] >> 7 == 1; } set { Data[0] &= 0x7F; if (value) Data[0] |= 0x80; } } - public ushort Species { get { return BigEndian.ToUInt16(Data, 0x1A); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x1A); } } - public uint PID { get { return BigEndian.ToUInt32(Data, 0x1C); }set { BigEndian.GetBytes(value).CopyTo(Data, 0x1C); } } + public int Species { get { return BigEndian.ToUInt16(Data, 0x1A); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x1A); } } + public uint PID { get { return BigEndian.ToUInt32(Data, 0x1C); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x1C); } } public int Purification { get { return BigEndian.ToInt32(Data, 0x24); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x24); } } public uint EXP { get { return BigEndian.ToUInt32(Data, 0x04) >> 12; } set { BigEndian.GetBytes((BigEndian.ToUInt32(Data, 0x04) & 0xFFF) | (value << 12)).CopyTo(Data, 0x04); } } + public bool IsEmpty => Species == 0; } - public class ShadowInfoColo + public class ShadowInfoEntryColo { - private readonly byte[] Data; - private const int SIZE_ENTRY = 12; - public ShadowInfoColo(byte[] data = null) + public byte[] Data { get; private set; } + internal const int SIZE_ENTRY = 12; + public ShadowInfoEntryColo(byte[] data = null) { Data = (byte[])(data?.Clone() ?? new byte[SIZE_ENTRY]); }