diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs
index 12346fc456..9600f8d375 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs
@@ -784,14 +784,14 @@ namespace BizHawk.Client.EmuHawk
}
}
+ ///
+ /// Scrolls to the given index, according to the scroll settings.
+ ///
public void ScrollToIndex(int index)
{
- if (ScrollMethod == "near" && !IsVisible(index))
+ if (ScrollMethod == "near")
{
- if (FirstVisibleRow > index)
- FirstVisibleRow = index;
- else
- LastVisibleRow = index;
+ MakeIndexVisible(index);
}
if (!IsVisible(index) || AlwaysScroll)
{
@@ -826,6 +826,19 @@ namespace BizHawk.Client.EmuHawk
}
}
}
+ ///
+ /// Scrolls so that the given index is visible, if it isn't already; doesn't use scroll settings.
+ ///
+ public void MakeIndexVisible(int index)
+ {
+ if (!IsVisible(index))
+ {
+ if (FirstVisibleRow > index)
+ FirstVisibleRow = index;
+ else
+ LastVisibleRow = index;
+ }
+ }
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
@@ -1448,30 +1461,16 @@ namespace BizHawk.Client.EmuHawk
_columnDownMoved = true;
}
- if (IsPaintDown)
- {
- if (HorizontalOrientation)
- {
- if (e.X <= ColumnWidth)
- _currentX = ColumnWidth + 2; // 2 because ColumnWidth/Height isn't correct
- else if (e.X > Width)
- _currentX = Width;
- }
- else
- {
- if (e.Y <= ColumnHeight)
- _currentY = ColumnHeight + 2;
- else if (e.Y > Height)
- _currentX = Height;
- }
- }
- var newCell = CalculatePointedCell(_currentX.Value, _currentY.Value);
+ Cell newCell = CalculatePointedCell(_currentX.Value, _currentY.Value);
// SuuperW: Hide lag frames
if (QueryFrameLag != null && newCell.RowIndex.HasValue)
{
newCell.RowIndex += CountLagFramesDisplay(newCell.RowIndex.Value);
}
newCell.RowIndex += FirstVisibleRow;
+ if (newCell.RowIndex < 0)
+ newCell.RowIndex = 0;
+
if (!newCell.Equals(CurrentCell))
{
CellChanged(newCell);
@@ -2151,10 +2150,7 @@ namespace BizHawk.Client.EmuHawk
{
if (HorizontalOrientation)
{
- if (x >= ColumnWidth)
- {
- newCell.RowIndex = PixelsToRows(x);
- }
+ newCell.RowIndex = PixelsToRows(x);
int colIndex = (y + VBar.Value) / CellHeight;
if (colIndex >= 0 && colIndex < columns.Count)
@@ -2164,14 +2160,11 @@ namespace BizHawk.Client.EmuHawk
}
else
{
- if (y >= CellHeight)
- {
- newCell.RowIndex = PixelsToRows(y);
- }
-
+ newCell.RowIndex = PixelsToRows(y);
newCell.Column = ColumnAtX(x);
}
}
+
return newCell;
}
@@ -2252,11 +2245,12 @@ namespace BizHawk.Client.EmuHawk
/// A row number between 0 and VisibleRows if it is a Datarow, otherwise a negative number if above all Datarows.
private int PixelsToRows(int pixels)
{
+ // Using Math.Floor and float because integer division rounds towards 0 but we want to round down.
if (_horizontalOrientation)
{
- return (pixels - ColumnWidth) / CellWidth;
+ return (int)Math.Floor((float)(pixels - ColumnWidth) / CellWidth);
}
- return (pixels - ColumnHeight) / CellHeight;
+ return (int)Math.Floor((float)(pixels - ColumnHeight) / CellHeight);
}
///
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs
index cc8905c9f3..569cfabbb1 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs
@@ -35,8 +35,7 @@ namespace BizHawk.Client.EmuHawk
if (AutoadjustInputMenuItem.Checked)
refreshNeeded = AutoAdjustInput();
- if (TasPlaybackBox.FollowCursor)
- SetVisibleIndex();
+ MaybeFollowCursor();
if (TasView.IsPartiallyVisible(Global.Emulator.Frame) || TasView.IsPartiallyVisible(lastRefresh))
refreshNeeded = true;
@@ -56,10 +55,7 @@ namespace BizHawk.Client.EmuHawk
TasView.RowCount = CurrentTasMovie.InputLogLength + 1;
- if (TasPlaybackBox.FollowCursor)
- {
- SetVisibleIndex();
- }
+ MaybeFollowCursor();
}
public void Restart()
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
index c25a55943b..25bd2fb8d4 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
@@ -37,7 +37,7 @@ namespace BizHawk.Client.EmuHawk
private bool mouseButtonHeld
{
get
- { // Need a left click
+ {
return _rightClickFrame != -1 || _leftButtonHeld;
}
}
@@ -734,9 +734,9 @@ namespace BizHawk.Client.EmuHawk
}
}
- if (Settings.FollowCursor && mouseButtonHeld)
+ if (Settings.FollowCursor && mouseButtonHeld) // todo; why FollowCursor? Should probably have it's own flag.
{
- SetVisibleIndex(TasView.CurrentCell.RowIndex.Value); // todo: limit scrolling speed
+ TasView.MakeIndexVisible(TasView.CurrentCell.RowIndex.Value); // todo: limit scrolling speed
}
RefreshTasView();
}
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs
index 701b1e1c36..c718dac825 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs
@@ -801,10 +801,7 @@ namespace BizHawk.Client.EmuHawk
private void HideLagFramesX_Click(object sender, EventArgs e)
{
TasView.LagFramesToHide = (int)(sender as ToolStripMenuItem).Tag;
- if (TasPlaybackBox.FollowCursor)
- {
- SetVisibleIndex();
- }
+ MaybeFollowCursor();
RefreshDialog();
}
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs
index 4c2401bcad..4343a3b51b 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs
@@ -37,10 +37,7 @@ namespace BizHawk.Client.EmuHawk
// Get as close as we can then emulate there
StartAtNearestFrameAndEmulate(frame);
- if (TasPlaybackBox.FollowCursor)
- {
- SetVisibleIndex(frame);
- }
+ MaybeFollowCursor();
return;
}
@@ -105,16 +102,21 @@ namespace BizHawk.Client.EmuHawk
GoToFrame(marker.Frame);
}
+ ///
+ /// Makes the given frame visible. If no frame is given, makes the current frame visible.
+ ///
public void SetVisibleIndex(int? indexThatMustBeVisible = null)
{
if (!indexThatMustBeVisible.HasValue)
- {
- indexThatMustBeVisible = CurrentTasMovie.IsRecording
- ? CurrentTasMovie.InputLogLength
- : Emulator.Frame;
- }
+ indexThatMustBeVisible = Emulator.Frame;
TasView.ScrollToIndex(indexThatMustBeVisible.Value);
}
+
+ private void MaybeFollowCursor()
+ {
+ if (TasPlaybackBox.FollowCursor && !TasView.IsPaintDown)
+ SetVisibleIndex();
+ }
}
}