Skip to content

Commit 2c61826

Browse files
committed
bunch of new studio toggleables
1 parent b145bd3 commit 2c61826

12 files changed

Lines changed: 232 additions & 55 deletions

File tree

Bloxstrap/Integrations/ActivityWatcher.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class ActivityWatcher : IDisposable
4949
public event EventHandler? OnLogOpen;
5050
public event EventHandler? OnAppClose;
5151
public event EventHandler<Message>? OnRPCMessage;
52+
public event EventHandler<StudioMessage>? OnStudioRPCMessage;
5253
public event EventHandler<ActivityData>? OnAutoRejoinTriggered;
5354

5455
private DateTime _lastInactivityTimeout = DateTime.MinValue;
@@ -272,19 +273,17 @@ private void ProcessStudioLogEntry(string logMessage)
272273
{
273274
Details = activityState,
274275
State = !string.IsNullOrEmpty(workspace) ? $"Workspace: {workspace}" : null!,
275-
TimestampStart = (ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
276276
Testing = testing,
277277
ScriptType = scriptType
278278
}
279279
};
280280

281281
string json = JsonSerializer.Serialize(studioRpc);
282-
var rpcMessage = JsonSerializer.Deserialize<Message>(json);
282+
var rpcMessage = JsonSerializer.Deserialize<StudioMessage>(json);
283283

284284
if (rpcMessage != null)
285285
{
286-
OnRPCMessage?.Invoke(this, rpcMessage);
287-
App.Logger.WriteLine(LOG_IDENT, $"Sent Studio RPC: Details: {activityState} | Type: {scriptType} | Testing: {testing}");
286+
OnStudioRPCMessage?.Invoke(this, rpcMessage);
288287
}
289288
}
290289
}
@@ -294,13 +293,6 @@ private void ProcessPlayerLogEntry(string logMessage)
294293
{
295294
const string LOG_IDENT = "ActivityWatcher::ProcessPlayerLogEntry";
296295

297-
if (logMessage.StartsWith(StudioMessageEntry) || logMessage.Contains("[FroststrapStudioRPC]"))
298-
{
299-
InRobloxStudio = true;
300-
ProcessStudioLogEntry(logMessage);
301-
return;
302-
}
303-
304296
if (logMessage.StartsWith(GameLeavingEntry))
305297
{
306298
App.Logger.WriteLine(LOG_IDENT, "User is back into the desktop app");
@@ -467,10 +459,8 @@ private void ProcessPlayerLogEntry(string logMessage)
467459
OnGameLeave?.Invoke(this, EventArgs.Empty);
468460
});
469461

