Fix "Toggle All Cheats" hotkey behaviour re: separators

This commit is contained in:
YoshiRulz 2022-09-11 14:17:25 +10:00
parent 3122078dfd
commit d7c79a5f03
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 10 additions and 20 deletions

View File

@ -324,26 +324,16 @@ namespace BizHawk.Client.EmuHawk
Tools.Load<Cheats>();
break;
case "Toggle All Cheats":
if (CheatList.Any())
{
string type = " (mixed)";
if (CheatList.All(c => c.Enabled))
{
type = " (off)";
}
else if (CheatList.All(c => !c.Enabled))
{
type = " (on)";
}
foreach (var x in CheatList)
{
x.Toggle();
}
AddOnScreenMessage($"Cheats toggled{type}");
}
var cheats = CheatList.Where(static c => !c.IsSeparator).ToList();
if (cheats.Count is 0) break;
var firstWasEnabled = cheats[0].Enabled;
var kind = cheats.All(c => c.Enabled == firstWasEnabled)
? firstWasEnabled
? "off"
: "on"
: "mixed";
foreach (var x in cheats) x.Toggle();
AddOnScreenMessage($"Cheats toggled ({kind})");
break;
case "TAStudio":
TAStudioMenuItem_Click(null, null);