Example #1
0
        public static void Launch(FormConfiguration conf, LaunchOptions options, bool worldBuilderLaunch)
        {
            LocalFilesWorker.SetGameFiles(conf);
            if (options.DeleteOldVersions)
            {
                LocalFilesWorker.DeleteAllOldPatchFiles(conf.Patch);
            }

            if (conf.Patch is BPatch && IPChecker.IsCurrentUserBanned())
            {
                LocalFilesWorker.DeleteAllPatchFiles(conf.Patch);
                MessageBox.Show(" Sorry, but infantry is countered by antiInfantry, DeLauncher counters BP Bruce now. \r Nonsense: Russian sanctions against an American, lol) \r If you are not Bruce, sorry, send a private message to DeL, i'll fix that");
                return;
            }

            var id = StartExe(conf, options, worldBuilderLaunch);

            var mon = new Monitor(id);

            mon.StartMonitoring();

            while (!mon.IsArrived)
            {
                Thread.Sleep(5000);
            }

            LocalFilesWorker.SetGameFilesBack();
        }
Example #2
0
        private async void LaunchManualSelectedFile(string fileName, bool worldBuilderLaunch)
        {
            if (!noInternet && !worldBuilderLaunch)
            {
                await CheckAndApplyOptions();
            }

            if (fileName.Contains("HP"))
            {
                configuration.Patch = new HPatch();
            }

            if (fileName.Contains("BP"))
            {
                configuration.Patch = new BPatch();
            }

            LocalFilesWorker.ActivateFileByName(fileName);

            this.Hide();

            SaveConfigAndOptions(this, null);
            await Task.Run(() => GameLauncher.Launch(configuration, options, worldBuilderLaunch));

            this.Close();
        }
Example #3
0
        private async void LaunchWithUpdate(bool worldBuilderLaunch)
        {
            if (!noInternet && !worldBuilderLaunch)
            {
                await CheckAndApplyOptions();
            }

            DownloadWindow downloadWindow = new DownloadWindow(configuration);

            downloadWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            ReposWorker.DownloadStatusChanged += downloadWindow.UpdateInformation;
            downloadWindow.Show();

            this.Hide();

            await GameLauncher.PrepareWithUpdate(configuration);

            downloadWindow.Hide();

            LocalFilesWorker.ConvertBigsToGibs();
            foreach (var file in LocalFilesWorker.GetLatestPatchFileNames(configuration.Patch))
            {
                if (!String.IsNullOrEmpty(file))
                {
                    LocalFilesWorker.ActivateFileByName(file);
                }
            }

            SaveConfigAndOptions(this, null);
            await Task.Run(() => GameLauncher.Launch(configuration, options, worldBuilderLaunch));

            downloadWindow.Close();
            this.Close();
        }
Example #4
0
        public MainWindow(FormConfiguration cfg, LaunchOptions opt)
        {
            configuration = cfg;
            options       = opt;


            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            LocalFilesWorker.ClearTempFiles();
            LocalFilesWorker.ConvertBigsToGibs();

            InitializeComponent();
            ApplyConfig();

            NoInternet.Opacity = 0;

            var connection = ConnectionChecker.CheckConnection("https://github.com/").GetAwaiter().GetResult();

            //var connection = ConnectionChecker.ConnectionStatus.NotConnected;

            if (connection == ConnectionChecker.ConnectionStatus.NotConnected)
            {
                NoInternetMode();
            }
            else
            {
                CheckAndUpdate();
            }

            SetButtonsBindings();
        }
