TAStudio work:

-Fixed InputRoll.VisibleRows property.
-Removed useless check for NeedsScrollbar.
-Removed TAStudio.ListView.cs property for hiding lag frames; changed InputRoll.cs to do that work more efficiently.
-Feature: User can now edit float values by holding the mouse button and dragging up/down.
-Bugfix: Moving the cursor past first displayed row while painting would not cause first displayed row to be painted. (and similarly with last)
This commit is contained in:
SuuperW 2015-02-25 21:17:50 +00:00
parent aa2984dd96
commit 81a8d38ca4
5 changed files with 142 additions and 85 deletions

View File

@ -527,24 +527,16 @@ namespace BizHawk.Client.EmuHawk
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)] [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
public int FirstVisibleRow public int FirstVisibleRow
{ {
get get // SuuperW: This was checking if the scroll bars were needed, which is useless because their Value is 0 if they aren't needed.
{ {
if (HorizontalOrientation) if (HorizontalOrientation)
{
if (NeedsHScrollbar)
{ {
return HBar.Value / CellWidth; return HBar.Value / CellWidth;
} }
}
if (NeedsVScrollbar)
{
return VBar.Value / CellHeight; return VBar.Value / CellHeight;
} }
return 0;
}
set set
{ {
if (HorizontalOrientation) if (HorizontalOrientation)
@ -578,6 +570,10 @@ namespace BizHawk.Client.EmuHawk
set set
{ {
FirstVisibleRow = Math.Max(value - VisibleRows, 0); FirstVisibleRow = Math.Max(value - VisibleRows, 0);
if (LastVisibleRow != value)
{
FirstVisibleRow -= (LastVisibleRow - value);
}
} }
} }
@ -597,14 +593,10 @@ namespace BizHawk.Client.EmuHawk
{ {
if (HorizontalOrientation) if (HorizontalOrientation)
{ {
var width = DrawWidth - (NeedsVScrollbar ? VBar.Width : 0); return (DrawWidth - ColumnWidth) / CellWidth;
return (width - ColumnWidth) / CellWidth;
} }
var height = DrawHeight - (NeedsHScrollbar ? HBar.Height : (CellHeight - 1)); return (DrawHeight - ColumnHeight) / CellHeight;
return (height / CellHeight) - 1; // adelikat: -1 to compensate for what this math should be doing anyway, TODO: figure out why it doesn't work without it?
} }
} }
@ -1196,7 +1188,24 @@ namespace BizHawk.Client.EmuHawk
_currentX = e.X; _currentX = e.X;
_currentY = e.Y; _currentY = e.Y;
var newCell = CalculatePointedCell(e.X, e.Y); 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);
// SuuperW: Hide lag frames // SuuperW: Hide lag frames
if (QueryFrameLag != null && newCell.RowIndex.HasValue) if (QueryFrameLag != null && newCell.RowIndex.HasValue)
{ {
@ -1974,7 +1983,7 @@ namespace BizHawk.Client.EmuHawk
// SuuperW: Count lag frames between FirstDisplayed and given display position // SuuperW: Count lag frames between FirstDisplayed and given display position
private int CountLagFramesDisplay(int relativeIndex) private int CountLagFramesDisplay(int relativeIndex)
{ {
if (QueryFrameLag != null) if (QueryFrameLag != null && LagFramesToHide != 0)
{ {
int count = 0; int count = 0;
for (int i = 0; i <= relativeIndex; i++) for (int i = 0; i <= relativeIndex; i++)
@ -1987,7 +1996,7 @@ namespace BizHawk.Client.EmuHawk
// Count lag frames between FirstDisplayed and given frame index (plus FirstDisplayed) // Count lag frames between FirstDisplayed and given frame index (plus FirstDisplayed)
private int CountLagFramesAbsolute(int index) private int CountLagFramesAbsolute(int index)
{ {
if (QueryFrameLag != null) if (QueryFrameLag != null && LagFramesToHide != 0)
{ {
int count = 0; int count = 0;
for (int i = 0; i + count <= index; i++) for (int i = 0; i + count <= index; i++)
@ -2000,7 +2009,7 @@ namespace BizHawk.Client.EmuHawk
private void SetLagFramesArray() private void SetLagFramesArray()
{ {
if (QueryFrameLag != null) if (QueryFrameLag != null && LagFramesToHide != 0)
{ {
bool showNext = false; bool showNext = false;
// First one needs to check BACKWARDS for lag frame count. // First one needs to check BACKWARDS for lag frame count.
@ -2031,10 +2040,13 @@ namespace BizHawk.Client.EmuHawk
} }
} }
} }
else
for (int i = 0; i < VisibleRows; i++)
lagFrames[i] = 0;
} }
private void SetLagFramesFirst() private void SetLagFramesFirst()
{ {
if (QueryFrameLag != null) if (QueryFrameLag != null && LagFramesToHide != 0)
{ {
// Count how many lag frames are above displayed area. // Count how many lag frames are above displayed area.
int count = 0; int count = 0;

View File

@ -141,14 +141,13 @@ namespace BizHawk.Client.EmuHawk
} }
// SuuperW: Marker renaming can be done with a right-click. // SuuperW: Marker renaming can be done with a right-click.
// A much more useful feature would be to easily jump to it. I'll put that in TAStudio.Navigation.cs // A much more useful feature would be to easily jump to it.
private void MarkerView_MouseDoubleClick(object sender, MouseEventArgs e) private void MarkerView_MouseDoubleClick(object sender, MouseEventArgs e)
{ {
if (MarkerView.CurrentCell != null && MarkerView.CurrentCell.RowIndex.HasValue && if (MarkerView.CurrentCell != null && MarkerView.CurrentCell.RowIndex.HasValue &&
MarkerView.CurrentCell.RowIndex < MarkerView.RowCount) MarkerView.CurrentCell.RowIndex < MarkerView.RowCount)
{ {
var marker = Tastudio.CurrentTasMovie.Markers[MarkerView.CurrentCell.RowIndex.Value]; var marker = Tastudio.CurrentTasMovie.Markers[MarkerView.CurrentCell.RowIndex.Value];
// Tastudio.CallEditMarkerPopUp(marker);
Tastudio.GoToFrame(marker.Frame); Tastudio.GoToFrame(marker.Frame);
} }
} }

View File

@ -680,7 +680,7 @@ namespace BizHawk.Client.EmuHawk
this.HideLagFrames0.CheckOnClick = true; this.HideLagFrames0.CheckOnClick = true;
this.HideLagFrames0.CheckState = System.Windows.Forms.CheckState.Checked; this.HideLagFrames0.CheckState = System.Windows.Forms.CheckState.Checked;
this.HideLagFrames0.Name = "HideLagFrames0"; this.HideLagFrames0.Name = "HideLagFrames0";
this.HideLagFrames0.Size = new System.Drawing.Size(152, 22); this.HideLagFrames0.Size = new System.Drawing.Size(131, 22);
this.HideLagFrames0.Tag = ""; this.HideLagFrames0.Tag = "";
this.HideLagFrames0.Text = "Don\'t Hide"; this.HideLagFrames0.Text = "Don\'t Hide";
this.HideLagFrames0.Click += new System.EventHandler(this.HideLagFrames0_Click); this.HideLagFrames0.Click += new System.EventHandler(this.HideLagFrames0_Click);
@ -689,14 +689,14 @@ namespace BizHawk.Client.EmuHawk
// //
this.HideLagFrames1.CheckOnClick = true; this.HideLagFrames1.CheckOnClick = true;
this.HideLagFrames1.Name = "HideLagFrames1"; this.HideLagFrames1.Name = "HideLagFrames1";
this.HideLagFrames1.Size = new System.Drawing.Size(152, 22); this.HideLagFrames1.Size = new System.Drawing.Size(131, 22);
this.HideLagFrames1.Text = "1 (30 fps)"; this.HideLagFrames1.Text = "1 (30 fps)";
this.HideLagFrames1.Click += new System.EventHandler(this.HideLagFrames1_Click); this.HideLagFrames1.Click += new System.EventHandler(this.HideLagFrames1_Click);
// //
// HideLagFrames2 // HideLagFrames2
// //
this.HideLagFrames2.Name = "HideLagFrames2"; this.HideLagFrames2.Name = "HideLagFrames2";
this.HideLagFrames2.Size = new System.Drawing.Size(152, 22); this.HideLagFrames2.Size = new System.Drawing.Size(131, 22);
this.HideLagFrames2.Text = "2 (20 fps)"; this.HideLagFrames2.Text = "2 (20 fps)";
this.HideLagFrames2.Click += new System.EventHandler(this.HideLagFrames2_Click); this.HideLagFrames2.Click += new System.EventHandler(this.HideLagFrames2_Click);
// //
@ -704,7 +704,7 @@ namespace BizHawk.Client.EmuHawk
// //
this.HideLagFrames3.CheckOnClick = true; this.HideLagFrames3.CheckOnClick = true;
this.HideLagFrames3.Name = "HideLagFrames3"; this.HideLagFrames3.Name = "HideLagFrames3";
this.HideLagFrames3.Size = new System.Drawing.Size(152, 22); this.HideLagFrames3.Size = new System.Drawing.Size(131, 22);
this.HideLagFrames3.Tag = ""; this.HideLagFrames3.Tag = "";
this.HideLagFrames3.Text = "3 (15fps)"; this.HideLagFrames3.Text = "3 (15fps)";
this.HideLagFrames3.Click += new System.EventHandler(this.HideLagFrames3_Click); this.HideLagFrames3.Click += new System.EventHandler(this.HideLagFrames3_Click);
@ -763,7 +763,7 @@ namespace BizHawk.Client.EmuHawk
this.TasView.FullRowSelect = true; this.TasView.FullRowSelect = true;
this.TasView.HorizontalOrientation = false; this.TasView.HorizontalOrientation = false;
this.TasView.LagFramesToHide = 0; this.TasView.LagFramesToHide = 0;
this.TasView.LastVisibleRow = 24; this.TasView.LastVisibleRow = 28;
this.TasView.Location = new System.Drawing.Point(8, 27); this.TasView.Location = new System.Drawing.Point(8, 27);
this.TasView.MaxCharactersInHorizontal = 1; this.TasView.MaxCharactersInHorizontal = 1;
this.TasView.MultiSelect = false; this.TasView.MultiSelect = false;
@ -780,6 +780,7 @@ namespace BizHawk.Client.EmuHawk
this.TasView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseDoubleClick); this.TasView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseDoubleClick);
this.TasView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseDown); this.TasView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseDown);
this.TasView.MouseEnter += new System.EventHandler(this.TasView_MouseEnter); this.TasView.MouseEnter += new System.EventHandler(this.TasView_MouseEnter);
this.TasView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseMove);
this.TasView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseUp); this.TasView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseUp);
this.TasView.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.TasView_PreviewKeyDown); this.TasView.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.TasView_PreviewKeyDown);
// //

