From a08e2f9a79411f78872084f6eb94adcdbec32b98 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 17 Oct 2014 18:14:21 +0000 Subject: [PATCH] Tastudio - another round of fix cleanup --- .../tools/TAStudio/TAStudio.Designer.cs | 16 ++--- .../tools/TAStudio/TAStudio.IToolForm.cs | 5 +- .../tools/TAStudio/TAStudio.ListView.cs | 59 +++++-------------- .../tools/TAStudio/TAStudio.MenuItems.cs | 24 ++++---- .../tools/TAStudio/TAStudio.Navigation.cs | 9 +-- 5 files changed, 38 insertions(+), 75 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs index b4560514dd..6a879b5d77 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs @@ -69,7 +69,7 @@ namespace BizHawk.Client.EmuHawk this.TruncateMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ClearGreenzoneMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.GreenzoneICheckSeparator = new System.Windows.Forms.ToolStripSeparator(); - this.GreenZzoneIntegrityCheckMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.GreenZoneIntegrityCheckMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ConfigSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.SetMaxUndoLevelsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); @@ -268,7 +268,7 @@ namespace BizHawk.Client.EmuHawk this.TruncateMenuItem, this.ClearGreenzoneMenuItem, this.GreenzoneICheckSeparator, - this.GreenZzoneIntegrityCheckMenuItem}); + this.GreenZoneIntegrityCheckMenuItem}); this.EditSubMenu.Name = "EditSubMenu"; this.EditSubMenu.Size = new System.Drawing.Size(39, 20); this.EditSubMenu.Text = "&Edit"; @@ -456,12 +456,12 @@ namespace BizHawk.Client.EmuHawk // // GreenZzoneIntegrityCheckMenuItem // - this.GreenZzoneIntegrityCheckMenuItem.Name = "GreenZzoneIntegrityCheckMenuItem"; - this.GreenZzoneIntegrityCheckMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + this.GreenZoneIntegrityCheckMenuItem.Name = "GreenZzoneIntegrityCheckMenuItem"; + this.GreenZoneIntegrityCheckMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) | System.Windows.Forms.Keys.I))); - this.GreenZzoneIntegrityCheckMenuItem.Size = new System.Drawing.Size(282, 22); - this.GreenZzoneIntegrityCheckMenuItem.Text = "Greenzone Integrity Check"; - this.GreenZzoneIntegrityCheckMenuItem.Click += new System.EventHandler(this.GreenZzoneIntegrityCheckMenuItem_Click); + this.GreenZoneIntegrityCheckMenuItem.Size = new System.Drawing.Size(282, 22); + this.GreenZoneIntegrityCheckMenuItem.Text = "Greenzone Integrity Check"; + this.GreenZoneIntegrityCheckMenuItem.Click += new System.EventHandler(this.GreenZzoneIntegrityCheckMenuItem_Click); // // ConfigSubMenu // @@ -1059,7 +1059,7 @@ namespace BizHawk.Client.EmuHawk private System.Windows.Forms.ToolStripMenuItem TruncateContextMenuItem; private System.Windows.Forms.ToolStripMenuItem ClearGreenzoneMenuItem; private System.Windows.Forms.ToolStripSeparator GreenzoneICheckSeparator; - private System.Windows.Forms.ToolStripMenuItem GreenZzoneIntegrityCheckMenuItem; + private System.Windows.Forms.ToolStripMenuItem GreenZoneIntegrityCheckMenuItem; private System.Windows.Forms.ToolStripMenuItem ColumnsSubMenu; private System.Windows.Forms.ToolStripSeparator toolStripSeparator19; private System.Windows.Forms.ToolStripSeparator toolStripSeparator20; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index 312338790e..a05fb42886 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -5,9 +5,9 @@ namespace BizHawk.Client.EmuHawk { public partial class TAStudio : IToolForm { - public bool UpdateBefore { get { return false; } } + private bool _hackyDontUpdate; - private bool _hackyDontUpdate = false; + public bool UpdateBefore { get { return false; } } public void UpdateValues() { @@ -57,7 +57,6 @@ namespace BizHawk.Client.EmuHawk } } - public bool AskSaveChanges() { if (_currentTasMovie != null && _currentTasMovie.Changes) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index c9db4de400..cbf46d10fd 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Windows.Forms; using BizHawk.Client.Common; -using BizHawk.Client.EmuHawk.WinFormExtensions; namespace BizHawk.Client.EmuHawk { @@ -17,7 +16,7 @@ namespace BizHawk.Client.EmuHawk private float _floatPaintState; private bool _startMarkerDrag; private bool _startFrameDrag; - private bool _supressContextMenu = false; + private bool _supressContextMenu; public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC); public static Color CurrentFrame_InputLog = Color.FromArgb(0xB5E7F7); @@ -44,36 +43,21 @@ namespace BizHawk.Client.EmuHawk { if (index == Global.Emulator.Frame && index == GlobalWin.MainForm.PauseOnFrame) { - if (TasView.HorizontalOrientation) - { - bitmap = Properties.Resources.ts_v_arrow_green_blue; - } - else - { - bitmap = Properties.Resources.ts_h_arrow_green_blue; - } + bitmap = TasView.HorizontalOrientation ? + Properties.Resources.ts_v_arrow_green_blue : + Properties.Resources.ts_h_arrow_green_blue; } else if (index == Global.Emulator.Frame) { - if (TasView.HorizontalOrientation) - { - bitmap = Properties.Resources.ts_v_arrow_blue; - } - else - { - bitmap = Properties.Resources.ts_h_arrow_blue; - } + bitmap = TasView.HorizontalOrientation ? + Properties.Resources.ts_v_arrow_blue : + Properties.Resources.ts_h_arrow_blue; } else if (index == GlobalWin.MainForm.PauseOnFrame) { - if (TasView.HorizontalOrientation) - { - bitmap = Properties.Resources.ts_v_arrow_green; - } - else - { - bitmap = Properties.Resources.ts_h_arrow_green; - } + bitmap = TasView.HorizontalOrientation ? + Properties.Resources.ts_v_arrow_green : + Properties.Resources.ts_h_arrow_green; } } } @@ -105,14 +89,9 @@ namespace BizHawk.Client.EmuHawk } else if (record.Lagged.HasValue) { - if (record.Lagged.Value) - { - color = LagZone_FrameCol; - } - else - { - color = GreenZone_FrameCol; - } + color = record.Lagged.Value ? + LagZone_FrameCol : + GreenZone_FrameCol; } else { @@ -129,15 +108,9 @@ namespace BizHawk.Client.EmuHawk { if (record.Lagged.HasValue) { - if (record.Lagged.Value) - { - color = LagZone_InputLog; - - } - else - { - color = GreenZone_InputLog; - } + color = record.Lagged.Value ? + LagZone_InputLog : + GreenZone_InputLog; } else { diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 1cbbd991b2..f8a600089b 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -130,7 +130,7 @@ namespace BizHawk.Client.EmuHawk _currentTasMovie != null && _currentTasMovie.TasStateManager.Any(); GreenzoneICheckSeparator.Visible = - GreenZzoneIntegrityCheckMenuItem.Visible = + GreenZoneIntegrityCheckMenuItem.Visible = VersionInfo.DeveloperBuild; } @@ -180,17 +180,16 @@ namespace BizHawk.Client.EmuHawk var list = TasView.SelectedRows.ToList(); var sb = new StringBuilder(); - for (var i = 0; i < list.Count; i++) + foreach (var index in list) { - var input = _currentTasMovie.GetInputState(list[i]); - _tasClipboard.Add(new TasClipboardEntry(list[i], input)); + var input = _currentTasMovie.GetInputState(index); + _tasClipboard.Add(new TasClipboardEntry(index, input)); var lg = _currentTasMovie.LogGeneratorInstance(); lg.SetSource(input); sb.AppendLine(lg.GenerateLogEntry()); } Clipboard.SetDataObject(sb.ToString()); - SetSplicer(); } } @@ -323,12 +322,10 @@ namespace BizHawk.Client.EmuHawk var framesToInsert = TasView.SelectedRows.ToList(); var insertionFrame = TasView.LastSelectedIndex.Value + 1; var needsToRollback = !(insertionFrame > Global.Emulator.Frame); - var inputLog = new List(); - foreach (var frame in framesToInsert) - { - inputLog.Add(_currentTasMovie.GetInputLogEntry(frame)); - } + var inputLog = framesToInsert + .Select(frame => _currentTasMovie.GetInputLogEntry(frame)) + .ToList(); _currentTasMovie.InsertInput(insertionFrame, inputLog); @@ -346,7 +343,7 @@ namespace BizHawk.Client.EmuHawk private void InsertFrameMenuItem_Click(object sender, EventArgs e) { var insertionFrame = TasView.SelectedRows.Any() ? TasView.FirstSelectedIndex.Value : 0; - bool needsToRollback = insertionFrame <= Global.Emulator.Frame; + var needsToRollback = insertionFrame <= Global.Emulator.Frame; _currentTasMovie.InsertEmptyFrame(insertionFrame); @@ -363,7 +360,7 @@ namespace BizHawk.Client.EmuHawk private void InsertNumFramesMenuItem_Click(object sender, EventArgs e) { var insertionFrame = TasView.SelectedRows.Any() ? TasView.FirstSelectedIndex.Value : 0; - bool needsToRollback = insertionFrame <= Global.Emulator.Frame; + var needsToRollback = insertionFrame <= Global.Emulator.Frame; var framesPrompt = new FramesPrompt(); var result = framesPrompt.ShowDialog(); @@ -404,7 +401,7 @@ namespace BizHawk.Client.EmuHawk private void SetMarkersMenuItem_Click(object sender, EventArgs e) { - foreach (int index in TasView.SelectedRows) + foreach (var index in TasView.SelectedRows) { CallAddMarkerPopUp(index); } @@ -425,7 +422,6 @@ namespace BizHawk.Client.EmuHawk private void GreenZzoneIntegrityCheckMenuItem_Click(object sender, EventArgs e) { GlobalWin.MainForm.RebootCore(); - GlobalWin.MainForm.FrameAdvance(); var frame = Global.Emulator.Frame; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs index fccc7e334d..cb4c3d5160 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs @@ -82,13 +82,8 @@ namespace BizHawk.Client.EmuHawk // TODO: get the last greenzone frame and go there _currentTasMovie.SwitchToPlay(); - - var shouldLoadstate = true; - // Some situations it is silly to load a state - if (frame - Global.Emulator.Frame == 1) - { - shouldLoadstate = false; - } + // no reason to loadstate when we can emulate a frame instead + var shouldLoadstate = frame - Global.Emulator.Frame != 1; if (_currentTasMovie.TasStateManager.LastEmulatedFrame > 0 && shouldLoadstate) {