New Ram Watch - set up autoload and misc small things

This commit is contained in:
adelikat 2013-09-05 15:34:47 +00:00
parent 50b7d9b8c1
commit d56c25392e
4 changed files with 81 additions and 3 deletions

View File

@ -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";

View File

@ -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();
}
}
}
}

View File

@ -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)

View File

@ -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()