Tastudio: drawing stuff, selection, patterns, add column lua function (#1125)

* alt+columnclick draws pattern
* selection: taseditor logic
* shift/ctrl keys restructure to taseditor
shift + up/down: move frame courser up/down by one
shift + pageup/pagedown: move frame courser to next/prev marker
ctrl + left/right: add/remove selection at last selected row
ctrl + shift + left/right: add/remove selection at first selected row
* Alt+drawing pattern
still not working with drawing upwards
* pattern drawing
upwards drawing working except it doesn't update last row.
TODO: Disallow Alt click to focus on menu.
* pattern: last input ignoring fixed
* Lua columnms
TODO: Don't save them into tasproj
* no need to update float edit stuff or cell changes when its not needed
* Shift+clicking draws input from first selected row to clicked cell
* fixed pattern drawing on empty cells
This commit is contained in:
TASeditor 2018-03-08 20:15:47 +01:00 committed by feos
parent 9d95a520f9
commit 6580c2abef
4 changed files with 210 additions and 70 deletions

View File

@ -1106,7 +1106,7 @@ namespace BizHawk.Client.EmuHawk
{
// do marker drag here
}
else if (ModifierKeys == Keys.Shift)
else if (ModifierKeys == Keys.Shift && (CurrentCell.Column.Name == "FrameColumn" || CurrentCell.Column.Type == RollColumn.InputType.Text))
{
if (_selectedItems.Any())
{
@ -1175,11 +1175,11 @@ namespace BizHawk.Client.EmuHawk
SelectCell(CurrentCell);
}
}
else if (ModifierKeys == Keys.Control)
else if (ModifierKeys == Keys.Control && (CurrentCell.Column.Name == "FrameColumn" || CurrentCell.Column.Type == RollColumn.InputType.Text))
{
SelectCell(CurrentCell, toggle: true);
}
else
else if (ModifierKeys != Keys.Shift)
{
var hadIndex = _selectedItems.Any();
_selectedItems.Clear();
@ -1319,6 +1319,7 @@ namespace BizHawk.Client.EmuHawk
{
HorizontalOrientation ^= true;
}
// Scroll
else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.PageUp) // Page Up
{
if (FirstVisibleRow > 0)
@ -1352,6 +1353,23 @@ namespace BizHawk.Client.EmuHawk
LastVisibleRow = RowCount;
Refresh();
}
else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Up
{
if (FirstVisibleRow > 0)
{
FirstVisibleRow--;
Refresh();
}
}
else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Down
{
if (FirstVisibleRow < RowCount - 1)
{
FirstVisibleRow++;
Refresh();
}
}
// Selection courser
else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Ctrl + Up
{
if (SelectedRows.Any() && LetKeysModifySelection)
@ -1374,36 +1392,70 @@ namespace BizHawk.Client.EmuHawk
}
}
}
else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Shift + Up
else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Left) // Ctrl + Left
{
if (SelectedRows.Any() && LetKeysModifySelection)
{
SelectRow(SelectedRows.First() - 1, true);
SelectRow(SelectedRows.Last(), false);
}
}
else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Shift + Down
else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Right) // Ctrl + Right
{
if (SelectedRows.Any() && LetKeysModifySelection)
{
SelectRow(SelectedRows.Last() + 1, true);
}
}
else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Up
else if (e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Left) // Ctrl + Shift + Left
{
if (FirstVisibleRow > 0)
if (SelectedRows.Any() && LetKeysModifySelection)
{
FirstVisibleRow--;
Refresh();
SelectRow(SelectedRows.First() - 1, true);
}
}
else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Down
else if (e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Right) // Ctrl + Shift + Right
{
if (FirstVisibleRow < RowCount - 1)
if (SelectedRows.Any() && LetKeysModifySelection)
{
FirstVisibleRow++;
Refresh();
SelectRow(SelectedRows.First(), false);
}
}
else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.PageUp) // Ctrl + Page Up
{
//jump to above marker with selection courser
if (LetKeysModifySelection)
{
}
}
else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.PageDown) // Ctrl + Page Down
{
//jump to below marker with selection courser
if (LetKeysModifySelection)
{
}
}
else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Home) // Ctrl + Home
{
//move selection courser to frame 0
if (LetKeysModifySelection)
{
DeselectAll();
SelectRow(0, true);
}
}
else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.End) // Ctrl + End
{
//move selection courser to end of movie
if (LetKeysModifySelection)
{
DeselectAll();
SelectRow(RowCount-1, true);
}
}
}
base.OnKeyDown(e);

