public bool Rewind()
        {
            // copy pasted from TasView_MouseWheel(), just without notch logic
            if (Mainform.IsSeeking && !Mainform.EmulatorPaused)
            {
                Mainform.PauseOnFrame--;

                // that's a weird condition here, but for whatever reason it works best
                if (Emulator.Frame >= Mainform.PauseOnFrame)
                {
                    Mainform.PauseEmulator();
                    Mainform.PauseOnFrame = null;
                    StopSeeking();
                    GoToPreviousFrame();
                }

                RefreshDialog();
            }
            else
            {
                StopSeeking();                 // late breaking memo: don't know whether this is needed
                GoToPreviousFrame();
            }

            return(true);
        }
Пример #2
0
        private void TasView_MouseWheel(object sender, MouseEventArgs e)
        {
            if (TasView.RightButtonHeld && TasView.CurrentCell.RowIndex.HasValue)
            {
                _supressContextMenu = true;
                int notch = e.Delta / 120;
                if (notch > 1)
                {
                    notch *= 2;
                }

                // warning: tastudio rewind hotkey/button logic is copypasted from here!
                if (Mainform.IsSeeking && !Mainform.EmulatorPaused)
                {
                    Mainform.PauseOnFrame -= notch;
                    // that's a weird condition here, but for whatever reason it works best
                    if (notch > 0 && Global.Emulator.Frame >= Mainform.PauseOnFrame)
                    {
                        Mainform.PauseEmulator();
                        Mainform.PauseOnFrame = null;
                        StopSeeking();
                        GoToFrame(Emulator.Frame - notch);
                    }
                    RefreshDialog();
                }
                else
                {
                    GoToFrame(Emulator.Frame - notch);
                }
            }
        }
Пример #3
0
        private bool InitializeOnLoad()
        {
            Mainform.PauseOnFrame = null;
            Mainform.PauseEmulator();

            // Start Scenario 1: A regular movie is active
            if (Global.MovieSession.Movie.IsActive && !(Global.MovieSession.Movie is TasMovie))
            {
                var result = MessageBox.Show("In order to use Tastudio, a new project must be created from the current movie\nThe current movie will be saved and closed, and a new project file will be created\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.OK)
                {
                    ConvertCurrentMovieToTasproj();
                    StartNewMovieWrapper(false);
                    SetUpColumns();
                }
                else
                {
                    return(false);
                }
            }

            // Start Scenario 2: A tasproj is already active
            else if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie)
            {
                bool result = LoadFile(new FileInfo(CurrentTasMovie.Filename), gotoFrame: Emulator.Frame);
                if (!result)
                {
                    TasView.AllColumns.Clear();
                    StartNewTasMovie();
                }
            }

            // Start Scenario 3: No movie, but user wants to autload their last project
            else if (Settings.RecentTas.AutoLoad && !string.IsNullOrEmpty(Settings.RecentTas.MostRecent))
            {
                bool result = LoadFile(new FileInfo(Settings.RecentTas.MostRecent));
                if (!result)
                {
                    TasView.AllColumns.Clear();
                    StartNewTasMovie();
                }
            }

            // Start Scenario 4: No movie, default behavior of engaging tastudio with a new default project
            else
            {
                StartNewTasMovie();
            }

            EngageTastudio();
            return(true);
        }
Пример #4
0
        private void StartNewProjectFromNowMenuItem_Click(object sender, EventArgs e)
        {
            if (AskSaveChanges())
            {
                int index = Emulator.Frame;

                TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie(
                    index, (byte[])StatableEmulator.SaveStateBinary().Clone());

                Mainform.PauseEmulator();
                LoadFile(new FileInfo(newProject.Filename), true);
            }
        }
Пример #5
0
 private void EngageTastudio()
 {
     Mainform.PauseOnFrame = null;
     GlobalWin.OSD.AddMessage("TAStudio engaged");
     SetTasMovieCallbacks();
     SetTextProperty();
     Mainform.PauseEmulator();
     Mainform.RelinquishControl(this);
     _originalEndAction = Global.Config.MovieEndAction;
     Mainform.ClearRewindData();
     Global.Config.MovieEndAction = MovieEndAction.Record;
     Mainform.SetMainformMovieInfo();
     Global.MovieSession.ReadOnly = true;
 }
Пример #6
0
        private void StartANewProjectFromSaveRamMenuItem_Click(object sender, EventArgs e)
        {
            if (AskSaveChanges())
            {
                int index = TasView.SelectedRows.First();
                GoToFrame(index);

                TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie(
                    SaveRamEmulator.CloneSaveRam());

                Mainform.PauseEmulator();
                LoadFile(new FileInfo(newProject.Filename), true);
            }
        }
