private VideoWriterChooserForm(IMainFormForTools mainForm, IEmulator emulator, Config config)
        {
            DialogController = mainForm;

            InitializeComponent();

            // TODO: do we want to use virtual w/h?
            if (emulator.HasVideoProvider())
            {
                var videoProvider = emulator.AsVideoProvider();
                _captureWidth  = videoProvider.BufferWidth;
                _captureHeight = videoProvider.BufferHeight;
            }

            if (config.AviCaptureOsd)
            {
                using var bb   = mainForm.CaptureOSD();
                _captureWidth  = bb.Width;
                _captureHeight = bb.Height;
            }

            lblSize.Text = $"Size:\r\n{_captureWidth}x{_captureHeight}";

            if (_captureWidth % 4 != 0 || _captureHeight % 4 != 0)
            {
                lblResolutionWarning.Visible = true;
            }
            else
            {
                lblResolutionWarning.Visible = false;
            }
        }
Beispiel #2
0
        public PlayMovie(
            IMainFormForTools mainForm,
            Config config,
            GameInfo game,
            IEmulator emulator,
            IMovieSession movieSession)
        {
            _mainForm     = mainForm;
            _config       = config;
            _game         = game;
            _emulator     = emulator;
            _movieSession = movieSession;
            InitializeComponent();
            Icon = Properties.Resources.TAStudioIcon;
            BrowseMovies.Image             = Properties.Resources.OpenFile;
            Scan.Image                     = Properties.Resources.Scan;
            editToolStripMenuItem.Image    = Properties.Resources.Cut;
            MovieView.RetrieveVirtualItem += MovieView_QueryItemText;
            MovieView.VirtualMode          = true;
            _sortReverse                   = false;
            _sortedCol                     = "";

            _sortDetailsReverse = false;
            _sortedDetailsCol   = "";
        }
        public RecordMovie(
            IMainFormForTools mainForm,
            Config config,
            GameInfo game,
            IEmulator core,
            IMovieSession movieSession,
            FirmwareManager firmwareManager)
        {
            _mainForm        = mainForm;
            _config          = config;
            _game            = game;
            _emulator        = core;
            _movieSession    = movieSession;
            _firmwareManager = firmwareManager;
            InitializeComponent();
            Icon            = Properties.Resources.TAStudioIcon;
            BrowseBtn.Image = Properties.Resources.OpenFile;
            if (OSTailoredCode.IsUnixHost)
            {
                Load += (_, _) =>
                {
                    //HACK to make this usable on Linux. No clue why this Form in particular is so much worse, maybe the GroupBox? --yoshi
                    groupBox1.Height -= 24;
                    DefaultAuthorCheckBox.Location += new Size(0, 32);
                    var s = new Size(0, 40);
                    OK.Location     += s;
                    Cancel.Location += s;
                }
            }
            ;

            if (!_emulator.HasSavestates())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "now"));
            }

            if (!_emulator.HasSaveRam())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "saveram"));
            }
        }
