From 6ce93c049625108293f69b2504ef4d6c4614de34 Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 1 Jan 2015 18:24:35 +0000 Subject: [PATCH] TAStudio - move some settings from Config.cs to the dialog using [ConfigPersist] --- BizHawk.Client.Common/config/Config.cs | 8 +--- .../tools/TAStudio/PlaybackBox.cs | 18 ++++----- .../tools/TAStudio/TAStudio.ListView.cs | 2 +- .../tools/TAStudio/TAStudio.MenuItems.cs | 20 +++++----- .../tools/TAStudio/TAStudio.Navigation.cs | 2 +- .../tools/TAStudio/TAStudio.cs | 39 ++++++++++++++----- 6 files changed, 51 insertions(+), 38 deletions(-) diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index 0b0f2e1a81..995d3d3bc2 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -341,14 +341,8 @@ namespace BizHawk.Client.Common #endregion - // TAStudio Dialog - public RecentFiles RecentTas = new RecentFiles(8); + // TAStudio public TasStateManagerSettings DefaultTasProjSettings = new TasStateManagerSettings(); - public bool TAStudioDrawInput = true; - public bool TAStudioAutoPause = true; - public bool TAStudioAutoRestoreLastPosition = false; - public bool TAStudioFollowCursor = true; - public bool TAStudioEmptyMarkers = false; // VirtualPad Dialog public ToolDialogSettings VirtualPadSettings = new ToolDialogSettings(); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs index 233c89d89e..d80760063f 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/PlaybackBox.cs @@ -38,12 +38,12 @@ namespace BizHawk.Client.EmuHawk { get { - return Global.Config.TAStudioAutoRestoreLastPosition; + return Tastudio.Settings.AutoRestoreLastPosition; } set { - AutoRestoreCheckbox.Checked = Global.Config.TAStudioAutoRestoreLastPosition = value; + AutoRestoreCheckbox.Checked = Tastudio.Settings.AutoRestoreLastPosition = value; } } @@ -53,12 +53,12 @@ namespace BizHawk.Client.EmuHawk { get { - return Global.Config.TAStudioFollowCursor; + return Tastudio.Settings.FollowCursor; } set { - FollowCursorCheckbox.Checked = Global.Config.TAStudioFollowCursor = value; + FollowCursorCheckbox.Checked = Tastudio.Settings.FollowCursor = value; } } @@ -69,8 +69,8 @@ namespace BizHawk.Client.EmuHawk if (Global.Config != null) // A check needed for the designer { TurboSeekCheckbox.Checked = Global.Config.TurboSeek; - AutoRestoreCheckbox.Checked = Global.Config.TAStudioAutoRestoreLastPosition; - FollowCursorCheckbox.Checked = Global.Config.TAStudioFollowCursor; + AutoRestoreCheckbox.Checked = Tastudio.Settings.AutoRestoreLastPosition; + FollowCursorCheckbox.Checked = Tastudio.Settings.FollowCursor; } _programmaticallyChangingValue = false; } @@ -112,7 +112,7 @@ namespace BizHawk.Client.EmuHawk { if (!_programmaticallyChangingValue) { - Global.Config.TAStudioAutoRestoreLastPosition ^= true; + Tastudio.Settings.AutoRestoreLastPosition ^= true; } } @@ -120,9 +120,9 @@ namespace BizHawk.Client.EmuHawk { if (!_programmaticallyChangingValue) { - Global.Config.TAStudioFollowCursor ^= true; + Tastudio.Settings.FollowCursor ^= true; - if (Global.Config.TAStudioFollowCursor) + if (Tastudio.Settings.FollowCursor) { Tastudio.SetVisibleIndex(); Tastudio.RefreshDialog(); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 75edf06cad..3a2a05b7ad 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -305,7 +305,7 @@ namespace BizHawk.Client.EmuHawk TasView.CurrentCell.Column.Name == FrameColumnName && e.Button == MouseButtons.Left) { - if (Global.Config.TAStudioEmptyMarkers) + if (Settings.EmptyMarkers) { CurrentTasMovie.Markers.Add(TasView.CurrentCell.RowIndex.Value, string.Empty); RefreshDialog(); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 829929ea88..06a046dc9a 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -35,7 +35,7 @@ namespace BizHawk.Client.EmuHawk { RecentSubMenu.DropDownItems.Clear(); RecentSubMenu.DropDownItems.AddRange( - Global.Config.RecentTas.RecentMenu(DummyLoadProject, true)); + Settings.RecentTas.RecentMenu(DummyLoadProject, true)); } private void NewTasMenuItem_Click(object sender, EventArgs e) @@ -79,7 +79,7 @@ namespace BizHawk.Client.EmuHawk { CurrentTasMovie.Save(); MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved."; - Global.Config.RecentTas.Add(CurrentTasMovie.Filename); + Settings.RecentTas.Add(CurrentTasMovie.Filename); } } @@ -96,7 +96,7 @@ namespace BizHawk.Client.EmuHawk { CurrentTasMovie.Filename = file.FullName; CurrentTasMovie.Save(); - Global.Config.RecentTas.Add(CurrentTasMovie.Filename); + Settings.RecentTas.Add(CurrentTasMovie.Filename); MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved."; SetTextProperty(); } @@ -529,26 +529,24 @@ namespace BizHawk.Client.EmuHawk private void ConfigSubMenu_DropDownOpened(object sender, EventArgs e) { - DrawInputByDraggingMenuItem.Checked = Global.Config.TAStudioDrawInput; - AutopauseAtEndOfMovieMenuItem.Checked = Global.Config.TAStudioAutoPause; - EmptyNewMarkerNotesMenuItem.Checked = Global.Config.TAStudioEmptyMarkers; - - + DrawInputByDraggingMenuItem.Checked = Settings.DrawInput; + AutopauseAtEndOfMovieMenuItem.Checked = Settings.AutoPause; + EmptyNewMarkerNotesMenuItem.Checked = Settings.EmptyMarkers; } private void DrawInputByDraggingMenuItem_Click(object sender, EventArgs e) { - TasView.InputPaintingMode = Global.Config.TAStudioDrawInput ^= true; + TasView.InputPaintingMode = Settings.DrawInput ^= true; } private void EmptyNewMarkerNotesMenuItem_Click(object sender, EventArgs e) { - Global.Config.TAStudioEmptyMarkers ^= true; + Settings.EmptyMarkers ^= true; } private void AutopauseAtEndMenuItem_Click(object sender, EventArgs e) { - Global.Config.TAStudioAutoPause ^= true; + Settings.AutoPause ^= true; } #endregion diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs index bf219d51fa..c05c783e0e 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs @@ -106,7 +106,7 @@ namespace BizHawk.Client.EmuHawk if (frame != Emulator.Frame) // If we aren't already at our destination, seek { GlobalWin.MainForm.UnpauseEmulator(); - if (Global.Config.TAStudioAutoPause && frame < CurrentTasMovie.InputLogLength) + if (Settings.AutoPause && frame < CurrentTasMovie.InputLogLength) { GlobalWin.MainForm.PauseOnFrame = CurrentTasMovie.InputLogLength; } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 0358d69fbe..f7663b85fe 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -34,6 +34,27 @@ namespace BizHawk.Client.EmuHawk private int? _autoRestoreFrame; // The frame auto-restore will restore to, if set + [ConfigPersist] + public TAStudioSettings Settings { get; set; } + + public class TAStudioSettings + { + public TAStudioSettings() + { + RecentTas = new RecentFiles(8); + DrawInput = true; + AutoPause = true; + FollowCursor = true; + } + + public RecentFiles RecentTas { get; set; } + public bool DrawInput { get; set; } + public bool AutoPause { get; set; } + public bool AutoRestoreLastPosition { get; set; } + public bool FollowCursor { get; set; } + public bool EmptyMarkers { get; set; } + } + public TasMovie CurrentTasMovie { get { return Global.MovieSession.Movie as TasMovie; } @@ -49,7 +70,7 @@ namespace BizHawk.Client.EmuHawk TasView.QueryItemText += TasView_QueryItemText; TasView.QueryItemBkColor += TasView_QueryItemBkColor; TasView.QueryItemIcon += TasView_QueryItemIcon; - TasView.InputPaintingMode = Global.Config.TAStudioDrawInput; + TasView.InputPaintingMode = Settings.DrawInput; TasView.PointedCellChanged += TasView_PointedCellChanged; TasView.MultiSelect = true; TasView.MaxCharactersInHorizontal = 1; @@ -62,13 +83,13 @@ namespace BizHawk.Client.EmuHawk GlobalWin.MainForm.SetMainformMovieInfo(); } - private static void ConvertCurrentMovieToTasproj() + private void ConvertCurrentMovieToTasproj() { Global.MovieSession.Movie.Save(); Global.MovieSession.Movie = Global.MovieSession.Movie.ToTasMovie(); Global.MovieSession.Movie.Save(); Global.MovieSession.Movie.SwitchToRecord(); - Global.Config.RecentTas.Add(Global.MovieSession.Movie.Filename); + Settings.RecentTas.Add(Global.MovieSession.Movie.Filename); } private void EngageTastudio() @@ -191,7 +212,7 @@ namespace BizHawk.Client.EmuHawk var file = new FileInfo(path); if (!file.Exists) { - Global.Config.RecentTas.HandleLoadError(path); + Settings.RecentTas.HandleLoadError(path); } WantsToControlStopMovie = false; @@ -207,7 +228,7 @@ namespace BizHawk.Client.EmuHawk SetTasMovieCallbacks(); WantsToControlStopMovie = true; - Global.Config.RecentTas.Add(path); + Settings.RecentTas.Add(path); Text = "TAStudio - " + CurrentTasMovie.Name; RefreshDialog(); @@ -235,7 +256,7 @@ namespace BizHawk.Client.EmuHawk private void DoAutoRestore() { - if (Global.Config.TAStudioAutoRestoreLastPosition && _autoRestoreFrame.HasValue) + if (Settings.AutoRestoreLastPosition && _autoRestoreFrame.HasValue) { if (_autoRestoreFrame > Emulator.Frame) // Don't unpause if we are already on the desired frame, else runaway seek { @@ -474,7 +495,7 @@ namespace BizHawk.Client.EmuHawk MessageBoxButtons.OK); return; } - Global.Config.RecentTas.Add(CurrentTasMovie.Filename); + Settings.RecentTas.Add(CurrentTasMovie.Filename); if (CurrentTasMovie.InputLogLength > 0) // TODO: this is probably reoccuring logic, break off into a function { @@ -537,9 +558,9 @@ namespace BizHawk.Client.EmuHawk } // Start Scenario 3: No movie, but user wants to autload their last project - else if (Global.Config.RecentTas.AutoLoad && !string.IsNullOrEmpty(Global.Config.RecentTas.MostRecent)) + else if (Settings.RecentTas.AutoLoad && !string.IsNullOrEmpty(Settings.RecentTas.MostRecent)) { - var result = LoadProject(Global.Config.RecentTas.MostRecent); + var result = LoadProject(Settings.RecentTas.MostRecent); if (!result) { TasView.AllColumns.Clear();