private void ServerStart() { if (IsServerProcessRunning) { return; } if (!ValidateArguments()) { return; } string exePath = WizardHelpers.GetServerPath(); if (string.IsNullOrEmpty(exePath)) { MessageBox.Show("'valheim_server.exe' could not be found. It must be installed using Steam.", "Hosting Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string argsFormat = "-nographics -batchmode -name \"{0}\" -port {1} -world \"{2}\" -password \"{3}\" -public {4}"; logTextBox.Text = ""; m_serverProcess = new Process(); m_serverProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; m_serverProcess.StartInfo.UseShellExecute = false; m_serverProcess.StartInfo.FileName = exePath; m_serverProcess.StartInfo.Arguments = string.Format(argsFormat, serverNameTextBox.Text, portNumeric.Value, worldsListBox.Text, passwordBox.Text, publicCheckBox.Checked ? "1" : "0"); m_serverProcess.StartInfo.EnvironmentVariables.Add("SteamAppId", "892970"); m_serverProcess.StartInfo.RedirectStandardOutput = true; m_serverProcess.StartInfo.RedirectStandardError = true; m_serverProcess.StartInfo.RedirectStandardInput = true; m_serverProcess.OutputDataReceived += HandleOutputDataReceived; m_serverProcess.ErrorDataReceived += HandleErrorDataReceived; m_serverProcess.Exited += HandleServerExit; m_serverProcess.EnableRaisingEvents = true; if (m_serverProcess.Start()) { onlineLabel.Text = "STARTING"; onlineLabel.ForeColor = Color.Orange; m_serverProcess.BeginOutputReadLine(); } else { m_serverProcess = null; } RefreshStateButtons(); }
private void CollectWorlds() { object prevSelected = worldsListBox.SelectedItem; worldsListBox.Items.Clear(); string worldsDirectory = WizardHelpers.GetWorldsDirectory(); if (Directory.Exists(worldsDirectory)) { foreach (string file in Directory.GetFiles(worldsDirectory, "*.fwl")) { worldsListBox.Items.Add(Path.GetFileNameWithoutExtension(file)); } } worldsListBox.SelectedItem = prevSelected; }
private void permittedListToolStripMenuItem_Click(object sender, EventArgs e) { string path = Path.Combine(WizardHelpers.GetValheimAppDataDirectory(), "permittedlist.txt"); Process.Start(path); }