Beispiel #1
0
        private void StartGame()
        {
            string cmdlineparamters = File.ReadLines("avp2cmds.txt").FirstOrDefault();

            cmdlineparamters = stripResolutionParameters(cmdlineparamters);

            if (customConfig.Windowed)
            {
                cmdlineparamters += " +windowed 1";
            }
            else
            {
                cmdlineparamters += " +windowed 0";
            }

            if (customConfig.DisableSound)
            {
                cmdlineparamters += " +DisableSound 1";
            }
            else
            {
                cmdlineparamters += " +DisableSound 0";
            }

            if (customConfig.DisableMusic)
            {
                cmdlineparamters += " +DisableMusic 1";
            }
            else
            {
                cmdlineparamters += " +DisableMusic 0";
            }

            if (customConfig.DisableLogos)
            {
                cmdlineparamters += " +DisableMovies 1";
            }
            else
            {
                cmdlineparamters += " +DisableMovies 0";
            }

            if (customConfig.DisableJoystick)
            {
                cmdlineparamters += " +DisableJoystick 1";
            }
            else
            {
                cmdlineparamters += " +DisableJoystick 0";
            }

            if (customConfig.DisableTrippleBuffering)
            {
                cmdlineparamters += " +EnableTripBuf 0";
            }
            else
            {
                cmdlineparamters += " +EnableTripBuf 1";
            }

            if (customConfig.DisableHardwareCursor)
            {
                cmdlineparamters += " +DisableHardwareCursor 1";
            }
            else
            {
                cmdlineparamters += " +DisableHardwareCursor 0";
            }

            if (customConfig.LithFixEnabled)
            {
                cmdlineparamters += " -rez lithfix";
            }

            cmdlineparamters += $" {originalParams} {customConfig.CVARS}";

            LogHandler.WriteLine("Launch parameters are: " + cmdlineparamters);

            Thread GameHackThread = new Thread(_gamehack.DoWork);

            if (customConfig.AspectRatioFix)
            {
                _gamehack.SendValues(customConfig.FOV, (int)lithTechConfig.GameScreenWidth, (int)lithTechConfig.GameScreenHeight, customConfig.LithFixEnabled);
                GameHackThread.Start();
            }

            try
            {
                Process gameProcess = new Process();
                gameProcess.StartInfo.FileName         = Path.Combine(Directory.GetCurrentDirectory(), "Lithtech.exe");
                gameProcess.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
                gameProcess.StartInfo.Arguments        = cmdlineparamters;
                this.WindowState = FormWindowState.Minimized;

                gameProcess.Start();
                gameProcess.WaitForExit();
                _gamehack.RequestStop();
                this.Close();
            }
            catch (Exception ex)
            {
                LogHandler.WriteLine("An error occurred when creating new process: " + ex.Message);
                return;
            }
        }