1+ /*
2+ * Froststrap
3+ * Copyright (c) Froststrap Team
4+ *
5+ * This file is part of Froststrap and is distributed under the terms of the
6+ * GNU Affero General Public License, version 3 or later.
7+ *
8+ * SPDX-License-Identifier: AGPL-3.0-or-later
9+ *
10+ * Description: Nix flake for shipping for Nix-darwin, Nix, NixOS, and modules
11+ * of the Nix ecosystem.
12+ */
13+
114using DiscordRPC ;
215
316namespace Bloxstrap . Integrations
@@ -6,7 +19,7 @@ public class StudioDiscordRichPresence : IDisposable
619 {
720 private readonly DiscordRpcClient _rpcClient = new ( "1454451301130960896" ) ;
821 private readonly ActivityWatcher _activityWatcher ;
9- private readonly Queue < Message > _messageQueue = new ( ) ;
22+ private readonly Queue < StudioMessage > _messageQueue = new ( ) ;
1023
1124 private DiscordRPC . RichPresence ? _currentPresence ;
1225 private DiscordRPC . RichPresence ? _originalPresence ;
@@ -19,7 +32,7 @@ public StudioDiscordRichPresence(ActivityWatcher activityWatcher)
1932
2033 _activityWatcher = activityWatcher ;
2134
22- _activityWatcher . OnRPCMessage += ( _ , message ) => ProcessRPCMessage ( message ) ;
35+ _activityWatcher . OnStudioRPCMessage += ( _ , message ) => ProcessRPCMessage ( message ) ;
2336 _activityWatcher . OnStudioPlaceOpened += ( _ , _ ) => HandleStudioPlaceOpened ( ) ;
2437 _activityWatcher . OnStudioPlaceClosed += ( _ , _ ) => HandleStudioPlaceClosed ( ) ;
2538
@@ -40,6 +53,7 @@ public StudioDiscordRichPresence(ActivityWatcher activityWatcher)
4053 InitializeStudioPresence ( ) ;
4154 }
4255
56+ // for future use
4357 private void HandleStudioPlaceOpened ( )
4458 {
4559 const string LOG_IDENT = "StudioDiscordRichPresence::HandleStudioPlaceOpened" ;
@@ -54,11 +68,11 @@ private void HandleStudioPlaceClosed()
5468 InitializeStudioPresence ( ) ;
5569 }
5670
57- public void ProcessRPCMessage ( Message message , bool implicitUpdate = true )
71+ public void ProcessRPCMessage ( StudioMessage message , bool implicitUpdate = true )
5872 {
5973 const string LOG_IDENT = "StudioDiscordRichPresence::ProcessRPCMessage" ;
6074
61- if ( message . Command != "SetRichPresence" )
75+ if ( message . StudioCommand != "SetRichPresence" )
6276 return ;
6377
6478 if ( _currentPresence is null || _originalPresence is null )
@@ -97,7 +111,7 @@ private void InitializeStudioPresence()
97111 UpdatePresence ( ) ;
98112 }
99113
100- private void ProcessStudioRichPresence ( Message message , bool implicitUpdate )
114+ private void ProcessStudioRichPresence ( StudioMessage message , bool implicitUpdate )
101115 {
102116 const string LOG_IDENT = "StudioDiscordRichPresence::ProcessStudioRichPresence" ;
103117 StudioRichPresence ? presenceData ;
@@ -107,7 +121,7 @@ private void ProcessStudioRichPresence(Message message, bool implicitUpdate)
107121
108122 try
109123 {
110- presenceData = message . Data . Deserialize < StudioRichPresence > ( ) ;
124+ presenceData = message . Data ;
111125 }
112126 catch ( Exception )
113127 {
@@ -123,18 +137,18 @@ private void ProcessStudioRichPresence(Message message, bool implicitUpdate)
123137
124138 DateTime ? currentTimestamp = _currentPresence . Timestamps . Start ;
125139
126- if ( ! string . IsNullOrEmpty ( presenceData . Details ) )
140+ if ( ! string . IsNullOrEmpty ( presenceData . Details ) && App . Settings . Prop . StudioEditingInfo )
127141 _currentPresence . Details = presenceData . Details ;
128142
129- if ( ! string . IsNullOrEmpty ( presenceData . State ) )
143+ if ( ! string . IsNullOrEmpty ( presenceData . State ) && App . Settings . Prop . StudioWorkspaceInfo )
130144 _currentPresence . State = presenceData . State ;
131145
132146 _currentPresence . Timestamps . Start = currentTimestamp ;
133147
134148 string largeImageKey = "roblox_studio" ;
135149 string largeImageText = "Roblox Studio" ;
136150
137- if ( ! string . IsNullOrEmpty ( presenceData . ScriptType ) )
151+ if ( ! string . IsNullOrEmpty ( presenceData . ScriptType ) && App . Settings . Prop . StudioThumbnailChanging )
138152 {
139153 switch ( presenceData . ScriptType . ToLower ( ) )
140154 {
@@ -162,9 +176,9 @@ private void ProcessStudioRichPresence(Message message, bool implicitUpdate)
162176 string smallImageKey = "" ;
163177 string smallImageText = "" ;
164178
165- if ( presenceData . Testing )
179+ if ( presenceData . Testing && App . Settings . Prop . StudioShowTesting )
166180 {
167- smallImageKey = "testing " ;
181+ smallImageKey = "play_icon " ;
168182 smallImageText = "Currently Testing" ;
169183 }
170184
0 commit comments