// SuuperW: I changed this to public so that it could be used by MarkerControl.cs public void GoToFrame(int frame) { // If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate // Otherwise, load the latest state (if not already there) and seek while recording. if (frame <= CurrentTasMovie.InputLogLength) { // Get as close as we can then emulate there StartAtNearestFrameAndEmulate(frame); MaybeFollowCursor(); return; } else // Emulate to a future frame { if (frame == Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame { bool wasPaused = GlobalWin.MainForm.EmulatorPaused; GlobalWin.MainForm.FrameAdvance(); if (!wasPaused) { GlobalWin.MainForm.UnpauseEmulator(); } } else { CurrentTasMovie.SwitchToPlay(); int lastState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame).Key; // Simply getting the last state doesn't work if that state is the frame. [dispaly isn't saved in the state, need to emulate to frame] if (lastState > Emulator.Frame) { LoadState(CurrentTasMovie.TasStateManager[lastState]); // STATE ACCESS } GlobalWin.MainForm.UnpauseEmulator(); GlobalWin.MainForm.PauseOnFrame = frame; } } RefreshDialog(); UpdateOtherTools(); }
// SuuperW: I changed this to public so that it could be used by MarkerControl.cs public void GoToFrame(int frame) { // If past greenzone, emulate and capture states // If past greenzone AND movie, record input and capture states // If in greenzone, loadstate // If near a greenzone item, load and emulate // Do capturing and recording as needed if (frame < CurrentTasMovie.InputLogLength) { if (frame < Emulator.Frame) // We are rewinding { int goToFrame = frame == 0 ? 0 : frame - 1; if (CurrentTasMovie[goToFrame].HasState) // Go back 1 frame and emulate to get the display (we don't store that) { CurrentTasMovie.SwitchToPlay(); LoadState(CurrentTasMovie.TasStateManager[goToFrame]); // STATE ACCESS if (frame > 0) // We can't emulate up to frame 0! { bool wasPaused = GlobalWin.MainForm.EmulatorPaused; GlobalWin.MainForm.FrameAdvance(); if (!wasPaused) { GlobalWin.MainForm.UnpauseEmulator(); } } GlobalWin.DisplayManager.NeedsToPaint = true; SetVisibleIndex(frame); } else // Get as close as we can then emulate there { StartAtNearestFrameAndEmulate(frame); return; } } else // We are going foward { if (frame == Emulator.Frame + 1) // Just emulate a frame we only have 1 to go! { bool wasPaused = GlobalWin.MainForm.EmulatorPaused; GlobalWin.MainForm.FrameAdvance(); if (!wasPaused) { GlobalWin.MainForm.UnpauseEmulator(); } } else { var goToFrame = frame == 0 ? 0 : frame - 1; if (CurrentTasMovie[goToFrame].HasState) // Can we go directly there? { CurrentTasMovie.SwitchToPlay(); LoadState(CurrentTasMovie.TasStateManager[goToFrame]); // STATE ACCESS Emulator.FrameAdvance(true); GlobalWin.DisplayManager.NeedsToPaint = true; SetVisibleIndex(frame); } else { StartAtNearestFrameAndEmulate(frame); return; } } } } else // Emulate to a future frame { if (frame == Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame { bool wasPaused = GlobalWin.MainForm.EmulatorPaused; GlobalWin.MainForm.FrameAdvance(); if (!wasPaused) { GlobalWin.MainForm.UnpauseEmulator(); } } else { // TODO: get the last greenzone frame and go there CurrentTasMovie.SwitchToPlay(); // no reason to loadstate when we can emulate a frame instead if (frame - Emulator.Frame != 1) { LoadState(CurrentTasMovie.TasStateManager[CurrentTasMovie.TasStateManager.LastEmulatedFrame]); // STATE ACCESS } if (frame != Emulator.Frame) // If we aren't already at our destination, seek { GlobalWin.MainForm.UnpauseEmulator(); if (Settings.AutoPause && frame < CurrentTasMovie.InputLogLength) { GlobalWin.MainForm.PauseOnFrame = CurrentTasMovie.InputLogLength; } else { GlobalWin.MainForm.PauseOnFrame = frame; } } } } RefreshDialog(); UpdateOtherTools(); }