diff --git a/BizHawk.MultiClient/MainForm.Events.cs b/BizHawk.MultiClient/MainForm.Events.cs index 91257773df..938db28b05 100644 --- a/BizHawk.MultiClient/MainForm.Events.cs +++ b/BizHawk.MultiClient/MainForm.Events.cs @@ -1142,15 +1142,13 @@ namespace BizHawk.MultiClient TAStudioMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["TAStudio"].Bindings; VirtualPadMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Virtual Pad"].Bindings; TraceLoggerMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Trace Logger"].Bindings; - ToolBoxMenuItem.Enabled = !ToolBox1.IsHandleCreated || ToolBox1.IsDisposed; TraceLoggerMenuItem.Enabled = Global.Emulator.CoreComm.CpuTraceAvailable; - CheatsMenuItem.Enabled = !(Global.Emulator is NullEmulator); } private void ToolBoxMenuItem_Click(object sender, EventArgs e) { - LoadToolBox(); + GlobalWinF.Tools.Load(); } private void RamWatchMenuItem_Click(object sender, EventArgs e) @@ -1362,7 +1360,7 @@ namespace BizHawk.MultiClient { if (Global.Emulator is TI83) { - LoadTI83KeyPad(); + GlobalWinF.Tools.Load(); } } diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 0695b7208b..2951f30dcf 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -84,14 +84,6 @@ namespace BizHawk.MultiClient private bool InFullscreen; private Point _windowed_location; - //tool dialogs - private ToolBox _toolbox; - private TI83KeyPad _ti83pad; - - //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 ToolBox ToolBox1 { get { if (_toolbox == null) _toolbox = new ToolBox(); return _toolbox; } set { _toolbox = value; } } - public TI83KeyPad TI83KeyPad1 { get { if (_ti83pad == null) _ti83pad = new TI83KeyPad(); return _ti83pad; } set { _ti83pad = value; } } - //TODO: clean me up public void Cheats_Restart() { @@ -195,6 +187,9 @@ namespace BizHawk.MultiClient CloseGame(); Global.MovieSession.Movie.Stop(); GlobalWinF.Tools.Close(); +#if WINDOWS + CloseForm(LuaConsole1); +#endif SaveConfig(); }; @@ -1280,7 +1275,9 @@ namespace BizHawk.MultiClient case "TI83": nextEmulator = new TI83(nextComm, game, rom.RomData); if (Global.Config.TI83autoloadKeyPad) - LoadTI83KeyPad(); + { + GlobalWinF.Tools.Load(); + } break; case "NES": { @@ -1565,21 +1562,16 @@ namespace BizHawk.MultiClient Global.Config.RecentRoms.Add(file.CanonicalFullPath); if (File.Exists(PathManager.SaveRamPath(game))) + { LoadSaveRam(); + } if (Global.Config.AutoSavestates) + { LoadState("Auto"); - - ////setup the throttle based on platform's specifications - ////(one day later for some systems we will need to modify it at runtime as the display mode changes) - //{ - // throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate); - // SyncThrottle(); - //} + } GlobalWinF.Tools.Restart(); - if (_ti83pad != null) TI83KeyPad1.Restart(); Cheats_Restart(); - if (_toolbox != null) ToolBox1.Restart(); if (Global.Config.LoadCheatFileByGame) { @@ -2066,7 +2058,7 @@ namespace BizHawk.MultiClient case "Lua Console": OpenLuaConsole(); break; case "Cheats": GlobalWinF.Tools.Load(); break; case "TAStudio": LoadTAStudio(); break; - case "ToolBox": LoadToolBox(); break; + case "ToolBox": GlobalWinF.Tools.Load(); break; case "Virtual Pad": GlobalWinF.Tools.Load(); break; case "Do Search": GlobalWinF.Tools.RamSearch.DoSearch(); break; @@ -2556,28 +2548,6 @@ namespace BizHawk.MultiClient } } - public void LoadToolBox() - { - if (!ToolBox1.IsHandleCreated || ToolBox1.IsDisposed) - { - ToolBox1 = new ToolBox(); - ToolBox1.Show(); - } - else - ToolBox1.Close(); - } - - public void LoadTI83KeyPad() - { - if (!TI83KeyPad1.IsHandleCreated || TI83KeyPad1.IsDisposed) - { - TI83KeyPad1 = new TI83KeyPad(); - TI83KeyPad1.Show(); - } - else - TI83KeyPad1.Focus(); - } - public VideoPluginSettings N64GenerateVideoSettings(GameInfo game, bool hasmovie) { string PluginToUse = ""; @@ -2913,9 +2883,7 @@ namespace BizHawk.MultiClient RewireSound(); ResetRewindBuffer(); - TI83KeyPad1.Restart(); Cheats_Restart(); - ToolBox1.Restart(); #if WINDOWS LuaConsole1.Restart(); #endif @@ -2944,14 +2912,6 @@ namespace BizHawk.MultiClient ConfigService.Save(PathManager.DefaultIniPath, Global.Config); } - public void CloseTools() - { - CloseForm(TI83KeyPad1); -#if WINDOWS - CloseForm(LuaConsole1); -#endif - } - private void CloseForm(Form form) { if (form != null && form.IsHandleCreated) form.Close(); @@ -3017,7 +2977,6 @@ namespace BizHawk.MultiClient { GlobalWinF.OSD.AddMessage("No movie active"); } - } public void LoadTAStudio() diff --git a/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.Client.cs index cd230fb019..59dfddf3ed 100644 --- a/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -142,7 +142,7 @@ namespace BizHawk.MultiClient public static void client_opentoolbox() { - GlobalWinF.MainForm.LoadToolBox(); + GlobalWinF.Tools.Load(); } public static void client_opentracelogger() diff --git a/BizHawk.MultiClient/tools/TI83/TI83KeyPad.cs b/BizHawk.MultiClient/tools/TI83/TI83KeyPad.cs index bfe556bc5d..6a9ede2cde 100644 --- a/BizHawk.MultiClient/tools/TI83/TI83KeyPad.cs +++ b/BizHawk.MultiClient/tools/TI83/TI83KeyPad.cs @@ -7,10 +7,13 @@ using BizHawk.Client.Common; namespace BizHawk.MultiClient { - public partial class TI83KeyPad : Form + public partial class TI83KeyPad : Form, IToolForm { //TODO: if wndx/wndy are negative, load window on the right edge of emulator window + public bool AskSave() { return true; } + public bool UpdateBefore { get { return false; } } + public TI83KeyPad() { InitializeComponent(); @@ -91,13 +94,18 @@ namespace BizHawk.MultiClient public void UpdateValues() { + if (!(Global.Emulator is TI83)) + { + Close(); + } } public void Restart() { if (!(Global.Emulator is TI83)) + { Close(); - if (!IsHandleCreated || IsDisposed) return; + } } private void exitToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/tools/ToolBox.cs b/BizHawk.MultiClient/tools/ToolBox.cs index 3a31b86a3b..e605cad1b1 100644 --- a/BizHawk.MultiClient/tools/ToolBox.cs +++ b/BizHawk.MultiClient/tools/ToolBox.cs @@ -10,7 +10,7 @@ using BizHawk.Emulation.Consoles.Sega; namespace BizHawk.MultiClient { - public partial class ToolBox : Form + public partial class ToolBox : Form, IToolForm { public ToolBox() { @@ -25,6 +25,9 @@ namespace BizHawk.MultiClient HideShowIcons(); } + public bool AskSave() { return true; } + public bool UpdateBefore { get { return false; } } + public void UpdateValues() { } public void Restart() { HideShowIcons(); @@ -135,7 +138,7 @@ namespace BizHawk.MultiClient { if (Global.Emulator is TI83) { - GlobalWinF.MainForm.LoadTI83KeyPad(); + GlobalWinF.Tools.Load(); } }