View File

@ -21,15 +21,10 @@ namespace BizHawk.Client.EmuHawk
private string _floatEditColumn = string.Empty; private string _floatEditColumn = string.Empty;
private int _floatEditRow = -1; private int _floatEditRow = -1;
private string _floatTypedValue; private string _floatTypedValue;
private int _floatEditYPos = -1;
private bool HideLagFrames
{
get { return TasView.LagFramesToHide > 0; }
}
private bool _triggerAutoRestore; // If true, autorestore will be called on mouse up 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 private int? _triggerAutoRestoreFromFrame; // If set and _triggerAutoRestore is true, will call GoToFrameIfNecessary() with this value
public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC); public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC);
public static Color CurrentFrame_InputLog = Color.FromArgb(0xB5E7F7); public static Color CurrentFrame_InputLog = Color.FromArgb(0xB5E7F7);
@ -191,7 +186,7 @@ namespace BizHawk.Client.EmuHawk
// SuuperW: Used in InputRoll.cs to hide lag frames. // SuuperW: Used in InputRoll.cs to hide lag frames.
private bool TasView_QueryFrameLag(int index) private bool TasView_QueryFrameLag(int index)
{ {
return HideLagFrames && CurrentTasMovie[index].Lagged.HasValue && CurrentTasMovie[index].Lagged.Value; return CurrentTasMovie[index].Lagged.HasValue && CurrentTasMovie[index].Lagged.Value;
} }
#endregion #endregion
@ -258,15 +253,25 @@ namespace BizHawk.Client.EmuHawk
var frame = TasView.CurrentCell.RowIndex.Value; var frame = TasView.CurrentCell.RowIndex.Value;
var buttonName = TasView.CurrentCell.Column.Name; var buttonName = TasView.CurrentCell.Column.Name;
// SuuperW: Exit float editing mode
if (e.Button == MouseButtons.Left)
{
// SuuperW: Exit float editing mode, or re-enter mouse editing
if (_floatEditRow != -1)
{
if (_floatEditColumn != buttonName || _floatEditRow != frame) if (_floatEditColumn != buttonName || _floatEditRow != frame)
{ {
_floatEditRow = -1; _floatEditRow = -1;
TasView.Refresh(); TasView.Refresh();
} }
else
if (e.Button == MouseButtons.Left)
{ {
_floatEditYPos = e.Y;
_floatPaintState = CurrentTasMovie.GetFloatValue(frame, buttonName);
return;
}
}
if (TasView.CurrentCell.Column.Name == MarkerColumnName) if (TasView.CurrentCell.Column.Name == MarkerColumnName)
{ {
_startMarkerDrag = true; _startMarkerDrag = true;
@ -298,6 +303,8 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{
if (e.Clicks != 2)
{ {
_startFloatDrawColumn = buttonName; _startFloatDrawColumn = buttonName;
@ -310,6 +317,26 @@ namespace BizHawk.Client.EmuHawk
_floatPaintState = Global.ClickyVirtualPadController.GetFloat(buttonName); _floatPaintState = Global.ClickyVirtualPadController.GetFloat(buttonName);
} }
} }
else // Double-click enters float editing mode
{
if (_floatEditColumn == buttonName && _floatEditRow == frame)
{
_floatEditRow = -1;
RefreshDialog();
}
else
{
_floatEditColumn = buttonName;
_floatEditRow = frame;
_floatTypedValue = "";
_floatEditYPos = e.Y;
_floatPaintState = CurrentTasMovie.GetFloatValue(_floatEditRow, _floatEditColumn);
_triggerAutoRestore = true;
_triggerAutoRestoreFromFrame = frame;
RefreshDialog();
}
}
}
} }
} }
} }
@ -326,7 +353,14 @@ namespace BizHawk.Client.EmuHawk
_startFrameDrag = false; _startFrameDrag = false;
_startBoolDrawColumn = string.Empty; _startBoolDrawColumn = string.Empty;
_startFloatDrawColumn = string.Empty; _startFloatDrawColumn = string.Empty;
// Exit float editing if value was changed with cursor
if (_floatEditRow != -1 && _floatPaintState != CurrentTasMovie.GetFloatValue(_floatEditRow, _floatEditColumn))
{
_floatEditRow = -1;
RefreshDialog();
}
_floatPaintState = 0; _floatPaintState = 0;
_floatEditYPos = -1;
} }
_supressContextMenu = false; _supressContextMenu = false;
@ -369,34 +403,11 @@ namespace BizHawk.Client.EmuHawk
CallAddMarkerPopUp(TasView.CurrentCell.RowIndex.Value); CallAddMarkerPopUp(TasView.CurrentCell.RowIndex.Value);
} }
} }
else if (Global.MovieSession.MovieControllerAdapter.Type.FloatControls.Contains(buttonName))
{ // SuuperW: Edit float input
int frame = TasView.CurrentCell.RowIndex.Value;
if (_floatEditColumn == buttonName && _floatEditRow == frame)
{
_floatEditRow = -1;
RefreshDialog();
}
else
{
_floatEditColumn = buttonName;
_floatEditRow = frame;
_floatTypedValue = "";
_triggerAutoRestore = true;
_triggerAutoRestoreFromFrame = frame;
RefreshDialog();
}
}
} }
} }
private void TasView_PointedCellChanged(object sender, InputRoll.CellEventArgs e) private void TasView_PointedCellChanged(object sender, InputRoll.CellEventArgs e)
{ {
// SuuperW: Will this allow TasView to see KeyDown?
TasView.Select();
// Temporary test code
TasView.Refresh();
// TODO: think about nullability // TODO: think about nullability
// For now return if a null because this happens OnEnter which doesn't have any of the below behaviors yet? // For now return if a null because this happens OnEnter which doesn't have any of the below behaviors yet?
// Most of these are stupid but I got annoyed at null crashes // Most of these are stupid but I got annoyed at null crashes
@ -470,6 +481,34 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void TasView_MouseMove(object sender, MouseEventArgs e)
{
// For float editing
int increment = (e.Y - _floatEditYPos) / 3;
if (_floatEditYPos == -1)
return;
float value = _floatPaintState + increment;
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Type.FloatRanges
[Global.MovieSession.MovieControllerAdapter.Type.FloatControls.IndexOf(_floatEditColumn)];
// Range for N64 Y axis has max -128 and min 127. That should probably be fixed elsewhere, but I'll put a quick fix here anyway.
float rMax = range.Max;
float rMin = range.Min;
if (rMax < rMin)
{
rMax = range.Min;
rMin = range.Max;
}
if (value > rMax)
value = rMax;
else if (value < rMin)
value = rMin;
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
RefreshDialog();
}
private void TasView_SelectedIndexChanged(object sender, EventArgs e) private void TasView_SelectedIndexChanged(object sender, EventArgs e)
{ {
SetSplicer(); SetSplicer();
@ -546,6 +585,11 @@ namespace BizHawk.Client.EmuHawk
} }
else if (e.KeyCode == Keys.Escape) else if (e.KeyCode == Keys.Escape)
{ {
if (_floatEditYPos != -1) // Cancel change from dragging cursor
{
_floatEditYPos = -1;
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, _floatPaintState);
}
_floatEditRow = -1; _floatEditRow = -1;
} }
else else

View File

@ -727,5 +727,6 @@ namespace BizHawk.Client.EmuHawk
{ {
MarkerControl.RemoveMarker(); MarkerControl.RemoveMarker();
} }
} }
} }