From 83686a5a15a6dcdf7c11398e81a4e40c35abd902 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 23 Aug 2020 19:27:21 -0500 Subject: [PATCH] slight refactor - MarkerControl.AddMarker, force the caller to pass in the frame instead of implicitely assuming Tastudio.Emulator.Frame when one is not passed on, only 2 places didn't pass a value in anyway --- .../tools/TAStudio/MarkerControl.cs | 21 ++++++++----------- .../tools/TAStudio/TAStudio.ListView.cs | 2 +- .../tools/TAStudio/TAStudio.MenuItems.cs | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs index 2ae721b862..e532605dd8 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs @@ -152,13 +152,13 @@ namespace BizHawk.Client.EmuHawk private void AddMarkerToolStripMenuItem_Click(object sender, EventArgs e) { - AddMarker(); + AddMarker(Tastudio.Emulator.Frame); MarkerView_SelectedIndexChanged(null, null); } private void AddMarkerWithTextToolStripMenuItem_Click(object sender, EventArgs e) { - AddMarker(editText: true); + AddMarker(Tastudio.Emulator.Frame, true); MarkerView_SelectedIndexChanged(null, null); } @@ -177,21 +177,18 @@ namespace BizHawk.Client.EmuHawk MarkerView.RowCount = Markers.Count; } - public void AddMarker(bool editText = false, int? frame = null) + public void AddMarker(int frame, bool editText = false) { - // feos: we specify the selected frame if we call this from TasView, otherwise marker should be added to the emulated frame - var markerFrame = frame ?? Tastudio.Emulator.Frame; - if (editText) { var i = new InputPrompt { - Text = $"Marker for frame {markerFrame}", + Text = $"Marker for frame {frame}", TextInputType = InputPrompt.InputType.Text, Message = "Enter a message", InitialValue = - Markers.IsMarker(markerFrame) ? - Markers.PreviousOrCurrent(markerFrame).Message : + Markers.IsMarker(frame) ? + Markers.PreviousOrCurrent(frame).Message : "" }; @@ -199,16 +196,16 @@ namespace BizHawk.Client.EmuHawk point.Offset(i.Width / -2, i.Height / -2); var result = i.ShowHawkDialog(position: point); - if (result == DialogResult.OK) + if (result.IsOk()) { - Markers.Add(new TasMovieMarker(markerFrame, i.PromptText)); + Markers.Add(new TasMovieMarker(frame, i.PromptText)); UpdateTextColumnWidth(); UpdateValues(); } } else { - Markers.Add(new TasMovieMarker(markerFrame)); + Markers.Add(new TasMovieMarker(frame)); UpdateValues(); } diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index abd85b3208..476fced6e5 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -932,7 +932,7 @@ namespace BizHawk.Client.EmuHawk else { ClearLeftMouseStates(); - MarkerControl.AddMarker(false, TasView.CurrentCell.RowIndex.Value); + MarkerControl.AddMarker(TasView.CurrentCell.RowIndex.Value, false); } } } diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 033353d056..7a75aaa90c 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -727,13 +727,13 @@ namespace BizHawk.Client.EmuHawk foreach (var index in TasView.SelectedRows) { - MarkerControl.AddMarker(false, index); + MarkerControl.AddMarker(index, false); } } private void SetMarkerWithTextMenuItem_Click(object sender, EventArgs e) { - MarkerControl.AddMarker(true, TasView.SelectedRows.FirstOrDefault()); + MarkerControl.AddMarker(TasView.SelectedRows.FirstOrDefault(), true); } private void RemoveMarkersMenuItem_Click(object sender, EventArgs e)