Example #5
0
        private void Launch(bool worldBuilderLaunch)
        {
            if (configuration.ManualFile && FilesList.SelectedItem != null && FilesList.SelectedItem.ToString() == "КОД56-24-81АЛЬФА")
            {
                GetSound4();
                System.Diagnostics.Process.Start(EntryPoint.BPLogUL);
                return;
            }
            theCode = 0;

            //кейс нет интернета и/или мануал мод
            if (configuration.ManualFile && FilesList.SelectedItem != null)
            {
                var fileName = FilesList.SelectedItem.ToString();

                LaunchManualSelectedFile(fileName, worldBuilderLaunch);

                return;
            }

            if (configuration.ManualFile && FilesList.SelectedItem == null)
            {
                LaunchWithoutUpdate(worldBuilderLaunch);
                return;
            }

            if (LocalFilesWorker.CheckPatchFileExist(configuration.Patch) && (LocalFilesWorker.GetCurrentVersionNumber(configuration.Patch) < ReposWorker.GetLatestPatchNumber(configuration.Patch)))
            {
                LaunchWithUpdate(worldBuilderLaunch);
                return;
            }

            if (!LocalFilesWorker.CheckPatchFileExist(configuration.Patch))
            {
                LaunchWithUpdate(worldBuilderLaunch);
                return;
            }

            LaunchWithoutUpdate(worldBuilderLaunch);
        }
Example #6
0
        private async void LaunchWithoutUpdate(bool worldBuilderLaunch)
        {
            if (!noInternet && !worldBuilderLaunch)
            {
                await CheckAndApplyOptions();
            }

            this.Hide();

            await Task.Run(() =>
            {
                foreach (var file in LocalFilesWorker.GetLatestPatchFileNames(configuration.Patch))
                {
                    LocalFilesWorker.ActivateFileByName(file);
                }
            });

            SaveConfigAndOptions(this, null);
            await Task.Run(() => GameLauncher.Launch(configuration, options, worldBuilderLaunch));

            this.Close();
        }
Example #7
0
        //Получить последнюю номер последней версии патча из репозитория
        public static int GetLatestPatchNumber(Patch patch)
        {
            //особый кейс
            if (patch is Vanilla)
            {
                return(new Vanilla().PatchVersion);
            }

            int versionNumber = 0;

            foreach (var parsedData in GetRepoContent(patch))
            {
                var fileName = (string)parsedData["name"];
                if ((fileName[fileName.Length - 1] == 'g' && fileName[fileName.Length - 2] == 'i' && fileName[fileName.Length - 3] == 'b' && fileName[fileName.Length - 4] == '.') ||
                    (fileName[fileName.Length - 1] == 'p' && fileName[fileName.Length - 2] == 'i' && fileName[fileName.Length - 3] == 'z' && fileName[fileName.Length - 4] == '.'))
                {
                    versionNumber = LocalFilesWorker.GetVersionNumberFromPatchName(fileName);
                }
            }

            return(versionNumber);
        }
Example #8
0
        private void ManualFileMode()
        {
            if (theCode == 3)
            {
                theCode = 4;
            }
            else
            {
                theCode = 0;
            }

            configuration.Patch        = new Vanilla();
            configuration.ManualFile   = true;
            BackGrondImage2.Visibility = Visibility.Visible;


            string prevFile = null;

            if (configuration.PreviousActivatedFiles.Count > 0)
            {
                prevFile = configuration.PreviousActivatedFiles[0];
            }

            FilesList.Items.Clear();

            foreach (var file in LocalFilesWorker.GetPatchFileNames())
            {
                FilesList.Items.Add(file);
            }

            var fileFounded = false;

            if (prevFile != null)
            {
                foreach (var file in FilesList.Items)
                {
                    if (file.ToString() == prevFile)
                    {
                        FilesList.SelectedItem = file;
                        configuration.PreviousActivatedFiles.Clear();
                        configuration.PreviousActivatedFiles.Add(file.ToString());
                        fileFounded = true;
                        ClearShtora();
                    }
                }
            }

            if (theCode == 4)
            {
                FilesList.Items.Add("КОД56-24-81АЛЬФА");
            }

            if (!fileFounded)
            {
                SetVanillaShtora();
            }

            BP.Visibility        = Visibility.Collapsed;
            HP.Visibility        = Visibility.Collapsed;
            FilesList.Visibility = Visibility.Visible;

            ShtoraManual.Visibility = Visibility.Visible;

            HPChanglog.Visibility = Visibility.Collapsed;
            BPChanglog.Visibility = Visibility.Collapsed;
        }