// 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();
            }
            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 = Mainform.EmulatorPaused;
                    Mainform.FrameAdvance();
                    if (!wasPaused)
                    {
                        Mainform.UnpauseEmulator();
                    }
                }
                else
                {
                    TastudioPlayMode();

                    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
                    }
                    StartSeeking(frame);
                }
            }

            RefreshDialog();
            UpdateOtherTools();
        }
Beispiel #2
0
        private void StartAtNearestFrameAndEmulate(int frame, bool fromLua, bool fromRewinding)
        {
            if (frame == Emulator.Frame)
            {
                return;
            }

            _unpauseAfterSeeking = (fromRewinding || WasRecording) && !Mainform.EmulatorPaused;
            TastudioPlayMode();
            var closestState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame);

            if (closestState.Value.Length > 0 && (frame < Emulator.Frame || closestState.Key > Emulator.Frame))
            {
                LoadState(closestState);
            }

            if (fromLua)
            {
                bool wasPaused = Mainform.EmulatorPaused;

                // why not use this? because I'm not letting the form freely run. it all has to be under this loop.
                // i could use this and then poll StepRunLoop_Core() repeatedly, but.. that's basically what I'm doing
                // PauseOnFrame = frame;

                // can't re-enter lua while doing this
                Mainform.SuppressLua = true;
                while (Emulator.Frame != frame)
                {
                    Mainform.SeekFrameAdvance();
                }

                Mainform.SuppressLua = false;

                if (!wasPaused)
                {
                    Mainform.UnpauseEmulator();
                }

                // lua botting users will want to re-activate record mode automatically -- it should be like nothing ever happened
                if (WasRecording)
                {
                    TastudioRecordMode();
                }

                // now the next section won't happen since we're at the right spot
            }

            // frame == Emulator.Frame when frame == 0
            if (frame > Emulator.Frame)
            {
                // make seek frame keep up with emulation on fast scrolls
                if (Mainform.EmulatorPaused || Mainform.IsSeeking || fromRewinding || WasRecording)
                {
                    StartSeeking(frame);
                }
                else
                {
                    // GUI users may want to be protected from clobbering their video when skipping around...
                    // well, users who are rewinding arent. (that gets done through the seeking system in the call above)
                    // users who are clicking around.. I dont know.
                }
            }
        }
