diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs
index eb3f96ef98..7a92f8f987 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs
@@ -36,6 +36,9 @@ namespace BizHawk.Client.EmuHawk
private int? _currentX;
private int? _currentY;
+ public int _lagFramesToHide = 1;
+ private int[] lagFrames = new int[50]; // Large enough value that it shouldn't ever need resizing.
+
private IntPtr RotatedFont;
private Font NormalFont;
@@ -253,6 +256,12 @@ namespace BizHawk.Client.EmuHawk
[Category("Virtual")]
public event QueryItemIconHandler QueryItemIcon;
+ ///
+ /// SuuperW: Fire the QueryFrameLag event which checks if a given frame is a lag frame
+ ///
+ [Category("Virtual")]
+ public event QueryFrameLagHandler QueryFrameLag;
+
///
/// Fires when the mouse moves from one cell to another (including column header cells)
///
@@ -302,6 +311,11 @@ namespace BizHawk.Client.EmuHawk
///
public delegate void QueryItemIconHandler(int index, RollColumn column, ref Bitmap icon);
+ ///
+ /// SuuperW: Check if a given frame is a lag frame
+ ///
+ public delegate bool QueryFrameLagHandler(int index);
+
public delegate void CellChangeEventHandler(object sender, CellEventArgs e);
public delegate void RightMouseScrollEventHandler(object sender, MouseEventArgs e);
@@ -553,7 +567,7 @@ namespace BizHawk.Client.EmuHawk
{
get
{
- return FirstVisibleRow + VisibleRows;
+ return FirstVisibleRow + VisibleRows + CountLagFramesDisplay(VisibleRows);
}
set
@@ -641,6 +655,9 @@ namespace BizHawk.Client.EmuHawk
Gdi.SetSolidPen(Color.White);
Gdi.FillRectangle(0, 0, Width, Height);
+ // Lag frame calculations
+ SetLagFramesArray();
+
if (_columns.VisibleColumns.Any())
{
DrawColumnBg(e);
@@ -748,8 +765,9 @@ namespace BizHawk.Client.EmuHawk
int range = Math.Min(LastVisibleRow, RowCount - 1) - startRow + 1;
Gdi.PrepDrawString(this.NormalFont, this.ForeColor);
- for (int i = 0; i < range; i++)
+ for (int i = 0, f = 0; f < range; i++, f++)
{
+ f += lagFrames[i];
for (int j = 0; j < columns.Count; j++)
{
Bitmap image = null;
@@ -761,7 +779,7 @@ namespace BizHawk.Client.EmuHawk
x = RowsToPixels(i) + CellWidthPadding;
y = (j * CellHeight) + (CellHeightPadding * 2);
- QueryItemIcon(i + startRow, columns[j], ref image);
+ QueryItemIcon(f + startRow, columns[j], ref image);
}
if (image != null)
@@ -771,7 +789,7 @@ namespace BizHawk.Client.EmuHawk
else
{
string text;
- QueryItemText(i + startRow, columns[j], out text);
+ QueryItemText(f + startRow, columns[j], out text);
// Center Text
x = RowsToPixels(i) + (CellWidth - text.Length * _charSize.Width) / 2;
@@ -806,8 +824,9 @@ namespace BizHawk.Client.EmuHawk
Gdi.PrepDrawString(this.NormalFont, this.ForeColor);
int xPadding = CellWidthPadding + 1 - HBar.Value;
- for (int i = 0; i < range; i++) // Vertical
+ for (int i = 0, f = 0; f < range; i++, f++) // Vertical
{
+ f += lagFrames[i];
for (int j = 0; j < columns.Count; j++) // Horizontal
{
var col = columns[j];
@@ -822,7 +841,7 @@ namespace BizHawk.Client.EmuHawk
Bitmap image = null;
if (QueryItemIcon != null)
{
- QueryItemIcon(i + startRow, columns[j], ref image);
+ QueryItemIcon(f + startRow, columns[j], ref image);
}
if (image != null)
@@ -831,10 +850,10 @@ namespace BizHawk.Client.EmuHawk
}
else
{
- QueryItemText(i + startRow, columns[j], out text);
+ QueryItemText(f + startRow, columns[j], out text);
bool rePrep = false;
- if (SelectedItems.Contains(new Cell { Column = columns[j], RowIndex = i + startRow }))
+ if (SelectedItems.Contains(new Cell { Column = columns[j], RowIndex = f + startRow }))
{
Gdi.PrepDrawString(this.NormalFont, SystemColors.HighlightText);
rePrep = true;
@@ -1054,6 +1073,8 @@ namespace BizHawk.Client.EmuHawk
Column = cell.Column,
CurrentText = cell.CurrentText
};
+ relativeCell.RowIndex -= CountLagFramesAbsolute(relativeCell.RowIndex.Value);
+
QueryItemBkColor(cell.RowIndex.Value, cell.Column, ref Highlight_Color);
Highlight_Color = Color.FromArgb((Highlight_Color.R + SystemColors.Highlight.R) / 2
, (Highlight_Color.G + SystemColors.Highlight.G) / 2
@@ -1115,12 +1136,13 @@ namespace BizHawk.Client.EmuHawk
int startIndex = FirstVisibleRow;
int range = Math.Min(LastVisibleRow, RowCount - 1) - startIndex + 1;
- for (int i = 0; i < range; i++)
+ for (int i = 0, f = 0; f < range; i++, f++)
{
+ f += lagFrames[i];
for (int j = 0; j < columns.Count; j++) // TODO: Don't query all columns
{
var color = Color.White;
- QueryItemBkColor(i + startIndex, columns[j], ref color);
+ QueryItemBkColor(f + startIndex, columns[j], ref color);
if (color != Color.White) // An easy optimization, don't draw unless the user specified something other than the default
{
@@ -1139,12 +1161,13 @@ namespace BizHawk.Client.EmuHawk
int startRow = FirstVisibleRow;
int range = Math.Min(LastVisibleRow, RowCount - 1) - startRow + 1;
- for (int i = 0; i < range; i++) // Vertical
+ for (int i = 0, f = 0; f < range; i++, f++) // Vertical
{
+ f += lagFrames[i];
for (int j = 0; j < columns.Count; j++) // Horizontal
{
var color = Color.White;
- QueryItemBkColor(i + startRow, columns[j], ref color);
+ QueryItemBkColor(f + startRow, columns[j], ref color);
if (color != Color.White) // An easy optimization, don't draw unless the user specified something other than the default
{
var cell = new Cell
@@ -1169,6 +1192,11 @@ namespace BizHawk.Client.EmuHawk
_currentY = e.Y;
var newCell = CalculatePointedCell(e.X, e.Y);
+ // SuuperW: Hide lag frames
+ if (QueryFrameLag != null && newCell.RowIndex.HasValue)
+ {
+ newCell.RowIndex += CountLagFramesDisplay(newCell.RowIndex.Value);
+ }
newCell.RowIndex += FirstVisibleRow;
if (!newCell.Equals(CurrentCell))
{
@@ -1400,11 +1428,19 @@ namespace BizHawk.Client.EmuHawk
{
if (HorizontalOrientation)
{
- IncrementScrollBar(HBar, e.Delta < 0);
+ do
+ {
+ IncrementScrollBar(HBar, e.Delta < 0);
+ SetLagFramesFirst();
+ } while (lagFrames[0] != 0 && HBar.Value != 0 && HBar.Value != HBar.Maximum);
}
else
{
- IncrementScrollBar(VBar, e.Delta < 0);
+ do
+ {
+ IncrementScrollBar(VBar, e.Delta < 0);
+ SetLagFramesFirst();
+ } while (lagFrames[0] != 0 && VBar.Value != 0 && VBar.Value != VBar.Maximum);
}
Refresh();
@@ -1930,6 +1966,90 @@ namespace BizHawk.Client.EmuHawk
CellWidth = (_charSize.Width * MaxCharactersInHorizontal) + (CellWidthPadding * 4); // Double the padding for horizontal because it looks better
}
+ // SuuperW: Count lag frames between FirstDisplayed and given display position
+ private int CountLagFramesDisplay(int relativeIndex)
+ {
+ if (QueryFrameLag != null)
+ {
+ int count = 0;
+ for (int i = 0; i <= relativeIndex; i++)
+ count += lagFrames[i];
+
+ return count;
+ }
+ return 0;
+ }
+ // Count lag frames between FirstDisplayed and given frame index (plus FirstDisplayed)
+ private int CountLagFramesAbsolute(int index)
+ {
+ if (QueryFrameLag != null)
+ {
+ int count = 0;
+ for (int i = 0; i + count <= index; i++)
+ count += lagFrames[i];
+
+ return count;
+ }
+ return 0;
+ }
+
+ private void SetLagFramesArray()
+ {
+ if (QueryFrameLag != null)
+ {
+ bool showNext = false;
+ // First one needs to check BACKWARDS for lag frame count.
+ SetLagFramesFirst();
+ int f = lagFrames[0];
+ if (QueryFrameLag(FirstVisibleRow + f))
+ showNext = true;
+ for (int i = 1; i <= VisibleRows; i++)
+ {
+ lagFrames[i] = 0;
+ if (!showNext)
+ {
+ for (; lagFrames[i] < _lagFramesToHide; lagFrames[i]++)
+ {
+ if (!QueryFrameLag(FirstVisibleRow + i + f))
+ break;
+ f++;
+ }
+ }
+ else
+ {
+ if (!QueryFrameLag(FirstVisibleRow + i + f))
+ showNext = false;
+ }
+ if (lagFrames[i] == _lagFramesToHide && QueryFrameLag(FirstVisibleRow + i + f))
+ {
+ showNext = true;
+ }
+ }
+ }
+ }
+ private void SetLagFramesFirst()
+ {
+ if (QueryFrameLag != null)
+ {
+ // Count how many lag frames are above displayed area.
+ int count = 0;
+ do
+ {
+ count++;
+ } while (QueryFrameLag(FirstVisibleRow - count) && count <= _lagFramesToHide);
+ count--;
+ // Count forward
+ int fCount = -1;
+ do
+ {
+ fCount++;
+ } while (QueryFrameLag(FirstVisibleRow + fCount) && count + fCount < _lagFramesToHide);
+ lagFrames[0] = fCount;
+ }
+ else
+ lagFrames[0] = 0;
+ }
+
#endregion
#region Classes
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs
index d656c09e2c..2ae4268026 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs
@@ -95,6 +95,10 @@ namespace BizHawk.Client.EmuHawk
this.DefaultStateSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SettingsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.RotateMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.hideLagFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.allToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.ColumnsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator19 = new System.Windows.Forms.ToolStripSeparator();
this.HelpSubMenu = new System.Windows.Forms.ToolStripMenuItem();
@@ -133,6 +137,7 @@ namespace BizHawk.Client.EmuHawk
this.StartFromNowSeparator = new System.Windows.Forms.ToolStripSeparator();
this.StartNewProjectFromNowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.TASMenu.SuspendLayout();
this.TasStatusStrip.SuspendLayout();
this.MarkerContextMenu.SuspendLayout();
@@ -643,7 +648,8 @@ namespace BizHawk.Client.EmuHawk
// SettingsSubMenu
//
this.SettingsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.RotateMenuItem});
+ this.RotateMenuItem,
+ this.hideLagFramesToolStripMenuItem});
this.SettingsSubMenu.Name = "SettingsSubMenu";
this.SettingsSubMenu.Size = new System.Drawing.Size(61, 20);
this.SettingsSubMenu.Text = "&Settings";
@@ -652,10 +658,46 @@ namespace BizHawk.Client.EmuHawk
// RotateMenuItem
//
this.RotateMenuItem.Name = "RotateMenuItem";
- this.RotateMenuItem.Size = new System.Drawing.Size(108, 22);
+ this.RotateMenuItem.Size = new System.Drawing.Size(162, 22);
this.RotateMenuItem.Text = "Rotate";
this.RotateMenuItem.Click += new System.EventHandler(this.RotateMenuItem_Click);
//
+ // hideLagFramesToolStripMenuItem
+ //
+ this.hideLagFramesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.allToolStripMenuItem,
+ this.toolStripMenuItem2,
+ this.toolStripMenuItem3,
+ this.toolStripMenuItem4});
+ this.hideLagFramesToolStripMenuItem.Name = "hideLagFramesToolStripMenuItem";
+ this.hideLagFramesToolStripMenuItem.Size = new System.Drawing.Size(162, 22);
+ this.hideLagFramesToolStripMenuItem.Text = "Hide Lag Frames";
+ //
+ // allToolStripMenuItem
+ //
+ this.allToolStripMenuItem.CheckOnClick = true;
+ this.allToolStripMenuItem.Name = "allToolStripMenuItem";
+ this.allToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.allToolStripMenuItem.Tag = "";
+ this.allToolStripMenuItem.Text = "All";
+ //
+ // toolStripMenuItem2
+ //
+ this.toolStripMenuItem2.Checked = true;
+ this.toolStripMenuItem2.CheckOnClick = true;
+ this.toolStripMenuItem2.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.toolStripMenuItem2.Name = "toolStripMenuItem2";
+ this.toolStripMenuItem2.Size = new System.Drawing.Size(152, 22);
+ this.toolStripMenuItem2.Tag = "";
+ this.toolStripMenuItem2.Text = "0";
+ //
+ // toolStripMenuItem3
+ //
+ this.toolStripMenuItem3.CheckOnClick = true;
+ this.toolStripMenuItem3.Name = "toolStripMenuItem3";
+ this.toolStripMenuItem3.Size = new System.Drawing.Size(152, 22);
+ this.toolStripMenuItem3.Text = "1";
+ //
// ColumnsSubMenu
//
this.ColumnsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -980,6 +1022,12 @@ namespace BizHawk.Client.EmuHawk
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Markers";
//
+ // toolStripMenuItem4
+ //
+ this.toolStripMenuItem4.Name = "toolStripMenuItem4";
+ this.toolStripMenuItem4.Size = new System.Drawing.Size(152, 22);
+ this.toolStripMenuItem4.Text = "2";
+ //
// TAStudio
//
this.AllowDrop = true;
@@ -1117,5 +1165,10 @@ namespace BizHawk.Client.EmuHawk
private System.Windows.Forms.ToolStripMenuItem RotateMenuItem;
private System.Windows.Forms.ToolStripProgressBar SavingProgressBar;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2;
+ private System.Windows.Forms.ToolStripMenuItem hideLagFramesToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem allToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
+ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
}
}
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
index 0b4e3994c3..62f80b12e2 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
@@ -21,6 +21,10 @@ namespace BizHawk.Client.EmuHawk
private string _floatEditColumn = string.Empty;
private int _floatEditRow = -1;
private string _floatTypedValue;
+ // SuuperW: Hiding lag frames (Mainly intended for 30fps play.)
+ private bool _hideLagFrames = true; // This toggles if lag frames are hidden. For the number, see InputRoll.cs: _lagFramesToHide
+ // Frames that were lag frames, but are now past the greenzone are shown make editing awkward.
+ // (Showing such frames might be desireable in certain situations, such as when trying to eliminate a lone lag frame.)
private bool _triggerAutoRestore; // If true, autorestore will be called on mouse up
private int? _triggerAutoRestoreFromFrame; // If set and _triggerAutoRestore is true, will clal GoToFrameIfNecessary() with this value
@@ -172,6 +176,12 @@ namespace BizHawk.Client.EmuHawk
}
}
+ // SuuperW: Used in InputRoll.cs to hide lag frames.
+ private bool TasView_QueryFrameLag(int index)
+ {
+ return _hideLagFrames && CurrentTasMovie[index].Lagged.HasValue && CurrentTasMovie[index].Lagged.Value;
+ }
+
#endregion
#region Events
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
index 3b7e5a993d..445dd8f6b3 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
@@ -107,6 +107,7 @@ namespace BizHawk.Client.EmuHawk
TasView.QueryItemText += TasView_QueryItemText;
TasView.QueryItemBkColor += TasView_QueryItemBkColor;
TasView.QueryItemIcon += TasView_QueryItemIcon;
+ TasView.QueryFrameLag += TasView_QueryFrameLag;
TasView.InputPaintingMode = Settings.DrawInput;
TasView.PointedCellChanged += TasView_PointedCellChanged;
TasView.MultiSelect = true;
@@ -475,24 +476,6 @@ namespace BizHawk.Client.EmuHawk
}
}
- // SuuperW: 'toggle' float state
- private void ToggleFloatState(int frame, string buttonName)
- {
- if (frame < CurrentTasMovie.InputLogLength)
- {
- float curState = CurrentTasMovie.GetFloatValue(frame, buttonName);
- if (curState == 0f)
- CurrentTasMovie.SetFloatState(frame, buttonName, 127.0f);
- else
- CurrentTasMovie.SetFloatState(frame, buttonName, 0f);
- }
- else if (frame == Emulator.Frame && frame == CurrentTasMovie.InputLogLength)
- {
- // Global.ClickyVirtualPadController.Toggle(buttonName);
- }
- }
-
-
private void SetColumnsFromCurrentStickies()
{
foreach (var column in TasView.VisibleColumns)