Пример #1
0
        public void InstallTeamSpeakPlugin()
        {
            this.AddonsFolder = Properties.Settings.Default.AddonsFolder;

            if (Directory.Exists(AddonsFolder + @"@task_force_radio\plugins"))
            {
                string sourcePath = AddonsFolder + @"@task_force_radio\plugins";

                foreach (string file in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories))
                {
                    if (file.EndsWith(".ts3_plugin"))
                    {
                        Process.Start(file).WaitForExit();
                    }
                }

                mainForm.ShowSnackBar("Task Force Radio plugins installed successfully", 2500, true, true, Primary.LightGreen800);
            }
            else
            {
                new Windows.MessageBox().Show("No such directory \"" + AddonsFolder + @"@task_force_radio\plugins" + "\".", "No such file or directory", MessageBoxButtons.OK, MessageIcon.Error);
            }
        }
Пример #2
0
        public async void ReadRepo(bool showMessage, bool autoDownload, bool validateFiles, bool isLaunch)
        {
            if (validateFiles)
            {
                mainForm.ShowSnackBar("Looking for updates...", 2000, false);
            }

            while (GlobalVar.isReadingRepo)
            {
                await taskDelay(100);
            }

            if (GlobalVar.isDownloading || GlobalVar.isInstalling || GlobalVar.offlineMode)
            {
                return;
            }

            if (Properties.Settings.Default.AddonsFolder == string.Empty)
            {
                this.repoTreeView.Nodes.Clear();
                this.repoTreeView.Nodes.Add("ERROR", "No addons folder selected!", 5, 5);
                this.mainForm.ShowSnackBar("No addons folder selected!", 2000, true, true, MaterialSkin.Primary.Red800);

                this.lbl_filesOK.Text      = "N/A";
                this.lbl_filesINVALID.Text = "N/A";
                this.lbl_filesMISSING.Text = "N/A";

                GlobalVar.isReadingRepo = false;
                return;
            }

            this.repoTreeView.Nodes.Clear();
            this.modsHash.Clear();
            this.modsEdit.Clear();
            this.modsList.Clear();

            this.filesOK      = 0;
            this.filesINVALID = 0;
            this.filesMISSING = 0;

            // update file status
            this.lbl_filesOK.Text      = filesOK.ToString();
            this.lbl_filesINVALID.Text = filesINVALID.ToString();
            this.lbl_filesMISSING.Text = filesMISSING.ToString();

            this.AddonsFolder = Properties.Settings.Default.AddonsFolder;

            this.showMessage   = showMessage;
            this.autoDownload  = autoDownload;
            this.validateFiles = validateFiles;
            this.isLaunch      = isLaunch;

            GlobalVar.folders2Create.Clear();
            GlobalVar.files2Download.Clear();

            this.needsUpdate = UpdateType.None;

            this.validateRepo.RunWorkerAsync();

            GlobalVar.repoChecked   = false;
            GlobalVar.isReadingRepo = true;
        }
