示例#1
0
        public bool Launch(LauncherPath gameFileDirectory, LauncherPath tempDirectory,
                           IGameFile gameFile, ISourcePortData sourcePort, bool isGameFileIwad)
        {
            if (!Directory.Exists(sourcePort.Directory.GetFullPath()))
            {
                LastError = string.Concat("The source port directory does not exist:", Environment.NewLine, Environment.NewLine,
                                          sourcePort.Directory.GetPossiblyRelativePath());
                return(false);
            }

            GameFile   = gameFile;
            SourcePort = sourcePort;

            string launchParameters = GetLaunchParameters(gameFileDirectory, tempDirectory, gameFile, sourcePort, isGameFileIwad);

            if (!string.IsNullOrEmpty(launchParameters))
            {
                Directory.SetCurrentDirectory(sourcePort.Directory.GetFullPath());

                try
                {
                    Process proc = Process.Start(sourcePort.GetFullExecutablePath(), launchParameters);
                    proc.EnableRaisingEvents = true;
                    proc.Exited += proc_Exited;
                }
                catch
                {
                    LastError = "Failed to execute the source port process.";
                    return(false);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        public bool RunUtility(IGameFile gameFile)
        {
            SpecificFilesForm form = new SpecificFilesForm();

            form.AutoCheckSupportedExtensions(false);
            form.ShowPkContentsCheckBox(true);
            form.Initialize(m_config.GameFileDirectory, new IGameFile[] { gameFile }, SourcePortData.GetSupportedExtensions(m_utility),
                            new string[] { }, m_config.TempDirectory);
            form.StartPosition = FormStartPosition.CenterParent;

            if (form.ShowDialog(m_parent) == DialogResult.OK)
            {
                var files = form.GetPathedSpecificFiles();

                GameFilePlayAdapter adapter = new GameFilePlayAdapter();
                StringBuilder       sb      = new StringBuilder();
                adapter.HandleGameFile(gameFile, sb, m_config.GameFileDirectory, m_config.TempDirectory,
                                       new GenericSourcePort(m_utility), files); //this checks File.Exists and might not be same file

                try
                {
                    if (!string.IsNullOrEmpty(m_utility.ExtraParameters))
                    {
                        sb.Append(" " + m_utility.ExtraParameters);
                    }

                    Process.Start(m_utility.GetFullExecutablePath(), sb.ToString().Trim());
                }
                catch
                {
                    return(false);
                }
            }

            return(true);
        }