Skip to content

Commit

Permalink
Merge pull request #3189 from bloxstraplabs/feature/improve-studio-su…
Browse files Browse the repository at this point in the history
…pport

Improve studio support
  • Loading branch information
bluepilledgreat authored Dec 4, 2024
2 parents fb52bb3 + eb9e134 commit 729ee2b
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Bloxstrap/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public partial class App : Application

public static bool IsProductionBuild => IsActionBuild && BuildMetadata.CommitRef.StartsWith("tag", StringComparison.Ordinal);

public static bool IsStudioVisible => !String.IsNullOrEmpty(App.State.Prop.Studio.VersionGuid);

public static readonly MD5 MD5Provider = MD5.Create();

public static readonly Logger Logger = new();
Expand Down
3 changes: 2 additions & 1 deletion Bloxstrap/Enums/NextAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum NextAction
{
Terminate,
LaunchSettings,
LaunchRoblox
LaunchRoblox,
LaunchRobloxStudio
}
}
4 changes: 2 additions & 2 deletions Bloxstrap/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void DoInstall()

App.Settings.Prop.EnableAnalytics = EnableAnalytics;

if (!String.IsNullOrEmpty(App.State.Prop.Studio.VersionGuid))
if (App.IsStudioVisible)
WindowsRegistry.RegisterStudio();

App.Settings.Save();
Expand Down Expand Up @@ -190,7 +190,7 @@ public static void DoUninstall(bool keepData)
if (!String.IsNullOrEmpty(App.State.Prop.Player.VersionGuid))
processes.AddRange(Process.GetProcessesByName(App.RobloxPlayerAppName));

if (!String.IsNullOrEmpty(App.State.Prop.Studio.VersionGuid))
if (App.IsStudioVisible)
processes.AddRange(Process.GetProcessesByName(App.RobloxStudioAppName));

// prompt to shutdown roblox if its currently running
Expand Down
4 changes: 4 additions & 0 deletions Bloxstrap/LaunchHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public static void ProcessNextAction(NextAction action, bool isUnfinishedInstall
LaunchRoblox(LaunchMode.Player);
break;

case NextAction.LaunchRobloxStudio:
LaunchRoblox(LaunchMode.Studio);
break;

default:
App.Terminate(isUnfinishedInstall ? ErrorCode.ERROR_INSTALL_USEREXIT : ErrorCode.ERROR_SUCCESS);
break;
Expand Down
22 changes: 21 additions & 1 deletion Bloxstrap/LaunchSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public LaunchSettings(string[] args)
{
const string LOG_IDENT = "LaunchSettings";

#if DEBUG
App.Logger.WriteLine(LOG_IDENT, $"Launched with arguments: {string.Join(' ', args)}");
#endif

Args = args;

// build flag map
Expand Down Expand Up @@ -125,7 +129,23 @@ private void ParseStudio(string? data)
{
RobloxLaunchMode = LaunchMode.Studio;

// TODO: do this later
if (String.IsNullOrEmpty(data))
return;

if (data.StartsWith("roblox-studio:"))
{
RobloxLaunchArgs = data;
}
else if (data.StartsWith("roblox-studio-auth:"))
{
RobloxLaunchMode = LaunchMode.StudioAuth;
RobloxLaunchArgs = data;
}
else
{
// likely a local path
RobloxLaunchArgs = $"-task EditFile -localPlaceFile \"{data}\"";
}
}
}
}
9 changes: 9 additions & 0 deletions Bloxstrap/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Bloxstrap/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,9 @@ Would you like to enable test mode?</value>
<value>Icons</value>
<comment>Name of the folder that gets created according to the "create shortcut icons" option. Ensure that it is a valid folder name.</comment>
</data>
<data name="LaunchMenu.LaunchRobloxStudio" xml:space="preserve">
<value>Launch Roblox Studio</value>
</data>
<data name="Dialog.Exception.Version" xml:space="preserve">
<value>Version {0}</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions Bloxstrap/UI/Elements/Dialogs/LaunchMenuDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
</StackPanel>
</ui:CardAction>

<ui:CardAction Margin="0,8,0,0" Icon="ArrowRight12" Visibility="{Binding RobloxStudioOptionVisibility, Mode=OneTime}" Command="{Binding LaunchRobloxStudioCommand, Mode=OneTime}">
<StackPanel>
<TextBlock FontSize="14" Text="{x:Static resources:Strings.LaunchMenu_LaunchRobloxStudio}" />
</StackPanel>
</ui:CardAction>

