示例#1
0
        public void Run(GameExecutable executable)
        {
            Mediator.MainForm.Hide();

            string           confPath = CreateNewConf(executable.Game);
            ProcessStartInfo psi      = new ProcessStartInfo(ExePath);

            psi.UseShellExecute = false;
            psi.Arguments       = "\"" + executable.ExePath + "\" -userconf \"" + UserConfigPath + "\" -conf \"" + confPath + "\" -noconsole -machine " + MachineType + " -forcescaler " + Scaler;
            psi.CreateNoWindow  = true;
            Process process = Process.Start(psi);
            int     cycles  = 0;

            while (process.WaitForExit(1000) == false)
            {
                process.Refresh();
                Match match = Regex.Match(process.MainWindowTitle, @"(\d+) cycles");
                if (match.Success)
                {
                    cycles = int.Parse(match.Groups[1].Value);
                }
            }

            Mediator.MainForm.Show();
            File.Delete(confPath);
            executable.Game.Cycles = cycles;
        }
示例#2
0
        public static void RunGame(object sender, EventArgs e)
        {
            Game game = GetSelectedGame();

            if (game != null)
            {
                GameExecutable executable = game.GetTargetExecutable();
                if (executable != null)
                {
                    Mediator.SetProfileString("DosBoxDirectory", DetectDosBox(), Mediator.SysProfilePath);
                    DosBox dosBox = GetDosBox();
                    if (dosBox.Verify())
                    {
                        int tick = Environment.TickCount;
                        dosBox.Run(executable);
                        tick = Environment.TickCount - tick;
                        game.PlayCount++;
                        game.PlayTime += tick / 1000;
                        StatusStrip.SetGame(game);
                    }
                    else
                    {
                        MessageBox.Show(MainForm, "DosBox executable is not found." + Environment.NewLine + "Download DosBox from http://www.dosbox.com.", "DosBlaster", MessageBoxButtons.OK);
                    }
                }
            }
        }