Warn when freezing >200 addresses at once (resolves #1155)

This commit is contained in:
YoshiRulz 2021-11-19 04:42:19 +10:00
parent e23a2df7e0
commit be13c08959
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 10 additions and 4 deletions

View File

@ -24,13 +24,16 @@ namespace BizHawk.Client.Common
private const string TypeColumn = "DisplayTypeColumn";
private const string ComparisonType = "ComparisonTypeColumn";
private readonly IDialogParent _dialogParent;
private readonly ICheatConfig _config;
private List<Cheat> _cheatList = new List<Cheat>();
private string _defaultFileName = "";
private bool _changes;
public CheatCollection(ICheatConfig config)
public CheatCollection(IDialogParent dialogParent, ICheatConfig config)
{
_dialogParent = dialogParent;
_config = config;
}
@ -131,8 +134,11 @@ namespace BizHawk.Client.Common
public void AddRange(IEnumerable<Cheat> cheats)
{
_cheatList.AddRange(
cheats.Where(c => !_cheatList.Contains(c)));
var toAdd = cheats.Where(c => !_cheatList.Contains(c)).ToList();
if (toAdd.Count is 0) return;
const int WARN_WHEN_ADDING_MORE_THAN = 200;
if (toAdd.Count > WARN_WHEN_ADDING_MORE_THAN && !_dialogParent.ModalMessageBox2($"Adding {toAdd.Count} freezes/cheats at once is probably a bad idea. Do it anyway?")) return;
_cheatList.AddRange(toAdd);
Changes = true;
}

View File

@ -479,7 +479,7 @@ namespace BizHawk.Client.EmuHawk
Sound.StartSound();
InputManager.SyncControls(Emulator, MovieSession, Config);
CheatList = new CheatCollection(Config.Cheats);
CheatList = new CheatCollection(this, Config.Cheats);
CheatList.Changed += Tools.UpdateCheatRelatedTools;
RewireSound();