From 6d4c5ef17fa814bedaff21a23f373e9ebef344ff Mon Sep 17 00:00:00 2001 From: feos Date: Sat, 5 Dec 2015 12:09:39 +0300 Subject: [PATCH] preparations for state hotkeys functioning with tastudio branches. typos. --- BizHawk.Client.Common/config/Binding.cs | 1 + .../movie/tasproj/TasMovie.cs | 1 + BizHawk.Client.EmuHawk/MainForm.Hotkey.cs | 2 +- BizHawk.Client.EmuHawk/MainForm.cs | 47 ++++++++++++++++++- BizHawk.Client.EmuHawk/tools/ToolManager.cs | 27 ++++++++++- 5 files changed, 74 insertions(+), 4 deletions(-) diff --git a/BizHawk.Client.Common/config/Binding.cs b/BizHawk.Client.Common/config/Binding.cs index c319ab5251..fd2a147973 100644 --- a/BizHawk.Client.Common/config/Binding.cs +++ b/BizHawk.Client.Common/config/Binding.cs @@ -207,6 +207,7 @@ namespace BizHawk.Client.Common new Binding { DisplayName = "ToolBox", Bindings = "Shift+T", TabGroup = "Tools", DefaultBinding = "" }, new Binding { DisplayName = "Virtual Pad", Bindings = "", TabGroup = "Tools", DefaultBinding = "" }, + //Ram Search new Binding { DisplayName = "New Search", Bindings = "", TabGroup = "Ram Search", DefaultBinding = "" }, new Binding { DisplayName = "Do Search", Bindings = "", TabGroup = "Ram Search", DefaultBinding = "" }, new Binding { DisplayName = "Previous Compare To", Bindings = "", TabGroup = "Ram Search", DefaultBinding = "" }, diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs index cb2eaa8a4c..baf6c23acc 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs @@ -88,6 +88,7 @@ namespace BizHawk.Client.Common public string NewBranchText = ""; public int CurrentBranch { get; set; } public int BranchCount { get { return Branches.Count; } } + public TasBranch GetBranch(int index) { if (index >= Branches.Count) diff --git a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs index 6c0c1853d0..26ae9ff81c 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs @@ -93,7 +93,7 @@ namespace BizHawk.Client.EmuHawk IncreaseWindowSize(); break; case "Smaller Window": - DecreaseWIndowSize(); + DecreaseWindowSize(); break; case "Increase Speed": IncreaseSpeed(); diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 53539b4375..962794e399 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -1567,6 +1567,11 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator.HasSavestates()) { + if (GlobalWin.Tools.TAStudio != null) + { + return; + } + Global.Config.SaveSlot = num; SaveSlotSelectedMessage(); UpdateStatusSlots(); @@ -1882,6 +1887,11 @@ namespace BizHawk.Client.EmuHawk return; } + if (GlobalWin.Tools.TAStudio != null) + { + return; + } + var path = PathManager.GetSaveStatePath(Global.Game); var file = new FileInfo(path); @@ -1913,6 +1923,11 @@ namespace BizHawk.Client.EmuHawk return; } + if (GlobalWin.Tools.TAStudio != null) + { + return; + } + var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetSaveStatePath(Global.Game), @@ -2177,6 +2192,11 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator.HasSavestates()) { + if (GlobalWin.Tools.TAStudio != null) + { + return; + } + if (Global.Config.SaveSlot == 0) { Global.Config.SaveSlot = 9; // Wrap to end of slot list @@ -2199,6 +2219,11 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator.HasSavestates()) { + if (GlobalWin.Tools.TAStudio != null) + { + return; + } + if (Global.Config.SaveSlot >= 9) { Global.Config.SaveSlot = 0; // Wrap to beginning of slot list @@ -2368,7 +2393,7 @@ namespace BizHawk.Client.EmuHawk FrameBufferResized(); } - private void DecreaseWIndowSize() + private void DecreaseWindowSize() { switch (Global.Config.TargetZoomFactor) { @@ -2680,6 +2705,11 @@ namespace BizHawk.Client.EmuHawk return; } + if (GlobalWin.Tools.TAStudio != null) + { + return; + } + // If from lua, disable counting rerecords bool wasCountingRerecords = Global.MovieSession.Movie.IsCountingRerecords; @@ -2722,6 +2752,11 @@ namespace BizHawk.Client.EmuHawk return; } + if (GlobalWin.Tools.TAStudio != null) + { + return; + } + var path = PathManager.SaveStatePrefix(Global.Game) + "." + quickSlotName + ".State"; if (File.Exists(path) == false) { @@ -2740,6 +2775,11 @@ namespace BizHawk.Client.EmuHawk return; } + if (GlobalWin.Tools.TAStudio != null) + { + return; + } + try { SavestateManager.SaveStateFile(path, userFriendlyStateName); @@ -3675,6 +3715,11 @@ namespace BizHawk.Client.EmuHawk return; } + if (GlobalWin.Tools.TAStudio != null) + { + return; + } + var path = PathManager.SaveStatePrefix(Global.Game) + "." + quickSlotName + ".State"; var file = new FileInfo(path); diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index 74e7fdaf9a..36b22a5379 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -63,7 +63,7 @@ namespace BizHawk.Client.EmuHawk } /// - /// Loads the tool dialog T (T must implemants ) , if it does not exist it will be created, if it is already open, it will be focused + /// Loads the tool dialog T (T must implement ) , if it does not exist it will be created, if it is already open, it will be focused /// /// Type of tool you want to load /// Define if the tool form has to get the focus or not (Default is true) @@ -75,7 +75,7 @@ namespace BizHawk.Client.EmuHawk } /// - /// Loads the tool dialog T (T must implemants ) , if it does not exist it will be created, if it is already open, it will be focused + /// Loads the tool dialog T (T must implement ) , if it does not exist it will be created, if it is already open, it will be focused /// /// Type of tool you want to load /// Define if the tool form has to get the focus or not (Default is true) @@ -888,6 +888,29 @@ namespace BizHawk.Client.EmuHawk } } + public TAStudio TAStudio + { + get + { + var tool = _tools.FirstOrDefault(x => x is TAStudio); + if (tool != null) + { + if (tool.IsDisposed) + { + _tools.Remove(tool); + } + else + { + return tool as TAStudio; + } + } + + var newTool = new TAStudio(); + _tools.Add(newTool); + return newTool; + } + } + #endregion #region Specialized Tool Loading Logic