예제 #1
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            string armaPath = Arma.GetArmaOAPath();

            Directory.Delete(armaPath + "\\@dayzmod", true);
            File.Delete(armaPath + "\\" + Main.keyFileName);
            Application.Restart();
        }
예제 #2
0
        private void btn_path2_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title            = "Выберете путь до arma2oa.exe";
            openFileDialog1.InitialDirectory = @"%PROGRAMFILES%"; // Open Program Files as start dir
            openFileDialog1.Filter           = "Файл запуска Arma: OA|arma2oa.exe";
            openFileDialog1.FileName         = "arma2oa.exe";
            openFileDialog1.DefaultExt       = "exe";
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileInfo path = new FileInfo(openFileDialog1.FileName);
                txtbox_arma2.Text = path.DirectoryName;
                Arma.UpdateArmaPath(path.DirectoryName, "armaoa");
            }
        }
예제 #3
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();
        }
예제 #4
0
 private void btn_changekey_Click(object sender, EventArgs e)
 {
     byte[] numArray = this.SerialToRegistry(this.box_cdkey.Text);
     if (Arma.SetArmaOAKey(numArray))
     {
         string str   = this.RegistryToSerial(numArray);
         string input = str.Substring(0, 4) + "-" + str.Substring(4, 5) + "-" + str.Substring(9, 5) + "-" + str.Substring(14, 5) + "-" + str.Substring(19, 5);
         SystemSounds.Exclamation.Play();
         int num = (int)MessageBox.Show("Ключь успешно сохранён");
         this.box_hexkey.Text = BitConverter.ToString(numArray);
         this.box_cdkey.Text  = input;
         this.box_guid.Text   = Tools.getMd5Hash("BE" + Tools.getMd5Hash(input));
     }
     else
     {
         SystemSounds.Hand.Play();
         int num = (int)MessageBox.Show("Сохранить ключ не удалось");
     }
 }
예제 #5
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;
            }
        }
예제 #6
0
 internal static string GetArmaOAPath()
 {
     try
     {
         RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(Arma.strArmaOARegLocation[Arma.GetArch()]);
         if (registryKey != null)
         {
             return(registryKey.GetValue("MAIN").ToString());
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         return(null);
     }
 }
예제 #7
0
 internal static bool SetArmaOAKey(byte[] hexkey)
 {
     try
     {
         RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(Arma.strArmaOARegLocation[Arma.GetArch()], true);
         if (registryKey == null)
         {
             return(false);
         }
         registryKey.SetValue("KEY", (object)hexkey);
         registryKey.Close();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #8
0
 internal static byte[] GetArmaOAKey()
 {
     try
     {
         RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(Arma.strArmaOARegLocation[Arma.GetArch()]);
         if (registryKey != null)
         {
             return((byte[])registryKey.GetValue("KEY"));
         }
         else
         {
             return((byte[])null);
         }
     }
     catch
     {
         return((byte[])null);
     }
 }