From 04f4a443b11bbbb468244e121e815a88cb75aa60 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Wed, 25 Dec 2019 17:10:24 +0000 Subject: [PATCH 1/3] Changed status variables to enums and fixed some whitespace --- .../Profiles/Discord/DiscordProfile.cs | 6 -- .../Profiles/Discord/GSI/GameState_Discord.cs | 55 ++++--------------- .../Profiles/Discord/GSI/Nodes/GuildNode.cs | 2 - .../Discord/GSI/Nodes/ProviderNode.cs | 1 - .../Profiles/Discord/GSI/Nodes/TextNode.cs | 8 +-- .../Profiles/Discord/GSI/Nodes/UserNode.cs | 35 ++++++++---- .../Profiles/Discord/GSI/Nodes/VoiceNode.cs | 8 +-- 7 files changed, 39 insertions(+), 76 deletions(-) diff --git a/Project-Aurora/Project-Aurora/Profiles/Discord/DiscordProfile.cs b/Project-Aurora/Project-Aurora/Profiles/Discord/DiscordProfile.cs index bb7e961a0..e0761d1f3 100644 --- a/Project-Aurora/Project-Aurora/Profiles/Discord/DiscordProfile.cs +++ b/Project-Aurora/Project-Aurora/Profiles/Discord/DiscordProfile.cs @@ -14,11 +14,7 @@ using System.Threading.Tasks; namespace Aurora.Profiles.Discord { - public class DiscordProfile : ApplicationProfile { - - public DiscordProfile() : base() { } - public override void Reset() { base.Reset(); @@ -59,8 +55,6 @@ public override void Reset() { _Sequence = new KeySequence(new DeviceKeys[] { DeviceKeys.PRINT_SCREEN, DeviceKeys.SCROLL_LOCK, DeviceKeys.PAUSE_BREAK }) } }, new OverrideLogicBuilder().SetDynamicBoolean("_Enabled", new BooleanGSIBoolean("User/UnreadMessages"))), - - }; } } diff --git a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/GameState_Discord.cs b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/GameState_Discord.cs index fe727d9e4..493152005 100644 --- a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/GameState_Discord.cs +++ b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/GameState_Discord.cs @@ -6,10 +6,10 @@ using System.Text; using System.Threading.Tasks; -namespace Aurora.Profiles.Discord.GSI { - - public class GameState_Discord : GameState { - +namespace Aurora.Profiles.Discord.GSI +{ + public class GameState_Discord : GameState + { private ProviderNode _Provider; private UserNode _User; private GuildNode _Guild; @@ -19,48 +19,15 @@ public class GameState_Discord : GameState { /// /// Provider node provides information about the data source so that Aurora can update the correct gamestate. /// - public ProviderNode Provider { - get { - if (_Provider == null) - _Provider = new ProviderNode(_ParsedData["provider"]?.ToString() ?? ""); - return _Provider; - } - } + public ProviderNode Provider => _Provider ?? (_Provider = new ProviderNode(_ParsedData["provider"]?.ToString() ?? "")); - public UserNode User - { - get - { - if (_User == null) - _User = new UserNode(_ParsedData["user"]?.ToString() ?? ""); - return _User; - } - } + public UserNode User => _User ?? (_User = new UserNode(_ParsedData["user"]?.ToString() ?? "")); - public GuildNode Guild - { - get - { - if (_Guild == null) - _Guild = new GuildNode(_ParsedData["guild"]?.ToString() ?? ""); - return _Guild; - } - } - public TextNode Text { - get { - if (_Text == null) - _Text = new TextNode(_ParsedData["text"]?.ToString() ?? ""); - return _Text; - } - } + public GuildNode Guild => _Guild ?? (_Guild = new GuildNode(_ParsedData["guild"]?.ToString() ?? "")); - public VoiceNode Voice { - get { - if (_Voice == null) - _Voice = new VoiceNode(_ParsedData["voice"]?.ToString() ?? ""); - return _Voice; - } - } + public TextNode Text => _Text ?? (_Text = new TextNode(_ParsedData["text"]?.ToString() ?? "")); + + public VoiceNode Voice => _Voice ?? (_Voice = new VoiceNode(_ParsedData["voice"]?.ToString() ?? "")); /// /// Creates a default GameState_Discord instance. @@ -77,6 +44,6 @@ public GameState_Discord(string JSONstring) : base(JSONstring) { } /// Creates a GameState_Discord instance based on the data from the passed GameState instance. /// public GameState_Discord(IGameState other) : base(other) { } - + } } diff --git a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/GuildNode.cs b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/GuildNode.cs index 06ddb5cd3..a5bad659e 100644 --- a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/GuildNode.cs +++ b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/GuildNode.cs @@ -6,11 +6,9 @@ namespace Aurora.Profiles.Discord.GSI.Nodes { public class GuildNode : Node { - public long Id = 0; public string Name = String.Empty; - internal GuildNode() : base() { } internal GuildNode(string json) : base(json) { Id = GetLong("id"); Name = GetString("name"); diff --git a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/ProviderNode.cs b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/ProviderNode.cs index 2c5f5cd15..e60ca96d5 100644 --- a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/ProviderNode.cs +++ b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/ProviderNode.cs @@ -6,7 +6,6 @@ namespace Aurora.Profiles.Discord.GSI.Nodes { public class ProviderNode : Node { - public string Name; public int AppID; diff --git a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/TextNode.cs b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/TextNode.cs index a8b7e371b..3ea9e0607 100644 --- a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/TextNode.cs +++ b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/TextNode.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; namespace Aurora.Profiles.Discord.GSI.Nodes { - public enum DiscordTextType { Undefined = -1, @@ -14,18 +13,15 @@ public enum DiscordTextType GroupChat = 3 } - public class TextNode : Node { - public long Id = 0; public string Name; - public int Type; + public DiscordTextType Type; - internal TextNode() : base() { } internal TextNode(string json) : base(json) { Id = GetLong("id"); Name = GetString("name"); - Type = GetInt("type"); + Type = (DiscordTextType)GetInt("type"); } } } diff --git a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/UserNode.cs b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/UserNode.cs index 980601b39..39c6333ae 100644 --- a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/UserNode.cs +++ b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/UserNode.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; namespace Aurora.Profiles.Discord.GSI.Nodes { - public enum DiscordStatus { Undefined, @@ -15,24 +14,38 @@ public enum DiscordStatus Invisible } - public class UserNode : Node { - public long Id = 0; - public string Status = ""; - public bool SelfMute = false; - public bool SelfDeafen = false; - public bool Mentions = false; - public bool UnreadMessages = false; - - internal UserNode() : base() { } + public DiscordStatus Status; + public bool SelfMute; + public bool SelfDeafen; + public bool Mentions; + public bool UnreadMessages; + internal UserNode(string json) : base(json) { Id = GetLong("id"); - Status = GetString("status"); + Status = GetStatus(GetString("status")); SelfMute = GetBool("self_mute"); SelfDeafen = GetBool("self_deafen"); Mentions = GetBool("mentions"); UnreadMessages = GetBool("unread_messages"); } + + private static DiscordStatus GetStatus(string status) + { + switch (status) + { + case "online": + return DiscordStatus.Online; + case "dnd": + return DiscordStatus.DoNotDisturb; + case "invisible": + return DiscordStatus.Invisible; + case "idle": + return DiscordStatus.Idle; + default: + return DiscordStatus.Undefined; + } + } } } diff --git a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/VoiceNode.cs b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/VoiceNode.cs index 1aa8b76c2..96570abe2 100644 --- a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/VoiceNode.cs +++ b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/Nodes/VoiceNode.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; namespace Aurora.Profiles.Discord.GSI.Nodes { - public enum DiscordVoiceType { Undefined = -1, @@ -14,17 +13,14 @@ public enum DiscordVoiceType } public class VoiceNode : Node { - public long Id = 0; public string Name; - public int Type; - + public DiscordVoiceType Type; - internal VoiceNode() : base() { } internal VoiceNode(string json) : base(json) { Id = GetLong("id"); Name = GetString("name"); - Type = GetInt("type"); + Type = (DiscordVoiceType)GetInt("type"); } } } From ccd89d9c5b7a3b9b3c2bc00b22dc6b105568ab60 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Wed, 25 Dec 2019 17:24:29 +0000 Subject: [PATCH 2/3] Added manual patch button --- .../Profiles/Discord/Control_Discord.xaml | 5 +- .../Profiles/Discord/Control_Discord.xaml.cs | 63 ++++++++++--------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Project-Aurora/Project-Aurora/Profiles/Discord/Control_Discord.xaml b/Project-Aurora/Project-Aurora/Profiles/Discord/Control_Discord.xaml index e024801a3..7974cc31d 100644 --- a/Project-Aurora/Project-Aurora/Profiles/Discord/Control_Discord.xaml +++ b/Project-Aurora/Project-Aurora/Profiles/Discord/Control_Discord.xaml @@ -14,8 +14,9 @@ -