Beispiel #4
0
        public PresentationPanel(IMainFormForTools mainForm, Config config, IGL gl)
        {
            _mainForm = mainForm;
            _config   = config;

            GraphicsControl = new GraphicsControl(gl)
            {
                Dock      = DockStyle.Fill,
                BackColor = Color.Black
            };

            // pass through these events to the form. we might need a more scalable solution for mousedown etc. for zapper and whatnot.
            // http://stackoverflow.com/questions/547172/pass-through-mouse-events-to-parent-control (HTTRANSPARENT)
            GraphicsControl.MouseDoubleClick += HandleFullscreenToggle;
            GraphicsControl.MouseClick       += _mainForm.MainForm_MouseClick;
            GraphicsControl.MouseMove        += _mainForm.MainForm_MouseMove;
            GraphicsControl.MouseWheel       += _mainForm.MainForm_MouseWheel;
        }
 public static void HandleLoadError(this RecentFiles recent, IMainFormForTools mainForm, string path, string encodedPath = null)
 {
     mainForm.DoWithTempMute(() =>
     {
         if (recent.Frozen)
         {
             mainForm.ShowMessageBox($"Could not open {path}", "File not found", EMsgBoxIcon.Error);
         }
         else
         {
             // ensure topmost, not to have to minimize everything to see and use our modal window, if it somehow got covered
             var result = MessageBox.Show(new Form {
                 TopMost = true
             }, $"Could not open {path}\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
             if (result == DialogResult.Yes)
             {
                 recent.Remove(encodedPath ?? path);
             }
         }
     });
 }
Beispiel #6
0
        public RecordMovie(
            IMainFormForTools mainForm,
            Config config,
            GameInfo game,
            IEmulator core,
            IMovieSession movieSession,
            FirmwareManager firmwareManager)
        {
            _mainForm        = mainForm;
            _config          = config;
            _game            = game;
            _emulator        = core;
            _movieSession    = movieSession;
            _firmwareManager = firmwareManager;
            InitializeComponent();
            Icon            = Properties.Resources.TAStudio_MultiSize;
            BrowseBtn.Image = Properties.Resources.OpenFile;

            if (!_emulator.HasSavestates())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "now"));
            }

            if (!_emulator.HasSaveRam())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "saveram"));
            }
        }
        public static ToolStripItem[] RecentMenu(this RecentFiles recent, IMainFormForTools mainForm, Action <string> loadFileCallback, string entrySemantic, bool noAutoload = false, bool romLoading = false)
        {
            var items = new List <ToolStripItem>();

            if (recent.Empty)
            {
                var none = new ToolStripMenuItem {
                    Enabled = false, Text = "None"
                };
                items.Add(none);
            }
            else
            {
                foreach (var filename in recent)
                {
                    string caption      = filename;
                    string path         = filename;
                    string physicalPath = filename;
                    bool   crazyStuff   = true;

                    //sentinel for newer format OpenAdvanced type code
                    if (romLoading)
                    {
                        if (filename.StartsWith("*"))
                        {
                            var oa = OpenAdvancedSerializer.ParseWithLegacy(filename);
                            caption = oa.DisplayName;

                            crazyStuff = false;
                            if (oa is OpenAdvanced_OpenRom openRom)
                            {
                                crazyStuff   = true;
                                physicalPath = openRom.Path;
                            }
                        }
                    }

                    // TODO - do TSMI and TSDD need disposing? yuck
                    var item = new ToolStripMenuItem {
                        Text = caption.Replace("&", "&&")
                    };
                    items.Add(item);

                    item.Click += (o, ev) =>
                    {
                        loadFileCallback(path);
                    };

                    var tsdd = new ToolStripDropDownMenu();

                    if (crazyStuff)
                    {
                        //TODO - use standard methods to split filename (hawkfile acquire?)
                        var  hf         = new HawkFile(physicalPath ?? throw new Exception("this will probably never appear but I can't be bothered checking --yoshi"), delayIOAndDearchive: true);
                        bool canExplore = File.Exists(hf.FullPathWithoutMember);

                        if (canExplore)
                        {
                            //make a menuitem to show the last modified timestamp
                            var timestamp     = File.GetLastWriteTime(hf.FullPathWithoutMember);
                            var tsmiTimestamp = new ToolStripLabel {
                                Text = timestamp.ToString()
                            };

                            tsdd.Items.Add(tsmiTimestamp);
                            tsdd.Items.Add(new ToolStripSeparator());

                            if (hf.IsArchive)
                            {
                                //make a menuitem to let you copy the path
                                var tsmiCopyCanonicalPath = new ToolStripMenuItem {
                                    Text = "&Copy Canonical Path"
                                };
                                tsmiCopyCanonicalPath.Click += (o, ev) => { Clipboard.SetText(physicalPath); };
                                tsdd.Items.Add(tsmiCopyCanonicalPath);

                                var tsmiCopyArchivePath = new ToolStripMenuItem {
                                    Text = "Copy Archive Path"
                                };
                                tsmiCopyArchivePath.Click += (o, ev) => { Clipboard.SetText(hf.FullPathWithoutMember); };
                                tsdd.Items.Add(tsmiCopyArchivePath);

                                var tsmiOpenArchive = new ToolStripMenuItem {
                                    Text = "Open &Archive"
                                };
                                tsmiOpenArchive.Click += (o, ev) => { System.Diagnostics.Process.Start(hf.FullPathWithoutMember); };
                                tsdd.Items.Add(tsmiOpenArchive);
                            }
                            else
                            {
                                // make a menuitem to let you copy the path
                                var tsmiCopyPath = new ToolStripMenuItem {
                                    Text = "&Copy Path"
                                };
                                tsmiCopyPath.Click += (o, ev) => { Clipboard.SetText(physicalPath); };
                                tsdd.Items.Add(tsmiCopyPath);
                            }

                            tsdd.Items.Add(new ToolStripSeparator());

                            // make a menuitem to let you explore to it
                            var tsmiExplore = new ToolStripMenuItem {
                                Text = "&Explore"
                            };
                            string explorePath = $"\"{hf.FullPathWithoutMember}\"";
                            tsmiExplore.Click += (o, ev) => { System.Diagnostics.Process.Start("explorer.exe", $"/select, {explorePath}"); };
                            tsdd.Items.Add(tsmiExplore);

                            var tsmiCopyFile = new ToolStripMenuItem {
                                Text = "Copy &File"
                            };
                            var lame = new System.Collections.Specialized.StringCollection
                            {
                                hf.FullPathWithoutMember
                            };

                            tsmiCopyFile.Click += (o, ev) => { Clipboard.SetFileDropList(lame); };
                            tsdd.Items.Add(tsmiCopyFile);

                            var tsmiTest = new ToolStripMenuItem {
                                Text = "&Shell Context Menu"
                            };
                            tsmiTest.Click += (o, ev) =>
                            {
                                var si    = new GongSolutions.Shell.ShellItem(hf.FullPathWithoutMember);
                                var scm   = new GongSolutions.Shell.ShellContextMenu(si);
                                var tsddi = o as ToolStripDropDownItem;
                                tsddi.Owner.Update();
                                scm.ShowContextMenu(tsddi.Owner, new System.Drawing.Point(0, 0));
                            };
                            tsdd.Items.Add(tsmiTest);

                            tsdd.Items.Add(new ToolStripSeparator());
                        }
                        else
                        {
                            //make a menuitem to show the last modified timestamp
                            var tsmiMissingFile = new ToolStripLabel {
                                Text = "-Missing-"
                            };
                            tsdd.Items.Add(tsmiMissingFile);
                            tsdd.Items.Add(new ToolStripSeparator());
                        }
                    }                     //crazystuff

                    //in any case, make a menuitem to let you remove the item
                    var tsmiRemovePath = new ToolStripMenuItem {
                        Text = "&Remove"
                    };
                    tsmiRemovePath.Click += (o, ev) => {
                        recent.Remove(path);
                    };
                    tsdd.Items.Add(tsmiRemovePath);

#if false //experiment of popping open a submenu. doesn't work well.
                    item.MouseDown += (o, mev) =>
                    {
                        if (mev.Button != MouseButtons.Right)
                        {
                            return;
                        }
                        //location of the menu containing this item that was just right-clicked
                        var pos = item.Owner.Bounds.Location;
                        //the offset within that menu of this item
                        pos.Offset(item.Bounds.Location);
                        //the offset of the click
                        pos.Offset(mev.Location);
//						tsdd.OwnerItem = item; //has interesting promise, but breaks things otherwise
                        tsdd.Show(pos);
                    };
#endif

                    //just add it to the submenu for now. seems to work well enough, even though its a bit odd
                    item.MouseDown += (o, mev) =>
                    {
                        if (mev.Button != MouseButtons.Right)
                        {
                            return;
                        }
                        if (item.DropDown != null)
                        {
                            item.DropDown = tsdd;
                        }
                        item.ShowDropDown();
                    };
                }
            }

            items.Add(new ToolStripSeparator());

            var clearItem = new ToolStripMenuItem {
                Text = "&Clear", Enabled = !recent.Frozen
            };
            clearItem.Click += (o, ev) => recent.Clear();
            items.Add(clearItem);

            var freezeItem = new ToolStripMenuItem
            {
                Text  = recent.Frozen ? "&Unfreeze" : "&Freeze",
                Image = recent.Frozen ? Properties.Resources.Unfreeze : Properties.Resources.Freeze
            };
            freezeItem.Click += (o, ev) => recent.Frozen ^= true;
            items.Add(freezeItem);

            if (!noAutoload)
            {
                var auto = new ToolStripMenuItem {
                    Text = $"&Autoload {entrySemantic}", Checked = recent.AutoLoad
                };
                auto.Click += (o, ev) => recent.ToggleAutoLoad();
                items.Add(auto);
            }

            var settingsItem = new ToolStripMenuItem {
                Text = "&Recent Settings..."
            };
            settingsItem.Click += (o, ev) =>
            {
                using var prompt = new InputPrompt
                      {
                          TextInputType = InputPrompt.InputType.Unsigned,
                          Message       = "Number of recent files to track",
                          InitialValue  = recent.MAX_RECENT_FILES.ToString()
                      };
                var result = mainForm.DoWithTempMute(() => prompt.ShowDialog());
                if (result == DialogResult.OK)
                {
                    int val = int.Parse(prompt.PromptText);
                    if (val > 0)
                    {
                        recent.MAX_RECENT_FILES = val;
                    }
                }
            };
            items.Add(settingsItem);

            return(items.ToArray());
        }
