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:
parent
6a01d9d9f6
commit
22e1dffc91
|
@ -7,16 +7,19 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
public List<List<Watch>> History { get; private set; }
|
||||
private int curPos; //1-based
|
||||
public bool Enabled { get; private set; }
|
||||
|
||||
public HistoryCollection()
|
||||
public HistoryCollection(bool enabled)
|
||||
{
|
||||
History = new List<List<Watch>>();
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public HistoryCollection(List<Watch> newState)
|
||||
public HistoryCollection(List<Watch> newState, bool enabled)
|
||||
{
|
||||
History = new List<List<Watch>>();
|
||||
AddState(newState);
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
|
@ -26,36 +29,39 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public bool CanUndo
|
||||
{
|
||||
get { return curPos > 1; }
|
||||
get { return Enabled && curPos > 1; }
|
||||
}
|
||||
|
||||
public bool CanRedo
|
||||
{
|
||||
get { return curPos < History.Count; }
|
||||
get { return Enabled && curPos < History.Count; }
|
||||
}
|
||||
|
||||
public bool HasHistory
|
||||
{
|
||||
get { return History.Any(); }
|
||||
get { return Enabled && History.Any(); }
|
||||
}
|
||||
|
||||
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);
|
||||
curPos = History.Count;
|
||||
History.Add(newState);
|
||||
curPos = History.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Watch> Undo()
|
||||
{
|
||||
if (CanUndo)
|
||||
if (CanUndo && Enabled)
|
||||
{
|
||||
curPos--;
|
||||
return History[curPos - 1];
|
||||
|
@ -68,7 +74,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public List<Watch> Redo()
|
||||
{
|
||||
if (CanRedo)
|
||||
if (CanRedo && Enabled)
|
||||
{
|
||||
curPos++;
|
||||
return History[curPos - 1];
|
||||
|
|
|
@ -148,6 +148,7 @@
|
|||
this.MemDomainLabel = new System.Windows.Forms.Label();
|
||||
this.MessageLabel = new System.Windows.Forms.Label();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.useUndoHistoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SearchtoolStrip1.SuspendLayout();
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
|
@ -699,7 +700,8 @@
|
|||
this.saveWindowPositionToolStripMenuItem,
|
||||
this.toolStripSeparator11,
|
||||
this.alwaysOnTopToolStripMenuItem,
|
||||
this.restoreOriginalWindowSizeToolStripMenuItem});
|
||||
this.restoreOriginalWindowSizeToolStripMenuItem,
|
||||
this.useUndoHistoryToolStripMenuItem});
|
||||
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
||||
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
|
||||
this.optionsToolStripMenuItem.Text = "&Options";
|
||||
|
@ -1277,6 +1279,13 @@
|
|||
this.MessageLabel.TabIndex = 9;
|
||||
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
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
|
@ -1441,5 +1450,6 @@
|
|||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator13;
|
||||
private System.Windows.Forms.ToolStripMenuItem clearUndoHistoryToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem fastModeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem useUndoHistoryToolStripMenuItem;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private string systemID = "NULL";
|
||||
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 readonly List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
|
||||
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)
|
||||
{
|
||||
LoadConfigSettings();
|
||||
StartNewSearch();
|
||||
SetMemoryDomainMenu();
|
||||
SearchHistory = new HistoryCollection(Searches);
|
||||
}
|
||||
|
||||
private void SetEndian()
|
||||
|
@ -388,6 +386,13 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void StartNewSearch()
|
||||
{
|
||||
useUndoHistoryToolStripMenuItem.Checked = true;
|
||||
if (Global.Emulator.SystemId == "N64")
|
||||
{
|
||||
useUndoHistoryToolStripMenuItem.Checked = false;
|
||||
Global.Config.RamSearchFastMode = true;
|
||||
|
||||
}
|
||||
IsAWeededList = false;
|
||||
SearchHistory.Clear();
|
||||
Searches.Clear();
|
||||
|
@ -448,7 +453,7 @@ namespace BizHawk.MultiClient
|
|||
sortReverse = false;
|
||||
sortedCol = "";
|
||||
DisplaySearchList();
|
||||
SearchHistory = new HistoryCollection(Searches);
|
||||
SearchHistory = new HistoryCollection(Searches, useUndoHistoryToolStripMenuItem.Checked);
|
||||
UpdateUndoRedoToolItems();
|
||||
}
|
||||
|
||||
|
@ -2729,5 +2734,11 @@ namespace BizHawk.MultiClient
|
|||
Global.Config.RamSearchPreviousAs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void useUndoHistoryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
useUndoHistoryToolStripMenuItem.Checked ^= true;
|
||||
SearchHistory = new HistoryCollection(Searches, useUndoHistoryToolStripMenuItem.Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue