mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-27 22:04:42 +00:00
Update Discord RPC
This commit is contained in:
@@ -5,52 +5,37 @@ using DiscordRPC.Exceptions;
|
||||
|
||||
namespace RichPresenceClient
|
||||
{
|
||||
public static class RPC
|
||||
// https://github.com/BullyWiiPlaza/Minecraft-Wii-U-Mod-Injector/blob/main/Minecraft%20Wii%20U%20Mod%20Injector/Helpers/DiscordRp.cs
|
||||
class RPC
|
||||
{
|
||||
public static DiscordRpcClient Client;
|
||||
public static DateTime StartUpTime = DateTime.UtcNow;
|
||||
|
||||
public static DiscordRpcClient client = null;
|
||||
|
||||
public static void Initialize(string ClientID)
|
||||
public static void Initialize()
|
||||
{
|
||||
client = new DiscordRpcClient(ClientID);
|
||||
try
|
||||
{
|
||||
client.Initialize();
|
||||
}
|
||||
catch (UninitializedException ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
catch (ObjectDisposedException ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
Client = new DiscordRpcClient("825875166574673940");
|
||||
Client.Initialize();
|
||||
}
|
||||
|
||||
public static void SetRPC(string details, string state, string imageLarge, string imageLargeText, string imageSmall)
|
||||
public static void SetPresence(string details, string state)
|
||||
{
|
||||
if (client == null) return;
|
||||
client.SetPresence(new RichPresence()
|
||||
Client?.SetPresence(new RichPresence()
|
||||
{
|
||||
Details = details,
|
||||
State = state,
|
||||
Timestamps = new Timestamps() { Start = StartUpTime },
|
||||
Assets = new Assets()
|
||||
{
|
||||
LargeImageKey = imageLarge,
|
||||
LargeImageText = imageLargeText,
|
||||
SmallImageKey = imageSmall
|
||||
LargeImageKey = "pcklgo",
|
||||
LargeImageText = "PCK Studio",
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void CloseRPC()
|
||||
public static void Deinitialize()
|
||||
{
|
||||
if (client != null && client.IsInitialized)
|
||||
{
|
||||
client.Deinitialize();
|
||||
}
|
||||
client.Dispose();
|
||||
Client?.Dispose();
|
||||
Client = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -324,7 +324,7 @@ namespace PckStudio.Forms
|
||||
|
||||
try
|
||||
{
|
||||
RPC.SetRPC("Viewing the PCK Center", "Program by PhoenixARC", "pcklogo", "PCK Studio", "pcklogo");
|
||||
RPC.SetPresence("Viewing the PCK Center", "Program by PhoenixARC");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -5,8 +5,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Diagnostics;
|
||||
using PckStudio.Properties;
|
||||
using Ohana3DS_Rebirth.Ohana;
|
||||
@@ -38,8 +36,6 @@ namespace PckStudio
|
||||
imageList.Images.Add(Resources.ZUnknown);
|
||||
pckOpen.AllowDrop = true;
|
||||
tabControl.SelectTab(0);
|
||||
RPC.Initialize("825875166574673940");
|
||||
labelVersion.Text = Application.ProductVersion;
|
||||
}
|
||||
|
||||
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@@ -872,17 +868,8 @@ namespace PckStudio
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RPC.SetRPC("Sitting alone", "Program by PhoenixARC", "pcklgo", "PCK Studio", "pcklgo");
|
||||
timer1.Start();
|
||||
timer1.Enabled = true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("ERROR WITH RPC");
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
RPC.Initialize();
|
||||
RPC.SetPresence("Sitting alone", "Program by PhoenixARC");
|
||||
#if DEBUG
|
||||
DBGLabel.Visible = true;
|
||||
#else
|
||||
@@ -2787,48 +2774,26 @@ namespace PckStudio
|
||||
SaveTemplate();
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
//! TODO
|
||||
//try
|
||||
//{
|
||||
// RPC.SetRPC("Developing " + Path.GetFileName(PCKFilePath), "Program by PhoenixARC", "pcklgo", "PCK Studio", "pcklgo");
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// Console.WriteLine(ex.Message);
|
||||
//}
|
||||
}
|
||||
|
||||
private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
checkSaveState();
|
||||
RPC.CloseRPC();
|
||||
RPC.Deinitialize();
|
||||
}
|
||||
|
||||
private void FormMain_Deactivate(object sender, EventArgs e)
|
||||
{
|
||||
RPC.CloseRPC();
|
||||
RPC.Deinitialize();
|
||||
}
|
||||
|
||||
private void FormMain_Activated(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RPC.Initialize("825875166574673940");
|
||||
RPC.SetRPC("Sitting alone", "Program by PhoenixARC", "pcklgo", "PCK Studio", "pcklgo");
|
||||
timer1.Start();
|
||||
timer1.Enabled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
RPC.Initialize();
|
||||
RPC.SetPresence("Sitting alone", "Program by PhoenixARC");
|
||||
}
|
||||
|
||||
private void forMattNLContributorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Process.Start("https://ko-fi.com/mattnl");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user