Ram Search - persist Use Undo History, and also set it to true by default, fixes #2413

This commit is contained in:
adelikat 2020-09-27 09:32:34 -05:00
parent 63f9de42a7
commit 725cee8b62
3 changed files with 17 additions and 8 deletions

View File

@ -21,7 +21,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
public RamSearchEngine(SearchEngineSettings settings, IMemoryDomains memoryDomains)
{
_settings = new SearchEngineSettings(memoryDomains)
_settings = new SearchEngineSettings(memoryDomains, settings.UseUndoHistory)
{
Mode = settings.Mode,
Domain = settings.Domain,
@ -29,7 +29,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
CheckMisAligned = settings.CheckMisAligned,
Type = settings.Type,
BigEndian = settings.BigEndian,
PreviousType = settings.PreviousType
PreviousType = settings.PreviousType,
};
}
@ -316,7 +316,11 @@ namespace BizHawk.Client.Common.RamSearchEngine
}
}
public bool UndoEnabled { get; set; }
public bool UndoEnabled
{
get => _settings.UseUndoHistory;
set => _settings.UseUndoHistory = value;
}
public bool CanUndo => UndoEnabled && _history.CanUndo;

View File

@ -4,7 +4,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
{
public class SearchEngineSettings
{
public SearchEngineSettings(IMemoryDomains memoryDomains)
public SearchEngineSettings(IMemoryDomains memoryDomains, bool useUndoHistory)
{
BigEndian = memoryDomains.MainMemory.EndianType == MemoryDomain.Endian.Big;
Size = (WatchSize)memoryDomains.MainMemory.WordSize;
@ -16,6 +16,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
Domain = memoryDomains.MainMemory;
CheckMisAligned = false;
PreviousType = PreviousType.LastSearch;
UseUndoHistory = useUndoHistory;
}
/*Require restart*/
@ -28,6 +29,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
public DisplayType Type { get; set; }
public bool BigEndian { get; set; }
public PreviousType PreviousType { get; set; }
public bool UseUndoHistory { get; set; }
}
public static class SearchEngineSettingsExtensions

View File

@ -144,7 +144,7 @@ namespace BizHawk.Client.EmuHawk
RamSearchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback));
_settings = new SearchEngineSettings(MemoryDomains);
_settings = new SearchEngineSettings(MemoryDomains, Settings.UseUndoHistory);
_searches = new RamSearchEngine(_settings, MemoryDomains);
ErrorIconButton.Visible = false;
@ -308,7 +308,7 @@ namespace BizHawk.Client.EmuHawk
public override void Restart()
{
_settings = new SearchEngineSettings(MemoryDomains);
_settings = new SearchEngineSettings(MemoryDomains, Settings.UseUndoHistory);
_searches = new RamSearchEngine(_settings, MemoryDomains);
MessageLabel.Text = "Search restarted";
DoDomainSizeCheck();
@ -944,12 +944,14 @@ namespace BizHawk.Client.EmuHawk
PreviewMode = true;
RecentSearches = new RecentFiles(8);
AutoSearchTakeLagFramesIntoAccount = true;
}
public List<RollColumn> Columns { get; set; }
public bool PreviewMode { get; set; }
public bool AlwaysExcludeRamWatch { get; set; }
public bool AutoSearchTakeLagFramesIntoAccount { get; set; }
public bool UseUndoHistory { get; set; } = true;
public RecentFiles RecentSearches { get; set; }
}
@ -1270,7 +1272,7 @@ namespace BizHawk.Client.EmuHawk
private void SettingsSubMenu_DropDownOpened(object sender, EventArgs e)
{
ExcludeRamWatchMenuItem.Checked = Settings.AlwaysExcludeRamWatch;
UseUndoHistoryMenuItem.Checked = _searches.UndoEnabled;
UseUndoHistoryMenuItem.Checked = Settings.UseUndoHistory;
PreviewModeMenuItem.Checked = Settings.PreviewMode;
AutoSearchMenuItem.Checked = _autoSearch;
AutoSearchAccountForLagMenuItem.Checked = Settings.AutoSearchTakeLagFramesIntoAccount;
@ -1307,6 +1309,7 @@ namespace BizHawk.Client.EmuHawk
private void UseUndoHistoryMenuItem_Click(object sender, EventArgs e)
{
_searches.UndoEnabled ^= true;
Settings.UseUndoHistory = _searches.UndoEnabled;
}
[RestoreDefaults]
@ -1323,7 +1326,7 @@ namespace BizHawk.Client.EmuHawk
RamSearchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback));
_settings = new SearchEngineSettings(MemoryDomains);
_settings = new SearchEngineSettings(MemoryDomains, Settings.UseUndoHistory);
if (_settings.IsFastMode())
{
SetToFastMode();