From 7624a920210f95ddbc5570e8b2544a918cf3e588 Mon Sep 17 00:00:00 2001 From: SuuperW Date: Thu, 26 Feb 2015 21:12:12 +0000 Subject: [PATCH] TAStudio edits: -Bugfix: TAStudio was refreshing before autoscrolling to cursor. -Partial fix: Made setting last visible frame more accurate when lag frames are hidden. -Removed a line that set an unused local variable. -Bugfix: Scrolling away from selection with lag frames hidden messed up the display. --- .../tools/TAStudio/InputRoll.cs | 53 +++++++++++++++---- .../tools/TAStudio/TAStudio.IToolForm.cs | 6 +-- .../tools/TAStudio/TAStudio.Navigation.cs | 6 +-- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs index 3b27debe03..9d168f6709 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs @@ -560,6 +560,16 @@ namespace BizHawk.Client.EmuHawk } } + private int LastFullyVisibleRow + { + get + { + int HalfRow = 0; + if ((DrawHeight - ColumnHeight - 3) % CellHeight < CellHeight / 2) + HalfRow = 1; + return FirstVisibleRow + VisibleRows - HalfRow + CountLagFramesDisplay(VisibleRows); + } + } public int LastVisibleRow { get @@ -569,17 +579,34 @@ namespace BizHawk.Client.EmuHawk set { - FirstVisibleRow = Math.Max(value - VisibleRows, 0); - if (LastVisibleRow != value) + int HalfRow = 0; + if ((DrawHeight - ColumnHeight - 3) % CellHeight < CellHeight / 2) + HalfRow = 1; + if (LagFramesToHide == 0) { - FirstVisibleRow -= (LastVisibleRow - value); + FirstVisibleRow = Math.Max(value - (VisibleRows - HalfRow), 0); + } + else + { + int Last = LastVisibleRow - HalfRow; + + if (Math.Abs(Last - value) > VisibleRows) // Big jump + FirstVisibleRow = Math.Max(value - (ExpectedDisplayRange() - HalfRow), 0); + else // Small jump + FirstVisibleRow -= (Last - value); + + // SuuperW: This can cause an infinite loop, don't have time to debug it right now. + //// Now a second re-check, with lagFrames[] updated. + //SetLagFramesArray(); + //if (Math.Abs(LastFullyVisibleRow - value) > LagFramesToHide) + // LastVisibleRow = value; } } } public bool IsVisible(int index) { - return (index >= FirstVisibleRow) && (index <= LastVisibleRow); + return (index >= FirstVisibleRow) && (index <= LastFullyVisibleRow); } /// @@ -596,7 +623,7 @@ namespace BizHawk.Client.EmuHawk return (DrawWidth - ColumnWidth) / CellWidth; } - return (DrawHeight - ColumnHeight) / CellHeight; + return (DrawHeight - ColumnHeight - 3) / CellHeight; // Minus three makes it work } } @@ -1064,11 +1091,13 @@ namespace BizHawk.Client.EmuHawk Color Highlight_Color = new Color(); foreach (var cell in SelectedItems) { + if (cell.RowIndex > LastVisibleRow || cell.RowIndex < FirstVisibleRow) + continue; + var relativeCell = new Cell { RowIndex = cell.RowIndex - FirstVisibleRow, Column = cell.Column, - CurrentText = cell.CurrentText }; relativeCell.RowIndex -= CountLagFramesAbsolute(relativeCell.RowIndex.Value); @@ -1993,13 +2022,13 @@ namespace BizHawk.Client.EmuHawk } return 0; } - // Count lag frames between FirstDisplayed and given frame index (plus FirstDisplayed) - private int CountLagFramesAbsolute(int index) + // Count lag frames between FirstDisplayed and given relative frame index + private int CountLagFramesAbsolute(int relativeIndex) { if (QueryFrameLag != null && LagFramesToHide != 0) { int count = 0; - for (int i = 0; i + count <= index; i++) + for (int i = 0; i + count <= relativeIndex; i++) count += lagFrames[i]; return count; @@ -2067,6 +2096,12 @@ namespace BizHawk.Client.EmuHawk lagFrames[0] = 0; } + // Number of displayed + hidden frames, if fps is as expected + private int ExpectedDisplayRange() + { + return (VisibleRows + 1) * LagFramesToHide; + } + #endregion #region Classes diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index 63e3086e71..6514b12944 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -30,13 +30,13 @@ namespace BizHawk.Client.EmuHawk return; } - RefreshDialog(); - if (TasPlaybackBox.FollowCursor) // TODO: we already refreshed in RefreshDialog now we will do it again, make this more efficient { SetVisibleIndex(); } - } + + RefreshDialog(); + } public void FastUpdate() { diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs index af6a009fb8..e016137143 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs @@ -25,7 +25,7 @@ namespace BizHawk.Client.EmuHawk } } - // SuuperW: I changed this to public so that it could be used by MarkerControl.cs + // SuuperW: I changed this to public so that it could be used by MarkerControl.cs public void GoToFrame(int frame) { // If past greenzone, emulate and capture states @@ -156,6 +156,6 @@ namespace BizHawk.Client.EmuHawk public void GoToMarker(TasMovieMarker marker) { GoToFrame(marker.Frame); - } - } + } + } }