This commit is contained in:
pizzaboxer 2024-04-24 17:24:30 +01:00
commit b3684b9e52
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
10 changed files with 88 additions and 17 deletions

View File

@ -138,6 +138,21 @@ namespace Bloxstrap
Paths.Initialize(BaseDirectory); Paths.Initialize(BaseDirectory);
// disallow running as administrator except for uninstallation
if (Utilities.IsAdministrator && !LaunchSettings.IsUninstall)
{
Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Bootstrapper_RanInAdminMode, MessageBoxImage.Error);
Terminate(ErrorCode.ERROR_INVALID_FUNCTION);
return;
}
if (LaunchSettings.IsUninstall && IsFirstRun)
{
Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Bootstrapper_FirstRunUninstall, MessageBoxImage.Error);
Terminate(ErrorCode.ERROR_INVALID_FUNCTION);
return;
}
// we shouldn't save settings on the first run until the first installation is finished, // we shouldn't save settings on the first run until the first installation is finished,
// just in case the user decides to cancel the install // just in case the user decides to cancel the install
if (!IsFirstRun) if (!IsFirstRun)
@ -175,13 +190,8 @@ namespace Bloxstrap
} }
else else
{ {
if (Process.GetProcessesByName(ProjectName).Length > 1 && !LaunchSettings.IsQuiet) bool showAlreadyRunningWarning = Process.GetProcessesByName(ProjectName).Length > 1 && !LaunchSettings.IsQuiet;
Frontend.ShowMessageBox( Frontend.ShowMenu(showAlreadyRunningWarning);
Bloxstrap.Resources.Strings.Menu_AlreadyRunning,
MessageBoxImage.Information
);
Frontend.ShowMenu();
} }
StartupFinished(); StartupFinished();

View File

@ -40,7 +40,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="DiscordRichPresence" Version="1.2.1.24" /> <PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
<PackageReference Include="Markdig" Version="0.35.0" /> <PackageReference Include="Markdig" Version="0.37.0" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.18-beta"> <PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.18-beta">
<!--<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>--> <!--<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>-->
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>

View File

@ -1202,7 +1202,7 @@ namespace Bloxstrap
if (App.IsFirstRun && App.CustomFontLocation is not null) if (App.IsFirstRun && App.CustomFontLocation is not null)
{ {
Directory.CreateDirectory(Path.GetDirectoryName(Paths.CustomFont)!); Directory.CreateDirectory(Path.GetDirectoryName(Paths.CustomFont)!);
File.Copy(App.CustomFontLocation, Paths.CustomFont); File.Copy(App.CustomFontLocation, Paths.CustomFont, true);
} }
if (File.Exists(Paths.CustomFont)) if (File.Exists(Paths.CustomFont))

View File

