Ejemplo n.º 1
0
        private void btnDestroyServer_Click_1(object sender, EventArgs e)
        {
            //Locate the associated GameServerObject, and allow the user to edit the values associated with them.
            var          currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text);
            DialogResult result        = MetroMessageBox.Show(ActiveForm,
                                                              "WARNING: Destroying a server is irreversible. are you sure you wish to do this?\nCurrently only the configuration will be destroyed, game data will need to be manually deleted.",
                                                              "Destroy GameServer?", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);

            if (result == DialogResult.Yes)
            {
                int GameServer_ObjectIndex = GameServerManagement.ServerCollection.FindIndex(x => x == currentServer);
                GameServerManagement.ServerCollection.RemoveAt(GameServer_ObjectIndex);

                //Clear the text fields since the server no longer exists, to simply tidy things up.
                txtboxFriendlyName.Text = "";
                txtboxArguments.Text    = "";
                txtboxPORT.Text         = "";
                txtboxStartingMap.Items.Clear();
                incMaxPlayers.Value       = 0;
                chkFirewallToggle.Checked = false;

                //Update the panel information after destroying the gameserver.
                RefreshData();
            }
        }
Ejemplo n.º 2
0
        private void comboboxGameserverList_SelectedValueChanged(object sender, EventArgs e)
        {
            var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text);
            var process       = ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly);
            var isRunning     = process?.IsRunning ?? false;

            if (isRunning)
            {
                btnStartServer.Enabled = false;
                chkAutoRestart.Enabled = false;
                lblAutoRestart.Enabled = false;
                //lblRedirectInOut.Enabled = false;
                //chkRedirectInOut.Enabled = false;
                btnStopServer.Enabled = true;
            }
            else
            {
                btnStartServer.Enabled = true;
                chkAutoRestart.Enabled = true;
                lblAutoRestart.Enabled = true;
                //lblRedirectInOut.Enabled = true;
                //chkRedirectInOut.Enabled = true;
                btnStopServer.Enabled = false;
            }

            SubscribeToProcess(process);
            return;
        }
Ejemplo n.º 3
0
        private void btnSendCommand_Click(object sender, EventArgs e)
        {
            var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text);

            consoleOutputList.Items.Add("Command Issued to Server: " + txtboxIssueCommand.Text);
            ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly)?.WriteLine(txtboxIssueCommand.Text);
            txtboxIssueCommand.Text = "";
        }
Ejemplo n.º 4
0
        //===================================================================================//
        // STARTUP:                                                                          //
        //===================================================================================//
        public void BorealisServerManager_Load(object sender, EventArgs e)
        {
            if (!DesignMode)
            {
                shadow = new Dropshadow(this)
                {
                    ShadowBlur   = 25,
                    ShadowSpread = -18,
                    ShadowColor  = Color.FromArgb(170, 0, 0, 0)
                };
                shadow.RefreshShadow();
            }
            //Destroy the bevelled border around MDI parent container.
            this.SetBevel(false);

            //Display current product version.
            lblVersion.Text = $"Version {Application.ProductVersion} Alpha";

            //Create blank gameservers.json
            if (File.Exists(Environment.CurrentDirectory + @"\gameservers.json"))
            {
                GameServerManagement.ConfigRead();
            }
            else
            {
                File.Create(Environment.CurrentDirectory + @"\gameservers.json").Dispose();
                GameServerManagement.ConfigRead();
            }

            //Store all gameservers into memory to be used by Borealis.

            GameServerManagement.ConfigRead();

            // Instantiate all Panels Immediately
            var panels = new List <Form>
            {
                new TAB_DEPLOYMENT(),
                new TAB_MANAGEMENT(),
                new TAB_CONTROL(),
                new TAB_STEAMGUARD_TOKEN(),
                new TAB_SCHEDULEDTASKS(),
                new TAB_STEAMWORKSHOP(),
                new TAB_DASHBOARD(),
            };

            foreach (Form panel in panels)
            {
                panel.MdiParent  = this;
                panel.AutoScroll = false;
                panel.Dock       = DockStyle.Fill;
                panel.Show();
            }
        }
Ejemplo n.º 5
0
        private void BorealisServerManager_FormClosed(object sender, FormClosedEventArgs e)
        {
            //Write data in memory to disk into gameservers.json
            if (GameServerManagement.ServerCollection != null)
            {
                //Delete existing gameservers.json
                if (File.Exists(Environment.CurrentDirectory + @"\gameservers.json"))
                {
                    File.Delete(Environment.CurrentDirectory + @"\gameservers.json");
                }

                GameServerManagement.ConfigWrite();
            }
        }