Beispiel #8
0
        /// <summary>
        /// chose an IVideoWriter
        /// </summary>
        /// <param name="list">list of IVideoWriters to choose from</param>
        /// <param name="owner">parent window</param>
        /// <param name="emulator">The current emulator</param>
        /// <returns>user choice, or null on Cancel\Close\invalid</returns>
        public static IVideoWriter DoVideoWriterChooserDlg(
            IEnumerable <VideoWriterInfo> list,
            IMainFormForTools owner,
            IEmulator emulator,
            Config config,
            out int resizeW,
            out int resizeH,
            out bool pad,
            ref bool audioSync)
        {
            var dlg = new VideoWriterChooserForm(owner, emulator, config)
            {
                labelDescriptionBody = { Text = "" }
            };

            int idx       = 0;
            int idxSelect = -1;

            dlg.listBox1.BeginUpdate();
            foreach (var vw in list)
            {
                dlg.listBox1.Items.Add(vw);
                if (vw.Attribs.ShortName == config.VideoWriter)
                {
                    idxSelect = idx;
                }

                idx++;
            }

            dlg.listBox1.SelectedIndex = idxSelect;
            dlg.listBox1.EndUpdate();

            foreach (Control c in dlg.panelSizeSelect.Controls)
            {
                c.Enabled = false;
            }

            dlg.checkBoxASync.Checked = audioSync;
            var result = owner.ShowDialogAsChild(dlg);

            IVideoWriter ret;

            if (result == DialogResult.OK && dlg.listBox1.SelectedIndex != -1)
            {
                var vwi = (VideoWriterInfo)dlg.listBox1.SelectedItem;
                ret = vwi.Create();
                config.VideoWriter = vwi.Attribs.ShortName;
            }
            else
            {
                ret = null;
            }

            if (ret != null && dlg.checkBoxResize.Checked)
            {
                resizeW = dlg.numericTextBoxW.IntValue;
                resizeH = dlg.numericTextBoxH.IntValue;
            }
            else
            {
                resizeW = -1;
                resizeH = -1;
            }

            pad       = dlg.checkBoxPad.Checked;
            audioSync = dlg.checkBoxASync.Checked;

            dlg.Dispose();
            return(ret);
        }