@ -8,6 +8,7 @@
public enum ErrorCode public enum ErrorCode
{ {
ERROR_SUCCESS = 0, ERROR_SUCCESS = 0,
ERROR_INVALID_FUNCTION = 1,
ERROR_INSTALL_USEREXIT = 1602, ERROR_INSTALL_USEREXIT = 1602,
ERROR_INSTALL_FAILURE = 1603, ERROR_INSTALL_FAILURE = 1603,
ERROR_CANCELLED = 1223, ERROR_CANCELLED = 1223,

View File

@ -133,6 +133,15 @@ namespace Bloxstrap.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to You must first install Bloxstrap before uninstalling..
/// </summary>
public static string Bootstrapper_FirstRunUninstall {
get {
return ResourceManager.GetString("Bootstrapper.FirstRunUninstall", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Roblox has now finished rolling out the new game client update, featuring 64-bit support and the Hyperion anticheat. ReShade does not work with this update, and so it has now been disabled and removed from Bloxstrap. /// Looks up a localized string similar to Roblox has now finished rolling out the new game client update, featuring 64-bit support and the Hyperion anticheat. ReShade does not work with this update, and so it has now been disabled and removed from Bloxstrap.
/// ///
@ -153,6 +162,15 @@ namespace Bloxstrap.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Bloxstrap does not support running in administrator mode. Relaunch or reinstall Bloxstrap with lower privileges..
/// </summary>
public static string Bootstrapper_RanInAdminMode {
get {
return ResourceManager.GetString("Bootstrapper.RanInAdminMode", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Applying Roblox modifications.... /// Looks up a localized string similar to Applying Roblox modifications....
/// </summary> /// </summary>
@ -1462,11 +1480,20 @@ namespace Bloxstrap.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Bloxstrap is currently running, likely as a background Roblox process. Please note that not all your changes will immediately apply until you close all currently open Roblox instances.. /// Looks up a localized string similar to Please note that not all your changes will immediately apply until you close all currently open Roblox instances..
/// </summary> /// </summary>
public static string Menu_AlreadyRunning { public static string Menu_AlreadyRunning_Caption {
get { get {
return ResourceManager.GetString("Menu.AlreadyRunning", resourceCulture); return ResourceManager.GetString("Menu.AlreadyRunning.Caption", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Bloxstrap is already running.
/// </summary>
public static string Menu_AlreadyRunning_Title {
get {
return ResourceManager.GetString("Menu.AlreadyRunning.Title", resourceCulture);
} }
} }

View File

@ -142,6 +142,9 @@ Would you like to switch to the default channel ({1})?</value>
<data name="Bootstrapper.DeeplinkTempEnabled" xml:space="preserve"> <data name="Bootstrapper.DeeplinkTempEnabled" xml:space="preserve">
<value>Roblox was launched via a deeplink, however the desktop app is required for deeplink launching to work. Because you've opted to disable the desktop app, it will temporarily be re-enabled for this launch only.</value> <value>Roblox was launched via a deeplink, however the desktop app is required for deeplink launching to work. Because you've opted to disable the desktop app, it will temporarily be re-enabled for this launch only.</value>
</data> </data>
<data name="Bootstrapper.FirstRunUninstall" xml:space="preserve">
<value>You must first install Bloxstrap before uninstalling.</value>
</data>
<data name="Bootstrapper.HyperionUpdateInfo" xml:space="preserve"> <data name="Bootstrapper.HyperionUpdateInfo" xml:space="preserve">
<value>Roblox has now finished rolling out the new game client update, featuring 64-bit support and the Hyperion anticheat. ReShade does not work with this update, and so it has now been disabled and removed from Bloxstrap. <value>Roblox has now finished rolling out the new game client update, featuring 64-bit support and the Hyperion anticheat. ReShade does not work with this update, and so it has now been disabled and removed from Bloxstrap.
@ -150,6 +153,9 @@ Your ReShade configuration files will still be saved, and you can locate them by
<data name="Bootstrapper.NotEnoughSpace" xml:space="preserve"> <data name="Bootstrapper.NotEnoughSpace" xml:space="preserve">
<value>Bloxstrap does not have enough disk space to download and install Roblox. Please free up some disk space and try again.</value> <value>Bloxstrap does not have enough disk space to download and install Roblox. Please free up some disk space and try again.</value>
</data> </data>
<data name="Bootstrapper.RanInAdminMode" xml:space="preserve">
<value>Bloxstrap does not support running in administrator mode. Relaunch or reinstall Bloxstrap with lower privileges.</value>
</data>
<data name="Bootstrapper.Status.ApplyingModifications" xml:space="preserve"> <data name="Bootstrapper.Status.ApplyingModifications" xml:space="preserve">
<value>Applying Roblox modifications...</value> <value>Applying Roblox modifications...</value>
</data> </data>
@ -590,8 +596,11 @@ Would you like to upgrade your currently installed version?</value>
<data name="Menu.AllFiles" xml:space="preserve"> <data name="Menu.AllFiles" xml:space="preserve">
<value>All files</value> <value>All files</value>
</data> </data>
<data name="Menu.AlreadyRunning" xml:space="preserve"> <data name="Menu.AlreadyRunning.Caption" xml:space="preserve">
<value>Bloxstrap is currently running, likely as a background Roblox process. Please note that not all your changes will immediately apply until you close all currently open Roblox instances.</value> <value>Please note that not all your changes will immediately apply until you close all currently open Roblox instances.</value>
</data>
<data name="Menu.AlreadyRunning.Title" xml:space="preserve">
<value>Bloxstrap is already running</value>
</data> </data>
<data name="Menu.Appearance.Bootstrapper.Description" xml:space="preserve"> <data name="Menu.Appearance.Bootstrapper.Description" xml:space="preserve">
<value>You can make it look different, retro, or even just like Roblox.</value> <value>You can make it look different, retro, or even just like Roblox.</value>

View File

@ -1,4 +1,4 @@
<base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.Menu.MainWindow" <base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.Menu.MainWindow"
x:Name="ConfigurationWindow" x:Name="ConfigurationWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -24,6 +24,12 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ui:Snackbar
x:Name="AlreadyRunningSnackbar"
Title="{x:Static resources:Strings.Menu_AlreadyRunning_Title}"
Message="{x:Static resources:Strings.Menu_AlreadyRunning_Caption}"
Icon="Info20" Timeout="10000" Margin="200,0,200,20" Grid.RowSpan="10" Panel.ZIndex="10" />
<ui:TitleBar Padding="8" x:Name="RootTitleBar" Grid.Row="0" ForceShutdown="False" MinimizeToTray="False" ShowHelp="True" HelpClicked="OpenWiki" UseSnapLayout="True" Title="{x:Static resources:Strings.Menu_Title}" Icon="pack://application:,,,/Bloxstrap.ico" /> <ui:TitleBar Padding="8" x:Name="RootTitleBar" Grid.Row="0" ForceShutdown="False" MinimizeToTray="False" ShowHelp="True" HelpClicked="OpenWiki" UseSnapLayout="True" Title="{x:Static resources:Strings.Menu_Title}" Icon="pack://application:,,,/Bloxstrap.ico" />
<Grid x:Name="RootGrid" Grid.Row="1" Margin="12,12,0,0" Visibility="Visible"> <Grid x:Name="RootGrid" Grid.Row="1" Margin="12,12,0,0" Visibility="Visible">

View File

@ -10,7 +10,7 @@ namespace Bloxstrap.UI.Elements.Menu
/// </summary> /// </summary>
public partial class MainWindow : INavigationWindow public partial class MainWindow : INavigationWindow
{ {
public MainWindow() public MainWindow(bool showAlreadyRunningWarning)
{ {
InitializeComponent(); InitializeComponent();
ApplyTheme(); ApplyTheme();
@ -22,6 +22,15 @@ namespace Bloxstrap.UI.Elements.Menu
#if DEBUG // easier access #if DEBUG // easier access
PreInstallNavItem.Visibility = System.Windows.Visibility.Visible; PreInstallNavItem.Visibility = System.Windows.Visibility.Visible;
#endif #endif
if (showAlreadyRunningWarning)
_ = ShowAlreadyRunningSnackbar();
}
private async Task ShowAlreadyRunningSnackbar()
{
await Task.Delay(500); // wait for everything to finish loading
AlreadyRunningSnackbar.Show();
} }
public void OpenWiki(object? sender, EventArgs e) => Utilities.ShellExecute($"https://github.com/{App.ProjectRepository}/wiki"); public void OpenWiki(object? sender, EventArgs e) => Utilities.ShellExecute($"https://github.com/{App.ProjectRepository}/wiki");

View File

@ -8,7 +8,7 @@ namespace Bloxstrap.UI
{ {
static class Frontend static class Frontend
{ {
public static void ShowMenu() => new MainWindow().ShowDialog(); public static void ShowMenu(bool showAlreadyRunningWarning = false) => new MainWindow(showAlreadyRunningWarning).ShowDialog();
public static MessageBoxResult ShowMessageBox(string message, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxResult defaultResult = MessageBoxResult.None) public static MessageBoxResult ShowMessageBox(string message, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxResult defaultResult = MessageBoxResult.None)
{ {

View File

@ -1,9 +1,18 @@
using System.ComponentModel; using System.ComponentModel;
using System.Security.Principal;
namespace Bloxstrap namespace Bloxstrap
{ {
static class Utilities static class Utilities
{ {
/// <summary>
/// Is process running as administrator
/// https://stackoverflow.com/a/11660205
/// </summary>
public static bool IsAdministrator =>
new WindowsPrincipal(WindowsIdentity.GetCurrent())
.IsInRole(WindowsBuiltInRole.Administrator);
public static void ShellExecute(string website) public static void ShellExecute(string website)
{ {
try try