More updates to TAStudio: (again all my changes marked with SuuperW)

-bugfix: Local variable hid another; float input couldn't be painted.
-bugfix: Bool input couldn't be painted starting from past the last frame.
-feature: Double-clicking a float input allows user to type value in. (arrow keys would also work, but those aren't seen by the InputRoll, no idea why)
-change: Selected cells are now half-highlighted, so user can still see the non-highlighed color.
This commit is contained in:
SuuperW 2015-02-24 06:47:32 +00:00
parent 6044215ad5
commit db09b12925
4 changed files with 1138 additions and 1026 deletions

View File

@ -133,8 +133,10 @@ namespace BizHawk.Client.EmuHawk
/// Gets or sets whether the control is horizontal or vertical
/// </summary>
[Category("Behavior")]
public bool HorizontalOrientation {
get{
public bool HorizontalOrientation
{
get
{
return _horizontalOrientation;
}
set
@ -436,7 +438,7 @@ namespace BizHawk.Client.EmuHawk
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
public int DrawHeight{ get; private set; }
public int DrawHeight { get; private set; }
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
@ -581,7 +583,7 @@ namespace BizHawk.Client.EmuHawk
return (width - ColumnWidth) / CellWidth;
}
var height = DrawHeight - (NeedsHScrollbar ? HBar.Height : (CellHeight -1));
var height = DrawHeight - (NeedsHScrollbar ? HBar.Height : (CellHeight - 1));
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?
}
@ -1042,7 +1044,9 @@ namespace BizHawk.Client.EmuHawk
private void DoSelectionBG(PaintEventArgs e)
{
foreach(var cell in SelectedItems)
// SuuperW: This allows user to see other colors in selected frames.
Color Highlight_Color = new Color();
foreach (var cell in SelectedItems)
{
var relativeCell = new Cell
{
@ -1050,7 +1054,11 @@ namespace BizHawk.Client.EmuHawk
Column = cell.Column,
CurrentText = cell.CurrentText
};
DrawCellBG(SystemColors.Highlight, relativeCell);
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
, (Highlight_Color.B + SystemColors.Highlight.B) / 2);
DrawCellBG(Highlight_Color, relativeCell);
}
}
@ -1645,7 +1653,8 @@ namespace BizHawk.Client.EmuHawk
{
DrawWidth = Width;
}
if (NeedsHScrollbar) {
if (NeedsHScrollbar)
{
DrawHeight = Height - HBar.Height;
}
else
@ -1810,12 +1819,12 @@ namespace BizHawk.Client.EmuHawk
/// <summary>
/// A boolean that indicates if the InputRoll is too large vertically and requires a vertical scrollbar.
/// </summary>
private bool NeedsVScrollbar{ get; set; }
private bool NeedsVScrollbar { get; set; }
/// <summary>
/// A boolean that indicates if the InputRoll is too large horizontally and requires a horizontal scrollbar.
/// </summary>
private bool NeedsHScrollbar{ get; set; }
private bool NeedsHScrollbar { get; set; }
/// <summary>
/// Updates the width of the supplied column.
@ -1835,7 +1844,8 @@ namespace BizHawk.Client.EmuHawk
/// <returns>A nullable Int representing total width.</returns>
private int? TotalColWidth
{
get{
get
{
if (_columns.VisibleColumns.Any())
{
return _columns.VisibleColumns.Last().Right;
@ -1983,7 +1993,7 @@ namespace BizHawk.Client.EmuHawk
public new void AddRange(IEnumerable<RollColumn> collection)
{
foreach(var column in collection)
foreach (var column in collection)
{
if (this.Any(c => c.Name == column.Name))
{

View File

@ -104,6 +104,8 @@ namespace BizHawk.Client.EmuHawk
this.TasView = new BizHawk.Client.EmuHawk.InputRoll();
this.TasStatusStrip = new StatusStripEx();
this.MessageStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.SavingProgressBar = new System.Windows.Forms.ToolStripProgressBar();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.SplicerStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.TasPlaybackBox = new BizHawk.Client.EmuHawk.PlaybackBox();
this.MarkerControl = new BizHawk.Client.EmuHawk.MarkerControl();
@ -131,8 +133,6 @@ 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.SavingProgressBar = new System.Windows.Forms.ToolStripProgressBar();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.TASMenu.SuspendLayout();
this.TasStatusStrip.SuspendLayout();
this.MarkerContextMenu.SuspendLayout();
@ -748,6 +748,17 @@ namespace BizHawk.Client.EmuHawk
this.MessageStatusLabel.Size = new System.Drawing.Size(105, 17);
this.MessageStatusLabel.Text = "TAStudio engaged";
//
// SavingProgressBar
//
this.SavingProgressBar.Name = "SavingProgressBar";
this.SavingProgressBar.Size = new System.Drawing.Size(100, 16);
//
// toolStripStatusLabel2
//
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(109, 17);
this.toolStripStatusLabel2.Spring = true;
//
// SplicerStatusLabel
//
this.SplicerStatusLabel.Name = "SplicerStatusLabel";
@ -969,17 +980,6 @@ namespace BizHawk.Client.EmuHawk
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Markers";
//
// SavingProgressBar
//
this.SavingProgressBar.Name = "SavingProgressBar";
this.SavingProgressBar.Size = new System.Drawing.Size(100, 16);
//
// toolStripStatusLabel2
//
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(109, 17);
this.toolStripStatusLabel2.Spring = true;
//
// TAStudio
//
this.AllowDrop = true;

View File

@ -17,6 +17,10 @@ namespace BizHawk.Client.EmuHawk
private bool _startMarkerDrag;
private bool _startFrameDrag;
private bool _supressContextMenu;
// SuuperW: For editing analog input
private string _floatEditColumn = string.Empty;
private int _floatEditRow = -1;
private string _floatTypedValue;
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
@ -35,6 +39,7 @@ namespace BizHawk.Client.EmuHawk
public static Color LagZone_Invalidated_InputLog = Color.FromArgb(0xF7E5E5);
public static Color Marker_FrameCol = Color.FromArgb(0xF7FFC9);
public static Color AnalogEdit_Col = Color.FromArgb(0x909070); // SuuperW: When editing an analog value, it will be a gray color.
#region Query callbacks
@ -80,6 +85,8 @@ namespace BizHawk.Client.EmuHawk
return;
}
if (columnName == FrameColumnName)
{
if (Emulator.Frame == index)
@ -103,6 +110,12 @@ namespace BizHawk.Client.EmuHawk
}
else
{
// SuuperW: Analog editing is indicated by a color change.
if (index == _floatEditRow && columnName == _floatEditColumn)
{
color = AnalogEdit_Col;
return;
}
if (Emulator.Frame == index)
{
color = CurrentFrame_InputLog;
@ -216,8 +229,20 @@ namespace BizHawk.Client.EmuHawk
return;
}
if (TasView.CurrentCell != null && TasView.CurrentCell.RowIndex.HasValue && TasView.CurrentCell.Column != null)
// SuuperW: Moved these.
if (TasView.CurrentCell == null || !TasView.CurrentCell.RowIndex.HasValue || TasView.CurrentCell.Column == null)
return;
var frame = TasView.CurrentCell.RowIndex.Value;
var buttonName = TasView.CurrentCell.Column.Name;
// SuuperW: Exit float editing mode
if (_floatEditColumn != buttonName || _floatEditRow != frame)
{
_floatEditRow = -1;
TasView.Refresh();
}
if (e.Button == MouseButtons.Left)
{
if (TasView.CurrentCell.Column.Name == MarkerColumnName)
@ -231,9 +256,6 @@ namespace BizHawk.Client.EmuHawk
}
else // User changed input
{
var frame = TasView.CurrentCell.RowIndex.Value;
var buttonName = TasView.CurrentCell.Column.Name;
if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
{
ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
@ -249,7 +271,7 @@ namespace BizHawk.Client.EmuHawk
}
else
{
Global.ClickyVirtualPadController.IsPressed(buttonName);
_boolPaintState = Global.ClickyVirtualPadController.IsPressed(buttonName);
}
}
@ -257,7 +279,6 @@ namespace BizHawk.Client.EmuHawk
{
_startFloatDrawColumn = buttonName;
float _floatPaintState = 0; // SuuperW: This variable isn't used, and hides another.
if (frame < CurrentTasMovie.InputLogLength)
{
_floatPaintState = CurrentTasMovie.GetFloatValue(frame, buttonName);
@ -268,24 +289,6 @@ namespace BizHawk.Client.EmuHawk
}
}
}
//else if (e.Button == System.Windows.Forms.MouseButtons.Right)
//{ // SuuperW: This will be a simple way to 'toggle' float values.
// if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
// {
// ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
// _triggerAutoRestore = true;
// _triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
// RefreshDialog();
// }
// else
// {
// ToggleFloatState(frame, buttonName);
// _triggerAutoRestore = true;
// _triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
// RefreshDialog();
// }
//}
}
}
}
@ -327,9 +330,12 @@ namespace BizHawk.Client.EmuHawk
private void TasView_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
var buttonName = TasView.CurrentCell.Column.Name;
if (TasView.CurrentCell.RowIndex.HasValue &&
TasView.CurrentCell.Column.Name == FrameColumnName &&
e.Button == MouseButtons.Left)
buttonName == FrameColumnName)
{
if (Settings.EmptyMarkers)
{
@ -341,10 +347,34 @@ namespace BizHawk.Client.EmuHawk
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)
{
// SuuperW: Will this allow TasView to see KeyDown?
TasView.Select();
// Temporary test code
TasView.Refresh();
// TODO: think about nullability
// 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
@ -407,8 +437,6 @@ namespace BizHawk.Client.EmuHawk
{
if (i < CurrentTasMovie.InputLogLength) // TODO: how do we really want to handle the user setting the float state of the pending frame?
{
// Temp SuuperW
_floatPaintState = 0.5f;
CurrentTasMovie.SetFloatState(i, _startFloatDrawColumn, _floatPaintState); // Notice it uses new row, old column, you can only paint across a single column
_triggerAutoRestore = true;
_triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
@ -447,8 +475,82 @@ namespace BizHawk.Client.EmuHawk
{
TasView.HorizontalOrientation ^= true;
}
// SuuperW: Float Editing
if (_floatEditRow != -1)
{
float value = CurrentTasMovie.GetFloatValue(_floatEditRow, _floatEditColumn);
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 (e.KeyCode == Keys.Right) // No arrow key presses are being detected. Why?
value = range.Max;
else if (e.KeyCode == Keys.Left)
value = range.Min;
else if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)
{
_floatTypedValue += e.KeyCode - Keys.D0;
value = Convert.ToSingle(_floatTypedValue);
}
else if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
{
_floatTypedValue += e.KeyCode - Keys.NumPad0;
value = Convert.ToSingle(_floatTypedValue);
}
else if (e.KeyCode == Keys.OemPeriod && !_floatTypedValue.Contains('.'))
{
if (_floatTypedValue == "")
_floatTypedValue = "0";
_floatTypedValue += ".";
}
else if (e.KeyCode == Keys.OemMinus && _floatTypedValue == "")
_floatTypedValue = "-";
else if (e.KeyCode == Keys.Back)
{
if (_floatTypedValue == "") // Very first key press is backspace?
_floatTypedValue = value.ToString();
_floatTypedValue = _floatTypedValue.Substring(0, _floatTypedValue.Length - 1);
if (_floatTypedValue == "" || _floatTypedValue == "-")
value = 0f;
else
value = Convert.ToSingle(_floatTypedValue);
}
else if (e.KeyCode == Keys.Escape)
{
_floatEditRow = -1;
}
else
{
// This needs some way to know what the increment is. (Does the emulator allow, say, 25.8?)
float changeBy = 0;
if (e.KeyCode == Keys.Up)
changeBy = 1; // This is where I'd put increment
else if (e.KeyCode == Keys.Down)
changeBy = -1;
if (e.Shift)
changeBy *= 10;
value += changeBy;
}
if (_floatEditRow != -1 && value != CurrentTasMovie.GetFloatValue(_floatEditRow, _floatEditColumn))
{
if (value > rMax)
value = rMax;
else if (value < rMin)
value = rMin;
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
}
}
TasView.Refresh();
}
#endregion
}
}

View File

@ -397,7 +397,7 @@ namespace BizHawk.Client.EmuHawk
message += list.Count() + " none, Clipboard: ";
}
message += _tasClipboard.Any() ? _tasClipboard.Count + " rows 0 col": "empty";
message += _tasClipboard.Any() ? _tasClipboard.Count + " rows 0 col" : "empty";
SplicerStatusLabel.Text = message;
}
@ -475,22 +475,22 @@ 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, 1.0f);
// else
// CurrentTasMovie.SetFloatState(frame, buttonName, 0f);
// }
// else if (frame == Emulator.Frame && frame == CurrentTasMovie.InputLogLength)
// {
// // Global.ClickyVirtualPadController.Toggle(buttonName);
// }
//}
// 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()
@ -577,7 +577,7 @@ namespace BizHawk.Client.EmuHawk
private void Tastudio_Load(object sender, EventArgs e)
{
if(!InitializeOnLoad())
if (!InitializeOnLoad())
{
Close();
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;