Пример #1
0
        /// <summary>
        /// Kills the server, but doesn't alter UI.
        /// </summary>
        private void KillServer()
        {
            //Destroy old server and set to null, ready for a new server
            if (m_tdlServer != null)
            {
                m_tdlServer.Dispose();
                m_tdlServer = null;
            }

            m_startServer.Enabled = true;
            m_stopServer.Enabled = false;

            m_chatLog.Clear();
            m_serverOutput.Clear();
            m_chatLog.DataBindings.Clear();
            m_serverOutput.DataBindings.Clear();
        }
Пример #2
0
        /// <summary>
        /// Starts the server using the UI components values to generate command line arguments.
        /// </summary>
        private void StartServer()
        {
            m_startServer.Enabled = false;
            m_stopServer.Enabled = true;

            m_upTimeTimer.Enabled = true;
            m_upTimeTimer.Start();

            //Disbles the section hold the server options
            m_options.Enabled = false;

            m_tdlServer = new TDLServer(this)
            {
                ServerName = m_serverName.Text,
                ServerType = m_serverType.Controls.OfType<RadioButton>().Where(r => r.Checked == true).FirstOrDefault().Text.ToLower(),
                MaxPlayers = (int)m_playerNumber.Value,
                Visibility = m_serverVisibility.Controls.OfType<RadioButton>().Where(r => r.Checked == true).FirstOrDefault().Text.ToLower()
            };

            if (m_customerFolderChosen)
            {
                m_tdlServer.CustomWorldSaveDir = m_saveDirectory.Text;
            }

            if (m_serverPassword.Text != String.Empty)
            {
                m_tdlServer.ServerPassword = m_serverPassword.Text;
            }

            if (m_adminPassword.Text != String.Empty)
            {
                m_tdlServer.AdminPassword = m_adminPassword.Text;
            }

            if (m_debugLog.Checked)
            {
                m_tdlServer.DebugMode = true;
            }

            m_tdlServer.Start();

            //For Debugging
            //this.Text += m_tdlServer.ServerArguments;

            m_chatLogFileNotifier = new LogFileNotifier(m_tdlServer.ChatLogFile, m_chatLog);
            m_serverLogFileNotifier = new LogFileNotifier(m_tdlServer.ServerLogFile, m_serverOutput);

            //Updates the Server information and chat log on the GUI when the files are updated.
            m_chatLog.DataBindings.Add("Text", m_chatLogFileNotifier, "FileContent");
            m_serverOutput.DataBindings.Add("Text", m_serverLogFileNotifier, "FileContent");
        }