move Ram Search into toolmanager

This commit is contained in:
adelikat 2013-11-02 20:13:53 +00:00
parent 024e005884
commit 5f1640a3b1
9 changed files with 69 additions and 55 deletions

View File

@ -1160,7 +1160,7 @@ namespace BizHawk.MultiClient
private void RamSearchMenuItem_Click(object sender, EventArgs e)
{
LoadRamSearch();
GlobalWinF.Tools.Load<RamSearch>();
}
private void HexEditorMenuItem_Click(object sender, EventArgs e)

View File

@ -86,8 +86,6 @@ namespace BizHawk.MultiClient
//tool dialogs
private RamSearch _ramsearch;
private HexEditor _hexeditor;
private TraceLogger _tracelogger;
private SNESGraphicsDebugger _snesgraphicsdebugger;
@ -109,7 +107,6 @@ namespace BizHawk.MultiClient
private NESSoundConfig _nessound;
//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 RamSearch RamSearch1 { get { if (_ramsearch == null) _ramsearch = new RamSearch(); return _ramsearch; } set { _ramsearch = value; } }
public HexEditor HexEditor1 { get { if (_hexeditor == null) _hexeditor = new HexEditor(); return _hexeditor; } set { _hexeditor = value; } }
public TraceLogger TraceLogger1 { get { if (_tracelogger == null) _tracelogger = new TraceLogger(); return _tracelogger; } set { _tracelogger = value; } }
public SNESGraphicsDebugger SNESGraphicsDebugger1 { get { if (_snesgraphicsdebugger == null) _snesgraphicsdebugger = new SNESGraphicsDebugger(); return _snesgraphicsdebugger; } set { _snesgraphicsdebugger = value; } }
@ -353,7 +350,7 @@ namespace BizHawk.MultiClient
}
if (Global.Config.RecentSearches.AutoLoad)
{
LoadRamSearch();
GlobalWinF.Tools.Load<RamSearch>();
}
if (Global.Config.AutoLoadHexEditor)
{
@ -1610,8 +1607,6 @@ namespace BizHawk.MultiClient
GlobalWinF.Tools.Restart();
if (_ramsearch != null) RamSearch1.Restart();
if (_hexeditor != null) HexEditor1.Restart();
if (_nesppu != null) NESPPU1.Restart();
if (_nesnametableview != null) NESNameTableViewer1.Restart();
@ -2102,7 +2097,7 @@ namespace BizHawk.MultiClient
case "Movie Poke": ToggleModePokeMode(); break;
case "Ram Watch": LoadRamWatch(true); break;
case "Ram Search": LoadRamSearch(); break;
case "Ram Search": GlobalWinF.Tools.Load<RamSearch>(); break;
case "Hex Editor": LoadHexEditor(); break;
case "Trace Logger": LoadTraceLogger(); break;
case "Lua Console": OpenLuaConsole(); break;
@ -2111,12 +2106,12 @@ namespace BizHawk.MultiClient
case "ToolBox": LoadToolBox(); break;
case "Virtual Pad": LoadVirtualPads(); break;
case "Do Search": RamSearch_DoSearch(); break;
case "New Search": RamSearch_NewSearch(); break;
case "Previous Compare To": RamSearch_PreviousCompareTo(); break;
case "Next Compare To": RamSearch_NextCompareTo(); break;
case "Previous Operator": RamSearch_PreviousOperator(); break;
case "Next Operator": RamSearch_NextOperator(); break;
case "Do Search": GlobalWinF.Tools.RamSearch.DoSearch(); break;
case "New Search": GlobalWinF.Tools.RamSearch.NewSearch(); break;
case "Previous Compare To": GlobalWinF.Tools.RamSearch.NextCompareTo(reverse: true); break;
case "Next Compare To": GlobalWinF.Tools.RamSearch.NextCompareTo(); break;
case "Previous Operator": GlobalWinF.Tools.RamSearch.NextOperator(reverse: true); break;
case "Next Operator": GlobalWinF.Tools.RamSearch.NextOperator(); break;
case "Toggle BG 1": SNES_ToggleBG1(); break;
case "Toggle BG 2": SNES_ToggleBG2(); break;
@ -2359,9 +2354,6 @@ namespace BizHawk.MultiClient
if (_snesgraphicsdebugger != null) SNESGraphicsDebugger1.UpdateToolsLoadstate();
}
/// <summary>
/// Update all tools that are frame dependent like Ram Search after processing
/// </summary>
public void UpdateToolsAfter(bool fromLua = false)
{
#if WINDOWS
@ -2372,7 +2364,6 @@ namespace BizHawk.MultiClient
#endif
GlobalWinF.Tools.UpdateAfter();
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
//frame of execution in its list view.
@ -2586,19 +2577,7 @@ namespace BizHawk.MultiClient
GlobalWinF.OSD.AddMessage("Slot " + Global.Config.SaveSlot + " selected.");
}
public void LoadRamSearch()
{
if (!RamSearch1.IsHandleCreated || RamSearch1.IsDisposed)
{
RamSearch1 = new RamSearch();
RamSearch1.Show();
}
else
{
RamSearch1.Focus();
}
}
/*TODO delete me
private void RamSearch_DoSearch()
{
if (!RamSearch1.IsHandleCreated || RamSearch1.IsDisposed)
@ -2670,6 +2649,7 @@ namespace BizHawk.MultiClient
RamSearch1.NextOperator(reverse: true);
}
}
*/
public void LoadNesSoundConfig()
{
@ -3210,7 +3190,6 @@ namespace BizHawk.MultiClient
RewireSound();
ResetRewindBuffer();
RamSearch1.Restart();
HexEditor1.Restart();
NESPPU1.Restart();
NESNameTableViewer1.Restart();
@ -3251,7 +3230,6 @@ namespace BizHawk.MultiClient
public void CloseTools()
{
CloseForm(RamSearch1);
CloseForm(HexEditor1);
CloseForm(NESNameTableViewer1);
CloseForm(NESPPU1);

View File

@ -895,9 +895,9 @@ namespace BizHawk.MultiClient
private void UpdateRelatedDialogs()
{
GlobalWinF.MainForm.UpdateCheatStatus();
GlobalWinF.MainForm.RamSearch1.UpdateValues();
GlobalWinF.Tools.UpdateValues<RamWatch>();
GlobalWinF.Tools.UpdateValues<RamSearch>();
GlobalWinF.MainForm.UpdateCheatStatus();
GlobalWinF.MainForm.Cheats_UpdateValues();
UpdateValues();
}

View File

@ -33,5 +33,6 @@
bool Focus();
void Show();
void Close();
bool IsDisposed { get; }
}
}

