Update Discord RPC class

This commit is contained in:
miku-666
2023-04-01 11:12:07 +02:00
parent cc788d35cb
commit 04fda240a2
4 changed files with 29 additions and 11 deletions

View File

@@ -10,12 +10,32 @@ namespace PckStudio.Classes.Misc
public static DiscordRpcClient Client;
public static readonly DateTime StartUpTime = DateTime.UtcNow;
private static readonly Assets _assets = new Assets()
{
LargeImageKey = "pcklgo",
LargeImageText = "PCK-Studio",
};
private static readonly Button[] _buttons = new Button[]
{
new Button()
{
Label = "Check it out.",
Url = Program.ProjectUrl,
}
};
public static void Initialize()
{
Client = new DiscordRpcClient(Settings.Default.RichPresenceId);
Client.Initialize();
}
public static void SetPresence(string details)
{
SetPresence(details, null);
}
public static void SetPresence(string details, string state)
{
Client?.SetPresence(new RichPresence()
@@ -23,16 +43,14 @@ namespace PckStudio.Classes.Misc
Details = details,
State = state,
Timestamps = new Timestamps() { Start = StartUpTime },
Assets = new Assets()
{
LargeImageKey = "pcklgo",
LargeImageText = "PCK-Studio",
}
Assets = _assets,
Buttons = _buttons
});
}
public static void Deinitialize()
{
Client?.ClearPresence();
Client?.Dispose();
Client = null;
}

View File

@@ -312,7 +312,7 @@ namespace PckStudio.Forms.Utilities
try
{
RPC.SetPresence("Viewing the PCK Center", "Program by PhoenixARC");
RPC.SetPresence("Viewing the PCK Center");
}
catch
{

View File

@@ -113,8 +113,7 @@ namespace PckStudio
private void Form1_Load(object sender, EventArgs e)
{
RPC.Initialize();
if (currentPCK == null)
RPC.SetPresence("An Open Source .PCK File Editor", "Program by PhoenixARC");
UpdateRPC();
skinToolStripMenuItem1.Click += (sender, e) => setFileType_Click(sender, e, PckFile.FileData.FileType.SkinFile);
capeToolStripMenuItem.Click += (sender, e) => setFileType_Click(sender, e, PckFile.FileData.FileType.CapeFile);
@@ -385,7 +384,7 @@ namespace PckStudio
{
if (currentPCK == null)
{
RPC.SetPresence("An Open Source .PCK File Editor", "Program by PhoenixARC");
RPC.SetPresence("An Open Source .PCK File Editor");
return;
};
@@ -393,11 +392,11 @@ namespace PckStudio
locfile.HasLocEntry("IDS_DISPLAY_NAME") &&
locfile.Languages.Contains("en-EN"))
{
RPC.SetPresence($"Editing a Pack: {locfile.GetLocEntry("IDS_DISPLAY_NAME", "en-EN")}", "Program by PhoenixARC");
RPC.SetPresence($"Editing a Pack: {locfile.GetLocEntry("IDS_DISPLAY_NAME", "en-EN")}");
return;
}
// default
RPC.SetPresence("An Open Source .PCK File Editor", "Program by PhoenixARC");
RPC.SetPresence("An Open Source .PCK File Editor");
}
private void HandleAudioFile(PckFile.FileData file)

View File

@@ -37,6 +37,7 @@ namespace PckStudio
static class Program
{
public static readonly string ProjectUrl = "https://github.com/PhoenixARC/-PCK-Studio";
public static readonly string BaseAPIUrl = "http://api.pckstudio.xyz/api/pck";
public static readonly string BackUpAPIUrl = "https://raw.githubusercontent.com/PhoenixARC/pckstudio.tk/main/studio/PCK/api/";
public static readonly string AppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "PCK-Studio");