Skip to content

Commit

Permalink
add SteamCMD Autoupdater
Browse files Browse the repository at this point in the history
  • Loading branch information
le3tspeak committed Apr 20, 2024
1 parent 30cd308 commit 5d782ce
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 30 deletions.
3 changes: 3 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@
<setting name="GitHub" serializeAs="String">
<value>https://github.com/le3tspeak/ByteMaster</value>
</setting>
<setting name="SteamCMDAutoUpdate" serializeAs="String">
<value>False</value>
</setting>
</Game_Server_Manager.Properties.Settings>
</userSettings>
<applicationSettings>
Expand Down
35 changes: 28 additions & 7 deletions Forms/FormByteMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,25 @@ private void LoadColorSettings()
// Timer für die Aktualisierung der Informationen
private void Timer()
{
// Timer 0.5 Sekunden
// Timer 6 Hours
Timer timerShort = new Timer();
timerShort.Interval = 500;
timerShort.Tick += Timer_Tick_Short;
timerShort.Interval = 1000 * 60 * 60 *6;
timerShort.Tick += Timer_Tick_6h;
timerShort.Start();
// Timer 2 Sekunden
Timer timerLong = new Timer();
timerLong.Interval = 1000;
timerLong.Tick += Timer_Tick_Long;
timerLong.Tick += Timer_Tick_Updates;
timerLong.Start();
}

// Eventhandler für die Timer
private void Timer_Tick_Short(object sender, EventArgs e)
private void Timer_Tick_6h(object sender, EventArgs e)
{

AutoUpdateSteamCMD();
}

private void Timer_Tick_Long(object sender, EventArgs e)
private void Timer_Tick_Updates(object sender, EventArgs e)
{
SystemInfo();
SteamCMD();
Expand All @@ -121,6 +121,27 @@ private void panelTitleBar_MouseDown(object sender, MouseEventArgs e)

// Methods

// Auto Update STeamCMD
private void AutoUpdateSteamCMD()
{
// Prüfe ob SteamCMD installiert ist
if (File.Exists(Path.Combine((GameManager.Default.SteamCMDPath), "steamerrorreporter.exe")))
{
// SteamCMD vorhanden
// Prüfe ob AutoUpdate aktiviert ist
if (GameManager.Default.SteamCMDAutoUpdate)
{
// Run the SteamCMD
FormSteamCMD formSteamCMD = new FormSteamCMD();
formSteamCMD.StartSteamCMD("+quit");
formSteamCMD.ShowDialog();
// Setze das Datum des letzten Updates
GameManager.Default.SteamCMDLastUpdate = DateTime.Now;
GameManager.Default.Save();
}
}
}

// Lade RAM-Informationen
private void SystemInfo()
{
Expand Down
84 changes: 62 additions & 22 deletions Forms/FormSettings.Designer.cs

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

30 changes: 29 additions & 1 deletion Forms/FormSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private void LoadInfos()
tbServerPath.Text = GameManager.Default.ServerPath;
tbSteamCMDPath.Text = GameManager.Default.SteamCMDPath;
lblVersion.Text = $"Version: {GameManager.Default.Version}";
lblSteamCMDAutoUpdate.Text = $"Auto Update: {GameManager.Default.SteamCMDAutoUpdate}";
}

// Laden der Form Einstellungen
Expand Down Expand Up @@ -74,8 +75,14 @@ private void LoadColorSettings()
btnThemeDesigner.FlatAppearance.MouseOverBackColor = ColorTheme.Default.MouseHover;
btnUpdateGMS.IconColor = ColorTheme.Default.Icon;
btnUpdateGMS.ForeColor = ColorTheme.Default.Text;
btnUpdateGMS.BackColor = ColorTheme.Default.ButtonBG;
btnUpdateGMS.FlatAppearance.MouseDownBackColor = ColorTheme.Default.MouseDown;
btnUpdateGMS.FlatAppearance.MouseOverBackColor = ColorTheme.Default.MouseHover;
btnSteamCMDAutoUpdate.IconColor = ColorTheme.Default.IconSteam;
btnSteamCMDAutoUpdate.ForeColor = ColorTheme.Default.Text;
btnSteamCMDAutoUpdate.BackColor = ColorTheme.Default.ButtonBG;
btnSteamCMDAutoUpdate.FlatAppearance.MouseDownBackColor = ColorTheme.Default.MouseDown;
btnSteamCMDAutoUpdate.FlatAppearance.MouseOverBackColor = ColorTheme.Default.MouseHover;
// Textboxen
tbServerPath.BackColor = ColorTheme.Default.TextBoxBG;
tbServerPath.ForeColor = ColorTheme.Default.TextBoxText;
Expand Down Expand Up @@ -108,13 +115,15 @@ private void SteamCMD()

if (File.Exists(Path.Combine((GameManager.Default.SteamCMDPath), "steamerrorreporter.exe")))
{
btnSteamCMDInstall.Text = "Update SteamCMD";
btnSteamCMDInstall.Text = "Update";
btnSteamCMDUninstall.Enabled = true;
btnSteamCMDAutoUpdate.Enabled = true;
}
else
{
btnSteamCMDInstall.Text = "Install SteamCMD";
btnSteamCMDUninstall.Enabled = false;
btnSteamCMDAutoUpdate.Enabled = false;
}
}

Expand Down Expand Up @@ -285,4 +294,23 @@ private void btnUpdateGMS_Click(object sender, EventArgs e)
FormUpdaterBM formUpdaterBM = new FormUpdaterBM();
formUpdaterBM.ShowDialog();
}

private void btnSteamCMDAutoUpdate_Click(object sender, EventArgs e)
{
// Set Steam CMD Auto Update
if (GameManager.Default.SteamCMDAutoUpdate)
{
GameManager.Default.SteamCMDAutoUpdate = false;
GameManager.Default.Save();
lblSteamCMDAutoUpdate.Text = $"Auto Update: {GameManager.Default.SteamCMDAutoUpdate}";
MessageBox.Show("SteamCMD Auto Update disabled!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
GameManager.Default.SteamCMDAutoUpdate = true;
GameManager.Default.Save();
lblSteamCMDAutoUpdate.Text = $"Auto Update: {GameManager.Default.SteamCMDAutoUpdate}";
MessageBox.Show("SteamCMD Auto Update enabled!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
12 changes: 12 additions & 0 deletions Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
<Setting Name="GitHub" Type="(Web Service URL)" Scope="User">
<Value Profile="(Default)">https://github.com/le3tspeak/ByteMaster</Value>
</Setting>
<Setting Name="SteamCMDAutoUpdate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit 5d782ce

Please sign in to comment.