From 512b03f1b44c90c86ea1dd63f86026c493363dff Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 28 Jun 2019 17:51:03 -0500 Subject: [PATCH] misc cleanups in tastudio files, mostly typos and redundant code --- BizHawk.Client.EmuHawk/MainForm.Hotkey.cs | 2 +- .../tools/TAStudio/BookmarksBranchesBox.cs | 2 +- .../TAStudio/TAStudio.IControlMainForm.cs | 8 +-- .../tools/TAStudio/TAStudio.ListView.cs | 68 +++++++++---------- .../tools/TAStudio/TAStudio.MenuItems.cs | 27 ++++---- .../tools/TAStudio/TAStudio.Navigation.cs | 3 - .../tools/TAStudio/TAStudio.cs | 12 ++-- .../tools/TAStudio/TAStudioClipboard.cs | 4 +- BizHawk.sln.DotSettings | 18 ++++- 9 files changed, 80 insertions(+), 64 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs index 28efe851c4..130d640a0f 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs @@ -445,7 +445,7 @@ namespace BizHawk.Client.EmuHawk case "Delete Branch": if (GlobalWin.Tools.IsLoaded()) { - GlobalWin.Tools.TAStudio.RemoveBranchExtrenal(); + GlobalWin.Tools.TAStudio.RemoveBranchExternal(); } else { diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index ac2116bb94..fd6d903991 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -448,7 +448,7 @@ namespace BizHawk.Client.EmuHawk UpdateBranchToolStripMenuItem_Click(null, null); } - public void RemoveBranchExtrenal() + public void RemoveBranchExternal() { RemoveBranchToolStripMenuItem_Click(null, null); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs index 8abd471b26..ed58dd96eb 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs @@ -69,10 +69,10 @@ public bool WantsToControlStopMovie { get; private set; } - public void StopMovie(bool supressSave) + public void StopMovie(bool suppressSave) { Focus(); - _suppressAskSave = supressSave; + _suppressAskSave = suppressSave; NewTasMenuItem_Click(null, null); _suppressAskSave = false; } @@ -86,7 +86,7 @@ public bool Rewind() { - // copypasted from TasView_MouseWheel(), just without notch logic + // copy pasted from TasView_MouseWheel(), just without notch logic if (Mainform.IsSeeking && !Mainform.EmulatorPaused) { Mainform.PauseOnFrame--; @@ -104,7 +104,7 @@ } else { - StopSeeking(); // late breaking memo: dont know whether this is needed + StopSeeking(); // late breaking memo: don't know whether this is needed GoToPreviousFrame(); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index c9cb910243..e8dbe1376d 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -44,23 +44,23 @@ namespace BizHawk.Client.EmuHawk private readonly List _extraFloatRows = new List(); // Right-click dragging - private string[] _rightClickInput = null; - private string[] _rightClickOverInput = null; + private string[] _rightClickInput; + private string[] _rightClickOverInput; private int _rightClickFrame = -1; private int _rightClickLastFrame = -1; private bool _rightClickShift, _rightClickControl, _rightClickAlt; - private bool _leftButtonHeld = false; + private bool _leftButtonHeld; private bool MouseButtonHeld => _rightClickFrame != -1 || _leftButtonHeld; private bool _triggerAutoRestore; // If true, autorestore will be called on mouse up - private bool? _autoRestorePaused = null; - private int? _seekStartFrame = null; - private bool _unpauseAfterSeeking = false; + private bool? _autoRestorePaused; + private int? _seekStartFrame; + private bool _unpauseAfterSeeking; private ControllerDefinition ControllerType => Global.MovieSession.MovieControllerAdapter.Definition; - public bool WasRecording; + public bool WasRecording { get; set; } public AutoPatternBool[] BoolPatterns; public AutoPatternFloat[] FloatPatterns; @@ -225,10 +225,12 @@ namespace BizHawk.Client.EmuHawk } string columnName = column.Name; - + if (columnName == CursorColumnName) + { color = Color.FromArgb(0xFEFFFF); - + } + if (columnName == FrameColumnName) { if (Emulator.Frame != index && CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithBGColor) @@ -379,14 +381,14 @@ namespace BizHawk.Client.EmuHawk if (Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(buttonName)) { - if (Control.ModifierKeys != Keys.Alt) + if (ModifierKeys != Keys.Alt) { // nifty taseditor logic bool allPressed = true; foreach (var index in TasView.SelectedRows) { - if ((index == CurrentTasMovie.FrameCount) // last movie frame can't have input, but can be selected - || (!CurrentTasMovie.BoolIsPressed(index, buttonName))) + if (index == CurrentTasMovie.FrameCount // last movie frame can't have input, but can be selected + || !CurrentTasMovie.BoolIsPressed(index, buttonName)) { allPressed = false; break; @@ -412,6 +414,7 @@ namespace BizHawk.Client.EmuHawk _triggerAutoRestore = true; JumpToGreenzone(); } + RefreshDialog(); } } @@ -424,6 +427,7 @@ namespace BizHawk.Client.EmuHawk RefreshTasView(); } + private void UpdateAutoFire() { for (int i = 2; i < TasView.AllColumns.Count; i++) @@ -431,6 +435,7 @@ namespace BizHawk.Client.EmuHawk UpdateAutoFire(TasView.AllColumns[i].Name, TasView.AllColumns[i].Emphasis); } } + public void UpdateAutoFire(string button, bool? isOn) { if (!isOn.HasValue) // No value means don't change whether it's on or off. @@ -546,7 +551,7 @@ namespace BizHawk.Client.EmuHawk // SuuperW: Exit float editing mode, or re-enter mouse editing if (FloatEditingMode) { - if (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift) + if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift) { _extraFloatRows.Clear(); _extraFloatRows.AddRange(TasView.SelectedRows); @@ -585,7 +590,7 @@ namespace BizHawk.Client.EmuHawk } else if (TasView.CurrentCell.Column.Name == FrameColumnName) { - if (Control.ModifierKeys == Keys.Alt && CurrentTasMovie.Markers.IsMarker(frame)) + if (ModifierKeys == Keys.Alt && CurrentTasMovie.Markers.IsMarker(frame)) { // TODO TasView.DragCurrentCell(); @@ -596,7 +601,7 @@ namespace BizHawk.Client.EmuHawk _selectionDragState = TasView.SelectedRows.Contains(frame); } } - else if (TasView.CurrentCell.Column.Type != InputRoll.RollColumn.InputType.Text)// User changed input + else if (TasView.CurrentCell.Column.Type != InputRoll.RollColumn.InputType.Text) // User changed input { bool wasPaused = Mainform.EmulatorPaused; @@ -627,8 +632,8 @@ namespace BizHawk.Client.EmuHawk bool allPressed = true; for (int i = firstSel; i <= frame; i++) { - if ((i == CurrentTasMovie.FrameCount) // last movie frame can't have input, but can be selected - || (!CurrentTasMovie.BoolIsPressed(i, buttonName))) + if (i == CurrentTasMovie.FrameCount // last movie frame can't have input, but can be selected + || !CurrentTasMovie.BoolIsPressed(i, buttonName)) { allPressed = false; break; @@ -640,7 +645,7 @@ namespace BizHawk.Client.EmuHawk JumpToGreenzone(); RefreshDialog(); } - else if (Control.ModifierKeys == Keys.Shift && Control.ModifierKeys == Keys.Alt) //Does not work? + else if (ModifierKeys == Keys.Shift && ModifierKeys == Keys.Alt) // Does not work? { // TODO: Pattern drawing from selection to current cell } @@ -720,9 +725,9 @@ namespace BizHawk.Client.EmuHawk { if (TasView.CurrentCell.Column.Name == FrameColumnName && frame < CurrentTasMovie.InputLogLength) { - _rightClickControl = (Control.ModifierKeys | Keys.Control) == Control.ModifierKeys; - _rightClickShift = (Control.ModifierKeys | Keys.Shift) == Control.ModifierKeys; - _rightClickAlt = (Control.ModifierKeys | Keys.Alt) == Control.ModifierKeys; + _rightClickControl = (ModifierKeys | Keys.Control) == ModifierKeys; + _rightClickShift = (ModifierKeys | Keys.Shift) == ModifierKeys; + _rightClickAlt = (ModifierKeys | Keys.Alt) == ModifierKeys; if (TasView.SelectedRows.Contains(frame)) { _rightClickInput = new string[TasView.SelectedRows.Count()]; @@ -825,7 +830,7 @@ namespace BizHawk.Client.EmuHawk } else if (e.Button == MouseButtons.Left) { - if (FloatEditingMode && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift)) + if (FloatEditingMode && (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift)) { _leftButtonHeld = false; _startSelectionDrag = false; @@ -978,7 +983,7 @@ namespace BizHawk.Client.EmuHawk for (var i = startVal; i <= endVal; i++) { TasView.SelectRow(i, _selectionDragState); - if (FloatEditingMode && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift)) + if (FloatEditingMode && (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift)) { if (_selectionDragState) { @@ -1014,7 +1019,9 @@ namespace BizHawk.Client.EmuHawk } if (startVal < _rightClickLastFrame) + { shouldInsert = false; + } if (shouldInsert) { @@ -1375,19 +1382,12 @@ namespace BizHawk.Client.EmuHawk } else if (e.KeyCode == Keys.Enter) { - if (_floatEditYPos != -1) - { - _floatEditYPos = -1; - } - + _floatEditYPos = -1; floatEditRow = -1; } else if (e.KeyCode == Keys.Escape) { - if (_floatEditYPos != -1) - { - _floatEditYPos = -1; - } + _floatEditYPos = -1; if (_floatBackupState != _floatPaintState) { @@ -1411,7 +1411,7 @@ namespace BizHawk.Client.EmuHawk changeBy = -1; } - if (Control.ModifierKeys == Keys.Shift) + if (ModifierKeys == Keys.Shift) { changeBy *= 10; } @@ -1476,7 +1476,7 @@ namespace BizHawk.Client.EmuHawk private void TasView_KeyDown(object sender, KeyEventArgs e) { - //taseditor uses Ctrl for selection and Shift for framecourser + // taseditor uses Ctrl for selection and Shift for framecourser if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.PageUp) // Shift + Page Up { GoToPreviousMarker(); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 3aa06f75b6..f24ce05243 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -482,10 +482,10 @@ namespace BizHawk.Client.EmuHawk if (TasView.AnyRowsSelected) { // TODO: if highlighting 2 rows and pasting 3, only paste 2 of them - // FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs + // FCEUX Taseditor doesn't do this, but I think it is the expected behavior in editor programs var wasPaused = Mainform.EmulatorPaused; - // copypaste from PasteInsertMenuItem_Click! + // copy paste from PasteInsertMenuItem_Click! IDataObject data = Clipboard.GetDataObject(); if (data.GetDataPresent(DataFormats.StringFormat)) { @@ -532,7 +532,7 @@ namespace BizHawk.Client.EmuHawk { var wasPaused = Mainform.EmulatorPaused; - // copypaste from PasteMenuItem_Click! + // copy paste from PasteMenuItem_Click! IDataObject data = Clipboard.GetDataObject(); if (data.GetDataPresent(DataFormats.StringFormat)) { @@ -652,7 +652,7 @@ namespace BizHawk.Client.EmuHawk var rollBackFrame = TasView.FirstSelectedIndex.Value; if (rollBackFrame >= CurrentTasMovie.InputLogLength) { - // Cannot delete non-existant frames + // Cannot delete non-existent frames RefreshDialog(); return; } @@ -1165,7 +1165,7 @@ namespace BizHawk.Client.EmuHawk private void HideLagFramesX_Click(object sender, EventArgs e) { - TasView.LagFramesToHide = (int)(sender as ToolStripMenuItem).Tag; + TasView.LagFramesToHide = (int)((ToolStripMenuItem)sender).Tag; MaybeFollowCursor(); RefreshDialog(); } @@ -1226,15 +1226,15 @@ namespace BizHawk.Client.EmuHawk private void WheelScrollSpeedMenuItem_Click(object sender, EventArgs e) { - var inputpromt = new InputPrompt + var inputPrompt = new InputPrompt { TextInputType = InputPrompt.InputType.Unsigned, Message = "Frames per tick:", InitialValue = TasView.ScrollSpeed.ToString() }; - if (inputpromt.ShowDialog() == DialogResult.OK) + if (inputPrompt.ShowDialog() == DialogResult.OK) { - TasView.ScrollSpeed = int.Parse(inputpromt.PromptText); + TasView.ScrollSpeed = int.Parse(inputPrompt.PromptText); Settings.ScrollSpeed = TasView.ScrollSpeed; } } @@ -1254,7 +1254,7 @@ namespace BizHawk.Client.EmuHawk int workingHeight = Screen.FromControl(this).WorkingArea.Height; int rowHeight = ColumnsSubMenu.Height + 4; int maxRows = workingHeight / rowHeight; - int keyCount = columns.Where(c => c.Name.StartsWith("Key ")).Count(); + int keyCount = columns.Count(c => c.Name.StartsWith("Key ")); int keysMenusCount = (int)Math.Ceiling((double)keyCount / maxRows); ToolStripMenuItem[] keysMenus = new ToolStripMenuItem[keysMenusCount]; @@ -1296,8 +1296,7 @@ namespace BizHawk.Client.EmuHawk if (column.Name.StartsWith("Key ")) { keysMenus - .Where(m => m.DropDownItems.Count < maxRows) - .FirstOrDefault() + .First(m => m.DropDownItems.Count < maxRows) .DropDownItems .Add(menuItem); } @@ -1487,7 +1486,11 @@ namespace BizHawk.Client.EmuHawk if (SaveRamEmulator.CloneSaveRam() != null) { int index = 0; - if (TasView.SelectedRows.Count() > 0) { index = TasView.SelectedRows.First(); } + if (TasView.SelectedRows.Any()) + { + index = TasView.SelectedRows.First(); + } + GoToFrame(index); TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie( SaveRamEmulator.CloneSaveRam()); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs index 4ea57477ed..92cfc9f365 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs @@ -11,8 +11,6 @@ namespace BizHawk.Client.EmuHawk { if (frame != Emulator.Frame) // Don't go to a frame if you are already on it! { - int restoreFrame = Emulator.Frame; - if (frame <= Emulator.Frame) { if ((Mainform.EmulatorPaused || !Mainform.IsSeeking) @@ -32,7 +30,6 @@ namespace BizHawk.Client.EmuHawk { // If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate // Otherwise, load the latest state (if not already there) and seek while recording. - WasRecording = CurrentTasMovie.IsRecording || WasRecording; if (frame <= CurrentTasMovie.InputLogLength) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index e7afee0d36..85a08c5ebe 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -37,7 +37,7 @@ namespace BizHawk.Client.EmuHawk private Timer _autosaveTimer; /// - /// Gets or sets a value that separates "restore last position" logic from seeking caused by navigation. + /// Gets a value that separates "restore last position" logic from seeking caused by navigation. /// TASEditor never kills LastPositionFrame, and it only pauses on it, if it hasn't been greenzoned beforehand and middle mouse button was pressed. /// public int LastPositionFrame { get; private set; } @@ -399,7 +399,7 @@ namespace BizHawk.Client.EmuHawk } } - // Start Scenario 3: No movie, but user wants to autload their last project + // Start Scenario 3: No movie, but user wants to autoload their last project else if (Settings.RecentTas.AutoLoad && !string.IsNullOrEmpty(Settings.RecentTas.MostRecent)) { bool result = LoadFile(new FileInfo(Settings.RecentTas.MostRecent)); @@ -974,9 +974,9 @@ namespace BizHawk.Client.EmuHawk BookMarkControl.AddBranchExternal(); } - public void RemoveBranchExtrenal() + public void RemoveBranchExternal() { - BookMarkControl.RemoveBranchExtrenal(); + BookMarkControl.RemoveBranchExternal(); } private void UpdateOtherTools() // a hack probably, surely there is a better way to do this @@ -1036,11 +1036,11 @@ namespace BizHawk.Client.EmuHawk } } - public void DeleteFrames(int beginningFrame, int numberofFrames) + public void DeleteFrames(int beginningFrame, int numberOfFrames) { if (beginningFrame < CurrentTasMovie.InputLogLength) { - int[] framesToRemove = Enumerable.Range(beginningFrame, numberofFrames).ToArray(); + int[] framesToRemove = Enumerable.Range(beginningFrame, numberOfFrames).ToArray(); CurrentTasMovie.RemoveFrames(framesToRemove); SetSplicer(); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs index 747d636646..57b9214e50 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs @@ -14,8 +14,8 @@ namespace BizHawk.Client.EmuHawk ControllerState = controllerState; } - public int Frame { get; private set; } - public IController ControllerState { get; private set; } + public int Frame { get; } + public IController ControllerState { get; } public override string ToString() { diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index f62ceeecdc..d39322b633 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -106,6 +106,7 @@ SGX SHA SNES + TA TAS TI TIA @@ -174,9 +175,24 @@ True True True + True + True + True True + True + True + True True + True + True True True - True + True + True + True + True + True + True + True + True \ No newline at end of file