<ui:CardAction Margin="0,8,0,0" TabIndex="1" Icon="Settings28" Command="{Binding LaunchSettingsCommand, Mode=OneTime}">
<StackPanel>
<TextBlock FontSize="14" Text="{x:Static resources:Strings.LaunchMenu_ConfigureSettings}" />
Expand Down
21 changes: 19 additions & 2 deletions Bloxstrap/UI/Elements/Settings/Pages/ShortcutsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,31 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<!-- https://stackoverflow.com/a/51967350 -->
<ColumnDefinition>
<ColumnDefinition.Style>
<Style TargetType="ColumnDefinition">
<Setter Property="Width" Value="*" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsStudioOptionVisible}" Value="False">
<Setter Property="Width" Value="0" />
</DataTrigger>
</Style.Triggers>
</Style>
</ColumnDefinition.Style>
</ColumnDefinition>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<controls:OptionControl Grid.Column="0" Margin="0,0,4,0" Header="{x:Static resources:Strings.LaunchMenu_LaunchRoblox}">
<controls:OptionControl Grid.Column="0" Margin="0,0,2,0" Header="{x:Static resources:Strings.LaunchMenu_LaunchRoblox}">
<ui:ToggleSwitch IsChecked="{Binding PlayerIconTask.NewState, Mode=TwoWay}" />
</controls:OptionControl>

<controls:OptionControl Grid.Column="1" Margin="4,0,0,0" Header="{x:Static resources:Strings.Menu_Title}">
<controls:OptionControl Grid.Column="1" Margin="2,0,2,0" Header="{x:Static resources:Strings.LaunchMenu_LaunchRobloxStudio}">
<ui:ToggleSwitch IsChecked="{Binding StudioIconTask.NewState, Mode=TwoWay}" />
</controls:OptionControl>

<controls:OptionControl Grid.Column="2" Margin="2,0,0,0" Header="{x:Static resources:Strings.Menu_Title}">
<ui:ToggleSwitch IsChecked="{Binding SettingsIconTask.NewState, Mode=TwoWay}" />
</controls:OptionControl>
</Grid>
Expand Down
9 changes: 8 additions & 1 deletion Bloxstrap/UI/ViewModels/Dialogs/LaunchMenuViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows.Input;
using System.Windows;
using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;

using Bloxstrap.UI.Elements.About;
Expand All @@ -9,10 +10,14 @@ public class LaunchMenuViewModel
{
public string Version => string.Format(Strings.Menu_About_Version, App.Version);

public Visibility RobloxStudioOptionVisibility => App.IsStudioVisible ? Visibility.Visible : Visibility.Collapsed;

public ICommand LaunchSettingsCommand => new RelayCommand(LaunchSettings);

public ICommand LaunchRobloxCommand => new RelayCommand(LaunchRoblox);

public ICommand LaunchRobloxStudioCommand => new RelayCommand(LaunchRobloxStudio);

public ICommand LaunchAboutCommand => new RelayCommand(LaunchAbout);

public event EventHandler<NextAction>? CloseWindowRequest;
Expand All @@ -21,6 +26,8 @@ public class LaunchMenuViewModel

private void LaunchRoblox() => CloseWindowRequest?.Invoke(this, NextAction.LaunchRoblox);

private void LaunchRobloxStudio() => CloseWindowRequest?.Invoke(this, NextAction.LaunchRobloxStudio);

private void LaunchAbout() => new MainWindow().ShowDialog();
}
}
9 changes: 5 additions & 4 deletions Bloxstrap/UI/ViewModels/Settings/ShortcutsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using Bloxstrap.Models.SettingTasks;
using Bloxstrap.Resources;

namespace Bloxstrap.UI.ViewModels.Settings
namespace Bloxstrap.UI.ViewModels.Settings
{
public class ShortcutsViewModel : NotifyPropertyChangedViewModel
{
public bool IsStudioOptionVisible => App.IsStudioVisible;

public ShortcutTask DesktopIconTask { get; } = new("Desktop", Paths.Desktop, $"{App.ProjectName}.lnk");

public ShortcutTask StartMenuIconTask { get; } = new("StartMenu", Paths.WindowsStartMenu, $"{App.ProjectName}.lnk");

public ShortcutTask PlayerIconTask { get; } = new("RobloxPlayer", Paths.Desktop, $"{Strings.LaunchMenu_LaunchRoblox}.lnk", "-player");

public ShortcutTask StudioIconTask { get; } = new("RobloxStudio", Paths.Desktop, $"{Strings.LaunchMenu_LaunchRobloxStudio}.lnk", "-studio");

public ShortcutTask SettingsIconTask { get; } = new("Settings", Paths.Desktop, $"{Strings.Menu_Title}.lnk", "-settings");

public ExtractIconsTask ExtractIconsTask { get; } = new();
Expand Down

0 comments on commit 729ee2b

Please sign in to comment.