Esempio n. 1
0
        private static void BrowseFolder(TextBox box, string name, string system)
        {
            // Ugly hack, we don't want to pass in the system in for system base and global paths
            if (name == "Base" || system == "Global" || system == "Global_NULL")
            {
                system = null;
            }

            var f = new FolderBrowserEx
            {
                Description = "Set the directory for " + name,
                SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
            };
            var result = f.ShowDialog();
            if (result == DialogResult.OK)
            {
                box.Text = PathManager.TryMakeRelative(f.SelectedPath, system);
            }
        }
Esempio n. 2
0
		private static void BrowseFolder(TextBox box, string name, string system)
		{
			// Ugly hack, we don't want to pass in the system in for system base and global paths
			if (name == "Base" || system == "Global" || system == "Global_NULL")
			{
				system = null;
			}

			var f = new FolderBrowserEx
			{
				Description = "Set the directory for " + name,
				SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
			};
			var result = f.ShowDialog();
			if (result == DialogResult.OK)
			{
				box.Text = PathManager.TryMakeRelative(f.SelectedPath, system);
			}
		}
Esempio n. 3
0
        private static void BrowseFolder(TextBox box, string name, string system)
        {
            // Ugly hack, we don't want to pass in the system in for system base and global paths
            if (name == "Base" || system == "Global" || system == "Global_NULL")
            {
                system = null;
            }

            DialogResult result       = new DialogResult();
            string       selectedPath = "";

            if (!BizHawk.Common.PlatformLinkedLibSingleton.RunningOnUnix)
            {
                var f = new FolderBrowserEx
                {
                    Description  = "Set the directory for " + name,
                    SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
                };
                result       = f.ShowDialog();
                selectedPath = f.SelectedPath;
            }
            else
            {
                // mono does not like FolderBrowserEx because of its managed calls
                // do standard winforms on *nix
                var f = new FolderBrowserDialog
                {
                    Description  = "Set the directory for " + name,
                    SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
                };
                result       = f.ShowDialog();
                selectedPath = f.SelectedPath;
            }


            if (result == DialogResult.OK)
            {
                box.Text = PathManager.TryMakeRelative(selectedPath, system);
            }
        }
        private void BrowseFolder(TextBox box, string name, string system)
        {
            // Ugly hack, we don't want to pass in the system in for system base and global paths
            if (name == "Base" || system == "Global" || system == "Global_NULL")
            {
                BrowseFolder(box, name, system: null);
                return;
            }

            DialogResult result;
            string       selectedPath;

            if (OSTailoredCode.IsUnixHost)
            {
                // FolderBrowserEx doesn't work in Mono for obvious reasons
                using var f = new FolderBrowserDialog
                      {
                          Description  = $"Set the directory for {name}",
                          SelectedPath = _pathEntries.AbsolutePathFor(box.Text, system)
                      };
                result       = f.ShowDialog();
                selectedPath = f.SelectedPath;
            }
            else
            {
                using var f = new FolderBrowserEx
                      {
                          Description  = $"Set the directory for {name}",
                          SelectedPath = _pathEntries.AbsolutePathFor(box.Text, system)
                      };
                result       = f.ShowDialog();
                selectedPath = f.SelectedPath;
            }
            if (result.IsOk())
            {
                box.Text = _pathEntries.TryMakeRelative(selectedPath, system);
            }
        }
