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) private void RamSearchMenuItem_Click(object sender, EventArgs e)
{ {
LoadRamSearch(); GlobalWinF.Tools.Load<RamSearch>();
} }
private void HexEditorMenuItem_Click(object sender, EventArgs e) private void HexEditorMenuItem_Click(object sender, EventArgs e)

View File

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

View File

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

View File

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

View File

@ -127,7 +127,7 @@ namespace BizHawk.MultiClient
public static void client_openramsearch() public static void client_openramsearch()
{ {
GlobalWinF.MainForm.LoadRamSearch(); GlobalWinF.Tools.Load<RamSearch>();
} }
public static void client_openrom(object lua_input) 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) private void toolStripButton3_Click(object sender, EventArgs e)
{ {
GlobalWinF.MainForm.LoadRamSearch(); GlobalWinF.Tools.Load<RamSearch>();
} }
private void HexEditor_Click(object sender, EventArgs e) private void HexEditor_Click(object sender, EventArgs e)

View File

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

View File

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

View File

@ -17,7 +17,7 @@ namespace BizHawk.MultiClient
/// <summary> /// <summary>
/// A winform designed to search through ram values /// A winform designed to search through ram values
/// </summary> /// </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 //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 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 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 #region Initialize, Load, and Save
public RamSearch() public RamSearch()