Example #1
0
        public Tools(bool full = false)
        {
            InitializeComponent();

            if (full)
            {
                btn_changekey.Enabled = true;
                btn_changekey.Visible = true;
                box_cdkey.ReadOnly    = false;
            }
            try
            {
                string armaPath  = Arma.GetArmaOAPath() + "\\Expansion\\beta\\arma2oa.exe";
                byte[] armaOaKey = Arma.GetArmaOAKey();
                string cdkey     = RegistryToSerial(armaOaKey);
                string input     = cdkey.Substring(0, 4) + "-" + cdkey.Substring(4, 5) + "-" + cdkey.Substring(9, 5) + "-" + cdkey.Substring(14, 5) + "-" + cdkey.Substring(19, 5);
                box_hexkey.Text         = BitConverter.ToString(armaOaKey);
                box_cdkey.Text          = input;
                box_guid.Text           = getMd5Hash("BE" + getMd5Hash(input));
                btn_startUpdate.Visible = false;
                txtbox_arma1.Text       = Arma.GetArmaPath();
                txtbox_arma2.Text       = Arma.GetArmaOAPath();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            new Thread(() =>
            {
                if (CheckBetaPatch())
                {
                    if (btn_startUpdate.InvokeRequired)
                    {
                        btn_startUpdate.BeginInvoke(new Action(() => { btn_startUpdate.Visible = true; }));
                    }
                    else
                    {
                        btn_startUpdate.Visible = true;
                    }
                }
            }).Start();
        }
Example #2
0
        private void Launch()
        {
            UpdateStatus("Запускаю игру...");
            Process process      = new Process();
            string  ArmaPath     = Arma.GetArmaPath();
            string  ArmaFreePath = Arma.GetArmaFreePath();

            if (System.IO.File.Exists(ArmaBasePath + "\\arma2.exe"))
            {
                ArmaPath = ArmaBasePath;
            }

            if (ArmaPath == null && ArmaFreePath == null)    // Есть ли следы игры в реестре ?
            {
                MessageBox.Show("Немогу найти Arma или Arma Free. Установите игру и запустите хотябы 1 раз.");
                Environment.Exit(0);
            }

            if (!Directory.Exists(ArmaBasePath + "\\Expansion\\beta")) // Проверка, есть ли директория с бэта-патчем
            {
                MessageBox.Show("Для игры необходим последний Beta-патч!");
                Environment.Exit(0);
            }
            else
            {
                if (ArmaBasePath.IndexOf("steamapps") > 0) // Если в пути к игре есть слово Steamapps - Считаем, что мы имеем дело со Steam верисией игры
                {
                    try                                    // Получаем путь до выполняемого файла из реестра
                    {
                        RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(strSteamRegPath);
                        if (registryKey != null)
                        {
                            process.StartInfo.FileName = registryKey.GetValue("SteamExe").ToString();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Немогу найти Steam");
                        Environment.Exit(0);
                    }

                    try // Фикс запуска Стим версии, в виде подмены исполняемого файла
                    {
                        if (FileVersionInfo.GetVersionInfo(ArmaBasePath + "\\arma2oa.exe").ProductVersion != FileVersionInfo.GetVersionInfo(ArmaBasePath + "\\Expansion\\beta\\arma2oa.exe").ProductVersion)
                        {
                            if (System.IO.File.Exists(ArmaBasePath + "\\arma2oa.bak"))
                            {
                                System.IO.File.Delete(ArmaBasePath + "\\arma2oa.bak");
                            }
                            System.IO.File.Move(ArmaBasePath + "\\arma2oa.exe", ArmaBasePath + "\\arma2oa.bak");
                            System.IO.File.Copy(ArmaBasePath + "\\Expansion\\beta\\arma2oa.exe", ArmaBasePath + "\\arma2oa.exe", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);    // Если есть какие траблы - выводим
                    }
                    // Строка запуска ...
                    process.StartInfo.Arguments = "-applaunch 33930 -skipIntro -noSplash -noFilePatching -world=empty \"-mod=" + ArmaPath + ";expansion;expansion\\beta;expansion\\beta\\expansion;@dayzmod\" -connect=" + ServerIP + " -port=" + ServerPort;
                }
                else if (ArmaBasePath != ArmaPath && ArmaPath != null) // Arma2 и Arma2: OA установлены в разные папки
                {
                    process.StartInfo.FileName         = ArmaBasePath + "\\Expansion\\beta\\arma2oa.exe";
                    process.StartInfo.Arguments        = " -skipIntro -noSplash -noFilePatching -world=empty \"-mod=" + ArmaPath + ";expansion;expansion\\beta;expansion\\beta\\expansion;@dayzmod\" -connect=" + ServerIP + " -port=" + ServerPort;
                    process.StartInfo.WorkingDirectory = ArmaBasePath;
                }
                else if (ArmaFreePath != null)    // Используется Arma Free...
                {
                    process.StartInfo.FileName         = ArmaBasePath + "\\Expansion\\beta\\arma2oa.exe";
                    process.StartInfo.Arguments        = " -skipIntro -noSplash -noFilePatching -world=empty \"-mod=" + ArmaFreePath + ";expansion;expansion\\beta;expansion\\beta\\expansion;@dayzmod\" -connect=" + ServerIP + " -port=" + ServerPort;
                    process.StartInfo.WorkingDirectory = ArmaBasePath;
                }
                else
                { // Arma2 и Arma2: OA в одной папке...
                    process.StartInfo.FileName         = ArmaBasePath + "\\Expansion\\beta\\arma2oa.exe";
                    process.StartInfo.Arguments        = " -beta=Expansion\\beta;Expansion\\beta\\Expansion -nosplash -skipIntro -mod=@dayzmod -world=empty -connect=" + ServerIP + " -port=" + ServerPort;
                    process.StartInfo.WorkingDirectory = ArmaBasePath;
                }

                /* Debug - Запуск блокнота намного быстре, чем запуск игры :) *
                 * process.StartInfo.FileName = "notepad.exe";
                 * process.StartInfo.Arguments = "";
                 * process.StartInfo.WorkingDirectory = @"D:/";
                 */

                // Сворачиваем лаунчер в трей
                WindowState         = FormWindowState.Minimized;
                notifyIcon1.Visible = true;
                notifyIcon1.ShowBalloonTip(100);
                Hide();

                // Запускаем сам процесс и ждём завершения
                process.Start();
                UpdateStatus("Игра в процессе.");
                process.WaitForExit();
                UpdateStatus("Всё готово для запуска игры");

                // Покаываем
                Show();
                WindowState         = FormWindowState.Normal;
                notifyIcon1.Visible = false;
                TopMost             = true; // Fix - brign to front
                Focus();
                TopMost = false;
            }
        }