Esempio n. 5
0
        private static void BrowseFolder(TextBox box, string name, string system)
        {
            // Ugly hack, we don't want to pass in the system in for system base and global paths
            if (name == "Base" || system == "Global" || system == "Global_NULL")
            {
                system = null;
            }

            DialogResult result;
            string       selectedPath;

            if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
            {
                using var f = new FolderBrowserEx
                      {
                          Description  = $"Set the directory for {name}",
                          SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
                      };
                result       = f.ShowDialog();
                selectedPath = f.SelectedPath;
            }
            else
            {
                // FolderBrowserEx doesn't work in Mono for obvious reasons
                using var f = new FolderBrowserDialog
                      {
                          Description  = $"Set the directory for {name}",
                          SelectedPath = PathManager.MakeAbsolutePath(box.Text, system)
                      };
                result       = f.ShowDialog();
                selectedPath = f.SelectedPath;
            }
            if (result == DialogResult.OK)
            {
                box.Text = PathManager.TryMakeRelative(selectedPath, system);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// start AV recording
        /// </summary>
        private void _RecordAv(string videowritername, string filename, bool unattended)
        {
            if (_currAviWriter != null)
            {
                return;
            }

            // select IVideoWriter to use
            IVideoWriter aw = null;

            if (unattended)
            {
                aw = VideoWriterInventory.GetVideoWriter(videowritername);

            }
            else
            {
                aw = VideoWriterChooserForm.DoVideoWriterChoserDlg(VideoWriterInventory.GetAllWriters(), this,
                    out _avwriterResizew, out _avwriterResizeh, out _avwriterpad, out _dumpaudiosync);
            }

            if (aw == null)
            {
                GlobalWin.OSD.AddMessage(
                    unattended ? string.Format("Couldn't start video writer \"{0}\"", videowritername) : "A/V capture canceled.");

                return;
            }

            try
            {
                if (_dumpaudiosync)
                {
                    aw = new VideoStretcher(aw);
                }
                else
                {
                    aw = new AudioStretcher(aw);
                }

                aw.SetMovieParameters(Global.Emulator.CoreComm.VsyncNum, Global.Emulator.CoreComm.VsyncDen);
                if (_avwriterResizew > 0 && _avwriterResizeh > 0)
                {
                    aw.SetVideoParameters(_avwriterResizew, _avwriterResizeh);
                }
                else
                {
                    aw.SetVideoParameters(Global.Emulator.VideoProvider().BufferWidth, Global.Emulator.VideoProvider().BufferHeight);
                }

                aw.SetAudioParameters(44100, 2, 16);

                // select codec token
                // do this before save dialog because ffmpeg won't know what extension it wants until it's been configured
                if (unattended)
                {
                    aw.SetDefaultVideoCodecToken();
                }
                else
                {
                    var token = aw.AcquireVideoCodecToken(this);
                    if (token == null)
                    {
                        GlobalWin.OSD.AddMessage("A/V capture canceled.");
                        aw.Dispose();
                        return;
                    }

                    aw.SetVideoCodecToken(token);
                }

                // select file to save to
                if (unattended)
                {
                    aw.OpenFile(filename);
                }
                else
                {
                    string ext = aw.DesiredExtension();
                    string pathForOpenFile;

                    //handle directories first
                    if (ext == "<directory>")
                    {
                        var fbd = new FolderBrowserEx();
                        if (fbd.ShowDialog() == DialogResult.Cancel)
                        {
                            aw.Dispose();
                            return;
                        }
                        pathForOpenFile = fbd.SelectedPath;
                    }
                    else
                    {
                        var sfd = new SaveFileDialog();
                        if (Global.Game != null)
                        {
                            sfd.FileName = PathManager.FilesystemSafeName(Global.Game) + "." + ext; //dont use Path.ChangeExtension, it might wreck game names with dots in them
                            sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AvPathFragment, null);
                        }
                        else
                        {
                            sfd.FileName = "NULL";
                            sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AvPathFragment, null);
                        }

                        sfd.Filter = string.Format("{0} (*.{0})|*.{0}|All Files|*.*", ext);

                        var result = sfd.ShowHawkDialog();
                        if (result == DialogResult.Cancel)
                        {
                            aw.Dispose();
                            return;
                        }

                        pathForOpenFile = sfd.FileName;
                    }

                    aw.OpenFile(pathForOpenFile);
                }

                // commit the avi writing last, in case there were any errors earlier
                _currAviWriter = aw;
                GlobalWin.OSD.AddMessage("A/V capture started");
                AVIStatusLabel.Image = Properties.Resources.AVI;
                AVIStatusLabel.ToolTipText = "A/V capture in progress";
                AVIStatusLabel.Visible = true;
            }
            catch
            {
                GlobalWin.OSD.AddMessage("A/V capture failed!");
                aw.Dispose();
                throw;
            }

            if (_dumpaudiosync)
            {
                Global.Emulator.EndAsyncSound();
            }
            else
            {
                _aviSoundInput = !Global.Emulator.StartAsyncSound()
                    ? new MetaspuAsync(Global.Emulator.SyncSoundProvider, ESynchMethod.ESynchMethod_V)
                    : Global.Emulator.SoundProvider;
            }
            _dumpProxy = new MetaspuSoundProvider(ESynchMethod.ESynchMethod_V);
            RewireSound();
        }