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);
// 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,
// just in case the user decides to cancel the install
if (!IsFirstRun)
@ -175,13 +190,8 @@ namespace Bloxstrap
}
else
{
if (Process.GetProcessesByName(ProjectName).Length > 1 && !LaunchSettings.IsQuiet)
Frontend.ShowMessageBox(
Bloxstrap.Resources.Strings.Menu_AlreadyRunning,
MessageBoxImage.Information
);
Frontend.ShowMenu();
bool showAlreadyRunningWarning = Process.GetProcessesByName(ProjectName).Length > 1 && !LaunchSettings.IsQuiet;
Frontend.ShowMenu(showAlreadyRunningWarning);
}
StartupFinished();

View File

@ -40,7 +40,7 @@
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<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">
<!--<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>-->
<PrivateAssets>all</PrivateAssets>

View File

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

View File

@ -8,6 +8,7 @@
public enum ErrorCode
{
ERROR_SUCCESS = 0,
ERROR_INVALID_FUNCTION = 1,
ERROR_INSTALL_USEREXIT = 1602,
ERROR_INSTALL_FAILURE = 1603,
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>
/// 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>
/// Looks up a localized string similar to Applying Roblox modifications....
/// </summary>
@ -1462,11 +1480,20 @@ namespace Bloxstrap.Resources {
}
/// <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>
public static string Menu_AlreadyRunning {
public static string Menu_AlreadyRunning_Caption {
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">
<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 name="Bootstrapper.FirstRunUninstall" xml:space="preserve">
<value>You must first install Bloxstrap before uninstalling.</value>
</data>
<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.
@ -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">
<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 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">
<value>Applying Roblox modifications...</value>
</data>
@ -590,8 +596,11 @@ Would you like to upgrade your currently installed version?</value>
<data name="Menu.AllFiles" xml:space="preserve">
<value>All files</value>
</data>
<data name="Menu.AlreadyRunning" 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>
<data name="Menu.AlreadyRunning.Caption" xml:space="preserve">
<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 name="Menu.Appearance.Bootstrapper.Description" xml:space="preserve">
<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"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -24,6 +24,12 @@
<RowDefinition Height="Auto" />
</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" />
<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>
public partial class MainWindow : INavigationWindow
{
public MainWindow()
public MainWindow(bool showAlreadyRunningWarning)
{
InitializeComponent();
ApplyTheme();
@ -22,6 +22,15 @@ namespace Bloxstrap.UI.Elements.Menu
#if DEBUG // easier access
PreInstallNavItem.Visibility = System.Windows.Visibility.Visible;
#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");

View File

@ -8,7 +8,7 @@ namespace Bloxstrap.UI
{
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)
{

View File

@ -1,9 +1,18 @@
using System.ComponentModel;
using System.Security.Principal;
namespace Bloxstrap
{
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)
{
try