Exemplo n.º 1
0
        private void TasView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e)
        {
            if (TasView.SelectedRows.Any())
            {
                var columnName = e.Column.Name;

                if (columnName == FrameColumnName)
                {
                    CurrentTasMovie.Markers.Add(TasView.LastSelectedIndex.Value, "");
                    RefreshDialog();
                }
                else if (columnName != MarkerColumnName)                 // TODO: what about float?
                {
                    foreach (var index in TasView.SelectedRows)
                    {
                        CurrentTasMovie.ToggleBoolState(index, columnName);
                        _triggerAutoRestore          = true;
                        _triggerAutoRestoreFromFrame = TasView.SelectedRows.Min();
                    }

                    RefreshDialog();
                }
            }
        }
Exemplo n.º 2
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)
            {
                TogglePause();
                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)
            {
                _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;
                        _triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
                        return;
                    }
                }

                if (TasView.CurrentCell.Column.Name == MarkerColumnName)
                {
                    _startMarkerDrag = true;
                    GoToFrame(TasView.CurrentCell.RowIndex.Value);
                }
                else if (TasView.CurrentCell.Column.Name == FrameColumnName)
                {
                    _startFrameDrag = true;
                    _frameDragState = TasView.SelectedRows.Contains(frame);
                }
                else                 // User changed input
                {
                    if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
                    {
                        CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool");

                        CurrentTasMovie.ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName);
                        _triggerAutoRestore          = true;
                        _triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
                        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;
                        }
                    }
                    else
                    {
                        if (frame >= CurrentTasMovie.InputLogLength)
                        {
                            CurrentTasMovie.SetFloatState(frame, buttonName, 0);
                            RefreshDialog();
                        }

                        _triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;

                        _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");
                            _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;
                                _triggerAutoRestoreFromFrame = frame;
                            }
                            RefreshDialog();
                        }
                    }
                }
            }
            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;
                    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;

                    _triggerAutoRestoreFromFrame = TasView.CurrentCell.RowIndex.Value;
                    // TODO: Turn off ChangeLog.IsRecording and handle the GeneralUndo here.
                    CurrentTasMovie.ChangeLog.BeginNewBatch("Right-Click Edit");
                }
            }
        }
Exemplo n.º 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);
                    }
                }
            }
        }