2014-07-09 23:04:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
2014-07-28 16:43:47 +00:00
|
|
|
|
using System.Linq;
|
2014-07-09 23:04:22 +00:00
|
|
|
|
using System.Windows.Forms;
|
2015-03-19 19:55:38 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-07-09 23:04:22 +00:00
|
|
|
|
|
2015-03-19 19:55:38 +00:00
|
|
|
|
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
2015-07-16 18:57:51 +00:00
|
|
|
|
using BizHawk.Common.NumberExtensions;
|
2014-07-09 23:04:22 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
|
|
|
|
{
|
|
|
|
|
public partial class TAStudio
|
|
|
|
|
{
|
2014-07-11 16:08:47 +00:00
|
|
|
|
// Input Painting
|
2014-07-11 16:26:19 +00:00
|
|
|
|
private string _startBoolDrawColumn = string.Empty;
|
|
|
|
|
private string _startFloatDrawColumn = string.Empty;
|
2014-07-11 16:08:47 +00:00
|
|
|
|
private bool _boolPaintState;
|
2014-07-11 16:26:19 +00:00
|
|
|
|
private float _floatPaintState;
|
2016-11-13 13:42:24 +00:00
|
|
|
|
private float _floatBackupState;
|
2015-03-23 22:11:55 +00:00
|
|
|
|
private bool _patternPaint = false;
|
2015-07-13 17:37:12 +00:00
|
|
|
|
private bool _startCursorDrag;
|
2015-11-22 09:44:24 +00:00
|
|
|
|
private bool _startSelectionDrag;
|
|
|
|
|
private bool _selectionDragState;
|
2014-10-17 18:14:21 +00:00
|
|
|
|
private bool _supressContextMenu;
|
2016-11-20 14:11:20 +00:00
|
|
|
|
|
2015-02-24 06:47:32 +00:00
|
|
|
|
// SuuperW: For editing analog input
|
|
|
|
|
private string _floatEditColumn = string.Empty;
|
|
|
|
|
private int _floatEditRow = -1;
|
2016-11-20 14:11:20 +00:00
|
|
|
|
private string _floatTypedValue;
|
|
|
|
|
private int _floatEditYPos = -1;
|
2016-05-07 12:04:42 +00:00
|
|
|
|
private int floatEditRow
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_floatEditRow = value;
|
|
|
|
|
TasView.suspendHotkeys = FloatEditingMode;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-20 14:11:20 +00:00
|
|
|
|
public bool FloatEditingMode
|
|
|
|
|
{
|
|
|
|
|
get { return _floatEditRow != -1; }
|
|
|
|
|
}
|
|
|
|
|
private List<int> _extraFloatRows = new List<int>();
|
|
|
|
|
|
2015-03-03 18:22:54 +00:00
|
|
|
|
// Right-click dragging
|
|
|
|
|
private string[] _rightClickInput = null;
|
|
|
|
|
private string[] _rightClickOverInput = null;
|
|
|
|
|
private int _rightClickFrame = -1;
|
|
|
|
|
private int _rightClickLastFrame = -1;
|
2015-11-22 09:44:24 +00:00
|
|
|
|
private bool _rightClickShift, _rightClickControl, _rightClickAlt;
|
2015-03-03 18:22:54 +00:00
|
|
|
|
private bool _leftButtonHeld = false;
|
|
|
|
|
private bool mouseButtonHeld
|
|
|
|
|
{
|
2016-11-20 14:11:20 +00:00
|
|
|
|
get { return _rightClickFrame != -1 || _leftButtonHeld; }
|
2015-03-03 18:22:54 +00:00
|
|
|
|
}
|
2014-07-11 16:08:47 +00:00
|
|
|
|
|
2014-10-17 20:10:21 +00:00
|
|
|
|
private bool _triggerAutoRestore; // If true, autorestore will be called on mouse up
|
2015-07-15 19:26:56 +00:00
|
|
|
|
private bool? _autoRestorePaused = null;
|
2015-12-09 22:38:06 +00:00
|
|
|
|
private int? _seekStartFrame = null;
|
2016-08-03 19:29:27 +00:00
|
|
|
|
private bool _wasRecording = false;
|
2015-12-12 20:59:55 +00:00
|
|
|
|
|
2016-11-20 14:11:20 +00:00
|
|
|
|
private Emulation.Common.ControllerDefinition controllerType
|
2016-12-12 18:30:32 +00:00
|
|
|
|
{ get { return Global.MovieSession.MovieControllerAdapter.Definition; } }
|
2016-11-20 14:11:20 +00:00
|
|
|
|
|
|
|
|
|
public AutoPatternBool[] BoolPatterns;
|
|
|
|
|
public AutoPatternFloat[] FloatPatterns;
|
|
|
|
|
|
2015-07-15 19:26:56 +00:00
|
|
|
|
private void JumpToGreenzone()
|
|
|
|
|
{
|
2016-12-04 18:30:51 +00:00
|
|
|
|
if (Emulator.Frame > CurrentTasMovie.LastValidFrame)
|
2015-07-15 19:26:56 +00:00
|
|
|
|
{
|
|
|
|
|
GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastValidFrame);
|
|
|
|
|
}
|
2016-11-26 21:28:52 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_triggerAutoRestore = false;
|
|
|
|
|
}
|
2015-07-15 19:26:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-27 22:08:43 +00:00
|
|
|
|
private void StartSeeking(int? frame)
|
2015-12-12 20:59:55 +00:00
|
|
|
|
{
|
|
|
|
|
if (!frame.HasValue)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-11-26 17:02:54 +00:00
|
|
|
|
if (Mainform.PauseOnFrame != null)
|
|
|
|
|
StopSeeking();
|
|
|
|
|
|
2015-12-12 20:59:55 +00:00
|
|
|
|
_seekStartFrame = Emulator.Frame;
|
2016-08-29 16:38:36 +00:00
|
|
|
|
Mainform.PauseOnFrame = frame.Value;
|
|
|
|
|
int? diff = Mainform.PauseOnFrame - _seekStartFrame;
|
2015-12-12 20:59:55 +00:00
|
|
|
|
|
2016-08-29 16:38:36 +00:00
|
|
|
|
Mainform.UnpauseEmulator();
|
2015-12-12 20:59:55 +00:00
|
|
|
|
|
2016-04-17 18:02:21 +00:00
|
|
|
|
if (!_seekBackgroundWorker.IsBusy && diff.Value > TasView.VisibleRows)
|
2015-12-12 20:59:55 +00:00
|
|
|
|
_seekBackgroundWorker.RunWorkerAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void StopSeeking()
|
|
|
|
|
{
|
|
|
|
|
_seekBackgroundWorker.CancelAsync();
|
2016-08-03 19:29:27 +00:00
|
|
|
|
if (_wasRecording)
|
|
|
|
|
{
|
|
|
|
|
TastudioRecordMode();
|
|
|
|
|
_wasRecording = false;
|
|
|
|
|
}
|
2016-11-21 20:59:12 +00:00
|
|
|
|
Mainform.PauseOnFrame = null;
|
2016-09-09 16:15:00 +00:00
|
|
|
|
if (CurrentTasMovie != null)
|
|
|
|
|
RefreshDialog();
|
2015-12-12 20:59:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-20 14:11:20 +00:00
|
|
|
|
#region Query callbacks
|
2016-05-07 12:04:42 +00:00
|
|
|
|
|
2015-03-19 19:55:38 +00:00
|
|
|
|
// public static Color CurrentFrame_FrameCol = Color.FromArgb(0xCFEDFC); Why?
|
2016-08-28 14:13:14 +00:00
|
|
|
|
public static Color CurrentFrame_InputLog = Color.FromArgb(0x00B5E7F7);
|
|
|
|
|
public static Color SeekFrame_InputLog = Color.FromArgb(0x70B5E7F7);
|
2014-07-16 00:10:37 +00:00
|
|
|
|
|
2014-07-21 02:23:47 +00:00
|
|
|
|
public static Color GreenZone_FrameCol = Color.FromArgb(0xDDFFDD);
|
2016-11-20 14:11:20 +00:00
|
|
|
|
public static Color GreenZone_InputLog = Color.FromArgb(0xD2F9D3);
|
|
|
|
|
public static Color GreenZone_InputLog_Stated = Color.FromArgb(0xC4F7C8);
|
2015-08-24 17:51:48 +00:00
|
|
|
|
public static Color GreenZone_InputLog_Invalidated = Color.FromArgb(0xE0FBE0);
|
2014-07-16 00:10:37 +00:00
|
|
|
|
|
2014-07-21 02:23:47 +00:00
|
|
|
|
public static Color LagZone_FrameCol = Color.FromArgb(0xFFDCDD);
|
2016-11-20 14:11:20 +00:00
|
|
|
|
public static Color LagZone_InputLog = Color.FromArgb(0xF4DADA);
|
|
|
|
|
public static Color LagZone_InputLog_Stated = Color.FromArgb(0xF0D0D2);
|
2015-08-24 17:51:48 +00:00
|
|
|
|
public static Color LagZone_InputLog_Invalidated = Color.FromArgb(0xF7E5E5);
|
2014-07-16 00:10:37 +00:00
|
|
|
|
|
2014-07-21 02:23:47 +00:00
|
|
|
|
public static Color Marker_FrameCol = Color.FromArgb(0xF7FFC9);
|
2015-02-24 06:47:32 +00:00
|
|
|
|
public static Color AnalogEdit_Col = Color.FromArgb(0x909070); // SuuperW: When editing an analog value, it will be a gray color.
|
2014-07-16 00:10:37 +00:00
|
|
|
|
|
2015-09-02 23:00:52 +00:00
|
|
|
|
private Bitmap ts_v_arrow_green_blue = Properties.Resources.ts_v_arrow_green_blue;
|
|
|
|
|
private Bitmap ts_h_arrow_green_blue = Properties.Resources.ts_h_arrow_green_blue;
|
|
|
|
|
private Bitmap ts_v_arrow_blue = Properties.Resources.ts_v_arrow_blue;
|
|
|
|
|
private Bitmap ts_h_arrow_blue = Properties.Resources.ts_h_arrow_blue;
|
|
|
|
|
private Bitmap ts_v_arrow_green = Properties.Resources.ts_v_arrow_green;
|
|
|
|
|
private Bitmap ts_h_arrow_green = Properties.Resources.ts_h_arrow_green;
|
|
|
|
|
|
|
|
|
|
private Bitmap icon_marker = Properties.Resources.icon_marker;
|
|
|
|
|
private Bitmap icon_anchor_lag = Properties.Resources.icon_anchor_lag;
|
|
|
|
|
private Bitmap icon_anchor = Properties.Resources.icon_anchor;
|
|
|
|
|
|
2015-08-24 22:30:45 +00:00
|
|
|
|
private void TasView_QueryItemIcon(int index, InputRoll.RollColumn column, ref Bitmap bitmap, ref int offsetX, ref int offsetY)
|
2014-09-03 03:16:16 +00:00
|
|
|
|
{
|
2015-07-09 16:47:59 +00:00
|
|
|
|
var overrideIcon = GetIconOverride(index, column);
|
|
|
|
|
|
|
|
|
|
if (overrideIcon != null)
|
|
|
|
|
{
|
|
|
|
|
bitmap = overrideIcon;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 19:30:59 +00:00
|
|
|
|
var columnName = column.Name;
|
2014-09-03 03:16:16 +00:00
|
|
|
|
|
2015-07-13 17:37:12 +00:00
|
|
|
|
if (columnName == CursorColumnName)
|
2014-09-03 03:16:16 +00:00
|
|
|
|
{
|
2016-08-29 16:38:36 +00:00
|
|
|
|
if (index == Emulator.Frame && index == Mainform.PauseOnFrame)
|
2014-09-16 19:20:19 +00:00
|
|
|
|
{
|
2014-10-17 18:14:21 +00:00
|
|
|
|
bitmap = TasView.HorizontalOrientation ?
|
2015-09-02 23:00:52 +00:00
|
|
|
|
ts_v_arrow_green_blue :
|
|
|
|
|
ts_h_arrow_green_blue;
|
2014-09-16 19:20:19 +00:00
|
|
|
|
}
|
2014-12-14 01:20:19 +00:00
|
|
|
|
else if (index == Emulator.Frame)
|
2014-09-03 03:16:16 +00:00
|
|
|
|
{
|
2014-10-17 18:14:21 +00:00
|
|
|
|
bitmap = TasView.HorizontalOrientation ?
|
2015-09-02 23:00:52 +00:00
|
|
|
|
ts_v_arrow_blue :
|
|
|
|
|
ts_h_arrow_blue;
|
2014-09-03 03:16:16 +00:00
|
|
|
|
}
|
2016-08-27 22:08:43 +00:00
|
|
|
|
else if (index == LastPositionFrame)
|
2014-09-16 19:20:19 +00:00
|
|
|
|
{
|
2014-10-17 18:14:21 +00:00
|
|
|
|
bitmap = TasView.HorizontalOrientation ?
|
2015-09-02 23:00:52 +00:00
|
|
|
|
ts_v_arrow_green :
|
|
|
|
|
ts_h_arrow_green;
|
2014-09-16 19:20:19 +00:00
|
|
|
|
}
|
2014-09-03 03:16:16 +00:00
|
|
|
|
}
|
2015-08-30 16:45:14 +00:00
|
|
|
|
else if (columnName == FrameColumnName)
|
2015-08-24 22:30:45 +00:00
|
|
|
|
{
|
|
|
|
|
TasMovieRecord record = CurrentTasMovie[index];
|
2015-08-30 16:45:14 +00:00
|
|
|
|
offsetX = -3;
|
|
|
|
|
offsetY = 1;
|
|
|
|
|
|
2016-11-17 17:25:06 +00:00
|
|
|
|
if (CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithIcons)
|
2015-09-02 23:00:52 +00:00
|
|
|
|
bitmap = icon_marker;
|
2016-11-17 17:25:06 +00:00
|
|
|
|
else if (record.HasState && Settings.DenoteStatesWithIcons)
|
2015-08-24 22:30:45 +00:00
|
|
|
|
{
|
2015-08-30 16:45:14 +00:00
|
|
|
|
if (record.Lagged.HasValue && record.Lagged.Value)
|
2015-09-02 23:00:52 +00:00
|
|
|
|
bitmap = icon_anchor_lag;
|
2015-08-30 16:45:14 +00:00
|
|
|
|
else
|
2015-09-02 23:00:52 +00:00
|
|
|
|
bitmap = icon_anchor;
|
2015-08-24 22:30:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-03 03:16:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 19:30:59 +00:00
|
|
|
|
private void TasView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2015-07-23 17:55:22 +00:00
|
|
|
|
Color? overrideColor = GetColorOverride(index, column);
|
2015-07-01 23:01:29 +00:00
|
|
|
|
|
|
|
|
|
if (overrideColor.HasValue)
|
|
|
|
|
{
|
|
|
|
|
color = overrideColor.Value;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-19 19:55:38 +00:00
|
|
|
|
string columnName = column.Name;
|
2015-08-24 17:51:48 +00:00
|
|
|
|
|
2015-07-13 17:37:12 +00:00
|
|
|
|
if (columnName == CursorColumnName)
|
2015-08-24 17:51:48 +00:00
|
|
|
|
color = Color.FromArgb(0xFEFFFF);
|
|
|
|
|
|
2014-07-16 23:04:56 +00:00
|
|
|
|
if (columnName == FrameColumnName)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2016-11-17 17:25:06 +00:00
|
|
|
|
if (Emulator.Frame != index && CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithBGColor)
|
2014-07-16 00:10:37 +00:00
|
|
|
|
color = Marker_FrameCol;
|
2016-12-04 18:30:51 +00:00
|
|
|
|
else
|
|
|
|
|
color = Color.FromArgb(0x60FFFFFF);
|
2015-03-19 19:55:38 +00:00
|
|
|
|
}
|
2016-11-20 14:11:20 +00:00
|
|
|
|
else if (FloatEditingMode &&
|
|
|
|
|
(index == _floatEditRow || _extraFloatRows.Contains(index)) &&
|
|
|
|
|
columnName == _floatEditColumn)
|
2015-03-19 19:55:38 +00:00
|
|
|
|
{ // SuuperW: Analog editing is indicated by a color change.
|
|
|
|
|
color = AnalogEdit_Col;
|
|
|
|
|
}
|
2015-07-23 17:55:22 +00:00
|
|
|
|
|
2016-12-04 18:30:51 +00:00
|
|
|
|
int player = Emulator.ControllerDefinition.PlayerNumber(columnName);
|
2015-07-23 17:55:22 +00:00
|
|
|
|
if (player != 0 && player % 2 == 0)
|
2015-08-30 16:45:14 +00:00
|
|
|
|
color = Color.FromArgb(0x0D000000);
|
2015-03-19 19:55:38 +00:00
|
|
|
|
}
|
2016-08-27 22:08:43 +00:00
|
|
|
|
|
2015-03-19 19:55:38 +00:00
|
|
|
|
private void TasView_QueryRowBkColor(int index, ref Color color)
|
|
|
|
|
{
|
|
|
|
|
TasMovieRecord record = CurrentTasMovie[index];
|
|
|
|
|
|
2016-08-29 16:38:36 +00:00
|
|
|
|
if (Mainform.IsSeeking && Mainform.PauseOnFrame == index)
|
2016-08-28 14:13:14 +00:00
|
|
|
|
{
|
|
|
|
|
color = CurrentFrame_InputLog;
|
|
|
|
|
}
|
2016-08-29 16:38:36 +00:00
|
|
|
|
else if (!Mainform.IsSeeking && Emulator.Frame == index)
|
2015-03-19 19:55:38 +00:00
|
|
|
|
{
|
|
|
|
|
color = CurrentFrame_InputLog;
|
|
|
|
|
}
|
|
|
|
|
else if (record.Lagged.HasValue)
|
|
|
|
|
{
|
2016-11-17 17:25:06 +00:00
|
|
|
|
if (!record.HasState && Settings.DenoteStatesWithBGColor)
|
2015-08-24 17:51:48 +00:00
|
|
|
|
color = record.Lagged.Value ?
|
|
|
|
|
LagZone_InputLog :
|
|
|
|
|
GreenZone_InputLog;
|
2015-08-30 16:45:14 +00:00
|
|
|
|
else
|
|
|
|
|
color = record.Lagged.Value ?
|
|
|
|
|
LagZone_InputLog_Stated :
|
|
|
|
|
GreenZone_InputLog_Stated;
|
2015-03-19 19:55:38 +00:00
|
|
|
|
}
|
|
|
|
|
else if (record.WasLagged.HasValue)
|
|
|
|
|
{
|
2016-09-04 09:03:12 +00:00
|
|
|
|
color = record.WasLagged.Value ?
|
|
|
|
|
LagZone_InputLog_Invalidated :
|
|
|
|
|
GreenZone_InputLog_Invalidated;
|
2014-07-16 00:10:37 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-03-19 19:55:38 +00:00
|
|
|
|
color = Color.FromArgb(0xFFFEEE);
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 22:30:45 +00:00
|
|
|
|
private void TasView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2015-07-01 23:46:14 +00:00
|
|
|
|
var overrideText = GetTextOverride(index, column);
|
|
|
|
|
if (overrideText != null)
|
|
|
|
|
{
|
|
|
|
|
text = overrideText;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-09 23:04:22 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2014-07-16 23:04:56 +00:00
|
|
|
|
text = string.Empty;
|
2014-10-13 19:10:11 +00:00
|
|
|
|
var columnName = column.Name;
|
2014-07-09 23:04:22 +00:00
|
|
|
|
|
2015-07-13 17:37:12 +00:00
|
|
|
|
if (columnName == CursorColumnName)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2015-09-16 16:40:50 +00:00
|
|
|
|
int branchIndex = CurrentTasMovie.BranchIndexByFrame(index);
|
2015-08-13 13:30:43 +00:00
|
|
|
|
if (branchIndex != -1)
|
2015-07-29 23:45:51 +00:00
|
|
|
|
{
|
2015-08-13 13:30:43 +00:00
|
|
|
|
text = branchIndex.ToString();
|
2015-07-29 23:45:51 +00:00
|
|
|
|
}
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
else if (columnName == FrameColumnName)
|
|
|
|
|
{
|
2015-08-24 22:30:45 +00:00
|
|
|
|
offsetX = 7;
|
2014-10-20 19:04:59 +00:00
|
|
|
|
text = (index).ToString().PadLeft(CurrentTasMovie.InputLogLength.ToString().Length, '0');
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-01-29 18:22:28 +00:00
|
|
|
|
// Display typed float value (string "-" can't be parsed, so CurrentTasMovie.DisplayValue can't return it)
|
|
|
|
|
if (index == _floatEditRow && columnName == _floatEditColumn)
|
|
|
|
|
text = _floatTypedValue;
|
|
|
|
|
else if (index < CurrentTasMovie.InputLogLength)
|
2016-11-19 16:31:04 +00:00
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
text = CurrentTasMovie.DisplayValue(index, columnName);
|
2016-11-19 16:31:04 +00:00
|
|
|
|
if (column.Type == InputRoll.RollColumn.InputType.Float)
|
|
|
|
|
{
|
|
|
|
|
// feos: this could be cashed, but I don't notice any slowdown this way either
|
2016-12-12 18:30:32 +00:00
|
|
|
|
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
|
|
|
|
|
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(columnName)];
|
2016-11-19 16:31:04 +00:00
|
|
|
|
if (text == range.Mid.ToString())
|
|
|
|
|
text = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
text = string.Empty;
|
|
|
|
|
MessageBox.Show("oops\n" + ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-24 19:00:12 +00:00
|
|
|
|
// SuuperW: Used in InputRoll.cs to hide lag frames.
|
2015-03-10 17:11:29 +00:00
|
|
|
|
private bool TasView_QueryFrameLag(int index, bool hideWasLag)
|
2015-02-24 19:00:12 +00:00
|
|
|
|
{
|
2015-03-10 17:11:29 +00:00
|
|
|
|
TasMovieRecord lag = CurrentTasMovie[index];
|
|
|
|
|
return (lag.Lagged.HasValue && lag.Lagged.Value) || (hideWasLag && lag.WasLagged.HasValue && lag.WasLagged.Value);
|
2015-02-24 19:00:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-09 23:04:22 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Events
|
|
|
|
|
|
2014-10-14 00:31:59 +00:00
|
|
|
|
private void TasView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e)
|
2014-07-28 16:43:47 +00:00
|
|
|
|
{
|
2015-07-26 03:42:50 +00:00
|
|
|
|
if (TasView.AnyRowsSelected)
|
2014-07-28 16:43:47 +00:00
|
|
|
|
{
|
2014-10-14 00:31:59 +00:00
|
|
|
|
var columnName = e.Column.Name;
|
2014-07-28 16:43:47 +00:00
|
|
|
|
|
|
|
|
|
if (columnName == FrameColumnName)
|
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
CurrentTasMovie.Markers.Add(TasView.LastSelectedIndex.Value, "");
|
2014-09-19 01:15:14 +00:00
|
|
|
|
RefreshDialog();
|
2014-07-28 16:43:47 +00:00
|
|
|
|
}
|
2015-07-13 17:37:12 +00:00
|
|
|
|
else if (columnName != CursorColumnName) // TODO: what about float?
|
2014-07-28 16:43:47 +00:00
|
|
|
|
{
|
2014-08-30 18:42:14 +00:00
|
|
|
|
foreach (var index in TasView.SelectedRows)
|
2014-07-28 16:43:47 +00:00
|
|
|
|
{
|
2015-03-10 04:16:42 +00:00
|
|
|
|
CurrentTasMovie.ToggleBoolState(index, columnName);
|
2014-10-17 20:10:21 +00:00
|
|
|
|
_triggerAutoRestore = true;
|
2014-07-28 16:43:47 +00:00
|
|
|
|
}
|
2015-07-15 19:26:56 +00:00
|
|
|
|
JumpToGreenzone();
|
2014-07-28 16:43:47 +00:00
|
|
|
|
|
|
|
|
|
RefreshDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-14 00:31:59 +00:00
|
|
|
|
private void TasView_ColumnRightClick(object sender, InputRoll.ColumnClickEventArgs e)
|
2014-09-25 17:52:21 +00:00
|
|
|
|
{
|
2014-10-14 00:31:59 +00:00
|
|
|
|
e.Column.Emphasis ^= true;
|
2014-09-25 17:52:21 +00:00
|
|
|
|
|
2015-03-08 04:42:04 +00:00
|
|
|
|
UpdateAutoFire(e.Column.Name, e.Column.Emphasis);
|
2014-09-25 18:12:18 +00:00
|
|
|
|
|
2015-03-03 06:56:45 +00:00
|
|
|
|
RefreshTasView();
|
2014-09-25 17:52:21 +00:00
|
|
|
|
}
|
2015-03-08 04:42:04 +00:00
|
|
|
|
private void UpdateAutoFire()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 2; i < TasView.AllColumns.Count; i++)
|
|
|
|
|
UpdateAutoFire(TasView.AllColumns[i].Name, TasView.AllColumns[i].Emphasis);
|
|
|
|
|
}
|
|
|
|
|
public void UpdateAutoFire(string button, bool? isOn)
|
|
|
|
|
{
|
|
|
|
|
if (!isOn.HasValue) // No value means don't change whether it's on or off.
|
|
|
|
|
isOn = TasView.AllColumns.Find(c => c.Name == button).Emphasis;
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
if (autoHoldToolStripMenuItem.Checked) index = 1;
|
|
|
|
|
if (autoFireToolStripMenuItem.Checked) index = 2;
|
|
|
|
|
if (controllerType.BoolButtons.Contains(button))
|
|
|
|
|
{
|
|
|
|
|
if (index == 0)
|
|
|
|
|
index = controllerType.BoolButtons.IndexOf(button);
|
|
|
|
|
else
|
|
|
|
|
index += controllerType.BoolButtons.Count - 1;
|
|
|
|
|
AutoPatternBool p = BoolPatterns[index];
|
2015-10-03 14:36:07 +00:00
|
|
|
|
Global.AutofireStickyXORAdapter.SetSticky(button, isOn.Value, p);
|
2015-03-08 04:42:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (index == 0)
|
|
|
|
|
index = controllerType.FloatControls.IndexOf(button);
|
|
|
|
|
else
|
|
|
|
|
index += controllerType.FloatControls.Count - 1;
|
|
|
|
|
float? value = null;
|
|
|
|
|
if (isOn.Value) value = 0f;
|
|
|
|
|
AutoPatternFloat p = FloatPatterns[index];
|
2015-10-03 14:36:07 +00:00
|
|
|
|
Global.AutofireStickyXORAdapter.SetFloat(button, value, p);
|
2015-03-08 04:42:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-25 17:52:21 +00:00
|
|
|
|
|
2014-10-19 14:46:01 +00:00
|
|
|
|
private void TasView_ColumnReordered(object sender, InputRoll.ColumnReorderedEventArgs e)
|
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
CurrentTasMovie.FlagChanges();
|
2014-10-19 14:46:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-17 17:40:11 +00:00
|
|
|
|
private void TasView_MouseEnter(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-03-14 16:38:07 +00:00
|
|
|
|
if (this.ContainsFocus)
|
|
|
|
|
TasView.Focus();
|
2014-10-17 17:40:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-09 23:04:22 +00:00
|
|
|
|
private void TasView_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2015-03-03 18:22:54 +00:00
|
|
|
|
// Clicking with left while right is held or vice versa does weird stuff
|
|
|
|
|
if (mouseButtonHeld)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-07-17 20:35:12 +00:00
|
|
|
|
if (e.Button == MouseButtons.Middle)
|
|
|
|
|
{
|
2016-08-29 16:38:36 +00:00
|
|
|
|
if (Mainform.EmulatorPaused)
|
2016-08-27 22:08:43 +00:00
|
|
|
|
{
|
|
|
|
|
TasMovieRecord record = CurrentTasMovie[LastPositionFrame];
|
2016-12-04 18:30:51 +00:00
|
|
|
|
if (!record.Lagged.HasValue && LastPositionFrame > Emulator.Frame)
|
2016-08-27 22:08:43 +00:00
|
|
|
|
StartSeeking(LastPositionFrame);
|
|
|
|
|
else
|
2016-08-29 16:38:36 +00:00
|
|
|
|
Mainform.UnpauseEmulator();
|
2016-08-27 22:08:43 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-08-29 16:38:36 +00:00
|
|
|
|
Mainform.PauseEmulator();
|
2016-08-27 22:08:43 +00:00
|
|
|
|
}
|
2014-07-17 20:35:12 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-24 06:47:32 +00:00
|
|
|
|
// SuuperW: Moved these.
|
|
|
|
|
if (TasView.CurrentCell == null || !TasView.CurrentCell.RowIndex.HasValue || TasView.CurrentCell.Column == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-03-23 22:11:55 +00:00
|
|
|
|
int frame = TasView.CurrentCell.RowIndex.Value;
|
|
|
|
|
string buttonName = TasView.CurrentCell.Column.Name;
|
2015-02-24 06:47:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2016-08-27 22:08:43 +00:00
|
|
|
|
bool wasHeld = _leftButtonHeld;
|
2015-03-03 18:22:54 +00:00
|
|
|
|
_leftButtonHeld = true;
|
2015-02-25 21:17:50 +00:00
|
|
|
|
// SuuperW: Exit float editing mode, or re-enter mouse editing
|
2016-11-20 14:11:20 +00:00
|
|
|
|
if (FloatEditingMode)
|
2015-02-25 21:17:50 +00:00
|
|
|
|
{
|
2016-11-20 14:11:20 +00:00
|
|
|
|
if (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
_extraFloatRows.Clear();
|
|
|
|
|
_extraFloatRows.AddRange(TasView.SelectedRows);
|
|
|
|
|
_startSelectionDrag = true;
|
|
|
|
|
_selectionDragState = TasView.SelectedRows.Contains(frame);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (_floatEditColumn != buttonName ||
|
|
|
|
|
!(_floatEditRow == frame || _extraFloatRows.Contains(frame)))
|
2015-02-25 21:17:50 +00:00
|
|
|
|
{
|
2016-11-20 14:11:20 +00:00
|
|
|
|
_extraFloatRows.Clear();
|
2016-05-07 12:04:42 +00:00
|
|
|
|
floatEditRow = -1;
|
2015-03-03 06:56:45 +00:00
|
|
|
|
RefreshTasView();
|
2015-02-25 21:17:50 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-11-20 14:11:20 +00:00
|
|
|
|
if (_extraFloatRows.Contains(frame))
|
|
|
|
|
{
|
|
|
|
|
_extraFloatRows.Clear();
|
|
|
|
|
floatEditRow = frame;
|
|
|
|
|
RefreshTasView();
|
|
|
|
|
}
|
2015-02-25 21:17:50 +00:00
|
|
|
|
_floatEditYPos = e.Y;
|
2015-03-10 04:16:42 +00:00
|
|
|
|
_floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
|
2015-03-12 18:31:28 +00:00
|
|
|
|
_triggerAutoRestore = true;
|
2015-07-15 19:26:56 +00:00
|
|
|
|
JumpToGreenzone();
|
2015-02-25 21:17:50 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-13 17:37:12 +00:00
|
|
|
|
if (TasView.CurrentCell.Column.Name == CursorColumnName)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2015-07-13 17:37:12 +00:00
|
|
|
|
_startCursorDrag = true;
|
2015-02-24 06:47:32 +00:00
|
|
|
|
GoToFrame(TasView.CurrentCell.RowIndex.Value);
|
|
|
|
|
}
|
|
|
|
|
else if (TasView.CurrentCell.Column.Name == FrameColumnName)
|
|
|
|
|
{
|
2015-08-06 17:24:56 +00:00
|
|
|
|
if (Control.ModifierKeys == Keys.Alt && CurrentTasMovie.Markers.IsMarker(frame))
|
2015-07-29 00:03:03 +00:00
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
TasView.DragCurrentCell();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-11-22 09:44:24 +00:00
|
|
|
|
_startSelectionDrag = true;
|
|
|
|
|
_selectionDragState = TasView.SelectedRows.Contains(frame);
|
2015-07-29 00:03:03 +00:00
|
|
|
|
}
|
2015-02-24 06:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
else // User changed input
|
|
|
|
|
{
|
2016-08-29 16:38:36 +00:00
|
|
|
|
bool wasPaused = Mainform.EmulatorPaused;
|
2016-08-27 22:08:43 +00:00
|
|
|
|
|
2016-12-12 18:30:32 +00:00
|
|
|
|
if (Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(buttonName))
|
2014-07-11 16:26:19 +00:00
|
|
|
|
{
|
2015-07-26 01:15:35 +00:00
|
|
|
|
CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame);
|
2015-03-03 18:22:54 +00:00
|
|
|
|
|
2015-03-10 04:16:42 +00:00
|
|
|
|
CurrentTasMovie.ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
|
2015-02-24 06:47:32 +00:00
|
|
|
|
_triggerAutoRestore = true;
|
2015-07-15 19:26:56 +00:00
|
|
|
|
JumpToGreenzone();
|
2015-02-24 06:47:32 +00:00
|
|
|
|
RefreshDialog();
|
2014-07-14 01:49:37 +00:00
|
|
|
|
|
2015-02-24 06:47:32 +00:00
|
|
|
|
_startBoolDrawColumn = buttonName;
|
2014-07-14 01:49:37 +00:00
|
|
|
|
|
2015-03-10 04:16:42 +00:00
|
|
|
|
_boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
|
2015-03-23 22:11:55 +00:00
|
|
|
|
if (applyPatternToPaintedInputToolStripMenuItem.Checked &&
|
|
|
|
|
(!onlyOnAutoFireColumnsToolStripMenuItem.Checked || TasView.CurrentCell.Column.Emphasis))
|
|
|
|
|
{
|
|
|
|
|
BoolPatterns[controllerType.BoolButtons.IndexOf(buttonName)].Reset();
|
|
|
|
|
BoolPatterns[controllerType.BoolButtons.IndexOf(buttonName)].GetNextValue();
|
|
|
|
|
_patternPaint = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
_patternPaint = false;
|
2016-06-13 15:29:29 +00:00
|
|
|
|
|
|
|
|
|
if (!Settings.AutoRestoreOnMouseUpOnly)
|
|
|
|
|
DoTriggeredAutoRestoreIfNeeded();
|
2015-02-24 06:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-03-10 04:16:42 +00:00
|
|
|
|
if (frame >= CurrentTasMovie.InputLogLength)
|
2015-02-27 19:06:02 +00:00
|
|
|
|
{
|
2015-03-10 04:16:42 +00:00
|
|
|
|
CurrentTasMovie.SetFloatState(frame, buttonName, 0);
|
|
|
|
|
RefreshDialog();
|
2015-02-27 19:06:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-15 19:26:56 +00:00
|
|
|
|
JumpToGreenzone();
|
2015-03-12 18:31:28 +00:00
|
|
|
|
|
2015-03-10 04:16:42 +00:00
|
|
|
|
_floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
|
2015-03-23 22:11:55 +00:00
|
|
|
|
if (applyPatternToPaintedInputToolStripMenuItem.Checked &&
|
|
|
|
|
(!onlyOnAutoFireColumnsToolStripMenuItem.Checked || TasView.CurrentCell.Column.Emphasis))
|
|
|
|
|
{
|
|
|
|
|
FloatPatterns[controllerType.FloatControls.IndexOf(buttonName)].Reset();
|
|
|
|
|
CurrentTasMovie.SetFloatState(frame, buttonName,
|
|
|
|
|
FloatPatterns[controllerType.FloatControls.IndexOf(buttonName)].GetNextValue());
|
|
|
|
|
_patternPaint = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
_patternPaint = false;
|
|
|
|
|
|
2015-03-10 04:16:42 +00:00
|
|
|
|
|
2016-11-12 14:52:53 +00:00
|
|
|
|
if (e.Clicks != 2 && !Settings.SingleClickFloatEdit)
|
2015-02-24 06:47:32 +00:00
|
|
|
|
{
|
2015-07-26 01:15:35 +00:00
|
|
|
|
CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Float " + buttonName + " from frame " + frame);
|
2015-02-25 21:17:50 +00:00
|
|
|
|
_startFloatDrawColumn = buttonName;
|
2014-07-14 01:49:37 +00:00
|
|
|
|
}
|
2015-02-25 21:17:50 +00:00
|
|
|
|
else // Double-click enters float editing mode
|
2014-07-14 01:49:37 +00:00
|
|
|
|
{
|
2015-02-25 21:17:50 +00:00
|
|
|
|
if (_floatEditColumn == buttonName && _floatEditRow == frame)
|
2016-05-07 12:04:42 +00:00
|
|
|
|
floatEditRow = -1;
|
2015-02-25 21:17:50 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2015-03-04 19:03:00 +00:00
|
|
|
|
CurrentTasMovie.ChangeLog.BeginNewBatch("Float Edit: " + frame);
|
2015-02-25 21:17:50 +00:00
|
|
|
|
_floatEditColumn = buttonName;
|
2016-05-07 12:04:42 +00:00
|
|
|
|
floatEditRow = frame;
|
2015-02-25 21:17:50 +00:00
|
|
|
|
_floatTypedValue = "";
|
|
|
|
|
_floatEditYPos = e.Y;
|
2016-11-13 13:42:24 +00:00
|
|
|
|
_floatBackupState = CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn);
|
2015-02-25 21:17:50 +00:00
|
|
|
|
}
|
2015-02-27 19:06:02 +00:00
|
|
|
|
RefreshDialog();
|
2014-07-14 01:49:37 +00:00
|
|
|
|
}
|
2014-07-11 16:26:19 +00:00
|
|
|
|
}
|
2016-07-10 19:25:02 +00:00
|
|
|
|
|
|
|
|
|
// taseditor behavior
|
|
|
|
|
if (!wasPaused)
|
2016-08-29 16:38:36 +00:00
|
|
|
|
Mainform.UnpauseEmulator();
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-03 18:22:54 +00:00
|
|
|
|
else if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
|
|
|
|
{
|
2015-03-10 05:12:13 +00:00
|
|
|
|
if (TasView.CurrentCell.Column.Name == FrameColumnName && frame < CurrentTasMovie.InputLogLength)
|
2015-03-03 18:22:54 +00:00
|
|
|
|
{
|
|
|
|
|
_rightClickControl = (Control.ModifierKeys | Keys.Control) == Control.ModifierKeys;
|
|
|
|
|
_rightClickShift = (Control.ModifierKeys | Keys.Shift) == Control.ModifierKeys;
|
2015-11-22 09:44:24 +00:00
|
|
|
|
_rightClickAlt = (Control.ModifierKeys | Keys.Alt) == Control.ModifierKeys;
|
2015-03-03 18:22:54 +00:00
|
|
|
|
if (TasView.SelectedRows.Contains(frame))
|
|
|
|
|
{
|
|
|
|
|
_rightClickInput = new string[TasView.SelectedRows.Count()];
|
|
|
|
|
_rightClickFrame = TasView.FirstSelectedIndex.Value;
|
2016-11-17 17:05:41 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CurrentTasMovie.GetLogEntries().CopyTo(_rightClickFrame, _rightClickInput, 0, TasView.SelectedRows.Count());
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
2015-03-03 18:22:54 +00:00
|
|
|
|
if (_rightClickControl && _rightClickShift)
|
|
|
|
|
_rightClickFrame += _rightClickInput.Length;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_rightClickInput = new string[1];
|
|
|
|
|
_rightClickInput[0] = CurrentTasMovie.GetLogEntries()[frame];
|
|
|
|
|
_rightClickFrame = frame;
|
|
|
|
|
}
|
|
|
|
|
_rightClickLastFrame = -1;
|
2015-03-12 18:31:28 +00:00
|
|
|
|
|
2015-11-22 09:44:24 +00:00
|
|
|
|
if (_rightClickAlt || _rightClickControl || _rightClickShift)
|
2015-07-16 19:39:33 +00:00
|
|
|
|
{
|
2015-11-22 09:44:24 +00:00
|
|
|
|
JumpToGreenzone();
|
|
|
|
|
// TODO: Turn off ChangeLog.IsRecording and handle the GeneralUndo here.
|
|
|
|
|
string undoStepName = "Right-Click Edit:";
|
|
|
|
|
if (_rightClickShift)
|
|
|
|
|
{
|
|
|
|
|
undoStepName += " Extend Input";
|
|
|
|
|
if (_rightClickControl)
|
|
|
|
|
undoStepName += ", Insert";
|
|
|
|
|
}
|
2015-07-16 19:39:33 +00:00
|
|
|
|
else
|
2015-11-22 09:44:24 +00:00
|
|
|
|
{
|
|
|
|
|
if (_rightClickControl)
|
|
|
|
|
undoStepName += " Copy";
|
|
|
|
|
else // _rightClickAlt
|
|
|
|
|
undoStepName += " Move";
|
|
|
|
|
}
|
|
|
|
|
CurrentTasMovie.ChangeLog.BeginNewBatch(undoStepName);
|
2015-07-16 19:39:33 +00:00
|
|
|
|
}
|
2015-03-03 18:22:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-18 16:33:03 +00:00
|
|
|
|
private void ClearLeftMouseStates()
|
|
|
|
|
{
|
|
|
|
|
_startCursorDrag = false;
|
2015-11-22 09:44:24 +00:00
|
|
|
|
_startSelectionDrag = false;
|
2015-07-18 16:33:03 +00:00
|
|
|
|
_startBoolDrawColumn = string.Empty;
|
|
|
|
|
_startFloatDrawColumn = string.Empty;
|
2015-07-29 00:03:03 +00:00
|
|
|
|
TasView.ReleaseCurrentCell();
|
2015-07-18 16:33:03 +00:00
|
|
|
|
// Exit float editing if value was changed with cursor
|
2016-11-20 14:11:20 +00:00
|
|
|
|
if (FloatEditingMode && _floatPaintState != CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn))
|
2015-07-18 16:33:03 +00:00
|
|
|
|
{
|
2016-05-07 12:04:42 +00:00
|
|
|
|
floatEditRow = -1;
|
2016-11-12 14:52:53 +00:00
|
|
|
|
_triggerAutoRestore = true;
|
|
|
|
|
JumpToGreenzone();
|
|
|
|
|
DoTriggeredAutoRestoreIfNeeded();
|
2015-07-18 16:33:03 +00:00
|
|
|
|
RefreshDialog();
|
|
|
|
|
}
|
|
|
|
|
_floatPaintState = 0;
|
|
|
|
|
_floatEditYPos = -1;
|
|
|
|
|
_leftButtonHeld = false;
|
|
|
|
|
|
2016-11-20 14:11:20 +00:00
|
|
|
|
if (!FloatEditingMode && CurrentTasMovie.ChangeLog != null)
|
2015-07-25 20:36:36 +00:00
|
|
|
|
{
|
2015-07-18 16:33:03 +00:00
|
|
|
|
CurrentTasMovie.ChangeLog.EndBatch();
|
2015-07-25 20:36:36 +00:00
|
|
|
|
}
|
2015-07-18 16:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-09 23:04:22 +00:00
|
|
|
|
private void TasView_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2015-10-04 15:00:04 +00:00
|
|
|
|
if (e.Button == MouseButtons.Right && !TasView.IsPointingAtColumnHeader && !_supressContextMenu && TasView.SelectedRows.Any())
|
2014-10-15 22:52:23 +00:00
|
|
|
|
{
|
2015-10-04 10:39:14 +00:00
|
|
|
|
if (Global.MovieSession.Movie.FrameCount < TasView.SelectedRows.Max())
|
|
|
|
|
{
|
|
|
|
|
// trying to be smart here
|
|
|
|
|
// if a loaded branch log is shorter than selection, keep selection until you attempt to call context menu
|
|
|
|
|
// you might need it when you load again the branch where this frame exists
|
|
|
|
|
TasView.DeselectAll();
|
|
|
|
|
RefreshTasView();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RightClickMenu.Show(TasView, e.X, e.Y);
|
|
|
|
|
}
|
2014-10-15 22:52:23 +00:00
|
|
|
|
}
|
|
|
|
|
else if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
2016-11-20 14:11:20 +00:00
|
|
|
|
if (FloatEditingMode && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift))
|
|
|
|
|
{
|
|
|
|
|
_leftButtonHeld = false;
|
|
|
|
|
_startSelectionDrag = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ClearLeftMouseStates();
|
2015-03-03 18:22:54 +00:00
|
|
|
|
}
|
2015-03-10 05:12:13 +00:00
|
|
|
|
|
|
|
|
|
if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
2015-03-03 18:22:54 +00:00
|
|
|
|
{
|
|
|
|
|
if (_rightClickFrame != -1)
|
|
|
|
|
{
|
|
|
|
|
_rightClickInput = null;
|
2015-07-16 18:57:51 +00:00
|
|
|
|
_rightClickOverInput = null;
|
2015-03-03 18:22:54 +00:00
|
|
|
|
_rightClickFrame = -1;
|
|
|
|
|
CurrentTasMovie.ChangeLog.EndBatch();
|
|
|
|
|
}
|
2014-10-15 22:52:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_supressContextMenu = false;
|
2014-10-17 20:10:21 +00:00
|
|
|
|
|
2014-10-21 01:31:41 +00:00
|
|
|
|
DoTriggeredAutoRestoreIfNeeded();
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-16 01:37:50 +00:00
|
|
|
|
private void TasView_MouseWheel(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2014-08-23 13:14:25 +00:00
|
|
|
|
if (TasView.RightButtonHeld && TasView.CurrentCell.RowIndex.HasValue)
|
2014-07-16 01:37:50 +00:00
|
|
|
|
{
|
2014-10-15 22:52:23 +00:00
|
|
|
|
_supressContextMenu = true;
|
2015-10-25 17:48:51 +00:00
|
|
|
|
int notch = e.Delta / 120;
|
2016-08-27 22:08:43 +00:00
|
|
|
|
if (notch > 1)
|
|
|
|
|
notch *= 2;
|
2015-10-25 17:48:51 +00:00
|
|
|
|
|
2016-08-29 16:38:36 +00:00
|
|
|
|
// warning: tastudio rewind hotkey/button logic is copypasted from here!
|
|
|
|
|
if (Mainform.IsSeeking && !Mainform.EmulatorPaused)
|
2014-07-16 01:37:50 +00:00
|
|
|
|
{
|
2016-08-29 16:38:36 +00:00
|
|
|
|
Mainform.PauseOnFrame -= notch;
|
2016-08-27 22:08:43 +00:00
|
|
|
|
// that's a weird condition here, but for whatever reason it works best
|
2016-12-04 18:30:51 +00:00
|
|
|
|
if (notch > 0 && Emulator.Frame >= Mainform.PauseOnFrame)
|
2015-07-15 20:11:32 +00:00
|
|
|
|
{
|
2016-08-29 16:38:36 +00:00
|
|
|
|
Mainform.PauseEmulator();
|
|
|
|
|
Mainform.PauseOnFrame = null;
|
2016-08-27 22:08:43 +00:00
|
|
|
|
StopSeeking();
|
|
|
|
|
GoToFrame(Emulator.Frame - notch);
|
2015-07-15 20:11:32 +00:00
|
|
|
|
}
|
2016-06-13 11:14:10 +00:00
|
|
|
|
RefreshDialog();
|
2014-07-16 01:37:50 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-10-25 17:48:51 +00:00
|
|
|
|
GoToFrame(Emulator.Frame - notch);
|
2014-07-16 01:37:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TasView_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2017-01-04 17:16:34 +00:00
|
|
|
|
if (TasView.CurrentCell.Column == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-02-24 06:47:32 +00:00
|
|
|
|
if (e.Button == MouseButtons.Left)
|
2014-07-16 01:37:50 +00:00
|
|
|
|
{
|
2015-02-24 06:47:32 +00:00
|
|
|
|
if (TasView.CurrentCell.RowIndex.HasValue &&
|
2017-01-19 20:24:41 +00:00
|
|
|
|
TasView.CurrentCell.Column.Name == FrameColumnName &&
|
2016-11-20 14:11:20 +00:00
|
|
|
|
!FloatEditingMode)
|
2014-10-15 16:09:14 +00:00
|
|
|
|
{
|
2017-01-19 20:24:41 +00:00
|
|
|
|
var existingMarker = CurrentTasMovie.Markers.FirstOrDefault(m => m.Frame == TasView.CurrentCell.RowIndex.Value);
|
|
|
|
|
|
|
|
|
|
if (existingMarker != null)
|
2015-02-24 06:47:32 +00:00
|
|
|
|
{
|
2017-01-19 20:24:41 +00:00
|
|
|
|
MarkerControl.EditMarkerPopUp(existingMarker, true);
|
2015-02-24 06:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-01-19 20:24:41 +00:00
|
|
|
|
if (Settings.EmptyMarkers)
|
|
|
|
|
{
|
|
|
|
|
CurrentTasMovie.Markers.Add(TasView.CurrentCell.RowIndex.Value, string.Empty);
|
|
|
|
|
RefreshDialog();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ClearLeftMouseStates();
|
|
|
|
|
MarkerControl.AddMarker(false, TasView.CurrentCell.RowIndex.Value);
|
|
|
|
|
}
|
2015-02-24 06:47:32 +00:00
|
|
|
|
}
|
2014-10-15 16:09:14 +00:00
|
|
|
|
}
|
2014-07-16 01:37:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-23 15:19:48 +00:00
|
|
|
|
private void TasView_PointedCellChanged(object sender, InputRoll.CellEventArgs e)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2014-08-23 15:19:48 +00:00
|
|
|
|
// 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
|
|
|
|
|
if (e.OldCell == null || e.OldCell.Column == null || e.OldCell.RowIndex == null ||
|
|
|
|
|
e.NewCell == null || e.NewCell.RowIndex == null || e.NewCell.Column == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
2015-08-06 17:03:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// skip rerecord counting on drawing entirely, mouse down is enough
|
|
|
|
|
// avoid introducing another global
|
|
|
|
|
bool wasCountingRerecords = Global.MovieSession.Movie.IsCountingRerecords;
|
2014-08-23 15:19:48 +00:00
|
|
|
|
|
2014-07-11 16:08:47 +00:00
|
|
|
|
int startVal, endVal;
|
2015-03-03 18:22:54 +00:00
|
|
|
|
int frame = e.NewCell.RowIndex.Value;
|
2014-08-23 13:14:25 +00:00
|
|
|
|
if (e.OldCell.RowIndex.Value < e.NewCell.RowIndex.Value)
|
2014-07-11 16:08:47 +00:00
|
|
|
|
{
|
2014-08-23 13:14:25 +00:00
|
|
|
|
startVal = e.OldCell.RowIndex.Value;
|
|
|
|
|
endVal = e.NewCell.RowIndex.Value;
|
2014-07-11 16:08:47 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-08-23 13:14:25 +00:00
|
|
|
|
startVal = e.NewCell.RowIndex.Value;
|
|
|
|
|
endVal = e.OldCell.RowIndex.Value;
|
2014-07-11 16:08:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-09 15:46:05 +00:00
|
|
|
|
if (_startCursorDrag && !Mainform.IsSeeking)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2014-08-23 13:14:25 +00:00
|
|
|
|
if (e.NewCell.RowIndex.HasValue)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2014-08-23 13:14:25 +00:00
|
|
|
|
GoToFrame(e.NewCell.RowIndex.Value);
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-22 09:44:24 +00:00
|
|
|
|
else if (_startSelectionDrag)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2014-08-23 13:14:25 +00:00
|
|
|
|
if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2015-03-01 19:29:33 +00:00
|
|
|
|
for (var i = startVal; i <= endVal; i++)
|
2014-07-09 23:04:22 +00:00
|
|
|
|
{
|
2015-11-22 09:44:24 +00:00
|
|
|
|
TasView.SelectRow(i, _selectionDragState);
|
2016-11-20 14:11:20 +00:00
|
|
|
|
if (FloatEditingMode && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift))
|
|
|
|
|
{
|
|
|
|
|
if (_selectionDragState)
|
|
|
|
|
_extraFloatRows.Add(i);
|
|
|
|
|
else
|
|
|
|
|
_extraFloatRows.Remove(i);
|
|
|
|
|
}
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
2016-04-17 10:52:58 +00:00
|
|
|
|
SetSplicer();
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-10 05:12:13 +00:00
|
|
|
|
|
2015-03-03 18:22:54 +00:00
|
|
|
|
else if (_rightClickFrame != -1)
|
|
|
|
|
{
|
|
|
|
|
if (frame > CurrentTasMovie.InputLogLength - _rightClickInput.Length)
|
|
|
|
|
frame = CurrentTasMovie.InputLogLength - _rightClickInput.Length;
|
|
|
|
|
if (_rightClickShift)
|
|
|
|
|
{
|
|
|
|
|
if (_rightClickControl) // Insert
|
|
|
|
|
{
|
|
|
|
|
// If going backwards, delete!
|
|
|
|
|
bool shouldInsert = true;
|
|
|
|
|
if (startVal < _rightClickFrame)
|
|
|
|
|
{ // Cloning to a previous frame makes no sense.
|
|
|
|
|
startVal = _rightClickFrame - 1;
|
|
|
|
|
}
|
|
|
|
|
if (startVal < _rightClickLastFrame)
|
|
|
|
|
shouldInsert = false;
|
|
|
|
|
|
|
|
|
|
if (shouldInsert)
|
|
|
|
|
{
|
|
|
|
|
for (int i = startVal + 1; i <= endVal; i++)
|
2015-07-16 18:57:51 +00:00
|
|
|
|
CurrentTasMovie.InsertInput(i, _rightClickInput[(i - _rightClickFrame).Mod(_rightClickInput.Length)]);
|
2015-03-03 18:22:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CurrentTasMovie.RemoveFrames(startVal + 1, endVal + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_rightClickLastFrame = frame;
|
|
|
|
|
}
|
|
|
|
|
else // Overwrite
|
|
|
|
|
{
|
|
|
|
|
for (int i = startVal; i <= endVal; i++)
|
2015-07-16 18:57:51 +00:00
|
|
|
|
CurrentTasMovie.SetFrame(i, _rightClickInput[(i - _rightClickFrame).Mod(_rightClickInput.Length)]);
|
2015-03-03 18:22:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (_rightClickControl)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < _rightClickInput.Length; i++) // Re-set initial range, just to verify it's still there.
|
|
|
|
|
CurrentTasMovie.SetFrame(_rightClickFrame + i, _rightClickInput[i]);
|
|
|
|
|
|
|
|
|
|
if (_rightClickOverInput != null) // Restore overwritten input from previous movement
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < _rightClickOverInput.Length; i++)
|
|
|
|
|
CurrentTasMovie.SetFrame(_rightClickLastFrame + i, _rightClickOverInput[i]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
_rightClickOverInput = new string[_rightClickInput.Length];
|
|
|
|
|
|
|
|
|
|
_rightClickLastFrame = frame; // Set new restore log
|
|
|
|
|
CurrentTasMovie.GetLogEntries().CopyTo(frame, _rightClickOverInput, 0, _rightClickOverInput.Length);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < _rightClickInput.Length; i++) // Place copied input
|
|
|
|
|
CurrentTasMovie.SetFrame(frame + i, _rightClickInput[i]);
|
|
|
|
|
}
|
2015-11-22 09:44:24 +00:00
|
|
|
|
else if (_rightClickAlt)
|
2015-03-03 18:22:54 +00:00
|
|
|
|
{
|
|
|
|
|
int shiftBy = _rightClickFrame - frame;
|
|
|
|
|
string[] shiftInput = new string[Math.Abs(shiftBy)];
|
|
|
|
|
int shiftFrom = frame;
|
|
|
|
|
if (shiftBy < 0)
|
|
|
|
|
shiftFrom = _rightClickFrame + _rightClickInput.Length;
|
|
|
|
|
|
|
|
|
|
CurrentTasMovie.GetLogEntries().CopyTo(shiftFrom, shiftInput, 0, shiftInput.Length);
|
|
|
|
|
int shiftTo = shiftFrom + (_rightClickInput.Length * Math.Sign(shiftBy));
|
|
|
|
|
for (int i = 0; i < shiftInput.Length; i++)
|
|
|
|
|
CurrentTasMovie.SetFrame(shiftTo + i, shiftInput[i]);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < _rightClickInput.Length; i++)
|
|
|
|
|
CurrentTasMovie.SetFrame(frame + i, _rightClickInput[i]);
|
|
|
|
|
_rightClickFrame = frame;
|
|
|
|
|
}
|
2015-07-15 19:26:56 +00:00
|
|
|
|
}
|
2015-11-22 09:44:24 +00:00
|
|
|
|
if (_rightClickAlt || _rightClickControl || _rightClickShift)
|
|
|
|
|
{
|
|
|
|
|
JumpToGreenzone();
|
|
|
|
|
_triggerAutoRestore = true;
|
|
|
|
|
_supressContextMenu = true;
|
|
|
|
|
}
|
2015-03-03 18:22:54 +00:00
|
|
|
|
}
|
2015-07-24 19:48:36 +00:00
|
|
|
|
// Left-click
|
2014-08-23 13:14:25 +00:00
|
|
|
|
else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startBoolDrawColumn))
|
2014-07-11 16:26:19 +00:00
|
|
|
|
{
|
2015-08-06 17:03:30 +00:00
|
|
|
|
Global.MovieSession.Movie.IsCountingRerecords = false;
|
|
|
|
|
|
2014-08-23 13:14:25 +00:00
|
|
|
|
if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue)
|
2014-07-11 16:26:19 +00:00
|
|
|
|
{
|
2015-07-24 19:48:36 +00:00
|
|
|
|
for (int i = startVal; i <= endVal; i++) // Inclusive on both ends (drawing up or down)
|
2014-07-11 16:26:19 +00:00
|
|
|
|
{
|
2015-03-23 22:11:55 +00:00
|
|
|
|
bool setVal = _boolPaintState;
|
|
|
|
|
if (_patternPaint && _boolPaintState)
|
|
|
|
|
{
|
|
|
|
|
if (CurrentTasMovie[frame].Lagged.HasValue && CurrentTasMovie[frame].Lagged.Value)
|
|
|
|
|
setVal = CurrentTasMovie.BoolIsPressed(i - 1, _startBoolDrawColumn);
|
|
|
|
|
else
|
|
|
|
|
setVal = BoolPatterns[controllerType.BoolButtons.IndexOf(_startBoolDrawColumn)].GetNextValue();
|
|
|
|
|
}
|
|
|
|
|
CurrentTasMovie.SetBoolState(i, _startBoolDrawColumn, setVal); // Notice it uses new row, old column, you can only paint across a single column
|
2015-07-15 19:26:56 +00:00
|
|
|
|
JumpToGreenzone();
|
2014-07-11 16:26:19 +00:00
|
|
|
|
}
|
2016-06-13 15:29:29 +00:00
|
|
|
|
|
|
|
|
|
if (!Settings.AutoRestoreOnMouseUpOnly)
|
|
|
|
|
{
|
|
|
|
|
_triggerAutoRestore = true;
|
|
|
|
|
DoTriggeredAutoRestoreIfNeeded();
|
|
|
|
|
}
|
2014-07-11 16:26:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-10 05:12:13 +00:00
|
|
|
|
|
2014-08-23 13:14:25 +00:00
|
|
|
|
else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startFloatDrawColumn))
|
2015-08-06 17:03:30 +00:00
|
|
|
|
{
|
|
|
|
|
Global.MovieSession.Movie.IsCountingRerecords = false;
|
|
|
|
|
|
2014-08-23 13:14:25 +00:00
|
|
|
|
if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue)
|
2014-07-11 16:08:47 +00:00
|
|
|
|
{
|
2015-07-24 19:48:36 +00:00
|
|
|
|
for (int i = startVal; i <= endVal; i++) // Inclusive on both ends (drawing up or down)
|
2014-07-11 16:08:47 +00:00
|
|
|
|
{
|
2015-03-23 22:11:55 +00:00
|
|
|
|
float setVal = _floatPaintState;
|
|
|
|
|
if (_patternPaint)
|
2014-07-16 23:04:56 +00:00
|
|
|
|
{
|
2015-03-23 22:11:55 +00:00
|
|
|
|
if (CurrentTasMovie[frame].Lagged.HasValue && CurrentTasMovie[frame].Lagged.Value)
|
|
|
|
|
setVal = CurrentTasMovie.GetFloatState(i - 1, _startFloatDrawColumn);
|
|
|
|
|
else
|
|
|
|
|
setVal = FloatPatterns[controllerType.FloatControls.IndexOf(_startFloatDrawColumn)].GetNextValue();
|
2014-07-16 23:04:56 +00:00
|
|
|
|
}
|
2015-07-15 19:26:56 +00:00
|
|
|
|
CurrentTasMovie.SetFloatState(i, _startFloatDrawColumn, setVal); // Notice it uses new row, old column, you can only paint across a single column
|
|
|
|
|
JumpToGreenzone();
|
2014-07-11 16:08:47 +00:00
|
|
|
|
}
|
2016-06-13 15:29:29 +00:00
|
|
|
|
|
|
|
|
|
if (!Settings.AutoRestoreOnMouseUpOnly)
|
|
|
|
|
{
|
|
|
|
|
_triggerAutoRestore = true;
|
|
|
|
|
DoTriggeredAutoRestoreIfNeeded();
|
|
|
|
|
}
|
2014-07-11 16:08:47 +00:00
|
|
|
|
}
|
2015-07-15 19:26:56 +00:00
|
|
|
|
}
|
2015-07-13 21:39:26 +00:00
|
|
|
|
|
2015-08-06 17:03:30 +00:00
|
|
|
|
Global.MovieSession.Movie.IsCountingRerecords = wasCountingRerecords;
|
|
|
|
|
|
2015-07-26 19:54:11 +00:00
|
|
|
|
if (mouseButtonHeld)
|
2015-07-15 19:26:56 +00:00
|
|
|
|
{
|
2015-07-26 00:55:52 +00:00
|
|
|
|
TasView.MakeIndexVisible(TasView.CurrentCell.RowIndex.Value); // todo: limit scrolling speed
|
2015-07-15 19:26:56 +00:00
|
|
|
|
}
|
|
|
|
|
RefreshTasView();
|
2014-07-09 23:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-25 21:17:50 +00:00
|
|
|
|
private void TasView_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// For float editing
|
2016-11-13 13:19:46 +00:00
|
|
|
|
int increment = (_floatEditYPos - e.Y) / 4;
|
2015-02-25 21:17:50 +00:00
|
|
|
|
if (_floatEditYPos == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
float value = _floatPaintState + increment;
|
2016-12-12 18:30:32 +00:00
|
|
|
|
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
|
|
|
|
|
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)];
|
2015-03-01 19:29:33 +00:00
|
|
|
|
// Range for N64 Y axis has max -128 and min 127. That should probably be fixed in ControllerDefinition.cs.
|
|
|
|
|
// SuuperW: I really don't think changing it would break anything, but adelikat isn't so sure.
|
2015-02-25 21:17:50 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2015-03-10 04:16:42 +00:00
|
|
|
|
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
|
2016-11-12 14:52:53 +00:00
|
|
|
|
_floatTypedValue = value.ToString();
|
2015-02-25 21:17:50 +00:00
|
|
|
|
|
2016-11-13 13:19:46 +00:00
|
|
|
|
_triggerAutoRestore = true;
|
|
|
|
|
JumpToGreenzone();
|
|
|
|
|
DoTriggeredAutoRestoreIfNeeded();
|
2015-02-25 21:17:50 +00:00
|
|
|
|
RefreshDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-09 23:04:22 +00:00
|
|
|
|
private void TasView_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SetSplicer();
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-20 20:25:54 +00:00
|
|
|
|
public void AnalogIncrementByOne()
|
2014-07-17 19:57:44 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
if (FloatEditingMode)
|
|
|
|
|
EditAnalogProgrammatically(new KeyEventArgs(Keys.Up));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AnalogDecrementByOne()
|
|
|
|
|
{
|
|
|
|
|
if (FloatEditingMode)
|
|
|
|
|
EditAnalogProgrammatically(new KeyEventArgs(Keys.Down));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AnalogIncrementByTen()
|
|
|
|
|
{
|
|
|
|
|
if (FloatEditingMode)
|
|
|
|
|
EditAnalogProgrammatically(new KeyEventArgs(Keys.Up | Keys.Shift));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AnalogDecrementByTen()
|
|
|
|
|
{
|
|
|
|
|
if (FloatEditingMode)
|
|
|
|
|
EditAnalogProgrammatically(new KeyEventArgs(Keys.Down | Keys.Shift));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AnalogMax()
|
|
|
|
|
{
|
|
|
|
|
if (FloatEditingMode)
|
|
|
|
|
EditAnalogProgrammatically(new KeyEventArgs(Keys.Right));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AnalogMin()
|
|
|
|
|
{
|
|
|
|
|
if (FloatEditingMode)
|
|
|
|
|
EditAnalogProgrammatically(new KeyEventArgs(Keys.Left));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void EditAnalogProgrammatically(KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!FloatEditingMode)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
float value = CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn);
|
|
|
|
|
float prev = value;
|
|
|
|
|
string prevTyped = _floatTypedValue;
|
|
|
|
|
|
2016-12-12 18:30:32 +00:00
|
|
|
|
Emulation.Common.ControllerDefinition.FloatRange range = Global.MovieSession.MovieControllerAdapter.Definition.FloatRanges
|
|
|
|
|
[Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(_floatEditColumn)];
|
2016-11-20 20:25:54 +00:00
|
|
|
|
|
|
|
|
|
float rMax = range.Max;
|
|
|
|
|
float rMin = range.Min;
|
|
|
|
|
// Range for N64 Y axis has max -128 and min 127. That should probably be fixed ControllerDefinition.cs, but I'll put a quick fix here anyway.
|
|
|
|
|
if (rMax < rMin)
|
2014-07-17 19:57:44 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
rMax = range.Min;
|
|
|
|
|
rMin = range.Max;
|
2014-07-17 19:57:44 +00:00
|
|
|
|
}
|
2016-11-20 20:25:54 +00:00
|
|
|
|
|
|
|
|
|
// feos: typing past max digits overwrites existing value, not touching the sign
|
|
|
|
|
// but doesn't handle situations where the range is like -50 through 100, where minimum is negative and has less digits
|
|
|
|
|
// it just uses 3 as maxDigits there too, leaving room for typing impossible values (that are still ignored by the game and then clamped)
|
|
|
|
|
int maxDigits = range.MaxDigits();
|
|
|
|
|
int curDigits = _floatTypedValue.Length;
|
|
|
|
|
string curMinus;
|
|
|
|
|
if (_floatTypedValue.StartsWith("-"))
|
2014-07-17 19:57:44 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
curDigits -= 1;
|
|
|
|
|
curMinus = "-";
|
2014-07-17 19:57:44 +00:00
|
|
|
|
}
|
2016-11-20 20:25:54 +00:00
|
|
|
|
else
|
2015-02-24 06:47:32 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
curMinus = "";
|
|
|
|
|
}
|
2016-11-12 12:30:09 +00:00
|
|
|
|
|
2016-11-20 20:25:54 +00:00
|
|
|
|
if (e.KeyCode == Keys.Right)
|
|
|
|
|
{
|
|
|
|
|
value = rMax;
|
|
|
|
|
_floatTypedValue = value.ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.Left)
|
|
|
|
|
{
|
|
|
|
|
value = rMin;
|
|
|
|
|
_floatTypedValue = value.ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)
|
|
|
|
|
{
|
|
|
|
|
if (curDigits >= maxDigits)
|
|
|
|
|
_floatTypedValue = curMinus;
|
|
|
|
|
_floatTypedValue += e.KeyCode - Keys.D0;
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9)
|
|
|
|
|
{
|
|
|
|
|
if (curDigits >= maxDigits)
|
|
|
|
|
_floatTypedValue = curMinus;
|
|
|
|
|
_floatTypedValue += e.KeyCode - Keys.NumPad0;
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.OemMinus || e.KeyCode == Keys.Subtract)
|
|
|
|
|
{
|
2016-11-12 12:30:09 +00:00
|
|
|
|
if (_floatTypedValue.StartsWith("-"))
|
2016-11-20 20:25:54 +00:00
|
|
|
|
_floatTypedValue = _floatTypedValue.Substring(1);
|
2016-11-12 12:30:09 +00:00
|
|
|
|
else
|
2016-11-20 20:25:54 +00:00
|
|
|
|
_floatTypedValue = "-" + _floatTypedValue;
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.Back)
|
|
|
|
|
{
|
|
|
|
|
if (_floatTypedValue == "") // Very first key press is backspace?
|
2016-11-20 14:11:20 +00:00
|
|
|
|
_floatTypedValue = value.ToString();
|
2016-11-20 20:25:54 +00:00
|
|
|
|
_floatTypedValue = _floatTypedValue.Substring(0, _floatTypedValue.Length - 1);
|
|
|
|
|
if (_floatTypedValue == "" || _floatTypedValue == "-")
|
|
|
|
|
value = 0f;
|
|
|
|
|
else
|
|
|
|
|
value = Convert.ToSingle(_floatTypedValue);
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.Enter)
|
|
|
|
|
{
|
|
|
|
|
if (_floatEditYPos != -1)
|
2016-11-12 12:30:09 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
_floatEditYPos = -1;
|
2016-11-12 12:30:09 +00:00
|
|
|
|
}
|
2016-11-20 20:25:54 +00:00
|
|
|
|
floatEditRow = -1;
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.Escape)
|
|
|
|
|
{
|
|
|
|
|
if (_floatEditYPos != -1)
|
2015-02-24 06:47:32 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
_floatEditYPos = -1;
|
2015-02-24 06:47:32 +00:00
|
|
|
|
}
|
2016-11-20 20:25:54 +00:00
|
|
|
|
if (_floatBackupState != _floatPaintState)
|
2016-11-12 14:52:53 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, _floatBackupState);
|
2016-11-26 16:49:26 +00:00
|
|
|
|
_triggerAutoRestore = Emulator.Frame > _floatEditRow;
|
2016-11-20 20:25:54 +00:00
|
|
|
|
JumpToGreenzone();
|
|
|
|
|
DoTriggeredAutoRestoreIfNeeded();
|
2016-11-12 14:52:53 +00:00
|
|
|
|
}
|
2016-11-20 20:25:54 +00:00
|
|
|
|
floatEditRow = -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
float changeBy = 0;
|
|
|
|
|
if (e.KeyCode == Keys.Up)
|
|
|
|
|
changeBy = 1; // We're assuming for now that ALL float controls should contain integers.
|
|
|
|
|
else if (e.KeyCode == Keys.Down)
|
|
|
|
|
changeBy = -1;
|
|
|
|
|
if (Control.ModifierKeys == Keys.Shift)
|
|
|
|
|
changeBy *= 10;
|
|
|
|
|
value += changeBy;
|
|
|
|
|
if (changeBy != 0)
|
|
|
|
|
_floatTypedValue = value.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!FloatEditingMode)
|
|
|
|
|
CurrentTasMovie.ChangeLog.EndBatch();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (_floatTypedValue == "")
|
2015-02-24 06:47:32 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
if (prevTyped != "")
|
2016-11-13 13:42:24 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
value = 0f;
|
|
|
|
|
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
|
2015-02-25 21:17:50 +00:00
|
|
|
|
}
|
2015-02-24 06:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
if (float.TryParse(_floatTypedValue, out value)) // String "-" can't be parsed.
|
|
|
|
|
{
|
|
|
|
|
if (value > rMax)
|
|
|
|
|
value = rMax;
|
|
|
|
|
else if (value < rMin)
|
|
|
|
|
value = rMin;
|
2015-02-24 20:55:24 +00:00
|
|
|
|
_floatTypedValue = value.ToString();
|
2016-11-20 20:25:54 +00:00
|
|
|
|
CurrentTasMovie.SetFloatState(_floatEditRow, _floatEditColumn, value);
|
|
|
|
|
}
|
2015-02-24 06:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-20 20:25:54 +00:00
|
|
|
|
if (_extraFloatRows.Any())
|
2015-02-24 06:47:32 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
foreach (int row in _extraFloatRows)
|
2015-03-10 04:16:42 +00:00
|
|
|
|
{
|
2016-11-20 20:25:54 +00:00
|
|
|
|
CurrentTasMovie.SetFloatState(row, _floatEditColumn, value);
|
2016-11-20 14:11:20 +00:00
|
|
|
|
}
|
2016-11-20 20:25:54 +00:00
|
|
|
|
}
|
2016-11-20 14:11:20 +00:00
|
|
|
|
|
2016-11-20 20:25:54 +00:00
|
|
|
|
if (value != prev) // Auto-restore
|
|
|
|
|
{
|
2016-11-26 16:49:26 +00:00
|
|
|
|
_triggerAutoRestore = Emulator.Frame > _floatEditRow;
|
2016-11-20 20:25:54 +00:00
|
|
|
|
JumpToGreenzone();
|
|
|
|
|
DoTriggeredAutoRestoreIfNeeded();
|
2015-02-24 06:47:32 +00:00
|
|
|
|
}
|
2016-06-13 11:14:10 +00:00
|
|
|
|
}
|
2016-11-20 20:25:54 +00:00
|
|
|
|
RefreshDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TasView_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Left) // Ctrl + Left
|
|
|
|
|
{
|
|
|
|
|
GoToPreviousMarker();
|
|
|
|
|
}
|
|
|
|
|
else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Right) // Ctrl + Right
|
|
|
|
|
{
|
|
|
|
|
GoToNextMarker();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (FloatEditingMode &&
|
|
|
|
|
e.KeyCode != Keys.Right && e.KeyCode != Keys.Left &&
|
|
|
|
|
e.KeyCode != Keys.Up && e.KeyCode != Keys.Down)
|
|
|
|
|
EditAnalogProgrammatically(e);
|
2015-02-24 06:47:32 +00:00
|
|
|
|
|
2015-03-01 05:47:32 +00:00
|
|
|
|
RefreshDialog();
|
2015-02-24 06:47:32 +00:00
|
|
|
|
}
|
2015-02-24 20:55:24 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This allows arrow keys to be detected by KeyDown.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void TasView_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
|
|
|
|
{
|
2015-03-01 19:29:33 +00:00
|
|
|
|
if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
|
|
|
|
|
e.IsInputKey = true;
|
2015-02-24 20:55:24 +00:00
|
|
|
|
}
|
2014-07-09 23:04:22 +00:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|