New Ram Search - Undo/Redo functionality
This commit is contained in:
parent
ece435555d
commit
b80f5a276e
|
@ -690,6 +690,7 @@
|
|||
<Compile Include="tools\Watch\WatchEditor.Designer.cs">
|
||||
<DependentUpon>WatchEditor.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="tools\Watch\WatchHistory.cs" />
|
||||
<Compile Include="tools\Watch\WatchLegacy.cs" />
|
||||
<Compile Include="tools\Watch\WatchList.cs" />
|
||||
<Compile Include="tools\Watch\WatchValueBox.cs">
|
||||
|
|
|
@ -692,6 +692,7 @@
|
|||
<Compile Include="tools\Watch\WatchEditor.designer.cs">
|
||||
<DependentUpon>WatchEditor.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="tools\Watch\WatchHistory.cs" />
|
||||
<Compile Include="tools\Watch\WatchLegacy.cs" />
|
||||
<Compile Include="tools\Watch\WatchList.cs" />
|
||||
<Compile Include="tools\Watch\WatchValueBox.cs">
|
||||
|
|
|
@ -84,8 +84,8 @@
|
|||
this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.newSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.redoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.UndoMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.RedoMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.CopyValueToPrevMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ClearChangeCountsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.RemoveMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -94,7 +94,7 @@
|
|||
this.PokeAddressMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.FreezeAddressMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator13 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.clearUndoHistoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ClearUndoMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.PreviewModeMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AutoSearchMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -142,6 +142,9 @@
|
|||
this.GreaterThanRadio = new System.Windows.Forms.RadioButton();
|
||||
this.LessThanRadio = new System.Windows.Forms.RadioButton();
|
||||
this.DiffColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.UndoToolBarButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.RedoToolBarItem = new System.Windows.Forms.ToolStripButton();
|
||||
this.SpecificValueBox = new BizHawk.MultiClient.WatchValueBox();
|
||||
SearchMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
|
@ -590,8 +593,8 @@
|
|||
this.newSearchToolStripMenuItem,
|
||||
this.toolStripSeparator7,
|
||||
SearchMenuItem,
|
||||
this.undoToolStripMenuItem,
|
||||
this.redoToolStripMenuItem,
|
||||
this.UndoMenuItem,
|
||||
this.RedoMenuItem,
|
||||
this.CopyValueToPrevMenuItem,
|
||||
this.ClearChangeCountsMenuItem,
|
||||
this.RemoveMenuItem,
|
||||
|
@ -600,7 +603,7 @@
|
|||
this.PokeAddressMenuItem,
|
||||
this.FreezeAddressMenuItem,
|
||||
this.toolStripSeparator13,
|
||||
this.clearUndoHistoryToolStripMenuItem});
|
||||
this.ClearUndoMenuItem});
|
||||
this.searchToolStripMenuItem.Name = "searchToolStripMenuItem";
|
||||
this.searchToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
|
||||
this.searchToolStripMenuItem.Text = "&Search";
|
||||
|
@ -619,24 +622,24 @@
|
|||
this.toolStripSeparator7.Name = "toolStripSeparator7";
|
||||
this.toolStripSeparator7.Size = new System.Drawing.Size(212, 6);
|
||||
//
|
||||
// undoToolStripMenuItem
|
||||
// UndoMenuItem
|
||||
//
|
||||
this.undoToolStripMenuItem.Enabled = false;
|
||||
this.undoToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.undo;
|
||||
this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
|
||||
this.undoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));
|
||||
this.undoToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.undoToolStripMenuItem.Text = "&Undo";
|
||||
this.UndoMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.undo;
|
||||
this.UndoMenuItem.Name = "UndoMenuItem";
|
||||
this.UndoMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));
|
||||
this.UndoMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.UndoMenuItem.Text = "&Undo";
|
||||
this.UndoMenuItem.Click += new System.EventHandler(this.UndoMenuItem_Click);
|
||||
//
|
||||
// redoToolStripMenuItem
|
||||
// RedoMenuItem
|
||||
//
|
||||
this.redoToolStripMenuItem.Enabled = false;
|
||||
this.redoToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.redo;
|
||||
this.redoToolStripMenuItem.Name = "redoToolStripMenuItem";
|
||||
this.redoToolStripMenuItem.ShortcutKeyDisplayString = "";
|
||||
this.redoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y)));
|
||||
this.redoToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.redoToolStripMenuItem.Text = "&Redo";
|
||||
this.RedoMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.redo;
|
||||
this.RedoMenuItem.Name = "RedoMenuItem";
|
||||
this.RedoMenuItem.ShortcutKeyDisplayString = "";
|
||||
this.RedoMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y)));
|
||||
this.RedoMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.RedoMenuItem.Text = "&Redo";
|
||||
this.RedoMenuItem.Click += new System.EventHandler(this.RedoMenuItem_Click);
|
||||
//
|
||||
// CopyValueToPrevMenuItem
|
||||
//
|
||||
|
@ -699,12 +702,12 @@
|
|||
this.toolStripSeparator13.Name = "toolStripSeparator13";
|
||||
this.toolStripSeparator13.Size = new System.Drawing.Size(212, 6);
|
||||
//
|
||||
// clearUndoHistoryToolStripMenuItem
|
||||
// ClearUndoMenuItem
|
||||
//
|
||||
this.clearUndoHistoryToolStripMenuItem.Enabled = false;
|
||||
this.clearUndoHistoryToolStripMenuItem.Name = "clearUndoHistoryToolStripMenuItem";
|
||||
this.clearUndoHistoryToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.clearUndoHistoryToolStripMenuItem.Text = "Clear Undo History";
|
||||
this.ClearUndoMenuItem.Name = "ClearUndoMenuItem";
|
||||
this.ClearUndoMenuItem.Size = new System.Drawing.Size(215, 22);
|
||||
this.ClearUndoMenuItem.Text = "Clear Undo History";
|
||||
this.ClearUndoMenuItem.Click += new System.EventHandler(this.ClearUndoMenuItem_Click);
|
||||
//
|
||||
// optionsToolStripMenuItem
|
||||
//
|
||||
|
@ -948,7 +951,10 @@
|
|||
this.RemoveToolBarItem,
|
||||
this.AddToRamWatchToolBarItem,
|
||||
this.PokeAddressToolBarItem,
|
||||
this.FreezeAddressToolBarItem});
|
||||
this.FreezeAddressToolBarItem,
|
||||
this.toolStripSeparator12,
|
||||
this.UndoToolBarButton,
|
||||
this.RedoToolBarItem});
|
||||
this.toolStrip1.Location = new System.Drawing.Point(0, 24);
|
||||
this.toolStrip1.Name = "toolStrip1";
|
||||
this.toolStrip1.Size = new System.Drawing.Size(470, 25);
|
||||
|
@ -1168,6 +1174,33 @@
|
|||
//
|
||||
this.DiffColumn.Text = "Diff";
|
||||
//
|
||||
// toolStripSeparator12
|
||||
//
|
||||
this.toolStripSeparator12.Name = "toolStripSeparator12";
|
||||
this.toolStripSeparator12.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
// UndoToolBarButton
|
||||
//
|
||||
this.UndoToolBarButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.UndoToolBarButton.Enabled = false;
|
||||
this.UndoToolBarButton.Image = global::BizHawk.MultiClient.Properties.Resources.undo;
|
||||
this.UndoToolBarButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.UndoToolBarButton.Name = "UndoToolBarButton";
|
||||
this.UndoToolBarButton.Size = new System.Drawing.Size(23, 22);
|
||||
this.UndoToolBarButton.Text = "Undo Search";
|
||||
this.UndoToolBarButton.Click += new System.EventHandler(this.UndoMenuItem_Click);
|
||||
//
|
||||
// RedoToolBarItem
|
||||
//
|
||||
this.RedoToolBarItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.RedoToolBarItem.Enabled = false;
|
||||
this.RedoToolBarItem.Image = global::BizHawk.MultiClient.Properties.Resources.redo;
|
||||
this.RedoToolBarItem.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.RedoToolBarItem.Name = "RedoToolBarItem";
|
||||
this.RedoToolBarItem.Size = new System.Drawing.Size(23, 22);
|
||||
this.RedoToolBarItem.Text = "Redo";
|
||||
this.RedoToolBarItem.Click += new System.EventHandler(this.RedoMenuItem_Click);
|
||||
//
|
||||
// SpecificValueBox
|
||||
//
|
||||
this.SpecificValueBox.ByteSize = BizHawk.MultiClient.Watch.WatchSize.Byte;
|
||||
|
@ -1239,7 +1272,7 @@
|
|||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||
private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ClearChangeCountsMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem undoToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem UndoMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem RemoveMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
|
||||
private System.Windows.Forms.ToolStripMenuItem AddToRamWatchMenuItem;
|
||||
|
@ -1258,7 +1291,7 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem FreezeContextMenuItem;
|
||||
private MenuStripEx menuStrip1;
|
||||
private System.Windows.Forms.ToolTip toolTip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem redoToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem RedoMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ViewInHexEditorContextMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem AutoloadDialogMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator11;
|
||||
|
@ -1266,7 +1299,7 @@
|
|||
private System.Windows.Forms.ToolStripSeparator ContextMenuSeparator3;
|
||||
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator13;
|
||||
private System.Windows.Forms.ToolStripMenuItem clearUndoHistoryToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ClearUndoMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem useUndoHistoryToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator ContextMenuSeparator2;
|
||||
private System.Windows.Forms.ToolStripMenuItem ClearPreviewContextMenuItem;
|
||||
|
@ -1329,5 +1362,8 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem AutoSearchMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator9;
|
||||
private System.Windows.Forms.ColumnHeader DiffColumn;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator12;
|
||||
private System.Windows.Forms.ToolStripButton UndoToolBarButton;
|
||||
private System.Windows.Forms.ToolStripButton RedoToolBarItem;
|
||||
}
|
||||
}
|
|
@ -216,6 +216,7 @@ namespace BizHawk.MultiClient
|
|||
DoSearchToolButton.Enabled =
|
||||
CopyValueToPrevToolBarItem.Enabled =
|
||||
Searches.Count > 0;
|
||||
UpdateUndoToolBarButtons();
|
||||
}
|
||||
|
||||
private void DoSearch()
|
||||
|
@ -225,7 +226,6 @@ namespace BizHawk.MultiClient
|
|||
WatchListView.ItemCount = Searches.Count;
|
||||
SetRemovedMessage(removed);
|
||||
ToggleSearchDependentToolBarItems();
|
||||
|
||||
}
|
||||
|
||||
private List<int> SelectedIndices
|
||||
|
@ -499,6 +499,12 @@ namespace BizHawk.MultiClient
|
|||
SetTotal();
|
||||
}
|
||||
|
||||
private void UpdateUndoToolBarButtons()
|
||||
{
|
||||
UndoToolBarButton.Enabled = Searches.CanUndo;
|
||||
RedoToolBarItem.Enabled = Searches.CanRedo;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Winform Events
|
||||
|
@ -718,6 +724,12 @@ namespace BizHawk.MultiClient
|
|||
PokeAddressMenuItem.Enabled =
|
||||
FreezeAddressMenuItem.Enabled =
|
||||
SelectedIndices.Any();
|
||||
|
||||
UndoMenuItem.Enabled =
|
||||
ClearUndoMenuItem.Enabled =
|
||||
Searches.CanUndo;
|
||||
|
||||
RedoMenuItem.Enabled = Searches.CanRedo;
|
||||
}
|
||||
|
||||
private void NewSearchMenuMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -730,6 +742,24 @@ namespace BizHawk.MultiClient
|
|||
DoSearch();
|
||||
}
|
||||
|
||||
private void UndoMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Searches.CanUndo)
|
||||
{
|
||||
Searches.Undo();
|
||||
UpdateUndoToolBarButtons();
|
||||
}
|
||||
}
|
||||
|
||||
private void RedoMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Searches.CanRedo)
|
||||
{
|
||||
Searches.Redo();
|
||||
UpdateUndoToolBarButtons();
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyValueToPrevMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Searches.SetPrevousToCurrent();
|
||||
|
@ -762,6 +792,12 @@ namespace BizHawk.MultiClient
|
|||
FreezeAddress();
|
||||
}
|
||||
|
||||
private void ClearUndoMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Searches.ClearHistory();
|
||||
UpdateUndoToolBarButtons();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Options
|
||||
|
|
|
@ -8,33 +8,31 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
class RamSearchEngine
|
||||
public class RamSearchEngine
|
||||
{
|
||||
public enum ComparisonOperator { Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual, DifferentBy };
|
||||
public enum Compare { Previous, SpecificValue, SpecificAddress, Changes, Difference }
|
||||
|
||||
private List<IMiniWatch> _watchList = new List<IMiniWatch>();
|
||||
private Settings _settings;
|
||||
|
||||
public Compare CompareTo = Compare.Previous;
|
||||
public int? CompareValue = null;
|
||||
public ComparisonOperator Operator = ComparisonOperator.Equal;
|
||||
public int? DifferentBy = null;
|
||||
|
||||
#region Constructors
|
||||
private List<IMiniWatch> _watchList = new List<IMiniWatch>();
|
||||
private Settings _settings;
|
||||
private WatchHistory _history = new WatchHistory(true);
|
||||
|
||||
public RamSearchEngine(Settings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region API
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_watchList.Clear();
|
||||
_history.Clear();
|
||||
switch (_settings.Size)
|
||||
{
|
||||
default:
|
||||
|
@ -87,6 +85,8 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
_history.AddState(_watchList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -126,6 +126,7 @@ namespace BizHawk.MultiClient
|
|||
public int DoSearch()
|
||||
{
|
||||
int before = _watchList.Count;
|
||||
|
||||
switch (CompareTo)
|
||||
{
|
||||
default:
|
||||
|
@ -151,6 +152,8 @@ namespace BizHawk.MultiClient
|
|||
SetPrevousToCurrent();
|
||||
}
|
||||
|
||||
_history.AddState(_watchList);
|
||||
|
||||
return before - _watchList.Count;
|
||||
}
|
||||
|
||||
|
@ -291,6 +294,28 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Undo API
|
||||
|
||||
public bool CanUndo { get { return _history.CanUndo; } }
|
||||
public bool CanRedo { get { return _history.CanRedo; } }
|
||||
|
||||
public void ClearHistory()
|
||||
{
|
||||
_history.Clear();
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
_watchList = _history.Undo();
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
_watchList = _history.Redo();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparisons
|
||||
|
@ -512,7 +537,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
#region Classes
|
||||
|
||||
private interface IMiniWatch
|
||||
public interface IMiniWatch
|
||||
{
|
||||
int Address { get; }
|
||||
int Previous { get; }
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public class WatchHistory
|
||||
{
|
||||
private List<List<RamSearchEngine.IMiniWatch>> _history = new List<List<RamSearchEngine.IMiniWatch>>();
|
||||
private int curPos; //1-based
|
||||
public bool Enabled { get; private set; }
|
||||
|
||||
public WatchHistory(bool enabled)
|
||||
{
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public WatchHistory(List<RamSearchEngine.IMiniWatch> newState, bool enabled)
|
||||
{
|
||||
AddState(newState);
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_history = new List<List<RamSearchEngine.IMiniWatch>>();
|
||||
curPos = 0;
|
||||
}
|
||||
|
||||
public bool CanUndo
|
||||
{
|
||||
get { return Enabled && curPos > 1; }
|
||||
}
|
||||
|
||||
public bool CanRedo
|
||||
{
|
||||
get { return Enabled && curPos < _history.Count; }
|
||||
}
|
||||
|
||||
public bool HasHistory
|
||||
{
|
||||
get { return Enabled && _history.Any(); }
|
||||
}
|
||||
|
||||
public void AddState(List<RamSearchEngine.IMiniWatch> newState)
|
||||
{
|
||||
if (Enabled)
|
||||
{
|
||||
if (curPos < _history.Count)
|
||||
{
|
||||
for (int i = curPos + 1; i <= _history.Count; i++)
|
||||
{
|
||||
_history.Remove(_history[i - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
_history.Add(newState);
|
||||
curPos = _history.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public List<RamSearchEngine.IMiniWatch> Undo()
|
||||
{
|
||||
if (CanUndo && Enabled)
|
||||
{
|
||||
curPos--;
|
||||
return _history[curPos - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<RamSearchEngine.IMiniWatch> Redo()
|
||||
{
|
||||
if (CanRedo && Enabled)
|
||||
{
|
||||
curPos++;
|
||||
return _history[curPos - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue