Fix cheat editor resetting display type when changing size

and when choice is no longer valid, default to hex instead of unsigned
This commit is contained in:
James Groom 2024-03-08 21:42:20 +10:00 committed by GitHub
parent 2f758459dd
commit 69d29c39f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 2 deletions

View File

@ -180,6 +180,19 @@ namespace BizHawk.Client.EmuHawk
private void PopulateTypeDropdown()
{
var wasSelected = DisplayTypeDropDown.SelectedItem?.ToString() ?? string.Empty;
bool Reselect()
{
for (var i = 0; i < DisplayTypeDropDown.Items.Count; i++)
{
if (DisplayTypeDropDown.Items[i].ToString() == wasSelected)
{
DisplayTypeDropDown.SelectedIndex = i;
return true;
}
}
return false;
}
DisplayTypeDropDown.Items.Clear();
switch (SizeDropDown.SelectedIndex)
{
@ -206,8 +219,10 @@ namespace BizHawk.Client.EmuHawk
break;
}
DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[0];
DisplayTypeDropDown.SelectedIndex = 0;
if (Reselect()) return;
wasSelected = Watch.DisplayTypeToString(WatchDisplayType.Hex);
_ = Reselect();
}
private void CheckFormState()