From ba4aff2e137778520c1cd603ad6c6d9755922d4d Mon Sep 17 00:00:00 2001
From: miku-666 <74728189+NessieHax@users.noreply.github.com>
Date: Sat, 3 Jun 2023 17:44:38 +0200
Subject: [PATCH] Added 'Show Rich Presence' to settings
---
PCK-Studio/Classes/Misc/RichPresenceClient.cs | 7 +++++--
.../AppBehaviorSettingsForm.Designer.cs | 17 +++++++++++++++++
.../Forms/Utilities/AppBehaviorSettingsForm.cs | 6 ++++++
PCK-Studio/Properties/Settings.Designer.cs | 12 ++++++++++++
PCK-Studio/Properties/Settings.settings | 3 +++
5 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/PCK-Studio/Classes/Misc/RichPresenceClient.cs b/PCK-Studio/Classes/Misc/RichPresenceClient.cs
index d64dfbdf..b83e1a1c 100644
--- a/PCK-Studio/Classes/Misc/RichPresenceClient.cs
+++ b/PCK-Studio/Classes/Misc/RichPresenceClient.cs
@@ -27,8 +27,11 @@ namespace PckStudio.Classes.Misc
public static void Initialize()
{
- Client = new DiscordRpcClient(Settings.Default.RichPresenceId);
- Client.Initialize();
+ if (Settings.Default.ShowRichPresence)
+ {
+ Client ??= new DiscordRpcClient(Settings.Default.RichPresenceId);
+ Client.Initialize();
+ }
}
public static void SetPresence(string details)
diff --git a/PCK-Studio/Forms/Utilities/AppBehaviorSettingsForm.Designer.cs b/PCK-Studio/Forms/Utilities/AppBehaviorSettingsForm.Designer.cs
index edab25aa..d92e3c80 100644
--- a/PCK-Studio/Forms/Utilities/AppBehaviorSettingsForm.Designer.cs
+++ b/PCK-Studio/Forms/Utilities/AppBehaviorSettingsForm.Designer.cs
@@ -33,6 +33,7 @@
this.endianCheckBox = new MetroFramework.Controls.MetroCheckBox();
this.autoUpdateCheckBox = new MetroFramework.Controls.MetroCheckBox();
this.autoLoadPckCheckBox = new MetroFramework.Controls.MetroCheckBox();
+ this.showPresenceCheckBox = new MetroFramework.Controls.MetroCheckBox();
this.SuspendLayout();
//
// autoSaveCheckBox
@@ -98,11 +99,26 @@
this.autoLoadPckCheckBox.UseSelectable = true;
this.autoLoadPckCheckBox.CheckedChanged += new System.EventHandler(this.autoLoadPckCheckBox_CheckedChanged);
//
+ // showPresenceCheckBox
+ //
+ this.showPresenceCheckBox.AutoSize = true;
+ this.showPresenceCheckBox.Location = new System.Drawing.Point(23, 147);
+ this.showPresenceCheckBox.Name = "showPresenceCheckBox";
+ this.showPresenceCheckBox.Size = new System.Drawing.Size(171, 15);
+ this.showPresenceCheckBox.Style = MetroFramework.MetroColorStyle.White;
+ this.showPresenceCheckBox.TabIndex = 4;
+ this.showPresenceCheckBox.Text = "Show Discord Rich Presence";
+ this.showPresenceCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
+ this.SettingToolTip.SetToolTip(this.showPresenceCheckBox, "Whether to show a rich presence on discord");
+ this.showPresenceCheckBox.UseSelectable = true;
+ this.showPresenceCheckBox.CheckedChanged += new System.EventHandler(this.showPresenceCheckBox_CheckedChanged);
+ //
// AppBehaviorSettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(527, 270);
+ this.Controls.Add(this.showPresenceCheckBox);
this.Controls.Add(this.autoLoadPckCheckBox);
this.Controls.Add(this.autoUpdateCheckBox);
this.Controls.Add(this.endianCheckBox);
@@ -128,5 +144,6 @@
private MetroFramework.Controls.MetroCheckBox endianCheckBox;
private MetroFramework.Controls.MetroCheckBox autoUpdateCheckBox;
private MetroFramework.Controls.MetroCheckBox autoLoadPckCheckBox;
+ private MetroFramework.Controls.MetroCheckBox showPresenceCheckBox;
}
}
\ No newline at end of file
diff --git a/PCK-Studio/Forms/Utilities/AppBehaviorSettingsForm.cs b/PCK-Studio/Forms/Utilities/AppBehaviorSettingsForm.cs
index 0e289324..3f2db5e0 100644
--- a/PCK-Studio/Forms/Utilities/AppBehaviorSettingsForm.cs
+++ b/PCK-Studio/Forms/Utilities/AppBehaviorSettingsForm.cs
@@ -35,11 +35,17 @@ namespace PckStudio.Forms.Utilities
Settings.Default.LoadSubPcks = autoLoadPckCheckBox.Checked;
}
+ private void showPresenceCheckBox_CheckedChanged(object sender, EventArgs e)
+ {
+ Settings.Default.ShowRichPresence = showPresenceCheckBox.Checked;
+ }
+
private void LoadSettings()
{
autoSaveCheckBox.Checked = Settings.Default.AutoSaveChanges;
endianCheckBox.Checked = Settings.Default.UseLittleEndianAsDefault;
autoLoadPckCheckBox.Checked = Settings.Default.LoadSubPcks;
+ showPresenceCheckBox.Checked = Settings.Default.ShowRichPresence;
}
private void AppBehaviorSettingsForm_FormClosing(object sender, FormClosingEventArgs e)
diff --git a/PCK-Studio/Properties/Settings.Designer.cs b/PCK-Studio/Properties/Settings.Designer.cs
index b9b30362..3af8d381 100644
--- a/PCK-Studio/Properties/Settings.Designer.cs
+++ b/PCK-Studio/Properties/Settings.Designer.cs
@@ -67,5 +67,17 @@ namespace PckStudio.Properties {
this["LoadSubPcks"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool ShowRichPresence {
+ get {
+ return ((bool)(this["ShowRichPresence"]));
+ }
+ set {
+ this["ShowRichPresence"] = value;
+ }
+ }
}
}
diff --git a/PCK-Studio/Properties/Settings.settings b/PCK-Studio/Properties/Settings.settings
index c2794ec2..1bbfe4fc 100644
--- a/PCK-Studio/Properties/Settings.settings
+++ b/PCK-Studio/Properties/Settings.settings
@@ -14,5 +14,8 @@
False
+
+ True
+
\ No newline at end of file