private void launchGame(object sender, EventArgs e)
        {
            if (Launcher.working)
            {
                return;
            }

            var game = ((PictureBox)sender).Name;

            if (game.Contains("mp") && !Environment.Is64BitOperatingSystem)
            {
                MessageBox.Show("The TruckersMP Mod does not support 32-Bit operating systems.\nPlease upgrade your system to 64-Bit.", "TruckersMP Launcher - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (game.Contains("mp"))
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate
                {
                    TruckersMP.integrityCheck(TruckersMPUpdateProgress, TruckersMPUpdateProgressLabel, true, game);
                });
                return;
            }

            if (game.Equals("play_ets2_btn"))
            {
                Game.runETS2();
            }
            else if (game.Equals("play_ats_btn"))
            {
                Game.runATS();
            }
        }
Exemple #2
0
        public static void initialize(CProgressBar TruckersMPUpdateProgress, Label TruckersMPUpdateProgressLabel)
        {
            if (Properties.Settings.Default.StartSteam)
            {
                if (Process.GetProcessesByName("Steam").Length == 0)
                {
                    Microsoft.Win32.RegistryKey steamKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Valve\\Steam");
                    if (steamKey != null)
                    {
                        string SteamExe = (string)steamKey.GetValue("SteamExe");
                        if (SteamExe != null)
                        {
                            Process.Start(SteamExe);
                        }
                    }
                }
            }

            Launcher.ETS2Installed = false;
            Launcher.ATSInstalled  = false;
            Microsoft.Win32.RegistryKey readKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\TruckersMP");
            if (readKey != null)
            {
                Launcher.TruckersMPLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\TruckersMP";
                Launcher.ETS2Location       = (string)readKey.GetValue("InstallLocationETS2");
                Launcher.ATSLocation        = (string)readKey.GetValue("InstallLocationATS");

                if (System.IO.Directory.Exists(Launcher.ETS2Location))
                {
                    Launcher.ETS2Installed = true;
                }

                if (System.IO.Directory.Exists(Launcher.ATSLocation))
                {
                    Launcher.ATSInstalled = true;
                }

                if (!System.IO.Directory.Exists(Launcher.TruckersMPLocation))
                {
                    DialogResult dialogResult = MessageBox.Show("Unable to locate TruckersMP.\n\nDo you want to install it now?\n(required)", "TruckersMP Launcher", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dialogResult == DialogResult.Yes)
                    {
                        System.Threading.ThreadPool.QueueUserWorkItem(delegate
                        {
                            TruckersMP.install(TruckersMPUpdateProgress, TruckersMPUpdateProgressLabel);
                        });
                    }
                    else
                    {
                        Environment.Exit(1);
                    }
                }
                else
                {
                    if (!(Launcher.ETS2Installed || Launcher.ATSInstalled))
                    {
                        DialogResult dialogResult = MessageBox.Show("There seems to be a problem with your TruckersMP install.\n\nDo you want to reinstall TruckersMP?\n(required)", "TruckersMP Launcher", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (dialogResult == DialogResult.Yes)
                        {
                            System.Threading.ThreadPool.QueueUserWorkItem(delegate
                            {
                                TruckersMP.install(TruckersMPUpdateProgress, TruckersMPUpdateProgressLabel, true);
                            });
                        }
                        else
                        {
                            Environment.Exit(1);
                        }
                    }
                    else
                    {
                        System.Threading.ThreadPool.QueueUserWorkItem(delegate
                        {
                            TruckersMP.integrityCheck(TruckersMPUpdateProgress, TruckersMPUpdateProgressLabel);
                        });
                    }
                }
            }
            else
            {
                DialogResult dialogResult = MessageBox.Show("TruckersMP has not been installed!\n\nPlease run the TruckersMP installer once.\n\nWant to do it now? ", "TruckersMP Launcher", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogResult == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("http://truckersmp.com/en_US/download");
                    Environment.Exit(1);
                }
                else
                {
                    Environment.Exit(1);
                }
            }
        }