Пример #3
0
        public void LaunchGame(string Arguments, DoubleBufferFlowPanel flowpanelAddonPacks, string[] serverInfo, string[] tsInfo, bool autoJoin, bool autoJoinTs)
        {
            /*
             * Array content list:
             *  serverInfo[0]: server ip
             *  serverInfo[1]: server port
             *  serverInfo[2]: server password
             *
             *  tsInfo[0]: server ip
             *  tsInfo[1]: server port
             *  tsInfo[2]: server password
             *  tsInfo[3]: default channel
             */

            waitEndGame.WorkerSupportsCancellation = true;
            waitEndGame.WorkerReportsProgress      = true;
            waitEndGame.DoWork             += WaitEndGame_DoWork;
            waitEndGame.RunWorkerCompleted += WaitEndGame_RunWorkerCompleted;

            this.flowpanelAddonPacks = flowpanelAddonPacks;

            if (!GlobalVar.isServer)
            {
                Ping ping = new Ping();
                if ((serverInfo[0] != string.Empty && serverInfo[2] != string.Empty) && autoJoin && !GlobalVar.offlineMode)
                {
                    /*PingReply pingresult = ping.Send(serverInfo[0]);
                     * if (pingresult.Status == IPStatus.Success)
                     * {*/
                    if (serverInfo[2] != string.Empty)
                    {
                        Arguments = "-connect=" + serverInfo[0] + " -port=" + serverInfo[1] + " -password=\"" + serverInfo[2] + "\" " + Arguments;
                    }
                    else
                    {
                        Arguments = "-connect=" + serverInfo[0] + " -port=" + serverInfo[1] + " " + Arguments;
                    }
                    //}
                }


                if (Process.GetProcessesByName("ts3client_win64").Length <= 0 && Process.GetProcessesByName("ts3client_win32").Length <= 0 && autoJoinTs && !GlobalVar.offlineMode)
                {
                    if (Directory.Exists(TSFolder) && (File.Exists(TSFolder + "ts3client_win64.exe") || File.Exists(TSFolder + "ts3client_win32.exe")))
                    {
                        try
                        {
                            var fass = new ProcessStartInfo
                            {
                                WorkingDirectory = TSFolder
                            };

                            if (tsInfo[0] != string.Empty && tsInfo[2] != string.Empty)
                            {
                                fass.Arguments = "ts3server://\"" + tsInfo[0] + "/?port=" + tsInfo[1] + "&channel=" + tsInfo[3] + "\"";
                            }
                            else if (tsInfo[0] != string.Empty)
                            {
                                fass.Arguments = "ts3server://\"" + tsInfo[0] + "/?port=" + tsInfo[1] + "&password="******"&channel=" + tsInfo[3] + "\"";
                            }

                            if (File.Exists(TSFolder + "ts3client_win64.exe"))
                            {
                                fass.FileName = "ts3client_win64.exe";
                            }

                            if (File.Exists(TSFolder + "ts3client_win32.exe"))
                            {
                                fass.FileName = "ts3client_win32.exe";
                            }

                            var process = new Process
                            {
                                StartInfo = fass
                            };

                            process.Start();
                        }
                        catch (Exception ex)
                        {
                            new Windows.MessageBox().Show(ex.Message, "Unable to start TeamSpeak 3");
                        }
                    }
                    else
                    {
                        new Windows.MessageBox().Show("TeamSpeak directory doesn't exist or executable not there. Please check your TeamSpeak directory and try again.", "Missing directory or file", MessageBoxButtons.OK, MessageIcon.Error);
                    }
                }

                Process[] pname = Process.GetProcessesByName("steam");
                if (pname.Length == 0)
                {
                    try
                    {
                        mainForm.ShowSnackBar("Opening Steam...", 2000, false);

                        var fass = new ProcessStartInfo
                        {
                            WorkingDirectory = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath", "").ToString().Replace(@"/", @"\") + @"\",
                            FileName         = "steam.exe",
                            Arguments        = Arguments
                        };

                        var process = new Process
                        {
                            StartInfo = fass
                        };
                        process.Start();
                        Thread.SpinWait(2000);
                        Thread.Sleep(2000);
                    }
                    catch { }
                }
            }
            else
            {
                SvArguments += "-port=" + serverInfo[1] + " " + Arguments;
                HcArguments += "-client -connect=localhost -port=" + serverInfo[1] + " -password=\"" + serverInfo[2] + "\" " + Arguments;
            }

            if (Directory.Exists(GameFolder) && File.Exists(GameFolder + GlobalVar.gameArtifact))
            {
                try
                {
                    var gameProcessInfo = new ProcessStartInfo();
                    var hcProcessInfo   = new ProcessStartInfo();
                    gameProcessInfo.WorkingDirectory = hcProcessInfo.WorkingDirectory = GameFolder;

                    if (GlobalVar.isServer)
                    {
                        gameProcessInfo.FileName  = hcProcessInfo.FileName = GlobalVar.gameArtifact;
                        gameProcessInfo.Arguments = SvArguments;
                        hcProcessInfo.Arguments   = HcArguments;

                        for (int i = 0; i < HcInstances; i++)
                        {
                            var hcProcess = new Process
                            {
                                StartInfo = hcProcessInfo
                            };
                            hcProcess.Start();
                        }
                    }
                    else
                    {
                        gameProcessInfo.FileName  = GlobalVar.gameArtifact;
                        gameProcessInfo.Arguments = "2 1 " + Arguments;
                    }

                    var gameProcess = new Process
                    {
                        StartInfo = gameProcessInfo
                    };
                    this.process = gameProcess;
                    gameProcess.Start();

                    Thread.Sleep(500);

                    GC.Collect(2, GCCollectionMode.Forced);

                    mainForm.minimizeWindow();
                    mainForm.Cursor = Cursors.Default;
                    waitEndGame.RunWorkerAsync();
                }
                catch (Exception ex)
                {
                    new Windows.MessageBox().Show(ex.Message, "Unable to start Arma 3");
                }
            }
            else
            {
                new Windows.MessageBox().Show("Game directory doesn't exist or executable not there. Please check your Arma 3 directory and try again.", "Missing directory or file", MessageBoxButtons.OK, MessageIcon.Error);
            }
        }