Пример #7
0
        private bool InitializeOnLoad()
        {
            Mainform.PauseOnFrame = null;
            Mainform.PauseEmulator();

            // Start Scenario 0: snes9x needs a nag (copied from RecordMovieMenuItem_Click())
            if (Emulator is Snes9x)
            {
                var box = new CustomControls.MsgBox(
                    "While the Snes9x core is faster, it is not nearly as accurate as bsnes. \nIt is recommended that you switch to the bsnes core for movie recording\nSwitch to bsnes?",
                    "Accuracy Warning",
                    MessageBoxIcon.Warning);

                box.SetButtons(
                    new[] { "Switch", "Continue" },
                    new[] { DialogResult.Yes, DialogResult.Cancel });

                box.MaximumSize = new Size(475, 350);
                box.SetMessageToAutoSize();
                var result = box.ShowDialog();

                if (result == DialogResult.Yes)
                {
                    Global.Config.SNES_InSnes9x = false;
                    Mainform.RebootCore();
                }
                else if (result == DialogResult.Cancel)
                {
                    //return false;
                }
            }
            else if (Emulator is QuickNES)             // Copy pasta of unsustainable logic, even better
            {
                var box = new CustomControls.MsgBox(
                    "While the QuickNes core is faster, it is not nearly as accurate as NesHawk. \nIt is recommended that you switch to the NesHawk core for movie recording\nSwitch to NesHawk?",
                    "Accuracy Warning",
                    MessageBoxIcon.Warning);

                box.SetButtons(
                    new[] { "Switch", "Continue" },
                    new[] { DialogResult.Yes, DialogResult.Cancel });

                box.MaximumSize = new Size(475, 350);
                box.SetMessageToAutoSize();
                var result = box.ShowDialog();

                if (result == DialogResult.Yes)
                {
                    Global.Config.NES_InQuickNES = false;
                    Mainform.RebootCore();
                }
                else if (result == DialogResult.Cancel)
                {
                    //return false;
                }
            }

            // Start Scenario 1: A regular movie is active
            if (Global.MovieSession.Movie.IsActive && !(Global.MovieSession.Movie is TasMovie))
            {
                var result = MessageBox.Show("In order to use Tastudio, a new project must be created from the current movie\nThe current movie will be saved and closed, and a new project file will be created\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.OK)
                {
                    ConvertCurrentMovieToTasproj();
                    StartNewMovieWrapper(false);
                    SetUpColumns();
                }
                else
                {
                    return(false);
                }
            }

            // Start Scenario 2: A tasproj is already active
            else if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie)
            {
                bool result = LoadFile(new FileInfo(CurrentTasMovie.Filename), gotoFrame: Emulator.Frame);
                if (!result)
                {
                    TasView.AllColumns.Clear();
                    StartNewTasMovie();
                }
            }

            // Start Scenario 3: No movie, but user wants to autoload their last project
            else if (Settings.RecentTas.AutoLoad && !string.IsNullOrEmpty(Settings.RecentTas.MostRecent))
            {
                bool result = LoadFile(new FileInfo(Settings.RecentTas.MostRecent));
                if (!result)
                {
                    TasView.AllColumns.Clear();
                    StartNewTasMovie();
                }
            }

            // Start Scenario 4: No movie, default behavior of engaging tastudio with a new default project
            else
            {
                StartNewTasMovie();
            }

            if (Global.Emulator is NullEmulator)
            {
                DisengageTastudio();
                return(false);
            }

            EngageTastudio();
            return(true);
        }
Пример #8
0
        private bool InitializeOnLoad()
        {
            Mainform.PauseOnFrame = null;
            Mainform.PauseEmulator();

            // Start Scenario 0: bsnes in performance mode (copied from RecordMovieMenuItem_Click())
            if (Emulator is BizHawk.Emulation.Cores.Nintendo.SNES.LibsnesCore)
            {
                var snes = (BizHawk.Emulation.Cores.Nintendo.SNES.LibsnesCore)Emulator;
                if (snes.CurrentProfile == "Performance")
                {
                    var box = new CustomControls.MsgBox(
                        "While the performance core is faster, it is not stable enough for movie recording\n\nSwitch to Compatibility?",
                        "Stability Warning",
                        MessageBoxIcon.Warning);

                    box.SetButtons(
                        new[] { "Switch", "Cancel" },
                        new[] { DialogResult.Yes, DialogResult.Cancel });

                    box.MaximumSize = new Size(450, 350);
                    box.SetMessageToAutoSize();
                    var result = box.ShowDialog();

                    if (result == DialogResult.Yes)
                    {
                        var ss = snes.GetSyncSettings();
                        ss.Profile = "Compatibility";
                        snes.PutSyncSettings(ss);
                        Mainform.RebootCore();
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        return(false);
                    }
                }
            }

            // Start Scenario 1: A regular movie is active
            if (Global.MovieSession.Movie.IsActive && !(Global.MovieSession.Movie is TasMovie))
            {
                var result = MessageBox.Show("In order to use Tastudio, a new project must be created from the current movie\nThe current movie will be saved and closed, and a new project file will be created\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (result == DialogResult.OK)
                {
                    ConvertCurrentMovieToTasproj();
                    StartNewMovieWrapper(false);
                    SetUpColumns();
                }
                else
                {
                    return(false);
                }
            }

            // Start Scenario 2: A tasproj is already active
            else if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie)
            {
                bool result = LoadFile(new FileInfo(CurrentTasMovie.Filename), gotoFrame: Emulator.Frame);
                if (!result)
                {
                    TasView.AllColumns.Clear();
                    StartNewTasMovie();
                }
            }

            // Start Scenario 3: No movie, but user wants to autload their last project
            else if (Settings.RecentTas.AutoLoad && !string.IsNullOrEmpty(Settings.RecentTas.MostRecent))
            {
                bool result = LoadFile(new FileInfo(Settings.RecentTas.MostRecent));
                if (!result)
                {
                    TasView.AllColumns.Clear();
                    StartNewTasMovie();
                }
            }

            // Start Scenario 4: No movie, default behavior of engaging tastudio with a new default project
            else
            {
                StartNewTasMovie();
            }

            EngageTastudio();
            return(true);
        }
Пример #9
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);
                    }
                }
            }
        }