Ejemplo n.º 6
0
        private void btnStopServer_Click(object senders, EventArgs e)
        {
            btnStopServer.Enabled  = false;
            btnStartServer.Enabled = true;
            chkAutoRestart.Enabled = true;
            lblAutoRestart.Enabled = true;
            //chkRedirectInOut.Enabled = true;
            //lblRedirectInOut.Enabled = true;
            txtboxIssueCommand.Text    = " > Server is Not Running";
            txtboxIssueCommand.Enabled = false;

            var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text);

            ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly)?.Stop();
        }
Ejemplo n.º 7
0
        //Methods that handle reporting progress back to the UI
        private void comboboxGameserverList_SelectedValueChanged(object sender, EventArgs e)
        {
            var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text);

            //Populate applicable data fields using data from GameServerObject
            txtboxFriendlyName.Text  = currentServer.SERVER_name_friendly;
            txtboxArguments.Text     = currentServer.SERVER_launch_arguments;
            btnSteamWorkshop.Enabled = currentServer.STEAM_workshop_enabled;
            incMaxPlayers.Value      = currentServer.GAME_maxplayers;
            txtboxPORT.Text          = currentServer.SERVER_port;

            //Clear the map dropdown list before adding new data to it.
            txtboxStartingMap.Items.Clear();


            var mapListing = Directory
                             .EnumerateFiles(currentServer.DIR_install_location + @"\steamapps\common" + currentServer.DIR_root + currentServer.DIR_maps, currentServer.DIR_maps_file_extension, SearchOption.AllDirectories)
                             .Select(Path.GetFileName); // <-- note you can shorten the lambda

            foreach (var mapfile in mapListing)
            {
                string preparedmap = Path.GetFileNameWithoutExtension(mapfile);

                //Specifically check for KF2's map system screwup to get around it.
                if (currentServer.SERVER_type == "Killing Floor 2")
                {
                    if (preparedmap.StartsWith("KF-"))
                    {
                        txtboxStartingMap.Items.Add(preparedmap);
                    }
                }
                else //Any other kind of gameserver / wildcard
                {
                    txtboxStartingMap.Items.Add(preparedmap);
                }
            }

            //The selected index indicating the original value must be called AFTER populating the Map List Combo Box.
            txtboxStartingMap.Text = currentServer.GAME_map;

            //Make properties boxes visible.
            groupboxServerProperties.Visible = true;
            groupboxGameProperties.Visible   = true;
            btnDestroyServer.Visible         = true;
            btnUpdateServerConfig.Visible    = true;
            btnAddonControl.Visible          = true;
            btnSteamWorkshop.Visible         = true;
        }
Ejemplo n.º 8
0
        private void btnUpdateServerConfig_Click(object sender, EventArgs e)
        {
            //Locate the associated GameServerObject, and allow the user to edit the values associated with them.
            var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text);

            currentServer.SERVER_name_friendly    = txtboxFriendlyName.Text;
            currentServer.SERVER_launch_arguments = txtboxArguments.Text;
            currentServer.GAME_maxplayers         = Convert.ToInt32(incMaxPlayers.Value);
            currentServer.GAME_map    = txtboxStartingMap.Text;
            currentServer.SERVER_port = txtboxPORT.Text;

            //Notify the user that the data has been committed to memory, and warn them that if Borealis crashes, they will lose their changes.
            MetroMessageBox.Show(ActiveForm, "The gameserver has been updated!\nPlease note: if Borealis crashes unexpectedly, these changes will be reverted.", "Changes Saved!", MessageBoxButtons.OK, MessageBoxIcon.Question);

            //Update the panel information after committing the updates to the gameserver.
            RefreshData();
        }
Ejemplo n.º 9
0
        private void serverStoreInMemory()
        {
            //Create the GameServerObject
            GameServerObject deployConfiguredServer = new GameServerObject();

            //Assign Data to the GameServerObject
            //Server-based Properties
            deployConfiguredServer.SERVER_name_friendly    = txtServerGivenName.Text;
            deployConfiguredServer.SERVER_type             = _currentDeploymentValues.SERVER_type;
            deployConfiguredServer.SERVER_launch_arguments = _currentDeploymentValues.SERVER_launch_arguments;
            deployConfiguredServer.SERVER_executable       = _currentDeploymentValues.SERVER_executable;
            deployConfiguredServer.SERVER_port             = "";

            //Game-based properties
            deployConfiguredServer.GAME_maxplayers = 6; //Defalt middle value
            deployConfiguredServer.GAME_map        = "NONE";

            //Directory-based Properties
            deployConfiguredServer.DIR_install_location    = _currentDeploymentValues.DIR_install_location;
            deployConfiguredServer.DIR_root                = _currentDeploymentValues.DIR_root;
            deployConfiguredServer.DIR_maps                = _currentDeploymentValues.DIR_maps;
            deployConfiguredServer.DIR_maps_file_extension = _currentDeploymentValues.DIR_maps_file_extension;
            deployConfiguredServer.DIR_mods                = _currentDeploymentValues.DIR_mods;
            deployConfiguredServer.DIR_config              = _currentDeploymentValues.DIR_config;

            //Steam-based Properties
            deployConfiguredServer.STEAM_authrequired      = _currentDeploymentValues.STEAM_authrequired;
            deployConfiguredServer.STEAM_steamcmd_required = _currentDeploymentValues.STEAM_steamcmd_required;
            deployConfiguredServer.STEAM_workshop_enabled  = _currentDeploymentValues.STEAM_workshop_enabled;

            //Miscellanious Properties
            deployConfiguredServer.ENGINE_type             = _currentDeploymentValues.ENGINE_type;
            deployConfiguredServer.bsm_integration         = _currentDeploymentValues.bsm_integration;
            deployConfiguredServer.bsm_custominstallfolder = _currentDeploymentValues.bsm_custominstallfolder;

            //Store that newly assigned and JSON-filled server into the GameServerObject Collection
            GameServerManagement.ServerCollection.Add(deployConfiguredServer);

            //Redundantly write the data to disk in the event of a crash.
            GameServerManagement.ConfigWrite();

            btnCancelDeployGameserver.Visible = false;
            btnDeployGameserver.Enabled       = true;
            _currentDeploymentValues          = null;
        }
