Merge pull request #15 from OcelotGamingDev/master

Added Discord Rich Presence
This commit is contained in:
KillzXGaming 2018-12-02 15:10:29 -05:00 committed by GitHub
commit bf8d214405
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View file

@ -11,10 +11,10 @@ using Switch_Toolbox.Library.Forms;
using WeifenLuo.WinFormsUI.Docking;
using Switch_Toolbox.Library;
using Smash_Forge.Rendering;
using Switch_Toolbox_Library;
using Switch_Toolbox.Library.IO;
using System.Net;
namespace Switch_Toolbox
{
public partial class MainForm : Form
@ -35,6 +35,7 @@ namespace Switch_Toolbox
public MainForm()
{
InitializeComponent();
new DiscordPresence().Initialize();
ShaderTools.executableDir = executableDir;

View file

@ -53,6 +53,9 @@
<HintPath>..\packages\CsvHelper.8.0.0-beta01\lib\net45\CsvHelper.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="DiscordRPC">
<HintPath>Lib\DiscordRPC.dll</HintPath>
</Reference>
<Reference Include="EditorCoreCommon">
<HintPath>..\..\..\..\Documents\Visual Studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Lib\EditorCoreCommon.dll</HintPath>
<Private>False</Private>
@ -402,4 +405,4 @@
</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\AssimpNet.4.1.0\build\AssimpNet.targets" Condition="Exists('..\packages\AssimpNet.4.1.0\build\AssimpNet.targets')" />
</Project>
</Project>

View 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"
}
});
}
}
}