From cac9f1d491ce4cc3c6c83a9a0c89a7a52b16a6b5 Mon Sep 17 00:00:00 2001 From: WeeXnes Date: Wed, 4 Jan 2023 18:13:23 +0100 Subject: [PATCH] added missing RPC log (will be beautified in next update) --- WeeXnes/App.config | 10 +++++++- WeeXnes/Core/Global.cs | 2 +- WeeXnes/Views/DiscordRPC/Game.cs | 12 ++++++---- WeeXnes/Views/DiscordRPC/RunRPCView.xaml.cs | 26 +++++++++++++++++++++ WeeXnes/WeeXnes.csproj | 6 ++--- WeeXnes/packages.config | 2 +- 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/WeeXnes/App.config b/WeeXnes/App.config index 193aecc..9062d10 100644 --- a/WeeXnes/App.config +++ b/WeeXnes/App.config @@ -1,6 +1,14 @@ - + + + + + + + + + \ No newline at end of file diff --git a/WeeXnes/Core/Global.cs b/WeeXnes/Core/Global.cs index 394ff68..d07236d 100644 --- a/WeeXnes/Core/Global.cs +++ b/WeeXnes/Core/Global.cs @@ -6,7 +6,7 @@ namespace WeeXnes.Core { public class Information { - public const string Version = "4.0.8"; + public const string Version = "4.0.9"; public const string EncryptionHash = "8zf5#RdyQ]$4x4_"; public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest"; } diff --git a/WeeXnes/Views/DiscordRPC/Game.cs b/WeeXnes/Views/DiscordRPC/Game.cs index ff0a1d3..d996664 100644 --- a/WeeXnes/Views/DiscordRPC/Game.cs +++ b/WeeXnes/Views/DiscordRPC/Game.cs @@ -87,7 +87,8 @@ namespace WeeXnes.Views.DiscordRPC public void Start() { this.IsRunning = true; - Console.WriteLine("Process started"); + //Console.WriteLine("Process started"); + RunRPCView.Data.LogCache.Value = this.ProcessName + " is running"; if (!this.PresenceClient.IsInitialized) { @@ -112,7 +113,8 @@ namespace WeeXnes.Views.DiscordRPC public void Stop() { this.IsRunning = false; - Console.WriteLine("Process stopped"); + //Console.WriteLine("Process stopped"); + RunRPCView.Data.LogCache.Value = this.ProcessName + " stopped running"; if (this.PresenceClient.IsInitialized) { this.PresenceClient.ClearPresence(); @@ -123,12 +125,14 @@ namespace WeeXnes.Views.DiscordRPC } private void PresenceClientOnOnPresenceUpdate(object sender, PresenceMessage args) { - Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name); + //Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name); + RunRPCView.Data.LogCache.Value = "[" + this.ProcessName + ".exe] ➜ Received Update on " + args.Name; } private void PresenceClientOnOnReady(object sender, ReadyMessage args) { - Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username); + //Console.WriteLine("[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username); + RunRPCView.Data.LogCache.Value = "[" + this.ProcessName + ".exe] ➜ Received Ready from user " + args.User.Username; } public void CheckState(Process[] processes) { diff --git a/WeeXnes/Views/DiscordRPC/RunRPCView.xaml.cs b/WeeXnes/Views/DiscordRPC/RunRPCView.xaml.cs index 3b1430c..0275a36 100644 --- a/WeeXnes/Views/DiscordRPC/RunRPCView.xaml.cs +++ b/WeeXnes/Views/DiscordRPC/RunRPCView.xaml.cs @@ -4,18 +4,43 @@ using System.Diagnostics; using System.Threading; using System.Windows; using System.Windows.Controls; +using WeeXnes.Core; namespace WeeXnes.Views.DiscordRPC { public partial class RunRPCView : Page { + public static class Data + { + public static UpdateVar LogCache = new UpdateVar(); + } BackgroundWorker backgroundWorker = new BackgroundWorker(); public RunRPCView() { InitializeComponent(); + SetupLogListener(); SetupBackgroundWorker(); } + public void SetupLogListener() + { + Data.LogCache.ValueChanged += LogChanged; + } + + public void RemoveListener() + { + Data.LogCache.ValueChanged -= LogChanged; + } + + private void LogChanged() + { + Console.WriteLine("Log Write Data: " + Data.LogCache.Value); + this.Dispatcher.Invoke(() => + { + RichTextBoxRPCLog.AppendText(Data.LogCache.Value + "\n"); + }); + } + private void SetupBackgroundWorker() { backgroundWorker.WorkerReportsProgress = true; @@ -78,6 +103,7 @@ namespace WeeXnes.Views.DiscordRPC private void RunRPCView_OnUnloaded(object sender, RoutedEventArgs e) { StopBackgroundWorker(); + RemoveListener(); } private void ButtonRPCStop_OnClick(object sender, RoutedEventArgs e) diff --git a/WeeXnes/WeeXnes.csproj b/WeeXnes/WeeXnes.csproj index f7fa6b9..ee83a0c 100644 --- a/WeeXnes/WeeXnes.csproj +++ b/WeeXnes/WeeXnes.csproj @@ -4,7 +4,7 @@ Debug AnyCPU - 4.0.8 + 4.0.9 {4B33CEE7-C74D-43B9-B99A-8B273D5195BC} WinExe WeeXnes @@ -39,8 +39,8 @@ ..\packages\DiscordRichPresence.1.0.175\lib\net35\DiscordRPC.dll - - ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll diff --git a/WeeXnes/packages.config b/WeeXnes/packages.config index 3a90f08..67bf91a 100644 --- a/WeeXnes/packages.config +++ b/WeeXnes/packages.config @@ -1,7 +1,7 @@  - + \ No newline at end of file