diff --git a/BizHawk.MultiClient/tools/RamPoke.cs b/BizHawk.MultiClient/tools/RamPoke.cs
index 7af1464e78..d1a2af0fe5 100644
--- a/BizHawk.MultiClient/tools/RamPoke.cs
+++ b/BizHawk.MultiClient/tools/RamPoke.cs
@@ -16,6 +16,7 @@ namespace BizHawk.MultiClient
//If signed/unsigned/hex radios selected, auto-change the value box
//Checked signed/u/h value on RamPoke_Load and set value appopriately
//Memory domain selection
+ //Overhaul input validation of textboxes to be like Ram Search
public Watch watch = new Watch();
public Point location = new Point();
diff --git a/BizHawk.MultiClient/tools/RamSearch.Designer.cs b/BizHawk.MultiClient/tools/RamSearch.Designer.cs
index 68e6bae19c..e8fb7c26fb 100644
--- a/BizHawk.MultiClient/tools/RamSearch.Designer.cs
+++ b/BizHawk.MultiClient/tools/RamSearch.Designer.cs
@@ -68,6 +68,7 @@
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.definePreviousValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sinceLastSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.originalValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sinceLastFrameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.restoreOriginalWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -113,7 +114,6 @@
this.AutoSearchCheckBox = new System.Windows.Forms.CheckBox();
this.MemDomainLabel = new System.Windows.Forms.Label();
this.OutputLabel = new System.Windows.Forms.Label();
- this.originalValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SearchtoolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
@@ -467,6 +467,13 @@
this.sinceLastSearchToolStripMenuItem.Text = "Since last Search";
this.sinceLastSearchToolStripMenuItem.Click += new System.EventHandler(this.sinceLastSearchToolStripMenuItem_Click);
//
+ // originalValueToolStripMenuItem
+ //
+ this.originalValueToolStripMenuItem.Name = "originalValueToolStripMenuItem";
+ this.originalValueToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
+ this.originalValueToolStripMenuItem.Text = "Original value";
+ this.originalValueToolStripMenuItem.Click += new System.EventHandler(this.originalValueToolStripMenuItem_Click);
+ //
// sinceLastFrameToolStripMenuItem
//
this.sinceLastFrameToolStripMenuItem.Name = "sinceLastFrameToolStripMenuItem";
@@ -730,7 +737,9 @@
this.NumberOfChangesBox.Name = "NumberOfChangesBox";
this.NumberOfChangesBox.Size = new System.Drawing.Size(65, 20);
this.NumberOfChangesBox.TabIndex = 6;
+ this.NumberOfChangesBox.TextChanged += new System.EventHandler(this.NumberOfChangesBox_TextChanged);
this.NumberOfChangesBox.Leave += new System.EventHandler(this.NumberOfChangesBox_Leave);
+ this.NumberOfChangesBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.NumberOfChangesBox_KeyPress);
//
// SpecificAddressBox
//
@@ -741,7 +750,9 @@
this.SpecificAddressBox.Name = "SpecificAddressBox";
this.SpecificAddressBox.Size = new System.Drawing.Size(65, 20);
this.SpecificAddressBox.TabIndex = 5;
+ this.SpecificAddressBox.TextChanged += new System.EventHandler(this.SpecificAddressBox_TextChanged);
this.SpecificAddressBox.Leave += new System.EventHandler(this.SpecificAddressBox_Leave);
+ this.SpecificAddressBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.SpecificAddressBox_KeyPress);
//
// SpecificValueBox
//
@@ -751,7 +762,9 @@
this.SpecificValueBox.Name = "SpecificValueBox";
this.SpecificValueBox.Size = new System.Drawing.Size(65, 20);
this.SpecificValueBox.TabIndex = 4;
+ this.SpecificValueBox.TextChanged += new System.EventHandler(this.SpecificValueBox_TextChanged);
this.SpecificValueBox.Leave += new System.EventHandler(this.SpecificValueBox_Leave);
+ this.SpecificValueBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.SpecificValueBox_KeyPress);
//
// NumberOfChangesRadio
//
@@ -825,7 +838,9 @@
this.DifferentByBox.Name = "DifferentByBox";
this.DifferentByBox.Size = new System.Drawing.Size(50, 20);
this.DifferentByBox.TabIndex = 9;
+ this.DifferentByBox.TextChanged += new System.EventHandler(this.DifferentByBox_TextChanged);
this.DifferentByBox.Leave += new System.EventHandler(this.DifferentByBox_Leave);
+ this.DifferentByBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.DifferentByBox_KeyPress);
//
// DifferentByRadio
//
@@ -937,13 +952,6 @@
this.OutputLabel.TabIndex = 9;
this.OutputLabel.Text = " ";
//
- // originalValueToolStripMenuItem
- //
- this.originalValueToolStripMenuItem.Name = "originalValueToolStripMenuItem";
- this.originalValueToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
- this.originalValueToolStripMenuItem.Text = "Original value";
- this.originalValueToolStripMenuItem.Click += new System.EventHandler(this.originalValueToolStripMenuItem_Click);
- //
// RamSearch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs
index 559b2ffbbf..e7f5cc9337 100644
--- a/BizHawk.MultiClient/tools/RamSearch.cs
+++ b/BizHawk.MultiClient/tools/RamSearch.cs
@@ -31,6 +31,9 @@ namespace BizHawk.MultiClient
//Add button to set copy current values to prev
//ON start new search, a preview of equal to prev value would remove all searches, there's an error here
//On start new search, don't do preview
+ //On text box leave event, do preview
+ //After search everything goes pink
+ //Limit number of digits in specific value based on data type
string systemID = "NULL";
@@ -556,7 +559,7 @@ namespace BizHawk.MultiClient
SaveUndo();
OutputLabel.Text = MakeAddressString(searchList.Count - weededList.Count) + " removed";
ReplaceSearchListWithWeedOutList();
- MakePreviousList();
+ if (Global.Config.RamSearchPreviousAs != 1) MakePreviousList(); //1 = Original value
DisplaySearchList();
}
else
@@ -1020,50 +1023,30 @@ namespace BizHawk.MultiClient
private void SpecificValueBox_Leave(object sender, EventArgs e)
{
- SpecificValueBox.Text = SpecificValueBox.Text.Replace(" ", "");
- if (!InputValidate.IsValidSignedNumber(SpecificValueBox.Text))
- {
- SpecificValueBox.Focus();
- SpecificValueBox.SelectAll();
- ToolTip t = new ToolTip();
- t.Show("Must be a valid decimal value", SpecificValueBox, 5000);
- }
+ DoPreview();
}
private void SpecificAddressBox_Leave(object sender, EventArgs e)
{
- SpecificAddressBox.Text = SpecificAddressBox.Text.Replace(" ", "");
- if (!InputValidate.IsValidHexNumber(SpecificAddressBox.Text))
- {
- SpecificAddressBox.Focus();
- SpecificAddressBox.SelectAll();
- ToolTip t = new ToolTip();
- t.Show("Must be a valid hexadecimal value", SpecificAddressBox, 5000);
- }
+ DoPreview();
}
private void NumberOfChangesBox_Leave(object sender, EventArgs e)
{
- NumberOfChangesBox.Text = NumberOfChangesBox.Text.Replace(" ", "");
- if (!InputValidate.IsValidUnsignedNumber(NumberOfChangesBox.Text))
- {
- NumberOfChangesBox.Focus();
- NumberOfChangesBox.SelectAll();
- ToolTip t = new ToolTip();
- t.Show("Must be a valid unsigned decimal value", NumberOfChangesBox, 5000);
- }
+ DoPreview();
}
private void DifferentByBox_Leave(object sender, EventArgs e)
{
- DifferentByBox.Text = DifferentByBox.Text.Replace(" ", "");
- if (!InputValidate.IsValidUnsignedNumber(DifferentByBox.Text))
+ if (!InputValidate.IsValidUnsignedNumber(DifferentByBox.Text)) //Actually the only way this could happen is from putting dashes after the first character
{
DifferentByBox.Focus();
DifferentByBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("Must be a valid unsigned decimal value", DifferentByBox, 5000);
+ return;
}
+ DoPreview();
}
private bool SaveSearchFile(string path)
@@ -1415,6 +1398,58 @@ namespace BizHawk.MultiClient
Global.Config.RamSearchPreviewMode ^= true;
}
+ private void SpecificValueBox_TextChanged(object sender, EventArgs e)
+ {
+ DoPreview();
+ }
+
+ private void SpecificValueBox_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (e.KeyChar == '\b') return;
+
+ if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
+ e.Handled = true;
+ }
+
+ private void SpecificAddressBox_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (e.KeyChar == '\b') return;
+
+ if (!InputValidate.IsValidHexNumber(e.KeyChar))
+ e.Handled = true;
+ }
+
+ private void NumberOfChangesBox_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (e.KeyChar == '\b') return;
+
+ if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
+ e.Handled = true;
+ }
+
+ private void DifferentByBox_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (e.KeyChar == '\b') return;
+
+ if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
+ e.Handled = true;
+ }
+
+ private void SpecificAddressBox_TextChanged(object sender, EventArgs e)
+ {
+ DoPreview();
+ }
+
+ private void NumberOfChangesBox_TextChanged(object sender, EventArgs e)
+ {
+ DoPreview();
+ }
+
+ private void DifferentByBox_TextChanged(object sender, EventArgs e)
+ {
+ DoPreview();
+ }
+
}
diff --git a/BizHawk.MultiClient/tools/RamSearch.resx b/BizHawk.MultiClient/tools/RamSearch.resx
index 1f988f2974..b954ff8d17 100644
--- a/BizHawk.MultiClient/tools/RamSearch.resx
+++ b/BizHawk.MultiClient/tools/RamSearch.resx
@@ -160,9 +160,6 @@
259, 17
-
- 358, 17
-
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@@ -194,6 +191,9 @@
s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC
+
+ 358, 17
+
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
diff --git a/BizHawk.Util/InputValidate.cs b/BizHawk.Util/InputValidate.cs
index ec68ef871f..a21a4c6b41 100644
--- a/BizHawk.Util/InputValidate.cs
+++ b/BizHawk.Util/InputValidate.cs
@@ -27,6 +27,14 @@ namespace BizHawk
return true;
}
+ public static bool IsValidUnsignedNumber(char c)
+ {
+ if (c < 47 || c > 58)
+ return false;
+
+ return true;
+ }
+
///
/// Validates all chars are 0-9 or a dash as the first value
///
@@ -58,6 +66,17 @@ namespace BizHawk
return true;
}
+ public static bool IsValidSignedNumber(char c)
+ {
+ if (c == 47) return true;
+
+ if (c < 47 || c > 58)
+ return false;
+
+ return true;
+ }
+
+
///
/// validates is a Hex number 0-9, A-F (must be capital letters)
///
@@ -84,5 +103,23 @@ namespace BizHawk
}
return true;
}
+
+ public static bool IsValidHexNumber(char c)
+ {
+ if (c < 47) return false; //0
+
+ if (c > 58) //9
+ {
+ if (c < 65) //A
+ return false;
+
+ if (c > 70) //F
+ {
+ if (c < 97 || c > 102) //a-f
+ return false;
+ }
+ }
+ return true;
+ }
}
}