Beispiel #3
0
        private void TasView_MouseDown(object sender, MouseEventArgs e)
        {
            // Clicking with left while right is held or vice versa does weird stuff
            if (mouseButtonHeld)
            {
                return;
            }

            if (e.Button == MouseButtons.Middle)
            {
                if (Mainform.EmulatorPaused)
                {
                    TasMovieRecord record = CurrentTasMovie[LastPositionFrame];
                    if (!record.Lagged.HasValue && LastPositionFrame > Global.Emulator.Frame)
                    {
                        StartSeeking(LastPositionFrame);
                    }
                    else
                    {
                        Mainform.UnpauseEmulator();
                    }
                }
                else
                {
                    Mainform.PauseEmulator();
                }
                return;
            }

            // SuuperW: Moved these.
            if (TasView.CurrentCell == null || !TasView.CurrentCell.RowIndex.HasValue || TasView.CurrentCell.Column == null)
            {
                return;
            }

            int    frame      = TasView.CurrentCell.RowIndex.Value;
            string buttonName = TasView.CurrentCell.Column.Name;


            if (e.Button == MouseButtons.Left)
            {
                bool wasHeld = _leftButtonHeld;
                _leftButtonHeld = true;
                // SuuperW: Exit float editing mode, or re-enter mouse editing
                if (_floatEditRow != -1)
                {
                    if (_floatEditColumn != buttonName || _floatEditRow != frame)
                    {
                        floatEditRow = -1;
                        RefreshTasView();
                    }
                    else
                    {
                        _floatEditYPos      = e.Y;
                        _floatPaintState    = CurrentTasMovie.GetFloatState(frame, buttonName);
                        _triggerAutoRestore = true;
                        JumpToGreenzone();
                        return;
                    }
                }

                if (TasView.CurrentCell.Column.Name == CursorColumnName)
                {
                    _startCursorDrag = true;
                    GoToFrame(TasView.CurrentCell.RowIndex.Value);
                }
                else if (TasView.CurrentCell.Column.Name == FrameColumnName)
                {
                    if (Control.ModifierKeys == Keys.Alt && CurrentTasMovie.Markers.IsMarker(frame))
                    {
                        // TODO
                        TasView.DragCurrentCell();
                    }
                    else
                    {
                        _startSelectionDrag = true;
                        _selectionDragState = TasView.SelectedRows.Contains(frame);
                    }
                }
                else                 // User changed input
                {
                    bool wasPaused = Mainform.EmulatorPaused;

                    if (Emulator.Frame > frame || CurrentTasMovie.LastValidFrame > frame)
                    {
                        if (wasPaused && !Mainform.IsSeeking && !CurrentTasMovie.LastPositionStable)
                        {
                            LastPositionFrame = Emulator.Frame;
                            CurrentTasMovie.LastPositionStable = true;                             // until new frame is emulated
                        }
                    }

                    if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
                    {
                        CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame);

                        CurrentTasMovie.ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
                        _triggerAutoRestore = true;
                        JumpToGreenzone();
                        RefreshDialog();

                        _startBoolDrawColumn = buttonName;

                        _boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName);
                        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;
                        }

                        if (!Settings.AutoRestoreOnMouseUpOnly)
                        {
                            DoTriggeredAutoRestoreIfNeeded();
                        }
                    }
                    else
                    {
                        if (frame >= CurrentTasMovie.InputLogLength)
                        {
                            CurrentTasMovie.SetFloatState(frame, buttonName, 0);
                            RefreshDialog();
                        }

                        JumpToGreenzone();

                        _floatPaintState = CurrentTasMovie.GetFloatState(frame, buttonName);
                        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;
                        }


                        if (e.Clicks != 2)
                        {
                            CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Float " + buttonName + " from frame " + frame);
                            _startFloatDrawColumn = buttonName;
                        }
                        else                         // Double-click enters float editing mode
                        {
                            if (_floatEditColumn == buttonName && _floatEditRow == frame)
                            {
                                floatEditRow = -1;
                            }
                            else
                            {
                                CurrentTasMovie.ChangeLog.BeginNewBatch("Float Edit: " + frame);
                                _floatEditColumn    = buttonName;
                                floatEditRow        = frame;
                                _floatTypedValue    = "";
                                _floatEditYPos      = e.Y;
                                _triggerAutoRestore = true;
                                JumpToGreenzone();
                            }
                            RefreshDialog();
                        }
                    }

                    // taseditor behavior
                    if (!wasPaused)
                    {
                        Mainform.UnpauseEmulator();
                    }
                }
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (TasView.CurrentCell.Column.Name == FrameColumnName && frame < CurrentTasMovie.InputLogLength)
                {
                    _rightClickControl = (Control.ModifierKeys | Keys.Control) == Control.ModifierKeys;
                    _rightClickShift   = (Control.ModifierKeys | Keys.Shift) == Control.ModifierKeys;
                    _rightClickAlt     = (Control.ModifierKeys | Keys.Alt) == Control.ModifierKeys;
                    if (TasView.SelectedRows.Contains(frame))
                    {
                        _rightClickInput = new string[TasView.SelectedRows.Count()];
                        _rightClickFrame = TasView.FirstSelectedIndex.Value;
                        CurrentTasMovie.GetLogEntries().CopyTo(_rightClickFrame, _rightClickInput, 0, TasView.SelectedRows.Count());
                        if (_rightClickControl && _rightClickShift)
                        {
                            _rightClickFrame += _rightClickInput.Length;
                        }
                    }
                    else
                    {
                        _rightClickInput    = new string[1];
                        _rightClickInput[0] = CurrentTasMovie.GetLogEntries()[frame];
                        _rightClickFrame    = frame;
                    }
                    _rightClickLastFrame = -1;

                    if (_rightClickAlt || _rightClickControl || _rightClickShift)
                    {
                        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";
                            }
                        }
                        else
                        {
                            if (_rightClickControl)
                            {
                                undoStepName += " Copy";
                            }
                            else                             // _rightClickAlt
                            {
                                undoStepName += " Move";
                            }
                        }
                        CurrentTasMovie.ChangeLog.BeginNewBatch(undoStepName);
                    }
                }
            }
        }