New Ram Search - support searching all basic operators for previous, specific value, specific address, and number of changes

This commit is contained in:
adelikat 2013-09-21 23:55:17 +00:00
parent b55498cdb3
commit 927b3e0d53
6 changed files with 572 additions and 85 deletions

View File

@ -29,7 +29,7 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem1;
System.Windows.Forms.ToolStripMenuItem SearchMenuItem;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NewRamSearch));
this.TotalSearchLabel = new System.Windows.Forms.Label();
this.WatchListView = new BizHawk.VirtualListView();
@ -125,24 +125,40 @@
this.SpecificAddressRadio = new System.Windows.Forms.RadioButton();
this.SpecificValueRadio = new System.Windows.Forms.RadioButton();
this.PreviousValueRadio = new System.Windows.Forms.RadioButton();
searchToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStrip1 = new ToolStripEx();
this.DoSearchToolButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
this.NewSearchToolButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator15 = new System.Windows.Forms.ToolStripSeparator();
this.ComparisonBox = new System.Windows.Forms.GroupBox();
this.DifferentByBox = new BizHawk.UnsignedIntegerBox();
this.DifferentByRadio = new System.Windows.Forms.RadioButton();
this.NotEqualToRadio = new System.Windows.Forms.RadioButton();
this.EqualToRadio = new System.Windows.Forms.RadioButton();
this.GreaterThanOrEqualToRadio = new System.Windows.Forms.RadioButton();
this.LessThanOrEqualToRadio = new System.Windows.Forms.RadioButton();
this.GreaterThanRadio = new System.Windows.Forms.RadioButton();
this.LessThanRadio = new System.Windows.Forms.RadioButton();
SearchMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.CompareToBox.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.ComparisonBox.SuspendLayout();
this.SuspendLayout();
//
// searchToolStripMenuItem1
// SearchMenuItem
//
searchToolStripMenuItem1.Enabled = false;
searchToolStripMenuItem1.Image = global::BizHawk.MultiClient.Properties.Resources.search;
searchToolStripMenuItem1.Name = "searchToolStripMenuItem1";
searchToolStripMenuItem1.Size = new System.Drawing.Size(215, 22);
searchToolStripMenuItem1.Text = "&Search";
SearchMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.search;
SearchMenuItem.Name = "SearchMenuItem";
SearchMenuItem.Size = new System.Drawing.Size(215, 22);
SearchMenuItem.Text = "&Search";
SearchMenuItem.Click += new System.EventHandler(this.SearchMenuItem_Click);
//
// TotalSearchLabel
//
this.TotalSearchLabel.AutoSize = true;
this.TotalSearchLabel.Location = new System.Drawing.Point(13, 33);
this.TotalSearchLabel.Location = new System.Drawing.Point(12, 49);
this.TotalSearchLabel.Name = "TotalSearchLabel";
this.TotalSearchLabel.Size = new System.Drawing.Size(64, 13);
this.TotalSearchLabel.TabIndex = 2;
@ -165,10 +181,10 @@
this.WatchListView.HideSelection = false;
this.WatchListView.ItemCount = 0;
this.WatchListView.LabelEdit = true;
this.WatchListView.Location = new System.Drawing.Point(9, 58);
this.WatchListView.Location = new System.Drawing.Point(9, 65);
this.WatchListView.Name = "WatchListView";
this.WatchListView.selectedItem = -1;
this.WatchListView.Size = new System.Drawing.Size(232, 363);
this.WatchListView.Size = new System.Drawing.Size(232, 366);
this.WatchListView.TabIndex = 1;
this.WatchListView.UseCompatibleStateImageBehavior = false;
this.WatchListView.View = System.Windows.Forms.View.Details;
@ -556,7 +572,7 @@
this.searchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newSearchToolStripMenuItem,
this.toolStripSeparator7,
searchToolStripMenuItem1,
SearchMenuItem,
this.undoToolStripMenuItem,
this.redoToolStripMenuItem,
this.copyValueToPrevToolStripMenuItem,
@ -810,7 +826,7 @@
// MemDomainLabel
//
this.MemDomainLabel.AutoSize = true;
this.MemDomainLabel.Location = new System.Drawing.Point(129, 33);
this.MemDomainLabel.Location = new System.Drawing.Point(135, 49);
this.MemDomainLabel.Name = "MemDomainLabel";
this.MemDomainLabel.Size = new System.Drawing.Size(70, 13);
this.MemDomainLabel.TabIndex = 8;
@ -838,7 +854,7 @@
this.CompareToBox.Controls.Add(this.SpecificAddressRadio);
this.CompareToBox.Controls.Add(this.SpecificValueRadio);
this.CompareToBox.Controls.Add(this.PreviousValueRadio);
this.CompareToBox.Location = new System.Drawing.Point(247, 58);
this.CompareToBox.Location = new System.Drawing.Point(247, 65);
this.CompareToBox.Name = "CompareToBox";
this.CompareToBox.Size = new System.Drawing.Size(211, 125);
this.CompareToBox.TabIndex = 10;
@ -874,6 +890,7 @@
this.NumberOfChangesBox.Name = "NumberOfChangesBox";
this.NumberOfChangesBox.Size = new System.Drawing.Size(65, 20);
this.NumberOfChangesBox.TabIndex = 28;
this.NumberOfChangesBox.TextChanged += new System.EventHandler(this.CompareToValue_TextChanged);
//
// SpecificAddressBox
//
@ -884,6 +901,7 @@
this.SpecificAddressBox.Name = "SpecificAddressBox";
this.SpecificAddressBox.Size = new System.Drawing.Size(65, 20);
this.SpecificAddressBox.TabIndex = 26;
this.SpecificAddressBox.TextChanged += new System.EventHandler(this.CompareToValue_TextChanged);
//
// SpecificValueBox
//
@ -896,6 +914,7 @@
this.SpecificValueBox.Size = new System.Drawing.Size(65, 20);
this.SpecificValueBox.TabIndex = 24;
this.SpecificValueBox.Type = BizHawk.MultiClient.Watch.DisplayType.Hex;
this.SpecificValueBox.TextChanged += new System.EventHandler(this.CompareToValue_TextChanged);
//
// NumberOfChangesRadio
//
@ -943,12 +962,164 @@
this.PreviousValueRadio.UseVisualStyleBackColor = true;
this.PreviousValueRadio.Click += new System.EventHandler(this.PreviousValueRadio_Click);
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.DoSearchToolButton,
this.toolStripSeparator10,
this.NewSearchToolButton,
this.toolStripSeparator15});
this.toolStrip1.Location = new System.Drawing.Point(0, 24);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(470, 25);
this.toolStrip1.TabIndex = 11;
this.toolStrip1.Text = "toolStrip1";
//
// DoSearchToolButton
//
this.DoSearchToolButton.Image = ((System.Drawing.Image)(resources.GetObject("DoSearchToolButton.Image")));
this.DoSearchToolButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.DoSearchToolButton.Name = "DoSearchToolButton";
this.DoSearchToolButton.Size = new System.Drawing.Size(65, 22);
this.DoSearchToolButton.Text = "Search ";
this.DoSearchToolButton.Click += new System.EventHandler(this.SearchMenuItem_Click);
//
// toolStripSeparator10
//
this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(6, 25);
//
// NewSearchToolButton
//
this.NewSearchToolButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.NewSearchToolButton.Image = global::BizHawk.MultiClient.Properties.Resources.restart;
this.NewSearchToolButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.NewSearchToolButton.Name = "NewSearchToolButton";
this.NewSearchToolButton.Size = new System.Drawing.Size(23, 22);
this.NewSearchToolButton.Text = "New Search";
this.NewSearchToolButton.Click += new System.EventHandler(this.NewSearchMenuMenuItem_Click);
//
// toolStripSeparator15
//
this.toolStripSeparator15.Name = "toolStripSeparator15";
this.toolStripSeparator15.Size = new System.Drawing.Size(6, 25);
//
// ComparisonBox
//
this.ComparisonBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ComparisonBox.Controls.Add(this.DifferentByBox);
this.ComparisonBox.Controls.Add(this.DifferentByRadio);
this.ComparisonBox.Controls.Add(this.NotEqualToRadio);
this.ComparisonBox.Controls.Add(this.EqualToRadio);
this.ComparisonBox.Controls.Add(this.GreaterThanOrEqualToRadio);
this.ComparisonBox.Controls.Add(this.LessThanOrEqualToRadio);
this.ComparisonBox.Controls.Add(this.GreaterThanRadio);
this.ComparisonBox.Controls.Add(this.LessThanRadio);
this.ComparisonBox.Location = new System.Drawing.Point(247, 196);
this.ComparisonBox.Name = "ComparisonBox";
this.ComparisonBox.Size = new System.Drawing.Size(211, 159);
this.ComparisonBox.TabIndex = 12;
this.ComparisonBox.TabStop = false;
this.ComparisonBox.Text = "Comparison Operator";
//
// DifferentByBox
//
this.DifferentByBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.DifferentByBox.Enabled = false;
this.DifferentByBox.Location = new System.Drawing.Point(90, 132);
this.DifferentByBox.MaxLength = 9;
this.DifferentByBox.Name = "DifferentByBox";
this.DifferentByBox.Size = new System.Drawing.Size(50, 20);
this.DifferentByBox.TabIndex = 34;
this.DifferentByBox.TextChanged += new System.EventHandler(this.DifferentByBox_TextChanged);
//
// DifferentByRadio
//
this.DifferentByRadio.AutoSize = true;
this.DifferentByRadio.Location = new System.Drawing.Point(7, 134);
this.DifferentByRadio.Name = "DifferentByRadio";
this.DifferentByRadio.Size = new System.Drawing.Size(83, 17);
this.DifferentByRadio.TabIndex = 6;
this.DifferentByRadio.Text = "Different By:";
this.DifferentByRadio.UseVisualStyleBackColor = true;
this.DifferentByRadio.Click += new System.EventHandler(this.DifferentByRadio_Click);
//
// NotEqualToRadio
//
this.NotEqualToRadio.AutoSize = true;
this.NotEqualToRadio.Location = new System.Drawing.Point(7, 35);
this.NotEqualToRadio.Name = "NotEqualToRadio";
this.NotEqualToRadio.Size = new System.Drawing.Size(88, 17);
this.NotEqualToRadio.TabIndex = 5;
this.NotEqualToRadio.Text = "Not Equal To";
this.NotEqualToRadio.UseVisualStyleBackColor = true;
this.NotEqualToRadio.Click += new System.EventHandler(this.NotEqualToRadio_Click);
//
// EqualToRadio
//
this.EqualToRadio.AutoSize = true;
this.EqualToRadio.Checked = true;
this.EqualToRadio.Location = new System.Drawing.Point(7, 15);
this.EqualToRadio.Name = "EqualToRadio";
this.EqualToRadio.Size = new System.Drawing.Size(68, 17);
this.EqualToRadio.TabIndex = 32;
this.EqualToRadio.TabStop = true;
this.EqualToRadio.Text = "Equal To";
this.EqualToRadio.UseVisualStyleBackColor = true;
this.EqualToRadio.Click += new System.EventHandler(this.EqualToRadio_Click);
//
// GreaterThanOrEqualToRadio
//
this.GreaterThanOrEqualToRadio.AutoSize = true;
this.GreaterThanOrEqualToRadio.Location = new System.Drawing.Point(7, 113);
this.GreaterThanOrEqualToRadio.Name = "GreaterThanOrEqualToRadio";
this.GreaterThanOrEqualToRadio.Size = new System.Drawing.Size(146, 17);
this.GreaterThanOrEqualToRadio.TabIndex = 3;
this.GreaterThanOrEqualToRadio.Text = "Greater Than or Equal To";
this.GreaterThanOrEqualToRadio.UseVisualStyleBackColor = true;
this.GreaterThanOrEqualToRadio.Click += new System.EventHandler(this.GreaterThanOrEqualToRadio_Click);
//
// LessThanOrEqualToRadio
//
this.LessThanOrEqualToRadio.AutoSize = true;
this.LessThanOrEqualToRadio.Location = new System.Drawing.Point(7, 93);
this.LessThanOrEqualToRadio.Name = "LessThanOrEqualToRadio";
this.LessThanOrEqualToRadio.Size = new System.Drawing.Size(133, 17);
this.LessThanOrEqualToRadio.TabIndex = 2;
this.LessThanOrEqualToRadio.Text = "Less Than or Equal To";
this.LessThanOrEqualToRadio.UseVisualStyleBackColor = true;
this.LessThanOrEqualToRadio.Click += new System.EventHandler(this.LessThanOrEqualToRadio_Click);
//
// GreaterThanRadio
//
this.GreaterThanRadio.AutoSize = true;
this.GreaterThanRadio.Location = new System.Drawing.Point(7, 74);
this.GreaterThanRadio.Name = "GreaterThanRadio";
this.GreaterThanRadio.Size = new System.Drawing.Size(88, 17);
this.GreaterThanRadio.TabIndex = 1;
this.GreaterThanRadio.Text = "Greater Than";
this.GreaterThanRadio.UseVisualStyleBackColor = true;
this.GreaterThanRadio.Click += new System.EventHandler(this.GreaterThanRadio_Click);
//
// LessThanRadio
//
this.LessThanRadio.AutoSize = true;
this.LessThanRadio.Location = new System.Drawing.Point(7, 54);
this.LessThanRadio.Name = "LessThanRadio";
this.LessThanRadio.Size = new System.Drawing.Size(75, 17);
this.LessThanRadio.TabIndex = 0;
this.LessThanRadio.Text = "Less Than";
this.LessThanRadio.UseVisualStyleBackColor = true;
this.LessThanRadio.Click += new System.EventHandler(this.LessThanRadio_Click);
//
// NewRamSearch
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(470, 459);
this.Controls.Add(this.ComparisonBox);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.CompareToBox);
this.Controls.Add(this.MessageLabel);
this.Controls.Add(this.MemDomainLabel);
@ -966,6 +1137,10 @@
this.menuStrip1.PerformLayout();
this.CompareToBox.ResumeLayout(false);
this.CompareToBox.PerformLayout();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.ComparisonBox.ResumeLayout(false);
this.ComparisonBox.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -1067,5 +1242,19 @@
private System.Windows.Forms.RadioButton SpecificAddressRadio;
private System.Windows.Forms.RadioButton SpecificValueRadio;
private System.Windows.Forms.RadioButton PreviousValueRadio;
private ToolStripEx toolStrip1;
private System.Windows.Forms.ToolStripButton DoSearchToolButton;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator10;
private System.Windows.Forms.ToolStripButton NewSearchToolButton;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator15;
private System.Windows.Forms.GroupBox ComparisonBox;
private UnsignedIntegerBox DifferentByBox;
private System.Windows.Forms.RadioButton DifferentByRadio;
private System.Windows.Forms.RadioButton NotEqualToRadio;
private System.Windows.Forms.RadioButton EqualToRadio;
private System.Windows.Forms.RadioButton GreaterThanOrEqualToRadio;
private System.Windows.Forms.RadioButton LessThanOrEqualToRadio;
private System.Windows.Forms.RadioButton GreaterThanRadio;
private System.Windows.Forms.RadioButton LessThanRadio;
}
}

