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

@ -99,13 +99,13 @@ namespace BizHawk.Client.EmuHawk
protected override void Dispose(bool disposing)
{
Gdi.Dispose();
this.NormalFont.Dispose();
GDIRenderer.DestroyHFont(RotatedFont);
base.Dispose(disposing);
}
#region Properties
/// <summary>
@ -133,16 +133,18 @@ 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
{
if (_horizontalOrientation != value)
{
_horizontalOrientation = value;
OrientationChanged();
if (_horizontalOrientation != value)
{
_horizontalOrientation = value;
OrientationChanged();
}
}
}
@ -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)]
@ -450,7 +452,7 @@ namespace BizHawk.Client.EmuHawk
get
{
return _maxCharactersInHorizontal;
}
}
set
{
_maxCharactersInHorizontal = value;
@ -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?
}
@ -621,7 +623,7 @@ namespace BizHawk.Client.EmuHawk
public string RotateHotkeyStr
{
get { return "Ctrl+Shift+F"; }
get { return "Ctrl+Shift+F"; }
}
#endregion
@ -686,9 +688,9 @@ namespace BizHawk.Client.EmuHawk
if (HorizontalOrientation)
{
int start = 0;
Gdi.PrepDrawString(this.RotatedFont, this.ForeColor);
foreach (var column in columns)
{
var point = new Point(CellWidthPadding, start + CellHeightPadding);
@ -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);
}
}
@ -1516,7 +1524,7 @@ namespace BizHawk.Client.EmuHawk
LastCell = CurrentCell;
CurrentCell = newCell;
if (PointedCellChanged != null &&
if (PointedCellChanged != null &&
(LastCell.Column != CurrentCell.Column || LastCell.RowIndex != CurrentCell.RowIndex))
{
PointedCellChanged(this, new CellEventArgs(LastCell, CurrentCell));
@ -1637,20 +1645,21 @@ namespace BizHawk.Client.EmuHawk
private void UpdateDrawSize()
{
if (NeedsVScrollbar)
if (NeedsVScrollbar)
{
DrawWidth = Width - VBar.Width;
DrawWidth = Width - VBar.Width;
}
else
{
DrawWidth = Width;
}
if (NeedsHScrollbar) {
if (NeedsHScrollbar)
{
DrawHeight = Height - HBar.Height;
}
else
{
DrawHeight = Height;
DrawHeight = Height;
}
}
@ -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.
@ -1834,8 +1843,9 @@ namespace BizHawk.Client.EmuHawk
/// </summary>
/// <returns>A nullable Int representing total width.</returns>
private int? TotalColWidth
{
get{
{
get
{
if (_columns.VisibleColumns.Any())
{
return _columns.VisibleColumns.Last().Right;
@ -1873,7 +1883,7 @@ namespace BizHawk.Client.EmuHawk
return (index * CellWidth) + ColumnWidth;
}
return (index * CellHeight) + ColumnHeight;
return (index * CellHeight) + ColumnHeight;
}
/// <summary>
@ -1917,7 +1927,7 @@ namespace BizHawk.Client.EmuHawk
private void UpdateCellSize()
{
CellHeight = _charSize.Height + (CellHeightPadding * 2);
CellWidth = (_charSize.Width * MaxCharactersInHorizontal) + (CellWidthPadding * 4); // Double the padding for horizontal because it looks better
CellWidth = (_charSize.Width * MaxCharactersInHorizontal) + (CellWidthPadding * 4); // Double the padding for horizontal because it looks better
}
#endregion
@ -1933,7 +1943,7 @@ namespace BizHawk.Client.EmuHawk
return this.SingleOrDefault(column => column.Name == name);
}
}
public IEnumerable<RollColumn> VisibleColumns
{
get
@ -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))
{

File diff suppressed because it is too large Load Diff

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,75 +229,65 @@ 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)
{
if (e.Button == MouseButtons.Left)
_floatEditRow = -1;
TasView.Refresh();
}
if (e.Button == MouseButtons.Left)
{
if (TasView.CurrentCell.Column.Name == MarkerColumnName)
{
if (TasView.CurrentCell.Column.Name == MarkerColumnName)
_startMarkerDrag = true;
GoToFrame(TasView.CurrentCell.RowIndex.Value);
}
else if (TasView.CurrentCell.Column.Name == FrameColumnName)
{
_startFrameDrag = true;
}
else // User changed input
{
if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
{
_startMarkerDrag = true;
GoToFrame(TasView.CurrentCell.RowIndex.Value);
}
else if (TasView.CurrentCell.Column.Name == FrameColumnName)
{
_startFrameDrag = true;
}
else // User changed input
{
var frame = TasView.CurrentCell.RowIndex.Value;
var buttonName = TasView.CurrentCell.Column.Name;
ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
_triggerAutoRestore = true;
_triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
RefreshDialog();
if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
_startBoolDrawColumn = buttonName;
if (frame < CurrentTasMovie.InputLogLength)
{
ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
_triggerAutoRestore = true;
_triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
RefreshDialog();
_startBoolDrawColumn = buttonName;
if (frame < CurrentTasMovie.InputLogLength)
{
_boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
}
else
{
Global.ClickyVirtualPadController.IsPressed(buttonName);
}
_boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
}
else
{
_startFloatDrawColumn = buttonName;
_boolPaintState = Global.ClickyVirtualPadController.IsPressed(buttonName);
}
float _floatPaintState = 0; // SuuperW: This variable isn't used, and hides another.
if (frame < CurrentTasMovie.InputLogLength)
{
_floatPaintState = CurrentTasMovie.GetFloatValue(frame, buttonName);
}
else
{
_floatPaintState = Global.ClickyVirtualPadController.GetFloat(buttonName);
}
}
else
{
_startFloatDrawColumn = buttonName;
if (frame < CurrentTasMovie.InputLogLength)
{
_floatPaintState = CurrentTasMovie.GetFloatValue(frame, buttonName);
}
else
{
_floatPaintState = Global.ClickyVirtualPadController.GetFloat(buttonName);
}
}
//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,24 +330,51 @@ namespace BizHawk.Client.EmuHawk
private void TasView_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (TasView.CurrentCell.RowIndex.HasValue &&
TasView.CurrentCell.Column.Name == FrameColumnName &&
e.Button == MouseButtons.Left)
if (e.Button == MouseButtons.Left)
{
if (Settings.EmptyMarkers)
var buttonName = TasView.CurrentCell.Column.Name;
if (TasView.CurrentCell.RowIndex.HasValue &&
buttonName == FrameColumnName)
{
CurrentTasMovie.Markers.Add(TasView.CurrentCell.RowIndex.Value, string.Empty);
RefreshDialog();
if (Settings.EmptyMarkers)
{
CurrentTasMovie.Markers.Add(TasView.CurrentCell.RowIndex.Value, string.Empty);
RefreshDialog();
}
else
{
CallAddMarkerPopUp(TasView.CurrentCell.RowIndex.Value);
}
}
else
{
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

@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk
private readonly List<TasClipboardEntry> _tasClipboard = new List<TasClipboardEntry>();
private BackgroundWorker _saveBackgroundWorker;
private BackgroundWorker _saveBackgroundWorker;
private MovieEndAction _originalEndAction; // The movie end behavior selected by the user (that is overridden by TAStudio)
private Dictionary<string, string> GenerateColumnNames()
@ -67,38 +67,38 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent();
Settings = new TAStudioSettings();
// TODO: show this at all times or hide it when saving is done?
this.SavingProgressBar.Visible = false;
_saveBackgroundWorker = new BackgroundWorker();
_saveBackgroundWorker.WorkerReportsProgress = true;
_saveBackgroundWorker.DoWork += (s, e) =>
{
this.Invoke(() => this.MessageStatusLabel.Text = "Saving " + Path.GetFileName(CurrentTasMovie.Filename) + "...");
this.Invoke(() => this.SavingProgressBar.Visible = true);
CurrentTasMovie.Save();
};
// TODO: show this at all times or hide it when saving is done?
this.SavingProgressBar.Visible = false;
_saveBackgroundWorker.ProgressChanged += (s, e) =>
{
SavingProgressBar.Value = e.ProgressPercentage;
};
_saveBackgroundWorker = new BackgroundWorker();
_saveBackgroundWorker.WorkerReportsProgress = true;
_saveBackgroundWorker.DoWork += (s, e) =>
{
this.Invoke(() => this.MessageStatusLabel.Text = "Saving " + Path.GetFileName(CurrentTasMovie.Filename) + "...");
this.Invoke(() => this.SavingProgressBar.Visible = true);
CurrentTasMovie.Save();
};
_saveBackgroundWorker.RunWorkerCompleted += (s, e) =>
{
this.Invoke(() => this.MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved.");
this.Invoke(() => this.SavingProgressBar.Visible = false);
_saveBackgroundWorker.ProgressChanged += (s, e) =>
{
SavingProgressBar.Value = e.ProgressPercentage;
};
// SUPER HACKY, and i'm not even sure it's necessary
Timer t = new Timer();
t.Tick += (a, b) =>
{
this.Invoke(() => this.MessageStatusLabel.Text = "TAStudio engaged.");
t.Stop();
};
t.Interval = 5000;
t.Start();
};
_saveBackgroundWorker.RunWorkerCompleted += (s, e) =>
{
this.Invoke(() => this.MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved.");
this.Invoke(() => this.SavingProgressBar.Visible = false);
// SUPER HACKY, and i'm not even sure it's necessary
Timer t = new Timer();
t.Tick += (a, b) =>
{
this.Invoke(() => this.MessageStatusLabel.Text = "TAStudio engaged.");
t.Stop();
};
t.Interval = 5000;
t.Start();
};
WantsToControlStopMovie = true;
TasPlaybackBox.Tastudio = this;
@ -112,7 +112,7 @@ namespace BizHawk.Client.EmuHawk
TasView.MultiSelect = true;
TasView.MaxCharactersInHorizontal = 1;
WantsToControlRestartMovie = true;
}
private void TastudioToStopMovie()
@ -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()
@ -539,7 +539,7 @@ namespace BizHawk.Client.EmuHawk
_triggerAutoRestore = false;
_triggerAutoRestoreFromFrame = null;
}
}
@ -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;
@ -706,7 +706,7 @@ namespace BizHawk.Client.EmuHawk
{
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}