diff --git a/BizHawk.MultiClient/MainForm.Designer.cs b/BizHawk.MultiClient/MainForm.Designer.cs index 9109881c08..198f49df16 100644 --- a/BizHawk.MultiClient/MainForm.Designer.cs +++ b/BizHawk.MultiClient/MainForm.Designer.cs @@ -1971,6 +1971,7 @@ // // newRamWatchToolStripMenuItem // + this.newRamWatchToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.FindHS; this.newRamWatchToolStripMenuItem.Name = "newRamWatchToolStripMenuItem"; this.newRamWatchToolStripMenuItem.Size = new System.Drawing.Size(189, 22); this.newRamWatchToolStripMenuItem.Text = "New Ram Watch"; diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 0f589a1042..00523e00bb 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -106,6 +106,7 @@ namespace BizHawk.MultiClient private GBGameGenie _gbgg = null; private GenGameGenie _gengg = null; private NESSoundConfig _nessound = null; + private NewRamWatch _newramwatch = null; //TODO: this is a lazy way to refactor things, but works for now. The point is to not have these objects created until needed, without refactoring a lot of code public RamWatch RamWatch1 { get { if (_ramwatch == null) _ramwatch = new RamWatch(); return _ramwatch; } set { _ramwatch = value; } } @@ -130,6 +131,8 @@ namespace BizHawk.MultiClient public GenGameGenie Gengg { get { if (_gengg == null) _gengg = new GenGameGenie(); return _gengg; } set { _gengg = value; } } public NESSoundConfig NesSound { get { if (_nessound == null) _nessound = new NESSoundConfig(); return _nessound; } set { _nessound = value; } } + public NewRamWatch NewRamWatch1 { get { if (_newramwatch == null) _newramwatch = new NewRamWatch(); return _newramwatch; } set { _newramwatch = value; } } + //TODO: eventually start doing this, rather than tools attempting to talk to tools public void Cheats_UpdateValues() { if (_cheats != null) { _cheats.UpdateValues(); } } @@ -322,10 +325,12 @@ namespace BizHawk.MultiClient if (Global.Config.DisplayRamWatch) { LoadRamWatch(false); + LoadNewRamWatch(false); } else { LoadRamWatch(true); + LoadNewRamWatch(true); } } if (Global.Config.AutoLoadRamSearch) @@ -2307,6 +2312,7 @@ namespace BizHawk.MultiClient #endif if (_ramwatch != null) RamWatch1.UpdateValues(); + if (_newramwatch != null) NewRamWatch1.UpdateValues(); if (_ramsearch != null) RamSearch1.UpdateValues(); if (_hexeditor != null) HexEditor1.UpdateValues(); //The other tool updates are earlier, TAStudio needs to be later so it can display the latest @@ -4187,7 +4193,27 @@ namespace BizHawk.MultiClient private void newRamWatchToolStripMenuItem_Click(object sender, EventArgs e) { - new NewRamWatch().Show(); + LoadNewRamWatch(true); + } + + private void LoadNewRamWatch(bool load_dialog) + { + if (!NewRamWatch1.IsHandleCreated || NewRamWatch1.IsDisposed) + { + NewRamWatch1 = new NewRamWatch(); + if (Global.Config.AutoLoadRamWatch && Global.Config.RecentWatches.Count > 0) + { + NewRamWatch1.LoadWatchFromRecent(Global.Config.RecentWatches.GetRecentFileByPosition(0)); + } + if (load_dialog) + { + NewRamWatch1.Show(); + } + } + else + { + NewRamWatch1.Focus(); + } } } } diff --git a/BizHawk.MultiClient/tools/NewRamWatch.cs b/BizHawk.MultiClient/tools/NewRamWatch.cs index 34b97f5c10..b723815005 100644 --- a/BizHawk.MultiClient/tools/NewRamWatch.cs +++ b/BizHawk.MultiClient/tools/NewRamWatch.cs @@ -101,7 +101,33 @@ namespace BizHawk.MultiClient public void UpdateValues() { - //TODO + if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch) + { + return; + } + + /* TODO + foreach (Watch t in Watches) + { + t.PeekAddress(); + } + + if (Global.Config.DisplayRamWatch) + { + for (int x = 0; x < Watches.Count; x++) + { + bool alert = Global.CheatList.IsActiveCheat(Domain, Watches[x].Address); + Global.OSD.AddGUIText(Watches[x].ToString(), + Global.Config.DispRamWatchx, (Global.Config.DispRamWatchy + (x * 14)), alert, Color.Black, Color.White, 0); + } + } + */ + + if (!IsHandleCreated || IsDisposed) return; + + WatchListView.BlazingFast = true; + WatchListView.Refresh(); + WatchListView.BlazingFast = false; } public bool AskSave() @@ -180,6 +206,29 @@ namespace BizHawk.MultiClient } } + public void LoadWatchFromRecent(string file) + { + bool ask_result = true; + if (Watches.Changes) + { + ask_result = AskSave(); + } + + if (ask_result) + { + bool load_result = Watches.Load(file, details: true, append: false); + if (!load_result) + { + DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); + if (result == DialogResult.Yes) + Global.Config.RecentWatches.Remove(file); + } + + DisplayWatches(); + Watches.Changes = false; + } + } + #region Winform Events private void NewRamWatch_Load(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/tools/Watch.cs b/BizHawk.MultiClient/tools/Watch.cs index e8986046df..a775569744 100644 --- a/BizHawk.MultiClient/tools/Watch.cs +++ b/BizHawk.MultiClient/tools/Watch.cs @@ -1233,7 +1233,7 @@ namespace BizHawk.MultiClient } } - public void Load(string path, bool details, bool append) + public bool Load(string path, bool details, bool append) { bool result = LoadFile(path, details, append); @@ -1248,6 +1248,8 @@ namespace BizHawk.MultiClient Changes = false; } } + + return result; } private void SaveFile()