Ejemplo n.º 10
0
        //===================================================================================//
        // SERVER CONTROL:                                                                   //
        //===================================================================================//
        private void btnStartServer_Click(object sender, EventArgs e)
        {
            var currentServer = GameServerManagement.PropertyGetSet(comboboxGameserverList.Text);
            //These strings tell the process manager how exactly to start the server processes based on the engine they use.
            string engineSpecificDirectory = null;
            string engineSpecificArguments = null;

            switch (currentServer.ENGINE_type)
            {
            case "SOURCE":
                //Copy SRCDS Redirection utility (Band-Aid Redirection Fix) into working gameserver.DIR_root directory.
                string fileName   = "SrcdsConRedirect.exe";
                string sourcePath = Environment.CurrentDirectory;
                string targetPath = currentServer.DIR_install_location + @"\steamapps\common" + currentServer.DIR_root;

                // Use Path class to manipulate file and directory paths.
                string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
                string destFile   = System.IO.Path.Combine(targetPath, fileName);

                // Create a new target folder, if necessary.
                if (!System.IO.Directory.Exists(targetPath))
                {
                    System.IO.Directory.CreateDirectory(targetPath);
                }

                // overwrite the destination file if it already exists.
                System.IO.File.Copy(sourceFile, destFile, true);

                engineSpecificDirectory = currentServer.DIR_install_location + @"\steamapps\common" + currentServer.DIR_root + @"\SrcdsConRedirect.exe";
                engineSpecificArguments =
                    $"-console {currentServer.SERVER_launch_arguments} +port {currentServer.SERVER_port} +map {currentServer.GAME_map} +maxplayers {currentServer.GAME_maxplayers}";
                break;

            case "UNREAL":
                engineSpecificDirectory =
                    currentServer.DIR_install_location + @"\steamapps\common" + currentServer.DIR_root + currentServer.SERVER_executable;
                engineSpecificArguments = string.Format("{0}{1}?maxplayers={3}",
                                                        currentServer.GAME_map,
                                                        currentServer.SERVER_launch_arguments,
                                                        currentServer.GAME_maxplayers);
                break;

            case "GENERIC":
                engineSpecificDirectory = currentServer.DIR_install_location + currentServer.DIR_root + currentServer.SERVER_executable;
                engineSpecificArguments = currentServer.SERVER_launch_arguments;
                break;
            }

            if (chkRedirectInOut.Value)
            {
                //CREATE THE PROCESS
                var process = ProcessManager.GetOrCreate(currentServer.SERVER_name_friendly,
                                                         engineSpecificDirectory, engineSpecificArguments, new ProcessLaunchOptions
                {
                    ShowWindowOnStart = false
                });

                //Start the Process!
                SubscribeToProcess(process);
                ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly)?.Start();
            }
            else
            {
                //CREATE THE PROCESS
                var process = ProcessManager.GetOrCreate(currentServer.SERVER_name_friendly,
                                                         engineSpecificDirectory, engineSpecificArguments, new ProcessLaunchOptions
                {
                    ShowWindowOnStart = true
                });

                //Start the Process!
                SubscribeToProcess(process);
                ProcessManager.GetProcessByNickname(currentServer.SERVER_name_friendly)?.Start();
            }

            btnStartServer.Enabled = false;
            btnStopServer.Enabled  = true;

            txtboxIssueCommand.Enabled = true;
            txtboxIssueCommand.Text    = "";

            //chkRedirectInOut.Enabled = false;
            //lblRedirectInOut.Enabled = false;
        }