From 356db93e9ff61b5804901b646bc3c6d9e56a4aba Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 2 Mar 2025 01:11:29 -0600 Subject: [PATCH] Settings: version select typeable combobox Was annoying cycling through all these versions that start with the same character. Works well enough to just do it bv5: ignore checksum integrity, the checksum is over the decrypted data (not while encrypted). --- .../Saves/Substructures/Battle Videos/BattleVideo5.cs | 3 +-- PKHeX.WinForms/Subforms/SettingsEditor.Designer.cs | 3 ++- PKHeX.WinForms/Subforms/SettingsEditor.cs | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/PKHeX.Core/Saves/Substructures/Battle Videos/BattleVideo5.cs b/PKHeX.Core/Saves/Substructures/Battle Videos/BattleVideo5.cs index 7702ae75c..534e9f751 100644 --- a/PKHeX.Core/Saves/Substructures/Battle Videos/BattleVideo5.cs +++ b/PKHeX.Core/Saves/Substructures/Battle Videos/BattleVideo5.cs @@ -24,8 +24,7 @@ public sealed class BattleVideo5(Memory Raw) : IBattleVideo public byte Generation => 5; public IEnumerable Contents => GetTeam(0).Concat(GetTeam(1)); // don't bother with multi-battles - public static bool IsValid(ReadOnlySpan data) => data.Length == SIZE - && ReadUInt16LittleEndian(data[^4..]) == Checksums.CRC16_CCITT(data[..^4]); + public static bool IsValid(ReadOnlySpan data) => data.Length == SIZE && ReadUInt16LittleEndian(data[^2..]) == 0; // Structure: // 0xC4 - 0x18A0: encrypted region diff --git a/PKHeX.WinForms/Subforms/SettingsEditor.Designer.cs b/PKHeX.WinForms/Subforms/SettingsEditor.Designer.cs index b0f173d7e..314e98013 100644 --- a/PKHeX.WinForms/Subforms/SettingsEditor.Designer.cs +++ b/PKHeX.WinForms/Subforms/SettingsEditor.Designer.cs @@ -58,7 +58,8 @@ private void InitializeComponent() // // CB_Blank // - CB_Blank.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + CB_Blank.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_Blank.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; CB_Blank.FormattingEnabled = true; CB_Blank.Location = new System.Drawing.Point(116, 3); CB_Blank.Name = "CB_Blank"; diff --git a/PKHeX.WinForms/Subforms/SettingsEditor.cs b/PKHeX.WinForms/Subforms/SettingsEditor.cs index b49d4af45..c877d4ed8 100644 --- a/PKHeX.WinForms/Subforms/SettingsEditor.cs +++ b/PKHeX.WinForms/Subforms/SettingsEditor.cs @@ -26,8 +26,15 @@ public SettingsEditor(object obj) CB_Blank.InitializeBinding(); CB_Blank.DataSource = GameInfo.VersionDataSource.Where(z => !IsInvalidSaveFileVersion((GameVersion)z.Value)).ToList(); CB_Blank.SelectedValue = (int)s.Startup.DefaultSaveVersion; - CB_Blank.SelectedValueChanged += (_, _) => s.Startup.DefaultSaveVersion = (GameVersion)WinFormsUtil.GetIndex(CB_Blank); - CB_Blank.SelectedIndexChanged += (_, _) => BlankChanged = true; + CB_Blank.SelectedValueChanged += (_, _) => + { + var index = WinFormsUtil.GetIndex(CB_Blank); + var version = (GameVersion)index; + if (IsInvalidSaveFileVersion(version)) + return; + s.Startup.DefaultSaveVersion = version; + }; + CB_Blank.SelectedIndexChanged += (_, _) => BlankChanged = !IsInvalidSaveFileVersion((GameVersion)WinFormsUtil.GetIndex(CB_Blank)); B_Reset.Click += (_, _) => DeleteSettings(); } else