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).
This commit is contained in:
Kurt
2025-03-02 01:11:29 -06:00
parent 4adf450b08
commit 356db93e9f
3 changed files with 12 additions and 5 deletions

View File

@@ -24,8 +24,7 @@ public sealed class BattleVideo5(Memory<byte> Raw) : IBattleVideo
public byte Generation => 5;
public IEnumerable<PKM> Contents => GetTeam(0).Concat(GetTeam(1)); // don't bother with multi-battles
public static bool IsValid(ReadOnlySpan<byte> data) => data.Length == SIZE
&& ReadUInt16LittleEndian(data[^4..]) == Checksums.CRC16_CCITT(data[..^4]);
public static bool IsValid(ReadOnlySpan<byte> data) => data.Length == SIZE && ReadUInt16LittleEndian(data[^2..]) == 0;
// Structure:
// 0xC4 - 0x18A0: encrypted region

View File

@@ -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";

View File

@@ -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