View File

@ -227,6 +227,21 @@ namespace BizHawk.MultiClient
SpecificValueBox.ByteSize = Settings.Size = size;
}
private void SetComparisonOperator(RamSearchEngine.ComparisonOperator op)
{
Searches.Operator = op;
}
private void SetCompareTo(RamSearchEngine.Compare comp)
{
Searches.CompareTo = comp;
}
private void SetCompareValue(int? value)
{
Searches.CompareValue = value;
}
#endregion
#region Winform Events
@ -407,6 +422,13 @@ namespace BizHawk.MultiClient
NewSearch();
}
private void SearchMenuItem_Click(object sender, EventArgs e)
{
Searches.DoSearch();
SetTotal();
WatchListView.ItemCount = Searches.Count;
}
#endregion
#region Options
@ -423,15 +445,14 @@ namespace BizHawk.MultiClient
#endregion
#region Dialog Widgets
#region Compare To Box
private void PreviousValueRadio_Click(object sender, EventArgs e)
{
SpecificValueBox.Enabled = false;
SpecificAddressBox.Enabled = false;
NumberOfChangesBox.Enabled = false;
SetCompareTo(RamSearchEngine.Compare.Previous);
}
private void SpecificValueRadio_Click(object sender, EventArgs e)
@ -439,6 +460,7 @@ namespace BizHawk.MultiClient
SpecificValueBox.Enabled = true;
SpecificAddressBox.Enabled = false;
NumberOfChangesBox.Enabled = false;
SetCompareTo(RamSearchEngine.Compare.SpecificValue);
}
private void SpecificAddressRadio_Click(object sender, EventArgs e)
@ -446,6 +468,7 @@ namespace BizHawk.MultiClient
SpecificValueBox.Enabled = false;
SpecificAddressBox.Enabled = true;
NumberOfChangesBox.Enabled = false;
SetCompareTo(RamSearchEngine.Compare.SpecificAddress);
}
private void NumberOfChangesRadio_Click(object sender, EventArgs e)
@ -453,6 +476,7 @@ namespace BizHawk.MultiClient
SpecificValueBox.Enabled = false;
SpecificAddressBox.Enabled = false;
NumberOfChangesBox.Enabled = true;
SetCompareTo(RamSearchEngine.Compare.Changes);
}
private void DifferenceRadio_Click(object sender, EventArgs e)
@ -460,10 +484,77 @@ namespace BizHawk.MultiClient
SpecificValueBox.Enabled = false;
SpecificAddressBox.Enabled = false;
NumberOfChangesBox.Enabled = false;
SetCompareTo(RamSearchEngine.Compare.Difference);
}
private void CompareToValue_TextChanged(object sender, EventArgs e)
{
SetCompareValue((sender as INumberBox).ToInt());
}
#endregion
#region Comparison Operator Box
private void EqualToRadio_Click(object sender, EventArgs e)
{
DifferentByBox.Enabled = false;
SetComparisonOperator(RamSearchEngine.ComparisonOperator.Equal);
}
private void NotEqualToRadio_Click(object sender, EventArgs e)
{
DifferentByBox.Enabled = false;
SetComparisonOperator(RamSearchEngine.ComparisonOperator.NotEqual);
}
private void LessThanRadio_Click(object sender, EventArgs e)
{
DifferentByBox.Enabled = false;
SetComparisonOperator(RamSearchEngine.ComparisonOperator.LessThan);
}
private void GreaterThanRadio_Click(object sender, EventArgs e)
{
DifferentByBox.Enabled = false;
SetComparisonOperator(RamSearchEngine.ComparisonOperator.GreaterThan);
}
private void LessThanOrEqualToRadio_Click(object sender, EventArgs e)
{
DifferentByBox.Enabled = false;
SetComparisonOperator(RamSearchEngine.ComparisonOperator.LessThanEqual);
}
private void GreaterThanOrEqualToRadio_Click(object sender, EventArgs e)
{
DifferentByBox.Enabled = false;
SetComparisonOperator(RamSearchEngine.ComparisonOperator.GreaterThanEqual);
}
private void DifferentByRadio_Click(object sender, EventArgs e)
{
DifferentByBox.Enabled = true;
SetComparisonOperator(RamSearchEngine.ComparisonOperator.DifferentBy);
if (String.IsNullOrWhiteSpace(DifferentByBox.Text))
{
DifferentByBox.Text = "0";
}
DifferentByBox.Focus();
}
private void DifferentByBox_TextChanged(object sender, EventArgs e)
{
if (!String.IsNullOrWhiteSpace(DifferentByBox.Text))
{
Searches.DifferentBy = DifferentByBox.ToInt();
}
else
{
Searches.DifferentBy = null;
}
}
#endregion
#endregion

