diff --git a/PKHeX.Core/Editing/CommonEdits.cs b/PKHeX.Core/Editing/CommonEdits.cs index 82c732dd4..8b3c7b4dc 100644 --- a/PKHeX.Core/Editing/CommonEdits.cs +++ b/PKHeX.Core/Editing/CommonEdits.cs @@ -543,6 +543,59 @@ public static void SetHiddenPower(this PKM pk, int hptype) /// Desired Hidden Power typing. public static void SetHiddenPower(this PKM pk, MoveType hptype) => pk.SetHiddenPower((int) hptype); + /// + /// Sets the Technical Record flags for the . + /// + /// Pokémon to modify. + /// Value to set for the record. + /// Max record to set. + public static void SetRecordFlags(this PKM pk, bool value, int max = 100) + { + if (!(pk is PK8 pk8)) + return; + for (int i = 0; i < max; i++) + pk8.SetMoveRecordFlag(i, value); + } + + /// + /// Clears the Technical Record flags for the . + /// + /// Pokémon to modify. + public static void ClearRecordFlags(this PKM pk) => pk.SetRecordFlags(false, 128); + + /// + /// Sets the Technical Record flags for the based on the current moves. + /// + /// Pokémon to modify. + /// Moves to set flags for (if applicable) + public static void SetRecordFlags(this PKM pk, IReadOnlyList moves) + { + if (!(pk is PK8 pk8)) + return; + foreach (var m in moves) + { + var index = Array.FindIndex(Legal.Pouch_TMHM_SWSH, 100, z => z == m) - 100; + if (index >= 0) + pk8.SetMoveRecordFlag(index, true); + } + } + + /// + /// Sets all the Technical Record flags for the . + /// + /// Pokémon to modify. + public static void SetRecordFlags(this PKM pk) + { + if (!(pk is PK8 pk8)) + return; + var pi = pk8.PersonalInfo.TMHM; + for (int i = 100; i < pi.Length; i++) + { + if (pi[i]) + pk8.SetMoveRecordFlag(i - 100, true); + } + } + /// /// Force hatches a PKM by applying the current species name and a valid Met Location from the origin game. /// diff --git a/PKHeX.Core/Legality/Tables/Tables8.cs b/PKHeX.Core/Legality/Tables/Tables8.cs index dc75072b9..158bd2bbc 100644 --- a/PKHeX.Core/Legality/Tables/Tables8.cs +++ b/PKHeX.Core/Legality/Tables/Tables8.cs @@ -264,7 +264,7 @@ public static partial class Legal 160, 162, }; - internal static readonly int[] TMHM_SWSH = + public static readonly int[] TMHM_SWSH = { // TM 005, 025, 006, 007, 008, 009, 019, 042, 063, 416, diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs index 733731227..329778753 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.Designer.cs @@ -159,6 +159,7 @@ private void InitializeComponent() this.Stats = new PKHeX.WinForms.Controls.StatEditor(); this.Contest = new PKHeX.WinForms.Controls.ContestStat(); this.Tab_Attacks = new System.Windows.Forms.TabPage(); + this.B_Records = new System.Windows.Forms.Button(); this.PB_WarnMove4 = new System.Windows.Forms.PictureBox(); this.PB_WarnMove3 = new System.Windows.Forms.PictureBox(); this.PB_WarnMove2 = new System.Windows.Forms.PictureBox(); @@ -197,6 +198,7 @@ private void InitializeComponent() this.TB_EC = new System.Windows.Forms.TextBox(); this.GB_nOT = new System.Windows.Forms.GroupBox(); this.Label_CTGender = new System.Windows.Forms.Label(); + this.CB_HTLanguage = new System.Windows.Forms.ComboBox(); this.TB_OTt2 = new System.Windows.Forms.TextBox(); this.Label_PrevOT = new System.Windows.Forms.Label(); this.BTN_RerollEC = new System.Windows.Forms.Button(); @@ -221,7 +223,6 @@ private void InitializeComponent() this.SpeciesIDTip = new System.Windows.Forms.ToolTip(this.components); this.NatureTip = new System.Windows.Forms.ToolTip(this.components); this.Tip3 = new System.Windows.Forms.ToolTip(this.components); - this.CB_HTLanguage = new System.Windows.Forms.ComboBox(); this.tabMain.SuspendLayout(); this.Tab_Main.SuspendLayout(); this.FLP_Main.SuspendLayout(); @@ -1847,6 +1848,7 @@ private void InitializeComponent() // Tab_Attacks // this.Tab_Attacks.AllowDrop = true; + this.Tab_Attacks.Controls.Add(this.B_Records); this.Tab_Attacks.Controls.Add(this.PB_WarnMove4); this.Tab_Attacks.Controls.Add(this.PB_WarnMove3); this.Tab_Attacks.Controls.Add(this.PB_WarnMove2); @@ -1856,11 +1858,26 @@ private void InitializeComponent() this.Tab_Attacks.Location = new System.Drawing.Point(4, 22); this.Tab_Attacks.Name = "Tab_Attacks"; this.Tab_Attacks.Padding = new System.Windows.Forms.Padding(3); - this.Tab_Attacks.Size = new System.Drawing.Size(192, 74); + this.Tab_Attacks.Size = new System.Drawing.Size(272, 539); this.Tab_Attacks.TabIndex = 3; this.Tab_Attacks.Text = "Attacks"; this.Tab_Attacks.UseVisualStyleBackColor = true; // + // B_Records + // + this.B_Records.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.B_Records.AutoSize = true; + this.B_Records.Location = new System.Drawing.Point(73, 284); + this.B_Records.Margin = new System.Windows.Forms.Padding(1); + this.B_Records.Name = "B_Records"; + this.B_Records.Size = new System.Drawing.Size(124, 23); + this.B_Records.TabIndex = 8; + this.B_Records.Text = "Technical Records"; + this.B_Records.UseVisualStyleBackColor = true; + this.B_Records.Click += new System.EventHandler(this.B_Records_Click); + // // PB_WarnMove4 // this.PB_WarnMove4.Image = global::PKHeX.WinForms.Properties.Resources.warn; @@ -2244,7 +2261,7 @@ private void InitializeComponent() this.Tab_OTMisc.Location = new System.Drawing.Point(4, 22); this.Tab_OTMisc.Name = "Tab_OTMisc"; this.Tab_OTMisc.Padding = new System.Windows.Forms.Padding(3); - this.Tab_OTMisc.Size = new System.Drawing.Size(272, 539); + this.Tab_OTMisc.Size = new System.Drawing.Size(192, 74); this.Tab_OTMisc.TabIndex = 4; this.Tab_OTMisc.Text = "OT/Misc"; this.Tab_OTMisc.UseVisualStyleBackColor = true; @@ -2369,6 +2386,17 @@ private void InitializeComponent() this.Label_CTGender.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.Label_CTGender.Click += new System.EventHandler(this.ClickTRGender); // + // CB_HTLanguage + // + this.CB_HTLanguage.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.CB_HTLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_HTLanguage.FormattingEnabled = true; + this.CB_HTLanguage.Location = new System.Drawing.Point(46, 43); + this.CB_HTLanguage.Margin = new System.Windows.Forms.Padding(0); + this.CB_HTLanguage.Name = "CB_HTLanguage"; + this.CB_HTLanguage.Size = new System.Drawing.Size(126, 21); + this.CB_HTLanguage.TabIndex = 15; + // // TB_OTt2 // this.TB_OTt2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; @@ -2610,17 +2638,6 @@ private void InitializeComponent() this.Label_EncryptionConstant.Text = "Encryption Constant:"; this.Label_EncryptionConstant.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // CB_HTLanguage - // - this.CB_HTLanguage.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.CB_HTLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.CB_HTLanguage.FormattingEnabled = true; - this.CB_HTLanguage.Location = new System.Drawing.Point(46, 43); - this.CB_HTLanguage.Margin = new System.Windows.Forms.Padding(0); - this.CB_HTLanguage.Name = "CB_HTLanguage"; - this.CB_HTLanguage.Size = new System.Drawing.Size(126, 21); - this.CB_HTLanguage.TabIndex = 15; - // // PKMEditor // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; @@ -2694,6 +2711,7 @@ private void InitializeComponent() this.FLP_TimeOfDay.ResumeLayout(false); this.Tab_Stats.ResumeLayout(false); this.Tab_Attacks.ResumeLayout(false); + this.Tab_Attacks.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.PB_WarnMove4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_WarnMove3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PB_WarnMove2)).EndInit(); @@ -2925,5 +2943,6 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox CB_StatNature; private System.Windows.Forms.PictureBox PB_Origin; private System.Windows.Forms.ComboBox CB_HTLanguage; + private System.Windows.Forms.Button B_Records; } } diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 81f3fe409..967fcc91e 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -1587,6 +1587,13 @@ private void OpenHistory(object sender, EventArgs e) TB_Friendship.Text = Entity.CurrentFriendship.ToString(); } + private void B_Records_Click(object sender, EventArgs e) + { + using var form = new TechRecordEditor(Entity); + form.ShowDialog(); + UpdateLegality(); + } + /// /// Refreshes the interface for the current PKM format. /// @@ -1614,6 +1621,7 @@ private void ToggleInterface(PKM t) BTN_Medals.Visible = gen >= 6 && gen <= 7 && !pb7; FLP_Country.Visible = FLP_SubRegion.Visible = FLP_3DSRegion.Visible = gen >= 6 && gen <= 7 && !pb7; FLP_OriginalNature.Visible = gen >= 8; + B_Records.Visible = gen >= 8; ToggleInterface(Entity.Format); } diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index bba81f48b..2176e57c9 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -718,6 +718,8 @@ private bool OpenSAV(SaveFile sav, string path) { if (sav == null || sav.Version == GameVersion.Invalid) { + // temporary swsh fix for initial release broken saves + // remove any time after November if (sav is SAV8SWSH z) { var shift = z.Game + (GameVersion.SW - GameVersion.SN); diff --git a/PKHeX.WinForms/PKHeX.WinForms.csproj b/PKHeX.WinForms/PKHeX.WinForms.csproj index 197c1db72..950b30e9e 100644 --- a/PKHeX.WinForms/PKHeX.WinForms.csproj +++ b/PKHeX.WinForms/PKHeX.WinForms.csproj @@ -62,6 +62,9 @@ True Resources.resx + + Form + diff --git a/PKHeX.WinForms/Subforms/PKM Editors/TechRecordEditor.Designer.cs b/PKHeX.WinForms/Subforms/PKM Editors/TechRecordEditor.Designer.cs new file mode 100644 index 000000000..0bbe6ebd1 --- /dev/null +++ b/PKHeX.WinForms/Subforms/PKM Editors/TechRecordEditor.Designer.cs @@ -0,0 +1,124 @@ +namespace PKHeX.WinForms +{ + partial class TechRecordEditor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TechRecordEditor)); + this.B_Save = new System.Windows.Forms.Button(); + this.B_Cancel = new System.Windows.Forms.Button(); + this.B_None = new System.Windows.Forms.Button(); + this.B_All = new System.Windows.Forms.Button(); + this.tipName = new System.Windows.Forms.ToolTip(this.components); + this.CLB_Flags = new System.Windows.Forms.CheckedListBox(); + this.SuspendLayout(); + // + // B_Save + // + this.B_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.B_Save.Location = new System.Drawing.Point(108, 345); + this.B_Save.Name = "B_Save"; + this.B_Save.Size = new System.Drawing.Size(90, 23); + this.B_Save.TabIndex = 1; + this.B_Save.Text = "Save"; + this.B_Save.UseVisualStyleBackColor = true; + this.B_Save.Click += new System.EventHandler(this.B_Save_Click); + // + // B_Cancel + // + this.B_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.B_Cancel.Location = new System.Drawing.Point(12, 345); + this.B_Cancel.Name = "B_Cancel"; + this.B_Cancel.Size = new System.Drawing.Size(90, 23); + this.B_Cancel.TabIndex = 2; + this.B_Cancel.Text = "Cancel"; + this.B_Cancel.UseVisualStyleBackColor = true; + this.B_Cancel.Click += new System.EventHandler(this.B_Cancel_Click); + // + // B_None + // + this.B_None.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.B_None.Location = new System.Drawing.Point(108, 316); + this.B_None.Name = "B_None"; + this.B_None.Size = new System.Drawing.Size(90, 23); + this.B_None.TabIndex = 5; + this.B_None.Text = "Remove All"; + this.B_None.UseVisualStyleBackColor = true; + this.B_None.Click += new System.EventHandler(this.B_None_Click); + // + // B_All + // + this.B_All.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.B_All.Location = new System.Drawing.Point(12, 316); + this.B_All.Name = "B_All"; + this.B_All.Size = new System.Drawing.Size(90, 23); + this.B_All.TabIndex = 4; + this.B_All.Text = "Give All"; + this.B_All.UseVisualStyleBackColor = true; + this.B_All.Click += new System.EventHandler(this.B_All_Click); + // + // CLB_Flags + // + this.CLB_Flags.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.CLB_Flags.FormattingEnabled = true; + this.CLB_Flags.Location = new System.Drawing.Point(12, 12); + this.CLB_Flags.Name = "CLB_Flags"; + this.CLB_Flags.Size = new System.Drawing.Size(186, 289); + this.CLB_Flags.TabIndex = 6; + // + // TechRecordEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(210, 380); + this.Controls.Add(this.CLB_Flags); + this.Controls.Add(this.B_None); + this.Controls.Add(this.B_All); + this.Controls.Add(this.B_Cancel); + this.Controls.Add(this.B_Save); + this.Icon = Properties.Resources.Icon; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TechRecordEditor"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "TR Relearn Editor"; + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.Button B_Save; + private System.Windows.Forms.Button B_Cancel; + private System.Windows.Forms.Button B_None; + private System.Windows.Forms.Button B_All; + private System.Windows.Forms.ToolTip tipName; + private System.Windows.Forms.CheckedListBox CLB_Flags; + } +} \ No newline at end of file diff --git a/PKHeX.WinForms/Subforms/PKM Editors/TechRecordEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/TechRecordEditor.cs new file mode 100644 index 000000000..9205299f8 --- /dev/null +++ b/PKHeX.WinForms/Subforms/PKM Editors/TechRecordEditor.cs @@ -0,0 +1,71 @@ +using System; +using System.Linq; +using System.Windows.Forms; +using PKHeX.Core; + +namespace PKHeX.WinForms +{ + public partial class TechRecordEditor : Form + { + private readonly PK8 pkm; + + public TechRecordEditor(PKM pk) + { + pkm = (PK8)pk; + InitializeComponent(); + WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); + + PopulateRecords(); + LoadRecords(); + } + + private void PopulateRecords() + { + var trs = Legal.TMHM_SWSH; + var names = GameInfo.Strings.Move; + var lines = trs.Skip(100).Select((z, i) => $"{i:00} - {names[z]}").ToArray(); + CLB_Flags.Items.AddRange(lines); + } + + private void B_Cancel_Click(object sender, EventArgs e) => Close(); + + private void B_Save_Click(object sender, EventArgs e) + { + Save(); + Close(); + } + + private void LoadRecords() + { + for (int i = 0; i < 100; i++) + CLB_Flags.SetItemChecked(i, pkm.GetMoveRecordFlag(i)); + } + + private void Save() + { + for (int i = 0; i < 100; i++) + pkm.SetMoveRecordFlag(i, CLB_Flags.GetItemChecked(i)); + } + + private void B_All_Click(object sender, EventArgs e) + { + Save(); + if (ModifierKeys == Keys.Shift) + pkm.SetRecordFlags(true); + else if (ModifierKeys == Keys.Control) + pkm.SetRecordFlags(pkm.Moves); + else + pkm.SetRecordFlags(); + LoadRecords(); + Close(); + } + + private void B_None_Click(object sender, EventArgs e) + { + Save(); + pkm.ClearRecordFlags(); + LoadRecords(); + Close(); + } + } +}