470-
if (App.Settings.Prop.AutoRejoinEnabled)
462+
if (App.Settings.Prop.AutoRejoin)
471463
{
472-
App.Logger.WriteLine(LOG_IDENT, "checking for inactivity timeout for 3 seconds");
473-
474464
_ = Task.Run(async () =>
475465
{
476466
try

Bloxstrap/Integrations/MemoryCleaner.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
using System.Runtime.InteropServices;
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+
14+
using System.Runtime.InteropServices;
215
using System.Timers;
316
using System.Diagnostics;
417
using System.ComponentModel;

Bloxstrap/Integrations/RobloxServerFetcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private async Task<HttpResponseMessage> SendJoinRequestWithRetriesAsync(long pla
259259
{
260260
attempt++;
261261
var joinReq = new HttpRequestMessage(HttpMethod.Post, "https://gamejoin.roblox.com/v1/join-game-instance");
262-
joinReq.Headers.Add("User-Agent", "Roblox/Froststrap");
262+
joinReq.Headers.Add("User-Agent", $"{App.ProjectName}/{App.Version}");
263263
joinReq.Headers.Add("Referer", $"https://roblox.com/games/{placeId}");
264264
joinReq.Headers.Add("Origin", "https://roblox.com");
265265

Bloxstrap/Integrations/StudioDiscordRichPresence.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
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+
114
using DiscordRPC;
215

316
namespace 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

Bloxstrap/Models/FroststrapStudioRPC/StudioMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class StudioMessage
44
{
55
[JsonPropertyName("command")]
6-
public string Command { get; set; } = "SetRichPresence";
6+
public string StudioCommand { get; set; } = "SetRichPresence";
77

88
[JsonPropertyName("data")]
99
public StudioRichPresence Data { get; set; } = new();

Bloxstrap/Models/FroststrapStudioRPC/StudioRichPresence.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ public class StudioRichPresence
88
[JsonPropertyName("state")]
99
public string State { get; set; } = "";
1010

11-
[JsonPropertyName("timeStart")]
12-
public ulong TimestampStart { get; set; } = (ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds();
13-
1411
[JsonPropertyName("testing")]
1512
public bool Testing { get; set; } = false;
1613

Bloxstrap/Models/Persistable/Settings.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class Settings
1111
public bool EnableActivityTracking { get; set; } = true;
1212
public bool ShowServerDetails { get; set; } = true;
1313
public bool ShowServerUptime { get; set; } = false;
14-
public bool AutoRejoinEnabled { get; set; } = false;
14+
public bool AutoRejoin { get; set; } = false;
1515
public bool ShowGameHistoryMenu { get; set; } = true;
1616
public List<ActivityData> ServerHistory { get; set; } = new List<ActivityData>();
1717
public bool PlaytimeCounter { get; set; } = true;
@@ -24,6 +24,11 @@ public class Settings
2424
public bool HideRPCButtons { get; set; } = true;
2525
public bool EnableCustomStatusDisplay { get; set; } = true;
2626
public bool ShowAccountOnRichPresence { get; set; } = false;
27+
public bool StudioRPC { get; set; } = false;
28+
public bool StudioThumbnailChanging { get; set; } = false;
29+
public bool StudioEditingInfo { get; set; } = false;
30+
public bool StudioWorkspaceInfo { get; set; } = false;
31+
public bool StudioShowTesting { get; set; } = false;
2732
public ObservableCollection<CustomIntegration> CustomIntegrations { get; set; } = new();
2833

2934
// Bootstrapper Page

Bloxstrap/Resources/Strings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Bloxstrap/Resources/Strings.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ Selecting 'No' will ignore this warning and continue installation.</value>
10591059
<value>Enable Activity Tracking</value>
10601060
</data>
10611061
<data name="Menu.Integrations.RequiresActivityTracking" xml:space="preserve">
1062-
<value>This feature requires activity tracking to be enabled and the Discord desktop app to be installed and running. [Find out more]({0}).</value>
1062+
<value>These feature requires activity tracking to be enabled and the Discord desktop app to be installed and running. [Find out more]({0}).</value>
10631063
</data>
10641064
<data name="Menu.Integrations.ShowGameActivity.Description" xml:space="preserve">
10651065
<value>The Roblox game you're playing will be shown on your Discord profile. [Not working?]({0})</value>

Bloxstrap/UI/Elements/Settings/Pages/IntegrationsPage.xaml

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
1111
x:Name="IntegrationsPageView"
1212
Title="IntegrationsPage"
13-
d:DesignHeight="1500"
13+
d:DesignHeight="2100"
1414
d:DesignWidth="800"
1515
Scrollable="True"
1616
mc:Ignorable="d">
@@ -64,7 +64,8 @@
6464
</controls:OptionControl>
6565

6666
<ui:CardExpander
67-
Margin="0,8,0,0"
67+
Margin="0,8,0,0"
68+
IsEnabled="{Binding InnerContent.IsChecked, ElementName=ActivityTrackingOption, Mode=OneWay}"
6869
IsExpanded="{Binding Path=ShowGameHistoryEnabled, Mode=OneWay}"
6970
Style="{StaticResource NoUserExpansionCardExpanderStyle}">
7071
<ui:CardExpander.Header>
@@ -87,13 +88,12 @@
8788
<controls:OptionControl
8889
Description="{x:Static resources:Strings.Menu_Integrations_GameHistoryMenu_Description}"
8990
Header="{x:Static resources:Strings.Menu_Integrations_GameHistoryMenu_Title}"
90-
IsEnabled="{Binding ShowGameHistoryEnabled, Mode=OneWay}">
91+
IsEnabled="{Binding InnerContent.IsChecked, ElementName=ActivityTrackingOption, Mode=OneWay}">
9192
<Button
9293
Margin="0,8,0,0"
9394
HorizontalAlignment="Left"
9495
Command="{Binding OpenGameHistoryCommand}"
95-
Content="View Game History"
96-
IsEnabled="{Binding ShowGameHistoryEnabled}" />
96+
Content="View Game History"/>
9797
</controls:OptionControl>
9898
</StackPanel>
9999
</ui:CardExpander>
@@ -167,6 +167,12 @@
167167
<ui:ToggleSwitch IsChecked="{Binding ShowUsingFroststrapRPC, Mode=TwoWay}" />
168168
</controls:OptionControl>
169169

170+
<TextBlock
171+
FontSize="18"
172+
Margin="0,16,0,0"
173+
FontWeight="Bold"
174+
Text="Roblox Player" />
175+
170176
<controls:OptionControl
171177
x:Name="DiscordActivityOption"
172178
Description="{Binding Source={x:Static resources:Strings.Menu_Integrations_ShowGameActivity_Description}, Converter={StaticResource StringFormatConverter}, ConverterParameter='https://github.com/bloxstraplabs/bloxstrap/wiki/Discord-Rich-Presence-does-not-work'}"
@@ -196,6 +202,48 @@
196202
<ui:ToggleSwitch IsChecked="{Binding DiscordAccountOnProfile, Mode=TwoWay}" />
197203
</controls:OptionControl>
198204

205+
<TextBlock
206+
FontSize="18"
207+
Margin="0,16,0,0"
208+
FontWeight="Bold"
209+
Text="Roblox Studio" />
210+
211+
<controls:OptionControl
212+
x:Name="StudioActivityOption"
213+
Header="Show Studio Activity"
214+
Description="Shows your playing Roblox Studio when launching."
215+
IsEnabled="{Binding InnerContent.IsChecked, ElementName=ActivityTrackingOption, Mode=OneWay}">
216+
<ui:ToggleSwitch IsChecked="{Binding StudioRPCEnabled, Mode=TwoWay}" />
217+
</controls:OptionControl>
218+
219+
<controls:OptionControl
220+
Header="Thumbnail Changing"
221+
Description="Changes the RPC thumbnail depending on the type of script you have open, Module/Client/Server Script."
222+
IsEnabled="{Binding InnerContent.IsChecked, ElementName=StudioActivityOption, Mode=OneWay}">
223+
<ui:ToggleSwitch IsChecked="{Binding ThumbnailChanging, Mode=TwoWay}" />
224+
</controls:OptionControl>
225+
226+
<controls:OptionControl
227+
Header="Editing Info"
228+
Description="Shows the script type and lines amount when opening it."
229+
IsEnabled="{Binding InnerContent.IsChecked, ElementName=StudioActivityOption, Mode=OneWay}">
230+
<ui:ToggleSwitch IsChecked="{Binding EditingInfo, Mode=TwoWay}" />
231+
</controls:OptionControl>
232+
233+
<controls:OptionControl
234+
Header="Workspace Info"
235+
Description="Shows the game name."
236+
IsEnabled="{Binding InnerContent.IsChecked, ElementName=StudioActivityOption, Mode=OneWay}">
237+
<ui:ToggleSwitch IsChecked="{Binding WorkspaceInfo, Mode=TwoWay}" />
238+
</controls:OptionControl>
239+
240+
<controls:OptionControl
241+
Header="Show Testing"
242+
Description="Shows your testing the game when debugging."
243+
IsEnabled="{Binding InnerContent.IsChecked, ElementName=StudioActivityOption, Mode=OneWay}">
244+
<ui:ToggleSwitch IsChecked="{Binding ShowTesting, Mode=TwoWay}" />
245+
</controls:OptionControl>
246+
199247
<Separator Margin="0,8,0,8" />
200248

201249
<TextBlock

0 commit comments

Comments
 (0)