View File

@ -117,7 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="searchToolStripMenuItem1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="SearchMenuItem.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
@ -129,7 +129,26 @@
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>602, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>699, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="DoSearchToolButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAI3SURBVDhPlZLRS9NRHMW3hwgKBxXRH1BR0UMvPfoQVBAJ
PbiXWETgQw/2MJopjdksa7RyuNQIIlC2alu2dJrQFslklmvQXOthtqlskjORam5jma46nfv7JbathA58
Xu4953u/33uvYj0ZDG6d5WFwpt01jm5vCl2OcK7pkrOTW9vJBsn0L7V3+G3T6Szmi0D4G/DiCzCWBx5E
Cjiv743RsodslMzlslpH6gKJDIQWlgD/J8CdBDwfgOFFwPUuj5oa7TNaRZFK3XNGR8NfgYkc4GPInwUC
BSC4DLxkwTHuXbg5lKf1lJwoldLhTyPEgG+OrbORMDuZIJPkPYl+B7rcb0BvqxwplfL+sFygd1o+OcZQ
mnASfCRxcndQKiAutELKW92vQwG2PTDLdtm2OFmEeZ/gBEgQk7V/id6/F2hutl9xhDIY4R2ImUXb84SP
ISnxOY/q6tOT9FaOUOw73vq03/nc3PYYjyJZvOII0R9yF1MklSlA29C2QKuNaKTQqlaeHLP/9KoRsZyE
Xqeb0Wga45ctvsIdzzj6gin09Lwt1qq1U7TaST3ZLXKSVlxHpXDs6hE49XqcqzcnudxBLpJrRMx7m5iI
eD4Rlj+SaBs+NeKmw1K4pcWRq6ra5ubWWbKf7CR7yT6yi6x95WXPiTp4a0vCKtXWQW7pyQEiTlGWsaah
zjOjSfMhuJoa/gwbyEGyiZQGymU0Gr03GkXYtqhSbRng0mp4M1k//Fs7iLiU60RH/iOsUPwCTRuEcdPL
7RYAAAAASUVORK5CYII=
</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAwAMDAQAAAAAABoBgAAxgAAACAgEAAAAAAA6AIAAC4HAAAYGBAAAAAAAOgBAAAWCgAAEBAQAAAA

