private void PasteMenuItem_Click(object sender, EventArgs e)
        {
            // TODO: if highlighting 2 rows and pasting 3, only paste 2 of them
            // FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs

            var wasPaused = GlobalWin.MainForm.EmulatorPaused;

            if (_tasClipboard.Any())
            {
                var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;

                CurrentTasMovie.CopyOverInput(TasView.FirstSelectedIndex.Value, _tasClipboard.Select(x => x.ControllerState));

                if (needsToRollback)
                {
                    GoToLastEmulatedFrameIfNecessary(TasView.FirstSelectedIndex.Value);
                    if (wasPaused)
                    {
                        DoAutoRestore();
                    }
                    else
                    {
                        GlobalWin.MainForm.UnpauseEmulator();
                    }
                }
                else
                {
                    RefreshDialog();
                }
            }
        }
Beispiel #2
0
        private void PasteMenuItem_Click(object sender, EventArgs e)
        {
            // TODO: if highlighting 2 rows and pasting 3, only paste 2 of them
            // FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs

            var wasPaused = Mainform.EmulatorPaused;

            // copypaste from PasteInsertMenuItem_Click!
            IDataObject data = Clipboard.GetDataObject();

            if (data.GetDataPresent(DataFormats.StringFormat))
            {
                string input = (string)data.GetData(DataFormats.StringFormat);
                if (!string.IsNullOrWhiteSpace(input))
                {
                    string[] lines = input.Split('\n');
                    if (lines.Length > 0)
                    {
                        _tasClipboard.Clear();
                        for (int i = 0; i < lines.Length - 1; i++)
                        {
                            var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]);
                            if (line == null)
                            {
                                return;
                            }
                            else
                            {
                                _tasClipboard.Add(new TasClipboardEntry(i, line));
                            }
                        }

                        var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
                        CurrentTasMovie.CopyOverInput(TasView.FirstSelectedIndex.Value, _tasClipboard.Select(x => x.ControllerState));
                        if (needsToRollback)
                        {
                            GoToLastEmulatedFrameIfNecessary(TasView.FirstSelectedIndex.Value);
                            DoAutoRestore();
                        }
                        else
                        {
                            RefreshDialog();
                        }
                    }
                }
            }
        }