tastudio: complete overhaul of seek logic, replicating taseditor
todo: fix lastpositionframe dying if editing the same row twice with no autorestore, probably improve cursor color and rename old seek related vars
This commit is contained in:
parent
91a29a8692
commit
0246c952eb
|
@ -14,10 +14,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
// General
|
||||
case "Pause":
|
||||
// check this here since TogglePause() has no idea who triggered it
|
||||
// and we need to treat pause hotkey specially in tastudio
|
||||
if (GlobalWin.MainForm.EmulatorPaused && GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
GlobalWin.Tools.TAStudio.IgnoreSeekFrame = true;
|
||||
TogglePause();
|
||||
break;
|
||||
case "Toggle Throttle":
|
||||
|
|
|
@ -2687,8 +2687,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
runFrame = true;
|
||||
_runloopFrameadvance = true;
|
||||
_frameAdvanceTimestamp = currentTimestamp;
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
GlobalWin.Tools.TAStudio.IgnoreSeekFrame = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2864,6 +2862,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
UpdateToolsAfter();
|
||||
}
|
||||
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>() &&
|
||||
GlobalWin.Tools.TAStudio.LastPositionFrame == Global.Emulator.Frame)
|
||||
{
|
||||
TasMovieRecord record = (Global.MovieSession.Movie as TasMovie)[Global.Emulator.Frame];
|
||||
if (!record.Lagged.HasValue && IsSeeking)
|
||||
// haven't yet greenzoned the frame, hence it's after editing
|
||||
// then we want to pause here. taseditor fasion
|
||||
PauseEmulator();
|
||||
}
|
||||
|
||||
if (IsSeeking && Global.Emulator.Frame == PauseOnFrame.Value)
|
||||
{
|
||||
PauseEmulator();
|
||||
|
|
|
@ -136,8 +136,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void PauseButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (GlobalWin.MainForm.EmulatorPaused)
|
||||
Tastudio.IgnoreSeekFrame = true;
|
||||
Tastudio.TogglePause();
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
return true;
|
||||
}
|
||||
|
||||
IgnoreSeekFrame = false; // don't unpause
|
||||
StopSeeking();
|
||||
|
||||
if (CurrentTasMovie != null && CurrentTasMovie.Changes)
|
||||
|
|
|
@ -68,11 +68,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastValidFrame);
|
||||
StartSeeking(_autoRestoreFrame, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void StartSeeking(int? frame, bool pause = false)
|
||||
private void StartSeeking(int? frame)
|
||||
{
|
||||
if (!frame.HasValue)
|
||||
return;
|
||||
|
@ -81,10 +80,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin.MainForm.PauseOnFrame = frame.Value;
|
||||
int? diff = GlobalWin.MainForm.PauseOnFrame - _seekStartFrame;
|
||||
|
||||
if (pause)
|
||||
GlobalWin.MainForm.PauseEmulator();
|
||||
else
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
|
||||
if (!_seekBackgroundWorker.IsBusy && diff.Value > TasView.VisibleRows)
|
||||
_seekBackgroundWorker.RunWorkerAsync();
|
||||
|
@ -98,11 +94,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
TastudioRecordMode();
|
||||
_wasRecording = false;
|
||||
}
|
||||
if (IgnoreSeekFrame)
|
||||
{
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
IgnoreSeekFrame = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool FloatEditingMode
|
||||
|
@ -171,7 +162,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
ts_v_arrow_blue :
|
||||
ts_h_arrow_blue;
|
||||
}
|
||||
else if (index == GlobalWin.MainForm.PauseOnFrame)
|
||||
else if (index == LastPositionFrame)
|
||||
{
|
||||
bitmap = TasView.HorizontalOrientation ?
|
||||
ts_v_arrow_green :
|
||||
|
@ -226,7 +217,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
int player = Global.Emulator.ControllerDefinition.PlayerNumber(columnName);
|
||||
if (player != 0 && player % 2 == 0)
|
||||
color = Color.FromArgb(0x0D000000);
|
||||
|
||||
if (GlobalWin.MainForm.IsSeeking &&
|
||||
GlobalWin.MainForm.PauseOnFrame == index &&
|
||||
columnName != CursorColumnName)
|
||||
{
|
||||
color = Color.FromArgb(unchecked((int)0x70B5E7F7));
|
||||
}
|
||||
}
|
||||
|
||||
private void TasView_QueryRowBkColor(int index, ref Color color)
|
||||
{
|
||||
TasMovieRecord record = CurrentTasMovie[index];
|
||||
|
@ -405,8 +404,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (e.Button == MouseButtons.Middle)
|
||||
{
|
||||
if (GlobalWin.MainForm.EmulatorPaused)
|
||||
IgnoreSeekFrame = false;
|
||||
TogglePause();
|
||||
{
|
||||
TasMovieRecord record = CurrentTasMovie[LastPositionFrame];
|
||||
if (!record.Lagged.HasValue && LastPositionFrame > Global.Emulator.Frame)
|
||||
StartSeeking(LastPositionFrame);
|
||||
else
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalWin.MainForm.PauseEmulator();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -420,6 +428,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
bool wasHeld = _leftButtonHeld;
|
||||
_leftButtonHeld = true;
|
||||
// SuuperW: Exit float editing mode, or re-enter mouse editing
|
||||
if (_floatEditRow != -1)
|
||||
|
@ -460,6 +469,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
else // User changed input
|
||||
{
|
||||
bool wasPaused = GlobalWin.MainForm.EmulatorPaused;
|
||||
|
||||
if (wasPaused && !GlobalWin.MainForm.IsSeeking)
|
||||
LastPositionFrame = Emulator.Frame;
|
||||
|
||||
if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
|
||||
{
|
||||
CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame);
|
||||
|
@ -534,9 +547,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
// taseditor behavior
|
||||
if (!wasPaused)
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
|
||||
if (!Settings.AutoRestoreLastPosition)
|
||||
IgnoreSeekFrame = true;
|
||||
}
|
||||
}
|
||||
else if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
||||
|
@ -653,20 +663,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
_supressContextMenu = true;
|
||||
int notch = e.Delta / 120;
|
||||
if (notch > 1)
|
||||
notch *= 2;
|
||||
|
||||
if (GlobalWin.MainForm.IsSeeking)
|
||||
if (GlobalWin.MainForm.IsSeeking && !GlobalWin.MainForm.EmulatorPaused)
|
||||
{
|
||||
if (e.Delta < 0)
|
||||
GlobalWin.MainForm.PauseOnFrame++;
|
||||
else
|
||||
GlobalWin.MainForm.PauseOnFrame -= notch;
|
||||
// that's a weird condition here, but for whatever reason it works best
|
||||
if (notch > 0 && Global.Emulator.Frame >= GlobalWin.MainForm.PauseOnFrame)
|
||||
{
|
||||
GlobalWin.MainForm.PauseOnFrame--;
|
||||
if (Global.Emulator.Frame == GlobalWin.MainForm.PauseOnFrame)
|
||||
{
|
||||
GlobalWin.MainForm.PauseEmulator();
|
||||
GlobalWin.MainForm.PauseOnFrame = null;
|
||||
StopSeeking();
|
||||
}
|
||||
GlobalWin.MainForm.PauseEmulator();
|
||||
GlobalWin.MainForm.PauseOnFrame = null;
|
||||
StopSeeking();
|
||||
GoToFrame(Emulator.Frame - notch);
|
||||
}
|
||||
RefreshDialog();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
public bool IsInMenuLoop { get; private set; }
|
||||
public bool IgnoreSeekFrame { get; set; }
|
||||
|
||||
[ConfigPersist]
|
||||
public TAStudioSettings Settings { get; set; }
|
||||
|
@ -111,6 +110,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
get { return Global.MovieSession.Movie as TasMovie; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Separates "restore last position" logic from seeking caused by navigation.
|
||||
/// TASEditor never kills LastPositionFrame, and it only pauses on it,
|
||||
/// if it hasn't been greenzoned beforehand and middle mouse button was pressed
|
||||
/// </summary>
|
||||
public int LastPositionFrame { get; set; }
|
||||
|
||||
#region "Initializing"
|
||||
|
||||
public TAStudio()
|
||||
|
@ -158,7 +164,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
TasView.PointedCellChanged += TasView_PointedCellChanged;
|
||||
TasView.MultiSelect = true;
|
||||
TasView.MaxCharactersInHorizontal = 1;
|
||||
IgnoreSeekFrame = false;
|
||||
LastPositionFrame = -1;
|
||||
}
|
||||
|
||||
private void AutosaveTimerEventProcessor(object sender, EventArgs e)
|
||||
|
@ -795,7 +801,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (_autoRestorePaused.HasValue && !_autoRestorePaused.Value)
|
||||
{
|
||||
// this happens when we're holding the left button while unpaused - view scrolls down, new input gets drawn, seek pauses
|
||||
IgnoreSeekFrame = true;
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
}
|
||||
_autoRestorePaused = null;
|
||||
|
|
Loading…
Reference in New Issue