View File

@ -9,11 +9,15 @@ namespace BizHawk.MultiClient
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 ComparisonOperator Operator;
public int? DifferentBy;
public Compare CompareTo = Compare.Previous;
public int? CompareValue = null;
public ComparisonOperator Operator = ComparisonOperator.Equal;
public int? DifferentBy = null;
#region Constructors
@ -117,6 +121,34 @@ namespace BizHawk.MultiClient
}
}
public void DoSearch()
{
switch (CompareTo)
{
default:
case RamSearchEngine.Compare.Previous:
ComparePrevious();
break;
case RamSearchEngine.Compare.SpecificValue:
CompareSpecificValue();
break;
case RamSearchEngine.Compare.SpecificAddress:
CompareSpecificAddress();
break;
case RamSearchEngine.Compare.Changes:
CompareChanges();
break;
case RamSearchEngine.Compare.Difference:
throw new NotImplementedException();
}
if (_settings.PreviousType == Watch.PreviousType.LastSearch)
{
_watchList.ForEach(x => x.SetPreviousToCurrent(_settings.Domain, _settings.BigEndian));
}
}
public int Count
{
get { return _watchList.Count; }
@ -176,32 +208,196 @@ namespace BizHawk.MultiClient
#region Comparisons
public void ComparePrevious()
private void ComparePrevious()
{
switch (Operator)
{
case ComparisonOperator.Equal:
_watchList = _watchList.Where(x => x.Previous == GetValue(x.Address)).ToList();
_watchList = _watchList.Where(x => GetValue(x.Address) == x.Previous).ToList();
break;
case ComparisonOperator.NotEqual:
_watchList = _watchList.Where(x => GetValue(x.Address) != x.Previous).ToList();
break;
case ComparisonOperator.GreaterThan:
_watchList = _watchList.Where(x => GetValue(x.Address) > x.Previous).ToList();
break;
case ComparisonOperator.GreaterThanEqual:
_watchList = _watchList.Where(x => GetValue(x.Address) >= x.Previous).ToList();
break;
case ComparisonOperator.LessThan:
_watchList = _watchList.Where(x => GetValue(x.Address) < x.Previous).ToList();
break;
case ComparisonOperator.LessThanEqual:
_watchList = _watchList.Where(x => GetValue(x.Address) <= x.Previous).ToList();
break;
case ComparisonOperator.DifferentBy:
if (DifferentBy.HasValue)
{
_watchList = _watchList.Where(x => (GetValue(x.Address) + DifferentBy.Value == x.Previous) || (GetValue(x.Address) - DifferentBy.Value == x.Previous)).ToList();
}
else
{
throw new InvalidOperationException();
}
break;
}
}
public void CompareSpecificValue(int val)
private void CompareSpecificValue()
{
if (CompareValue.HasValue)
{
switch (Operator)
{
case ComparisonOperator.Equal:
_watchList = _watchList.Where(x => GetValue(x.Address) == CompareValue.Value).ToList();
break;
case ComparisonOperator.NotEqual:
_watchList = _watchList.Where(x => GetValue(x.Address) != CompareValue.Value).ToList();
break;
case ComparisonOperator.GreaterThan:
_watchList = _watchList.Where(x => GetValue(x.Address) > CompareValue.Value).ToList();
break;
case ComparisonOperator.GreaterThanEqual:
_watchList = _watchList.Where(x => GetValue(x.Address) >= CompareValue.Value).ToList();
break;
case ComparisonOperator.LessThan:
_watchList = _watchList.Where(x => GetValue(x.Address) < CompareValue.Value).ToList();
break;
case ComparisonOperator.LessThanEqual:
_watchList = _watchList.Where(x => GetValue(x.Address) <= CompareValue.Value).ToList();
break;
case ComparisonOperator.DifferentBy:
if (DifferentBy.HasValue)
{
_watchList = _watchList.Where(x => (GetValue(x.Address) + DifferentBy.Value == CompareValue.Value) || (GetValue(x.Address) - DifferentBy.Value == CompareValue.Value)).ToList();
}
else
{
throw new InvalidOperationException();
}
break;
}
}
else
{
throw new InvalidOperationException();
}
}
public void CompareSpecificAddress(int addr)
private void CompareSpecificAddress()
{
if (CompareValue.HasValue)
{
switch (Operator)
{
case ComparisonOperator.Equal:
_watchList = _watchList.Where(x => x.Address == CompareValue.Value).ToList();
break;
case ComparisonOperator.NotEqual:
_watchList = _watchList.Where(x => x.Address != CompareValue.Value).ToList();
break;
case ComparisonOperator.GreaterThan:
_watchList = _watchList.Where(x => x.Address > CompareValue.Value).ToList();
break;
case ComparisonOperator.GreaterThanEqual:
_watchList = _watchList.Where(x => x.Address >= CompareValue.Value).ToList();
break;
case ComparisonOperator.LessThan:
_watchList = _watchList.Where(x => x.Address < CompareValue.Value).ToList();
break;
case ComparisonOperator.LessThanEqual:
_watchList = _watchList.Where(x => x.Address <= CompareValue.Value).ToList();
break;
case ComparisonOperator.DifferentBy:
if (DifferentBy.HasValue)
{
_watchList = _watchList.Where(x => (x.Address + DifferentBy.Value == CompareValue.Value) || (x.Address - DifferentBy.Value == CompareValue.Value)).ToList();
}
else
{
throw new InvalidOperationException();
}
break;
}
}
else
{
throw new InvalidOperationException();
}
}
public void CompareChanges(int changes)
public void CompareChanges()
{
if (_settings.Mode == Settings.SearchMode.Detailed && CompareValue.HasValue)
{
switch (Operator)
{
case ComparisonOperator.Equal:
_watchList = _watchList
.Cast<IWatchDetails>()
.Where(x => x.ChangeCount == CompareValue.Value)
.Cast<IMiniWatch>()
.ToList();
break;
case ComparisonOperator.NotEqual:
_watchList = _watchList
.Cast<IWatchDetails>()
.Where(x => x.ChangeCount != CompareValue.Value)
.Cast<IMiniWatch>()
.ToList();
break;
case ComparisonOperator.GreaterThan:
_watchList = _watchList
.Cast<IWatchDetails>()
.Where(x => x.ChangeCount > CompareValue.Value)
.Cast<IMiniWatch>()
.ToList();
break;
case ComparisonOperator.GreaterThanEqual:
_watchList = _watchList
.Cast<IWatchDetails>()
.Where(x => x.ChangeCount >= CompareValue.Value)
.Cast<IMiniWatch>()
.ToList();
break;
case ComparisonOperator.LessThan:
_watchList = _watchList
.Cast<IWatchDetails>()
.Where(x => x.ChangeCount < CompareValue.Value)
.Cast<IMiniWatch>()
.ToList();
break;
case ComparisonOperator.LessThanEqual:
_watchList = _watchList
.Cast<IWatchDetails>()
.Where(x => x.ChangeCount <= CompareValue.Value)
.Cast<IMiniWatch>()
.ToList();
break;
case ComparisonOperator.DifferentBy:
if (DifferentBy.HasValue)
{
_watchList = _watchList
.Cast<IWatchDetails>()
.Where(x => (x.ChangeCount + DifferentBy.Value == CompareValue.Value) || (x.ChangeCount - DifferentBy.Value == CompareValue.Value))
.Cast<IMiniWatch>()
.ToList();
}
else
{
throw new InvalidOperationException();
}
break;
}
}
else
{
throw new InvalidCastException();
}
}
public void CompareDifference()
private void CompareDifference()
{
}
@ -227,7 +423,7 @@ namespace BizHawk.MultiClient
return (ushort)((_settings.Domain.PeekByte(addr)) | (_settings.Domain.PeekByte(addr + 1) << 8));
}
case Watch.WatchSize.DWord:
return 0;
throw new NotImplementedException();
}
}
@ -239,6 +435,7 @@ namespace BizHawk.MultiClient
{
int Address { get; }
int Previous { get; }
void SetPreviousToCurrent(MemoryDomain domain, bool bigendian);
}
private interface IMiniWatchDetails
@ -255,13 +452,18 @@ namespace BizHawk.MultiClient
public MiniByteWatch(MemoryDomain domain, int addr)
{
Address = addr;
_previous = domain.PeekByte(addr);
SetPreviousToCurrent(domain, false);
}
public int Previous
{
get { return _previous; }
}
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekByte(Address);
}
}
private class MiniWordWatch : IMiniWatch
@ -272,14 +474,7 @@ namespace BizHawk.MultiClient
public MiniWordWatch(MemoryDomain domain, int addr, bool bigEndian)
{
Address = addr;
if (bigEndian)
{
_previous = (ushort)((domain.PeekByte(addr) << 8) | (domain.PeekByte(addr + 1)));
}
else
{
_previous = (ushort)((domain.PeekByte(addr)) | (domain.PeekByte(addr + 1) << 8));
}
SetPreviousToCurrent(domain, bigEndian);
}
public int Previous
@ -287,6 +482,10 @@ namespace BizHawk.MultiClient
get { return _previous; }
}
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekWord(Address, bigendian ? Endian.Big : Endian.Little);
}
}
public class MiniDWordWatch : IMiniWatch
@ -297,30 +496,21 @@ namespace BizHawk.MultiClient
public MiniDWordWatch(MemoryDomain domain, int addr, bool bigEndian)
{
Address = addr;
if (bigEndian)
{
_previous = (uint)((domain.PeekByte(addr) << 24)
| (domain.PeekByte(addr + 1) << 16)
| (domain.PeekByte(addr + 2) << 8)
| (domain.PeekByte(addr + 3) << 0));
}
else
{
_previous = (uint)((domain.PeekByte(addr) << 0)
| (domain.PeekByte(addr + 1) << 8)
| (domain.PeekByte(addr + 2) << 16)
| (domain.PeekByte(addr + 3) << 24));
}
SetPreviousToCurrent(domain, bigEndian);
}
public int Previous
{
get { return (int)_previous; }
}
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekDWord(Address, bigendian ? Endian.Big : Endian.Little);
}
}
private class MiniByteWatchDetailed : IMiniWatch, IMiniWatchDetails
private sealed class MiniByteWatchDetailed : IMiniWatch, IMiniWatchDetails
{
public int Address { get; private set; }
private byte _previous;
@ -329,7 +519,12 @@ namespace BizHawk.MultiClient
public MiniByteWatchDetailed(MemoryDomain domain, int addr)
{
Address = addr;
_previous = domain.PeekByte(addr);
SetPreviousToCurrent(domain, false);
}
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekByte(Address);
}
public int Previous
@ -358,7 +553,6 @@ namespace BizHawk.MultiClient
if (value != _previous)
{
_changecount++;
_previous = value;
}
break;
case Watch.PreviousType.LastFrame:
@ -380,7 +574,7 @@ namespace BizHawk.MultiClient
}
}
private class MiniWordWatchDetailed : IMiniWatch, IMiniWatchDetails
private sealed class MiniWordWatchDetailed : IMiniWatch, IMiniWatchDetails
{
public int Address { get; private set; }
private ushort _previous;
@ -389,14 +583,12 @@ namespace BizHawk.MultiClient
public MiniWordWatchDetailed(MemoryDomain domain, int addr, bool bigEndian)
{
Address = addr;
if (bigEndian)
{
_previous = (ushort)((domain.PeekByte(addr) << 8) | (domain.PeekByte(addr + 1)));
}
else
{
_previous = (ushort)((domain.PeekByte(addr)) | (domain.PeekByte(addr + 1) << 8));
}
SetPreviousToCurrent(domain, bigEndian);
}
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekWord(Address, bigendian ? Endian.Big : Endian.Little);
}
public int Previous
@ -428,7 +620,7 @@ namespace BizHawk.MultiClient
}
}
public class MiniDWordWatchDetailed : IMiniWatch, IMiniWatchDetails
public sealed class MiniDWordWatchDetailed : IMiniWatch, IMiniWatchDetails
{
public int Address { get; private set; }
private uint _previous;
@ -437,21 +629,12 @@ namespace BizHawk.MultiClient
public MiniDWordWatchDetailed(MemoryDomain domain, int addr, bool bigEndian)
{
Address = addr;
SetPreviousToCurrent(domain, bigEndian);
}
if (bigEndian)
{
_previous = (uint)((domain.PeekByte(addr) << 24)
| (domain.PeekByte(addr + 1) << 16)
| (domain.PeekByte(addr + 2) << 8)
| (domain.PeekByte(addr + 3) << 0));
}
else
{
_previous = (uint)((domain.PeekByte(addr) << 0)
| (domain.PeekByte(addr + 1) << 8)
| (domain.PeekByte(addr + 2) << 16)
| (domain.PeekByte(addr + 3) << 24));
}
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian)
{
_previous = domain.PeekDWord(Address, bigendian ? Endian.Big : Endian.Little);
}
public int Previous

View File

@ -3,7 +3,7 @@ using System.Globalization;
using System.Windows.Forms;
namespace BizHawk.MultiClient
{
class WatchValueBox : TextBox
class WatchValueBox : TextBox, INumberBox
{
private Watch.WatchSize _size = Watch.WatchSize.Byte;
private Watch.DisplayType _type = Watch.DisplayType.Hex;

View File

@ -4,7 +4,12 @@ using System.Windows.Forms;
namespace BizHawk
{
public class HexTextBox : TextBox
public interface INumberBox
{
int ToInt();
}
public class HexTextBox : TextBox, INumberBox
{
public HexTextBox()
{
@ -57,7 +62,7 @@ namespace BizHawk
}
}
public class UnsignedIntegerBox : TextBox
public class UnsignedIntegerBox : TextBox, INumberBox
{
public UnsignedIntegerBox()
{