TAStudio: -Fix: Undo/Redo didn't always jump back to valid frame.
-Performance boosts with multiple selected rows
This commit is contained in:
parent
7a0103963d
commit
f72eadb76e
|
@ -164,7 +164,7 @@ namespace BizHawk.Client.Common
|
|||
if (!batch.Where(a => a.GetType() != typeof(MovieActionMarker)).Any())
|
||||
return Movie.InputLogLength;
|
||||
|
||||
return PreviousUndoFrame;
|
||||
return PreviousRedoFrame;
|
||||
}
|
||||
|
||||
public bool CanUndo { get { return UndoIndex > -1; } }
|
||||
|
@ -180,7 +180,7 @@ namespace BizHawk.Client.Common
|
|||
if (History[UndoIndex + 1].Count == 0)
|
||||
return Movie.InputLogLength;
|
||||
|
||||
return History[UndoIndex + 1].Max(a => a.FirstFrame);
|
||||
return History[UndoIndex + 1].Min(a => a.FirstFrame);
|
||||
}
|
||||
}
|
||||
public int PreviousRedoFrame
|
||||
|
@ -193,7 +193,7 @@ namespace BizHawk.Client.Common
|
|||
if (History[UndoIndex].Count == 0)
|
||||
return Movie.InputLogLength;
|
||||
|
||||
return History[UndoIndex].Max(a => a.FirstFrame);
|
||||
return History[UndoIndex].Min(a => a.FirstFrame);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
get
|
||||
{
|
||||
if (BranchView.SelectedRows.Any())
|
||||
if (BranchView.AnyRowsSelected)
|
||||
{
|
||||
return Branches[BranchView.SelectedRows.First()];
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public class InputRoll : Control
|
||||
{
|
||||
private readonly GDIRenderer Gdi;
|
||||
private readonly List<Cell> SelectedItems = new List<Cell>();
|
||||
private readonly SortedSet<Cell> SelectedItems = new SortedSet<Cell>(new sortCell());
|
||||
|
||||
private readonly VScrollBar VBar;
|
||||
private readonly HScrollBar HBar;
|
||||
|
@ -448,8 +448,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
var items = SelectedItems.Where(cell => cell.RowIndex == index);
|
||||
SelectedItems.RemoveAll(items.Contains);
|
||||
IEnumerable<Cell> items = SelectedItems.Where(cell => cell.RowIndex == index);
|
||||
SelectedItems.RemoveWhere(items.Contains);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
public void TruncateSelection(int index)
|
||||
{
|
||||
SelectedItems.RemoveAll(cell => cell.RowIndex > index);
|
||||
SelectedItems.RemoveWhere(cell => cell.RowIndex > index);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
|
@ -490,11 +490,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
get
|
||||
{
|
||||
if (SelectedRows.Any())
|
||||
if (AnyRowsSelected)
|
||||
{
|
||||
return SelectedRows
|
||||
.OrderBy(x => x)
|
||||
.First();
|
||||
return SelectedRows.Min();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -507,11 +505,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
get
|
||||
{
|
||||
if (SelectedRows.Any())
|
||||
if (AnyRowsSelected)
|
||||
{
|
||||
return SelectedRows
|
||||
.OrderBy(x => x)
|
||||
.Last();
|
||||
return SelectedRows.Max();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -852,6 +848,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
.Distinct();
|
||||
}
|
||||
}
|
||||
public bool AnyRowsSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return SelectedItems.Any(cell => cell.RowIndex.HasValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearSelectedRows()
|
||||
{
|
||||
|
@ -998,7 +1001,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DrawData(PaintEventArgs e)
|
||||
{
|
||||
var columns = _columns.VisibleColumns.ToList();
|
||||
List<RollColumn> columns = _columns.VisibleColumns.ToList();
|
||||
if (QueryItemText != null)
|
||||
{
|
||||
if (HorizontalOrientation)
|
||||
|
@ -1300,12 +1303,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
// SuuperW: This allows user to see other colors in selected frames.
|
||||
Color Highlight_Color = new Color();
|
||||
foreach (var cell in SelectedItems)
|
||||
foreach (Cell cell in SelectedItems)
|
||||
{
|
||||
if (cell.RowIndex > LastVisibleRow || cell.RowIndex < FirstVisibleRow)
|
||||
continue;
|
||||
|
||||
var relativeCell = new Cell
|
||||
Cell relativeCell = new Cell
|
||||
{
|
||||
RowIndex = cell.RowIndex - FirstVisibleRow,
|
||||
Column = cell.Column,
|
||||
|
@ -1366,7 +1369,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// <param name="e"></param>
|
||||
private void DoBackGroundCallback(PaintEventArgs e)
|
||||
{
|
||||
var columns = _columns.VisibleColumns.ToList();
|
||||
List<RollColumn> columns = _columns.VisibleColumns.ToList();
|
||||
|
||||
if (HorizontalOrientation)
|
||||
{
|
||||
|
@ -2588,6 +2591,33 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private class sortCell : IComparer<Cell>
|
||||
{
|
||||
int IComparer<Cell>.Compare(Cell a, Cell b)
|
||||
{
|
||||
Cell c1 = a as Cell;
|
||||
Cell c2 = b as Cell;
|
||||
if (c1.RowIndex.HasValue)
|
||||
{
|
||||
if (c2.RowIndex.HasValue)
|
||||
{
|
||||
int row = c1.RowIndex.Value.CompareTo(c2.RowIndex.Value);
|
||||
if (row == 0)
|
||||
{
|
||||
return c1.Column.Name.CompareTo(c2.Column.Name);
|
||||
}
|
||||
else
|
||||
return row;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
else if (c2.RowIndex.HasValue)
|
||||
return -1;
|
||||
else
|
||||
return c1.Column.Name.CompareTo(c2.Column.Name);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void EditMarker()
|
||||
{
|
||||
if (MarkerView.SelectedRows.Any())
|
||||
if (MarkerView.AnyRowsSelected)
|
||||
{
|
||||
var index = MarkerView.SelectedRows.First();
|
||||
var marker = Tastudio.CurrentTasMovie.Markers[index];
|
||||
|
@ -179,7 +179,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public int SelectedMarkerFrame()
|
||||
{
|
||||
if (MarkerView.SelectedRows.Any())
|
||||
if (MarkerView.AnyRowsSelected)
|
||||
{
|
||||
var index = MarkerView.SelectedRows.First();
|
||||
var marker = Tastudio.CurrentTasMovie.Markers[index];
|
||||
|
|
|
@ -228,7 +228,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void TasView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e)
|
||||
{
|
||||
if (TasView.SelectedRows.Any())
|
||||
if (TasView.AnyRowsSelected)
|
||||
{
|
||||
var columnName = e.Column.Name;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (TasView.LastSelectedIndex == CurrentTasMovie.InputLogLength)
|
||||
TasView.SelectRow(CurrentTasMovie.InputLogLength, false);
|
||||
|
||||
if (!TasView.SelectedRows.Any())
|
||||
if (!TasView.AnyRowsSelected)
|
||||
return;
|
||||
|
||||
MovieZone macro = new MovieZone(CurrentTasMovie, TasView.FirstSelectedIndex.Value,
|
||||
|
@ -132,7 +132,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
private void placeMacroAtSelectionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TasView.SelectedRows.Any())
|
||||
if (!TasView.AnyRowsSelected)
|
||||
return;
|
||||
|
||||
MovieZone macro = MacroInputTool.LoadMacro();
|
||||
|
@ -207,7 +207,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DeleteFramesMenuItem.Enabled =
|
||||
CloneMenuItem.Enabled =
|
||||
TruncateMenuItem.Enabled =
|
||||
TasView.SelectedRows.Any();
|
||||
TasView.AnyRowsSelected;
|
||||
ReselectClipboardMenuItem.Enabled =
|
||||
PasteMenuItem.Enabled =
|
||||
PasteInsertMenuItem.Enabled =
|
||||
|
@ -235,7 +235,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SelectBetweenMarkersMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TasView.SelectedRows.Any())
|
||||
if (TasView.AnyRowsSelected)
|
||||
{
|
||||
var prevMarker = CurrentTasMovie.Markers.PreviousOrCurrent(TasView.LastSelectedIndex.Value);
|
||||
var nextMarker = CurrentTasMovie.Markers.Next(TasView.LastSelectedIndex.Value);
|
||||
|
@ -265,7 +265,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void CopyMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TasView.SelectedRows.Any())
|
||||
if (TasView.AnyRowsSelected)
|
||||
{
|
||||
_tasClipboard.Clear();
|
||||
var list = TasView.SelectedRows.ToList();
|
||||
|
@ -348,7 +348,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void CutMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TasView.SelectedRows.Any())
|
||||
if (TasView.AnyRowsSelected)
|
||||
{
|
||||
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
|
||||
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
|
||||
|
@ -392,7 +392,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void ClearMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TasView.SelectedRows.Any())
|
||||
if (TasView.AnyRowsSelected)
|
||||
{
|
||||
bool wasPaused = GlobalWin.MainForm.EmulatorPaused;
|
||||
bool needsToRollback = !(TasView.FirstSelectedIndex > Emulator.Frame);
|
||||
|
@ -426,7 +426,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DeleteFramesMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TasView.SelectedRows.Any())
|
||||
if (TasView.AnyRowsSelected)
|
||||
{
|
||||
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
|
||||
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
|
||||
|
@ -461,7 +461,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void CloneMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TasView.SelectedRows.Any())
|
||||
if (TasView.AnyRowsSelected)
|
||||
{
|
||||
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
|
||||
var framesToInsert = TasView.SelectedRows.ToList();
|
||||
|
@ -496,7 +496,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void InsertFrameMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var wasPaused = GlobalWin.MainForm.EmulatorPaused;
|
||||
var insertionFrame = TasView.SelectedRows.Any() ? TasView.FirstSelectedIndex.Value : 0;
|
||||
var insertionFrame = TasView.AnyRowsSelected ? TasView.FirstSelectedIndex.Value : 0;
|
||||
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
|
||||
|
||||
CurrentTasMovie.InsertEmptyFrame(insertionFrame);
|
||||
|
@ -522,7 +522,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void InsertNumFramesMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool wasPaused = GlobalWin.MainForm.EmulatorPaused;
|
||||
int insertionFrame = TasView.SelectedRows.Any() ? TasView.FirstSelectedIndex.Value : 0;
|
||||
int insertionFrame = TasView.AnyRowsSelected ? TasView.FirstSelectedIndex.Value : 0;
|
||||
bool needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
|
||||
|
||||
FramesPrompt framesPrompt = new FramesPrompt();
|
||||
|
@ -552,7 +552,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void TruncateMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TasView.SelectedRows.Any())
|
||||
if (TasView.AnyRowsSelected)
|
||||
{
|
||||
var rollbackFrame = TasView.LastSelectedIndex.Value;
|
||||
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
|
||||
|
@ -981,7 +981,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
InsertFrameContextMenuItem.Enabled =
|
||||
InsertNumFramesContextMenuItem.Enabled =
|
||||
TruncateContextMenuItem.Enabled =
|
||||
TasView.SelectedRows.Any();
|
||||
TasView.AnyRowsSelected;
|
||||
|
||||
StartFromNowSeparator.Visible =
|
||||
StartNewProjectFromNowMenuItem.Visible =
|
||||
|
|
|
@ -469,7 +469,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
private void DummyLoadMacro(string path)
|
||||
{
|
||||
if (!TasView.SelectedRows.Any())
|
||||
if (!TasView.AnyRowsSelected)
|
||||
return;
|
||||
|
||||
MovieZone loadZone = new MovieZone(path);
|
||||
|
@ -803,7 +803,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
EditMarkerContextMenuItem.Enabled =
|
||||
RemoveMarkerContextMenuItem.Enabled =
|
||||
ScrollToMarkerToolStripMenuItem.Enabled =
|
||||
MarkerControl.MarkerInputRoll.SelectedRows.Any();
|
||||
MarkerControl.MarkerInputRoll.AnyRowsSelected;
|
||||
}
|
||||
|
||||
private void ScrollToMarkerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue