コード例 #1
0
ファイル: Launcher.cs プロジェクト: SteveLever73/Budford
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="fileName"></param>
        /// <param name="forceFullScreen"></param>
        internal void LaunchRpx(Model.Model model, string fileName, bool forceFullScreen = false)
        {
            makeBorderLess = false;
            string cemuExe = "";
            var    latest  = model.Settings.InstalledVersions.FirstOrDefault(v => v.IsLatest);

            if (latest != null)
            {
                cemuExe = Path.Combine(latest.Folder, CemuFeatures.Cemu);
            }

            if (File.Exists(cemuExe))
            {
                if (model.Settings.DisableShaderCache)
                {
                    FileManager.DeleteShaderCache(latest);
                }

                CemuSettings cs = new CemuSettings(model, null, null);
                cs.WriteSettingsBinFile();

                // Prepare the process to run
                ProcessStartInfo start = new ProcessStartInfo
                {
                    Arguments      = forceFullScreen ? "-f -g \"" + fileName + "\"" : "-g \"" + fileName + "\"",
                    FileName       = cemuExe,
                    CreateNoWindow = true
                };

                // Run the external process & wait for it to finish
                startTime      = DateTime.Now;
                runningProcess = Process.Start(start);
            }
            else
            {
                MessageBox.Show(parent, Resources.Launcher_LaunchCemu_Please_install_CEMU, Resources.Launcher_LaunchCemu_CEMU_is_not_installed);
                if (parent != null)
                {
                    parent.ProcessExited();
                }
            }
        }
コード例 #2
0
ファイル: Launcher.cs プロジェクト: SteveLever73/Budford
        /// <summary>
        ///
        /// </summary>
        /// <param name="parentIn"></param>
        /// <param name="modelIn"></param>
        /// <param name="game"></param>
        /// <param name="getSaveDir"></param>
        /// <param name="cemuOnly"></param>
        /// <param name="shiftUp"></param>
        /// <param name="forceFullScreen"></param>
        internal void LaunchCemu(FormMainWindow parentIn, Model.Model modelIn, GameInformation game, bool getSaveDir = false, bool cemuOnly = false, bool shiftUp = true, bool forceFullScreen = false)
        {
            makeBorderLess = false;
            SetCemuVersion(modelIn, game);

            if (runningVersion == null)
            {
                if (parent != null)
                {
                    parent.ProcessExited();
                }
                return;
            }

            Model = modelIn;

            if (game != null && !game.Exists)
            {
                if (parentIn != null)
                {
                    if (!parentIn.InvokeRequired)
                    {
                        MessageBox.Show(parentIn, Resources.Launcher_LaunchCemu_If_you_are_using_a_removable_storage_device_check_it_is_plugged_in_and_try_again, Resources.Launcher_LaunchCemu_Can_not_find_file);
                        if (parent != null)
                        {
                            parent.ProcessExited();
                        }
                    }
                }
                return;
            }

            if (File.Exists(cemu) || File.Exists(modelIn.Settings.WineExe))
            {
                DeleteLogFile(modelIn, logfile);
                SetupCafeLibs(modelIn, game);
                if (game != null)
                {
                    CopyLargestShaderCacheToCemu(game);
                    CopyLatestSaveToCemu(game);
                }

                if (modelIn.Settings.DisableShaderCache)
                {
                    FileManager.DeleteShaderCache(runningVersion);
                }

                if (!getSaveDir)
                {
                    CreateDefaultSettingsFile(runningVersion, game);

                    DeleteShaderCacheIfRequired(modelIn, runningVersion);

                    CreateDefaultSettingsFile(modelIn, game);
                }
                // Prepare the process to run
                ProcessStartInfo start = new ProcessStartInfo();

                PopulateStartInfo(game, getSaveDir, cemuOnly, CemuFeatures.Cemu, start, shiftUp, forceFullScreen);

                // Required since 1.11.2
                if (runningVersion != null)
                {
                    start.WorkingDirectory = runningVersion.Folder;
                }

                // Run the external process & wait for it to finish
                var parentProcess = Process.GetCurrentProcess();
                var original      = parentProcess.PriorityClass;

                parentProcess.PriorityClass = GetProcessPriority(modelIn.Settings.ShaderPriority);

                startTime = DateTime.Now;
                if (File.Exists(Path.Combine(runningVersion.Folder, start.FileName)))
                {
                    runningProcess = Process.Start(start);

                    if (runningProcess != null)
                    {
                        runningProcess.EnableRaisingEvents = true;
                        runningProcess.Exited += proc_Exited;

                        runningGame = game;

                        if (parentIn != null)
                        {
                            try
                            {
                                parentIn.SetParent(runningProcess);
                            }
                            catch (Exception)
                            {
                                // Dies in Linux
                            }
                        }
                        parentProcess.PriorityClass = original;

                        // Allow the process to finish starting.
                        if (runningProcess != null)
                        {
                            try
                            {
                                runningProcess.PriorityClass = GetProcessPriority(modelIn.Settings.ShaderPriority);
                            }
                            catch (Exception)
                            {
                                // Probably not enough permissions...
                            }
                            WaitForProcess(modelIn, game, getSaveDir, cemuOnly);
                        }
                    }
                }
                else
                {
                    if (parent != null)
                    {
                        parent.ProcessExited();
                    }
                }
            }
            else
            {
                MessageBox.Show(parentIn, Resources.Launcher_LaunchCemu_Please_install_CEMU, Resources.Launcher_LaunchCemu_CEMU_is_not_installed);
                if (parent != null)
                {
                    parent.ProcessExited();
                }
            }
        }