View File

@ -127,7 +127,7 @@ namespace BizHawk.MultiClient
public static void client_openramsearch()
{
GlobalWinF.MainForm.LoadRamSearch();
GlobalWinF.Tools.Load<RamSearch>();
}
public static void client_openrom(object lua_input)

View File

@ -98,7 +98,7 @@ namespace BizHawk.MultiClient
private void toolStripButton3_Click(object sender, EventArgs e)
{
GlobalWinF.MainForm.LoadRamSearch();
GlobalWinF.Tools.Load<RamSearch>();
}
private void HexEditor_Click(object sender, EventArgs e)

View File

@ -207,9 +207,9 @@ namespace BizHawk.MultiClient
public static void UpdateCheatRelatedTools()
{
GlobalWinF.Tools.UpdateValues<RamWatch>();
GlobalWinF.Tools.UpdateValues<RamSearch>();
GlobalWinF.MainForm.HexEditor1.UpdateValues();
GlobalWinF.MainForm.Cheats_UpdateValues();
GlobalWinF.MainForm.RamSearch1.UpdateValues();
GlobalWinF.MainForm.UpdateCheatStatus();
}

View File

@ -23,16 +23,21 @@ namespace BizHawk.MultiClient
var existingTool = _tools.FirstOrDefault(x => x is T);
if (existingTool != null)
{
existingTool.Show();
existingTool.Focus();
return existingTool;
}
else
{
var result = Get<T>();
result.Show();
return result;
if (existingTool.IsDisposed)
{
_tools.Remove(existingTool);
}
else
{
existingTool.Show();
existingTool.Focus();
return existingTool;
}
}
var result = Get<T>();
result.Show();
return result;
}
/// <summary>
@ -183,17 +188,44 @@ namespace BizHawk.MultiClient
var tool = _tools.FirstOrDefault(x => x is RamWatch);
if (tool != null)
{
return tool as RamWatch;
}
else
{
var ramWatch = new RamWatch();
_tools.Add(ramWatch);
return ramWatch;
if (tool.IsDisposed)
{
_tools.Remove(tool);
}
else
{
return tool as RamWatch;
}
}
var ramWatch = new RamWatch();
_tools.Add(ramWatch);
return ramWatch;
}
}
public RamSearch RamSearch
{
get
{
var tool = _tools.FirstOrDefault(x => x is RamSearch);
if (tool != null)
{
if (tool.IsDisposed)
{
_tools.Remove(tool);
}
else
{
return tool as RamSearch;
}
}
var ramWatch = new RamSearch();
_tools.Add(ramWatch);
return ramWatch;
}
}
#endregion
}

View File

@ -17,7 +17,7 @@ namespace BizHawk.MultiClient
/// <summary>
/// A winform designed to search through ram values
/// </summary>
public partial class RamSearch : Form
public partial class RamSearch : Form, IToolForm
{
//TODO: DoSearch grabs the state of widgets and passes it to the engine before running, so rip out code that is attempting to keep the state up to date through change events
@ -47,6 +47,9 @@ namespace BizHawk.MultiClient
public const int MaxDetailedSize = (1024 * 1024); //1mb, semi-arbituary decision, sets the size to check for and automatically switch to fast mode for the user
public const int MaxSupportedSize = (1024 * 1024 * 64); //64mb, semi-arbituary decision, sets the maximum size ram search will support (as it will crash beyond this)
public bool AskSave() { return true; }
public bool UpdateBefore { get { return false; } }
#region Initialize, Load, and Save
public RamSearch()