diff --git a/BizHawk.MultiClient/tools/RamSearch.Designer.cs b/BizHawk.MultiClient/tools/RamSearch.Designer.cs index e8fb7c26fb..fc08b36b5b 100644 --- a/BizHawk.MultiClient/tools/RamSearch.Designer.cs +++ b/BizHawk.MultiClient/tools/RamSearch.Designer.cs @@ -114,6 +114,7 @@ this.AutoSearchCheckBox = new System.Windows.Forms.CheckBox(); this.MemDomainLabel = new System.Windows.Forms.Label(); this.OutputLabel = new System.Windows.Forms.Label(); + this.TruncateFromFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SearchtoolStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); @@ -276,6 +277,7 @@ this.saveToolStripMenuItem, this.saveAsToolStripMenuItem, this.appendFileToolStripMenuItem, + this.TruncateFromFileToolStripMenuItem, this.recentToolStripMenuItem, this.toolStripSeparator4, this.exitToolStripMenuItem}); @@ -952,6 +954,13 @@ this.OutputLabel.TabIndex = 9; this.OutputLabel.Text = " "; // + // TruncateFromFileToolStripMenuItem + // + this.TruncateFromFileToolStripMenuItem.Name = "TruncateFromFileToolStripMenuItem"; + this.TruncateFromFileToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.TruncateFromFileToolStripMenuItem.Text = "&Truncate from File..."; + this.TruncateFromFileToolStripMenuItem.Click += new System.EventHandler(this.TruncateFromFileToolStripMenuItem_Click); + // // RamSearch // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1081,5 +1090,6 @@ private System.Windows.Forms.ToolStripMenuItem sinceLastFrameToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem previewModeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem originalValueToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem TruncateFromFileToolStripMenuItem; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 5696763aac..c6f7fab78b 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -22,7 +22,7 @@ namespace BizHawk.MultiClient //Multiple memory domains //Option to remove current Ram Watch list from search list //Option to always remove Ram Watch list from search list - //Truncate from file in File menu (and toolstrip?) + //Truncate from file toolstrip button //Save Dialog - user cancelling crashes, same for Ram Watch? //Weddedlist & undoList are getting references instead of copies, somehow still works but there has to be some failures as a result, fix //Add button to set copy current values to prev @@ -113,7 +113,7 @@ namespace BizHawk.MultiClient var file = GetFileFromUser(); if (file != null) { - LoadSearchFile(file.FullName, false); + LoadSearchFile(file.FullName, false, false, searchList); DisplaySearchList(); } } @@ -1110,7 +1110,7 @@ namespace BizHawk.MultiClient private void LoadSearchFromRecent(string file) { - bool r = LoadSearchFile(file, false); + bool r = LoadSearchFile(file, false, false, searchList); if (!r) { DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); @@ -1131,7 +1131,7 @@ namespace BizHawk.MultiClient return count; } - bool LoadSearchFile(string path, bool append) + bool LoadSearchFile(string path, bool append, bool truncate, List list) { int y, z; var file = new FileInfo(path); @@ -1139,15 +1139,15 @@ namespace BizHawk.MultiClient using (StreamReader sr = file.OpenText()) { - if (!append) + if (!append && !truncate) currentSearchFile = path; int count = 0; string s = ""; string temp = ""; - if (append == false) - searchList.Clear(); //Wipe existing list and read from file + if (!append) + list.Clear(); //Wipe existing list and read from file while ((s = sr.ReadLine()) != null) { @@ -1190,13 +1190,16 @@ namespace BizHawk.MultiClient //w.notes = s.Substring(2, s.Length - 2); //User notes - searchList.Add(w); + list.Add(w); } - Global.Config.RecentSearches.Add(file.FullName); - OutputLabel.Text = Path.GetFileName(file.FullName); - //Update the number of watches - SetTotal(); + if (!append && !truncate) + { + Global.Config.RecentSearches.Add(file.FullName); + OutputLabel.Text = Path.GetFileName(file.FullName); + //Update the number of watches + SetTotal(); + } } return true; @@ -1250,7 +1253,7 @@ namespace BizHawk.MultiClient { var file = GetFileFromUser(); if (file != null) - LoadSearchFile(file.FullName, true); + LoadSearchFile(file.FullName, true, false, searchList); DisplaySearchList(); } @@ -1455,6 +1458,43 @@ namespace BizHawk.MultiClient DoPreview(); } + private void TruncateFromFileToolStripMenuItem_Click(object sender, EventArgs e) + { + TruncateFromFile(); + } + + private void TruncateFromFile() + { + //TODO: what about byte size? Think about the implications of this + var file = GetFileFromUser(); + if (file != null) + { + List temp = new List(); + LoadSearchFile(file.FullName, false, true, temp); + weededList.Clear(); + bool found = false; + for (int x = 0; x < searchList.Count; x++) + { + found = false; + for (int y = 0; y < temp.Count; y++) + { + if (searchList[x].address == temp[y].address) + { + found = true; + break; + } + + } + if (!found) + weededList.Add(searchList[x]); + } + SaveUndo(); + OutputLabel.Text = MakeAddressString(searchList.Count - weededList.Count) + " removed"; + ReplaceSearchListWithWeedOutList(); + if (Global.Config.RamSearchPreviousAs != 1) MakePreviousList(); //1 = Original value + DisplaySearchList(); + } + } } diff --git a/BizHawk.MultiClient/tools/RamSearch.resx b/BizHawk.MultiClient/tools/RamSearch.resx index b954ff8d17..1f988f2974 100644 --- a/BizHawk.MultiClient/tools/RamSearch.resx +++ b/BizHawk.MultiClient/tools/RamSearch.resx @@ -160,6 +160,9 @@ 259, 17 + + 358, 17 + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 @@ -191,9 +194,6 @@ s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC - - 358, 17 - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8