mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 12:33:12 +00:00
Merge pull request #15 from OcelotGamingDev/master
Added Discord Rich Presence
This commit is contained in:
commit
bf8d214405
5 changed files with 64 additions and 2 deletions
BIN
Switch_Toolbox/Lib/DiscordRPC.dll
Normal file
BIN
Switch_Toolbox/Lib/DiscordRPC.dll
Normal file
Binary file not shown.
BIN
Switch_Toolbox/Lib/Newtonsoft.Json.dll
Normal file
BIN
Switch_Toolbox/Lib/Newtonsoft.Json.dll
Normal file
Binary file not shown.
|
@ -11,10 +11,10 @@ using Switch_Toolbox.Library.Forms;
|
||||||
using WeifenLuo.WinFormsUI.Docking;
|
using WeifenLuo.WinFormsUI.Docking;
|
||||||
using Switch_Toolbox.Library;
|
using Switch_Toolbox.Library;
|
||||||
using Smash_Forge.Rendering;
|
using Smash_Forge.Rendering;
|
||||||
|
using Switch_Toolbox_Library;
|
||||||
using Switch_Toolbox.Library.IO;
|
using Switch_Toolbox.Library.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
|
|
||||||
namespace Switch_Toolbox
|
namespace Switch_Toolbox
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
|
@ -35,6 +35,7 @@ namespace Switch_Toolbox
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
new DiscordPresence().Initialize();
|
||||||
|
|
||||||
ShaderTools.executableDir = executableDir;
|
ShaderTools.executableDir = executableDir;
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,9 @@
|
||||||
<HintPath>..\packages\CsvHelper.8.0.0-beta01\lib\net45\CsvHelper.dll</HintPath>
|
<HintPath>..\packages\CsvHelper.8.0.0-beta01\lib\net45\CsvHelper.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="DiscordRPC">
|
||||||
|
<HintPath>Lib\DiscordRPC.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="EditorCoreCommon">
|
<Reference Include="EditorCoreCommon">
|
||||||
<HintPath>..\..\..\..\Documents\Visual Studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Lib\EditorCoreCommon.dll</HintPath>
|
<HintPath>..\..\..\..\Documents\Visual Studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Lib\EditorCoreCommon.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
|
@ -402,4 +405,4 @@
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="..\packages\Costura.Fody.3.1.4\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.3.1.4\build\Costura.Fody.targets')" />
|
<Import Project="..\packages\Costura.Fody.3.1.4\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.3.1.4\build\Costura.Fody.targets')" />
|
||||||
<Import Project="..\packages\AssimpNet.4.1.0\build\AssimpNet.targets" Condition="Exists('..\packages\AssimpNet.4.1.0\build\AssimpNet.targets')" />
|
<Import Project="..\packages\AssimpNet.4.1.0\build\AssimpNet.targets" Condition="Exists('..\packages\AssimpNet.4.1.0\build\AssimpNet.targets')" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
58
Switch_Toolbox_Library/DiscordPresence.cs
Normal file
58
Switch_Toolbox_Library/DiscordPresence.cs
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
using DiscordRPC;
|
||||||
|
using DiscordRPC.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Switch_Toolbox_Library
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Code from the DiscordRpc examples:
|
||||||
|
* https://github.com/Lachee/discord-rpc-csharp#usage
|
||||||
|
*/
|
||||||
|
public class DiscordPresence
|
||||||
|
{
|
||||||
|
public DiscordRpcClient client;
|
||||||
|
public String ClientID = "517901453935771668";
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
client = new DiscordRpcClient(ClientID);
|
||||||
|
|
||||||
|
client.Logger = new ConsoleLogger() { Level = LogLevel.Warning };
|
||||||
|
|
||||||
|
client.OnReady += (sender, e) =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("Received Ready from user {0}", e.User.Username);
|
||||||
|
};
|
||||||
|
|
||||||
|
client.OnPresenceUpdate += (sender, e) =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("Received Update! {0}", e.Presence);
|
||||||
|
};
|
||||||
|
|
||||||
|
client.Initialize();
|
||||||
|
|
||||||
|
var timer = new System.Timers.Timer(150);
|
||||||
|
timer.Elapsed += (sender, args) => { UpdatePresence(); };
|
||||||
|
timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdatePresence()
|
||||||
|
{
|
||||||
|
client.SetPresence(new RichPresence()
|
||||||
|
{
|
||||||
|
Details = "Working on a mod",
|
||||||
|
State ="",
|
||||||
|
Assets = new Assets()
|
||||||
|
{
|
||||||
|
LargeImageKey = "toolbox-logo",
|
||||||
|
LargeImageText = "Switch Toolbox"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue