From de7660710160d0f2616151867175012029b91e72 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 19 Feb 2011 13:32:03 +0000 Subject: [PATCH] Implement Poke Address, and Add to RamWatch --- .../tools/RamSearch.Designer.cs | 3 +- BizHawk.MultiClient/tools/RamSearch.cs | 63 ++++++++++++++----- BizHawk.MultiClient/tools/RamWatch.cs | 6 ++ 3 files changed, 57 insertions(+), 15 deletions(-) diff --git a/BizHawk.MultiClient/tools/RamSearch.Designer.cs b/BizHawk.MultiClient/tools/RamSearch.Designer.cs index ce73cfcc32..90ecbb88ee 100644 --- a/BizHawk.MultiClient/tools/RamSearch.Designer.cs +++ b/BizHawk.MultiClient/tools/RamSearch.Designer.cs @@ -177,7 +177,7 @@ this.WatchtoolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; this.WatchtoolStripButton1.Name = "WatchtoolStripButton1"; this.WatchtoolStripButton1.Size = new System.Drawing.Size(23, 22); - this.WatchtoolStripButton1.Text = "toolStripButton1"; + this.WatchtoolStripButton1.Text = "Watch"; this.WatchtoolStripButton1.Click += new System.EventHandler(this.WatchtoolStripButton1_Click); // // PoketoolStripButton1 @@ -188,6 +188,7 @@ this.PoketoolStripButton1.Name = "PoketoolStripButton1"; this.PoketoolStripButton1.Size = new System.Drawing.Size(23, 22); this.PoketoolStripButton1.Text = "Poke"; + this.PoketoolStripButton1.Click += new System.EventHandler(this.PoketoolStripButton1_Click); // // TotalSearchLabel // diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 6cdff68f46..5ca1cf7b67 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -18,14 +18,12 @@ namespace BizHawk.MultiClient //Window position gets saved but doesn't load properly string systemID = "NULL"; + List searchList = new List(); //Reset window position item int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired int defaultHeight; - - List searchList = new List(); - public RamSearch() { InitializeComponent(); @@ -57,7 +55,7 @@ namespace BizHawk.MultiClient bigEndianToolStripMenuItem.Checked = false; littleEndianToolStripMenuItem.Checked = true; } - SetTotal(); + StartNewSearch(); if (Global.Config.RamSearchWndx >= 0 && Global.Config.RamSearchWndy >= 0) @@ -71,7 +69,7 @@ namespace BizHawk.MultiClient private void SetTotal() { - int x = Global.Emulator.MainMemory.Size; + int x = searchList.Count; string str; if (x == 1) str = " address"; @@ -180,17 +178,28 @@ namespace BizHawk.MultiClient ModuloBox.Enabled = false; } + private void AddToRamWatch() + { + ListView.SelectedIndexCollection indexes = SearchListView.SelectedIndices; + + if (indexes.Count > 0) + { + if (!Global.MainForm.RamWatch1.IsDisposed) + { + Global.MainForm.RamWatch1.Focus(); + } + else + { + Global.MainForm.RamWatch1 = new RamWatch(); + Global.MainForm.RamWatch1.Show(); + } + Global.MainForm.RamWatch1.AddWatch(searchList[indexes[0]]); + } + } + private void WatchtoolStripButton1_Click(object sender, EventArgs e) { - //TODO: get listview watch object and feed to ram watch - - if (!Global.MainForm.RamWatch1.IsDisposed) - Global.MainForm.RamWatch1.Focus(); - else - { - Global.MainForm.RamWatch1 = new RamWatch(); - Global.MainForm.RamWatch1.Show(); - } + AddToRamWatch(); } private void RamSearch_LocationChanged(object sender, EventArgs e) @@ -227,6 +236,7 @@ namespace BizHawk.MultiClient searchList[x].address = x + startaddress; searchList[x].value = Global.Emulator.MainMemory.PeekByte(x); } + SetTotal(); DisplaySearchList(); } @@ -253,5 +263,30 @@ namespace BizHawk.MultiClient systemID = Global.Emulator.SystemId; MemDomainLabel.Text = systemID + " " + memoryDomain; } + + private Point GetPromptPoint() + { + + Point p = new Point(SearchListView.Location.X, SearchListView.Location.Y); + Point q = new Point(); + q = PointToScreen(p); + return q; + } + + private void PokeAddress() + { + ListView.SelectedIndexCollection indexes = SearchListView.SelectedIndices; + RamPoke p = new RamPoke(); + + if (indexes.Count > 0) + p.SetWatchObject(searchList[indexes[0]]); + p.location = GetPromptPoint(); + p.ShowDialog(); + } + + private void PoketoolStripButton1_Click(object sender, EventArgs e) + { + PokeAddress(); + } } } diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index 9433bc376f..706bdc76fb 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -73,6 +73,12 @@ namespace BizHawk.MultiClient } } + public void AddWatch(Watch w) + { + watchList.Add(w); + DisplayWatchList(); + } + public RamWatch() { InitializeComponent();