Ram Search - don't create a search history and start a new search twice. Add a "Use Undo History" option. For that and fast mode when the user opens ram search on the n64 core, currently this overrides their settings every time they open the dialog.

This commit is contained in:
adelikat 2013-08-14 01:04:14 +00:00
parent 6a01d9d9f6
commit 22e1dffc91
3 changed files with 45 additions and 18 deletions

View File

@ -7,16 +7,19 @@ namespace BizHawk.MultiClient
{ {
public List<List<Watch>> History { get; private set; } public List<List<Watch>> History { get; private set; }
private int curPos; //1-based private int curPos; //1-based
public bool Enabled { get; private set; }
public HistoryCollection() public HistoryCollection(bool enabled)
{ {
History = new List<List<Watch>>(); History = new List<List<Watch>>();
Enabled = enabled;
} }
public HistoryCollection(List<Watch> newState) public HistoryCollection(List<Watch> newState, bool enabled)
{ {
History = new List<List<Watch>>(); History = new List<List<Watch>>();
AddState(newState); AddState(newState);
Enabled = enabled;
} }
public void Clear() public void Clear()
@ -26,36 +29,39 @@ namespace BizHawk.MultiClient
public bool CanUndo public bool CanUndo
{ {
get { return curPos > 1; } get { return Enabled && curPos > 1; }
} }
public bool CanRedo public bool CanRedo
{ {
get { return curPos < History.Count; } get { return Enabled && curPos < History.Count; }
} }
public bool HasHistory public bool HasHistory
{ {
get { return History.Any(); } get { return Enabled && History.Any(); }
} }
public void AddState(List<Watch> newState) public void AddState(List<Watch> newState)
{ {
if (curPos < History.Count) if (Enabled)
{ {
for (int i = curPos + 1; i <= History.Count; i++) if (curPos < History.Count)
{ {
History.Remove(History[i - 1]); for (int i = curPos + 1; i <= History.Count; i++)
{
History.Remove(History[i - 1]);
}
} }
}
History.Add(newState); History.Add(newState);
curPos = History.Count; curPos = History.Count;
}
} }
public List<Watch> Undo() public List<Watch> Undo()
{ {
if (CanUndo) if (CanUndo && Enabled)
{ {
curPos--; curPos--;
return History[curPos - 1]; return History[curPos - 1];
@ -68,7 +74,7 @@ namespace BizHawk.MultiClient
public List<Watch> Redo() public List<Watch> Redo()
{ {
if (CanRedo) if (CanRedo && Enabled)
{ {
curPos++; curPos++;
return History[curPos - 1]; return History[curPos - 1];

View File

@ -148,6 +148,7 @@
this.MemDomainLabel = new System.Windows.Forms.Label(); this.MemDomainLabel = new System.Windows.Forms.Label();
this.MessageLabel = new System.Windows.Forms.Label(); this.MessageLabel = new System.Windows.Forms.Label();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.useUndoHistoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SearchtoolStrip1.SuspendLayout(); this.SearchtoolStrip1.SuspendLayout();
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
@ -699,7 +700,8 @@
this.saveWindowPositionToolStripMenuItem, this.saveWindowPositionToolStripMenuItem,
this.toolStripSeparator11, this.toolStripSeparator11,
this.alwaysOnTopToolStripMenuItem, this.alwaysOnTopToolStripMenuItem,
this.restoreOriginalWindowSizeToolStripMenuItem}); this.restoreOriginalWindowSizeToolStripMenuItem,
this.useUndoHistoryToolStripMenuItem});
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
this.optionsToolStripMenuItem.Text = "&Options"; this.optionsToolStripMenuItem.Text = "&Options";
@ -1277,6 +1279,13 @@
this.MessageLabel.TabIndex = 9; this.MessageLabel.TabIndex = 9;
this.MessageLabel.Text = " "; this.MessageLabel.Text = " ";
// //
// useUndoHistoryToolStripMenuItem
//
this.useUndoHistoryToolStripMenuItem.Name = "useUndoHistoryToolStripMenuItem";
this.useUndoHistoryToolStripMenuItem.Size = new System.Drawing.Size(240, 22);
this.useUndoHistoryToolStripMenuItem.Text = "&Use Undo History";
this.useUndoHistoryToolStripMenuItem.Click += new System.EventHandler(this.useUndoHistoryToolStripMenuItem_Click);
//
// RamSearch // RamSearch
// //
this.AllowDrop = true; this.AllowDrop = true;
@ -1441,5 +1450,6 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator13; private System.Windows.Forms.ToolStripSeparator toolStripSeparator13;
private System.Windows.Forms.ToolStripMenuItem clearUndoHistoryToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem clearUndoHistoryToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fastModeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem fastModeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem useUndoHistoryToolStripMenuItem;
} }
} }

View File

@ -21,7 +21,7 @@ namespace BizHawk.MultiClient
private string systemID = "NULL"; private string systemID = "NULL";
private List<Watch> Searches = new List<Watch>(); private List<Watch> Searches = new List<Watch>();
private HistoryCollection SearchHistory = new HistoryCollection(); private HistoryCollection SearchHistory = new HistoryCollection(enabled:true);
private bool IsAWeededList = false; //For deciding whether the weeded list is relevant (0 size could mean all were removed in a legit preview private bool IsAWeededList = false; //For deciding whether the weeded list is relevant (0 size could mean all were removed in a legit preview
private readonly List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>(); private readonly List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
private MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { }); private MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
@ -101,9 +101,7 @@ namespace BizHawk.MultiClient
private void RamSearch_Load(object sender, EventArgs e) private void RamSearch_Load(object sender, EventArgs e)
{ {
LoadConfigSettings(); LoadConfigSettings();
StartNewSearch();
SetMemoryDomainMenu(); SetMemoryDomainMenu();
SearchHistory = new HistoryCollection(Searches);
} }
private void SetEndian() private void SetEndian()
@ -388,6 +386,13 @@ namespace BizHawk.MultiClient
private void StartNewSearch() private void StartNewSearch()
{ {
useUndoHistoryToolStripMenuItem.Checked = true;
if (Global.Emulator.SystemId == "N64")
{
useUndoHistoryToolStripMenuItem.Checked = false;
Global.Config.RamSearchFastMode = true;
}
IsAWeededList = false; IsAWeededList = false;
SearchHistory.Clear(); SearchHistory.Clear();
Searches.Clear(); Searches.Clear();
@ -448,7 +453,7 @@ namespace BizHawk.MultiClient
sortReverse = false; sortReverse = false;
sortedCol = ""; sortedCol = "";
DisplaySearchList(); DisplaySearchList();
SearchHistory = new HistoryCollection(Searches); SearchHistory = new HistoryCollection(Searches, useUndoHistoryToolStripMenuItem.Checked);
UpdateUndoRedoToolItems(); UpdateUndoRedoToolItems();
} }
@ -2729,5 +2734,11 @@ namespace BizHawk.MultiClient
Global.Config.RamSearchPreviousAs = 0; Global.Config.RamSearchPreviousAs = 0;
} }
} }
private void useUndoHistoryToolStripMenuItem_Click(object sender, EventArgs e)
{
useUndoHistoryToolStripMenuItem.Checked ^= true;
SearchHistory = new HistoryCollection(Searches, useUndoHistoryToolStripMenuItem.Checked);
}
} }
} }