Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Added Update Functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
LynxarA-Coding committed Jan 30, 2024
1 parent dc1df24 commit 4113599
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 166 deletions.
132 changes: 66 additions & 66 deletions PalworldServer/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 28 additions & 15 deletions PalworldServer/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ private void Main_Load(object sender, EventArgs e)
// Checking if server exists
if (GetServerStatus())
{
btnInstall.Enabled = false;
btnInstall.Text = "Update Server";
btnInstall.Enabled = true;
btnStart.Enabled = true;
lblStatus.Text = "Server Status: Installed and Ready";
}
else
{
btnInstall.Text = "Install Server";
btnInstall.Enabled = true;
btnStart.Enabled = false;
lblStatus.Text = "Server Status: Not Installed";
Expand Down Expand Up @@ -121,14 +123,33 @@ private void ServerInstalled(Process process)
{
// Stop reading output on exit
process.CancelOutputRead();
LogConsole("Server Installation Complete");

if (btnInstall.Text != "Update Server")
{
// Copy Config
string path = tbFolder.Text;
string serverPath = path + "/PalworldServer";
string configPath = serverPath + "/Pal/Saved/Config/WindowsServer";
Directory.CreateDirectory(configPath);
File.Copy(serverPath + "/DefaultPalWorldSettings.ini", configPath + "/PalWorldSettings.ini", true);
LogConsole("Config Copied");

// Open Config
Process.Start(configPath + "/PalWorldSettings.ini");
LogConsole("Server Installation Complete");
}
else
{
LogConsole("Server Update Complete");
}

// Last Check
if (GetServerStatus())
{
UpdateUI(() =>
{
btnInstall.Enabled = false;
btnInstall.Text = "Update Server";
btnInstall.Enabled = true;
btnStart.Enabled = true;
lblStatus.Text = "Server Status: Installed and Ready";
});
Expand All @@ -137,22 +158,12 @@ private void ServerInstalled(Process process)
{
UpdateUI(() =>
{
btnInstall.Text = "Install Server";
btnInstall.Enabled = true;
btnStart.Enabled = false;
lblStatus.Text = "Server Status: Not Installed";
});
}

// Copy Config
string path = tbFolder.Text;
string serverPath = path + "/PalworldServer";
string configPath = serverPath + "/Pal/Saved/Config/WindowsServer";
Directory.CreateDirectory(configPath);
File.Copy(serverPath + "/DefaultPalWorldSettings.ini", configPath + "/PalWorldSettings.ini", true);
LogConsole("Config Copied");

// Open Config
Process.Start(configPath + "/PalWorldSettings.ini");
}

private void btnInstall_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -225,14 +236,16 @@ private void btnSelect_Click(object sender, EventArgs e)
}

btnStart.Enabled = GetServerStatus();
btnInstall.Enabled = !GetServerStatus();
btnInstall.Enabled = GetServerStatus();

if (btnInstall.Enabled)
{
btnInstall.Text = "Update Server";
lblStatus.Text = "Server Status: Installed and Ready";
}
else
{
btnInstall.Text = "Install Server";
lblStatus.Text = "Server Status: Not Installed";
}

Expand Down
Loading

0 comments on commit 4113599

Please sign in to comment.