View File

@ -553,5 +553,14 @@ namespace BizHawk.Client.EmuHawk
if (Engaged())
changeList.Clear();
}
[LuaMethod("addcolumn", "")]
public void AddColumn(string name, string text, int width)
{
if (Engaged())
{
Tastudio.AddColumn(name, text, width, InputRoll.RollColumn.InputType.Text);
}
}
}
}

View File

@ -23,6 +23,7 @@ namespace BizHawk.Client.EmuHawk
private bool _startSelectionDrag;
private bool _selectionDragState;
private bool _supressContextMenu;
private int _startrow;
// Editing analog input
private string _floatEditColumn = "";
@ -367,7 +368,6 @@ namespace BizHawk.Client.EmuHawk
if (columnName == FrameColumnName)
{
CurrentTasMovie.Markers.Add(TasView.LastSelectedIndex.Value, "");
RefreshDialog();
}
else if (columnName != CursorColumnName)
{
@ -375,6 +375,8 @@ namespace BizHawk.Client.EmuHawk
string buttonName = TasView.CurrentCell.Column.Name;
if (Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(buttonName))
{
if (Control.ModifierKeys != Keys.Alt)
{
// nifty taseditor logic
bool allPressed = true;
@ -390,6 +392,15 @@ namespace BizHawk.Client.EmuHawk
CurrentTasMovie.SetBoolStates(frame, TasView.SelectedRows.Count(), buttonName, !allPressed);
}
else
{
BoolPatterns[ControllerType.BoolButtons.IndexOf(buttonName)].Reset();
foreach (var index in TasView.SelectedRows)
{
CurrentTasMovie.SetBoolState(index, buttonName, BoolPatterns[ControllerType.BoolButtons.IndexOf(buttonName)].GetNextValue());
}
}
}
else
{
// feos: there's no default value other than mid, and we can't go arbitrary here, so do nothing for now
// autohold is ignored for float input too for the same reasons: lack of demand + ambiguity
@ -397,8 +408,8 @@ namespace BizHawk.Client.EmuHawk
_triggerAutoRestore = true;
JumpToGreenzone();
RefreshDialog();
}
RefreshDialog();
}
}
@ -582,32 +593,63 @@ namespace BizHawk.Client.EmuHawk
_selectionDragState = TasView.SelectedRows.Contains(frame);
}
}
else // User changed input
else if (TasView.CurrentCell.Column.Type != InputRoll.RollColumn.InputType.Text)// User changed input
{
bool wasPaused = Mainform.EmulatorPaused;
if (Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(buttonName))
{
CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame);
_patternPaint = false;
_startBoolDrawColumn = buttonName;
CurrentTasMovie.ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
if ((Control.ModifierKeys == Keys.Alt && Control.ModifierKeys != Keys.Shift) || (applyPatternToPaintedInputToolStripMenuItem.Checked && (!onlyOnAutoFireColumnsToolStripMenuItem.Checked
|| TasView.CurrentCell.Column.Emphasis)))
{
BoolPatterns[ControllerType.BoolButtons.IndexOf(buttonName)].Reset();
//BoolPatterns[ControllerType.BoolButtons.IndexOf(buttonName)].GetNextValue();
_patternPaint = true;
_startrow = TasView.CurrentCell.RowIndex.Value;
_boolPaintState = !CurrentTasMovie.BoolIsPressed(frame, buttonName);
}
else if (Control.ModifierKeys == Keys.Shift && Control.ModifierKeys != Keys.Alt)
{
int firstSel = TasView.SelectedRows.First();
if (frame <= firstSel)
{
firstSel = frame;
frame = TasView.SelectedRows.First();
}
bool allPressed = true;
for (int i = firstSel; i <= frame; i++)
{
if ((i == CurrentTasMovie.FrameCount) // last movie frame can't have input, but can be selected
|| (!CurrentTasMovie.BoolIsPressed(i, buttonName)))
{
allPressed = false;
break;
}
}
CurrentTasMovie.SetBoolStates(firstSel, (frame - firstSel) + 1, buttonName, !allPressed);
_boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
_triggerAutoRestore = true;
JumpToGreenzone();
RefreshDialog();
_startBoolDrawColumn = buttonName;
_boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
if (applyPatternToPaintedInputToolStripMenuItem.Checked && (!onlyOnAutoFireColumnsToolStripMenuItem.Checked
|| TasView.CurrentCell.Column.Emphasis))
}
else if (Control.ModifierKeys == Keys.Shift && Control.ModifierKeys == Keys.Alt) //Does not work?
{
BoolPatterns[ControllerType.BoolButtons.IndexOf(buttonName)].Reset();
BoolPatterns[ControllerType.BoolButtons.IndexOf(buttonName)].GetNextValue();
_patternPaint = true;
// TODO: Pattern drawing from selection to current cell
}
else
{
_patternPaint = false;
CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame);
CurrentTasMovie.ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
_boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
_triggerAutoRestore = true;
JumpToGreenzone();
RefreshDialog();
}
if (!Settings.AutoRestoreOnMouseUpOnly)
@ -888,6 +930,11 @@ namespace BizHawk.Client.EmuHawk
return;
}
if (!MouseButtonHeld)
{
return;
}
// skip rerecord counting on drawing entirely, mouse down is enough
// avoid introducing another global
bool wasCountingRerecords = Global.MovieSession.Movie.IsCountingRerecords;
@ -899,11 +946,19 @@ namespace BizHawk.Client.EmuHawk
{
startVal = e.OldCell.RowIndex.Value;
endVal = e.NewCell.RowIndex.Value;
if (_patternPaint)
{
endVal--;
}
}
else
{
startVal = e.NewCell.RowIndex.Value;
endVal = e.OldCell.RowIndex.Value;
if(_patternPaint)
{
endVal = _startrow;
}
}
if (_startCursorDrag && !Mainform.IsSeeking)
@ -1050,9 +1105,12 @@ namespace BizHawk.Client.EmuHawk
if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue)
{
for (int i = startVal; i <= endVal; i++) // Inclusive on both ends (drawing up or down)
{
bool setVal = _boolPaintState;
if (_patternPaint && _boolPaintState)
{
if (CurrentTasMovie[frame].Lagged.HasValue && CurrentTasMovie[frame].Lagged.Value)
@ -1123,6 +1181,8 @@ namespace BizHawk.Client.EmuHawk
private void TasView_MouseMove(object sender, MouseEventArgs e)
{
// For float editing
if (FloatEditingMode)
{
int increment = (_floatEditYPos - e.Y) / 4;
if (_floatEditYPos == -1)
return;
@ -1156,6 +1216,8 @@ namespace BizHawk.Client.EmuHawk
_triggerAutoRestore = true;
JumpToGreenzone();
DoTriggeredAutoRestoreIfNeeded();
}
RefreshDialog();
}
@ -1411,14 +1473,31 @@ namespace BizHawk.Client.EmuHawk
private void TasView_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Left) // Ctrl + Left
//taseditor uses Ctrl for selection and Shift for framecourser
if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.PageUp) // Shift + Page Up
{
GoToPreviousMarker();
}
else if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.Right) // Ctrl + Right
else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.PageDown) // Shift + Page Down
{
GoToNextMarker();
}
else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Home) // Shift + Home
{
GoToFrame(0);
}
else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.End) // Shift + End
{
GoToFrame(CurrentTasMovie.InputLogLength-1);
}
else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Up) // Shift + Up
{
GoToPreviousFrame();
}
else if (!e.Control && e.Shift && !e.Alt && e.KeyCode == Keys.Down) // Shift + Down
{
GoToNextFrame();
}
if (FloatEditingMode && e.KeyCode != Keys.Right
&& e.KeyCode != Keys.Left

View File

@ -479,7 +479,7 @@ namespace BizHawk.Client.EmuHawk
SetUpToolStripColumns();
}
private void AddColumn(string columnName, string columnText, int columnWidth, InputRoll.RollColumn.InputType columnType = InputRoll.RollColumn.InputType.Boolean)
public void AddColumn(string columnName, string columnText, int columnWidth, InputRoll.RollColumn.InputType columnType = InputRoll.RollColumn.InputType.Boolean)
{
if (TasView.AllColumns[columnName] == null)
{