From e3803bc58cef65d9c85f61c5ae3dd5a88d700b77 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sat, 1 Oct 2022 06:47:17 +0100 Subject: [PATCH] (v1.4.4) Add support for multiple game instances --- Bloxstrap/Bloxstrap.csproj | 4 +- Bloxstrap/Bootstrapper.cs | 39 +++++++++++-------- .../Integrations/DiscordRichPresence.cs | 8 ++-- .../Helpers/Integrations/RbxFpsUnlocker.cs | 2 +- Bloxstrap/Program.cs | 12 +++--- README.md | 23 +++++------ 6 files changed, 47 insertions(+), 41 deletions(-) diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj index 177eff94..55b4d6a0 100644 --- a/Bloxstrap/Bloxstrap.csproj +++ b/Bloxstrap/Bloxstrap.csproj @@ -9,8 +9,8 @@ AnyCPU AnyCPU;x86 Bloxstrap.ico - 1.4.3 - 1.4.3.0 + 1.4.4 + 1.4.4.0 diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index f6e36708..b0ac6f7d 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -70,9 +70,9 @@ public partial class Bootstrapper private string? LaunchCommandLine; - private string VersionGuid; - private PackageManifest VersionPackageManifest; - private string VersionFolder; + private string VersionGuid = null!; + private PackageManifest VersionPackageManifest = null!; + private string VersionFolder = null!; private readonly bool FreshInstall; @@ -101,7 +101,9 @@ public async Task Run() await CheckLatestVersion(); - if (!Directory.Exists(VersionFolder) || Program.Settings.VersionGuid != VersionGuid) + // if bloxstrap is installing for the first time but is running, prompt to close roblox + // if roblox needs updating but is running, ignore update for now + if (!Directory.Exists(VersionFolder) && CheckIfRunning(true) || Program.Settings.VersionGuid != VersionGuid && !CheckIfRunning(false)) await InstallLatestVersion(); ApplyModifications(); @@ -130,24 +132,31 @@ private async Task CheckLatestVersion() VersionPackageManifest = await PackageManifest.Get(VersionGuid); } - private void CheckIfRunning() + private bool CheckIfRunning(bool shutdown) { Process[] processes = Process.GetProcessesByName("RobloxPlayerBeta"); - if (processes.Length > 0) - Dialog.PromptShutdown(); + if (processes.Length == 0) + return false; - try + if (shutdown) { - // try/catch just in case process was closed before prompt was answered + Dialog.PromptShutdown(); - foreach (Process process in processes) + try { - process.CloseMainWindow(); - process.Close(); + // try/catch just in case process was closed before prompt was answered + + foreach (Process process in processes) + { + process.CloseMainWindow(); + process.Close(); + } } + catch (Exception) { } } - catch (Exception) { } + + return true; } private async Task StartRoblox() @@ -321,7 +330,7 @@ public static void CheckInstall() private void Uninstall() { - CheckIfRunning(); + CheckIfRunning(true); Dialog.Message = $"Uninstalling {Program.ProjectName}..."; @@ -368,8 +377,6 @@ private void Uninstall() #region Roblox Install private async Task InstallLatestVersion() { - CheckIfRunning(); - if (FreshInstall) Dialog.Message = "Installing Roblox..."; else diff --git a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs index 172db0b4..01a17903 100644 --- a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs @@ -9,7 +9,7 @@ internal class DiscordRichPresence : IDisposable public async Task SetPresence(string placeId) { - string placeThumbnail; + string placeThumbnail = "roblox"; var placeInfo = await Utilities.GetJson($"https://economy.roblox.com/v2/assets/{placeId}/details"); @@ -18,10 +18,8 @@ public async Task SetPresence(string placeId) var thumbnailInfo = await Utilities.GetJson($"https://thumbnails.roblox.com/v1/places/gameicons?placeIds={placeId}&returnPolicy=PlaceHolder&size=512x512&format=Png&isCircular=false"); - if (thumbnailInfo is null) - placeThumbnail = "roblox"; //fallback - else - placeThumbnail = thumbnailInfo.Data[0].ImageUrl; + if (thumbnailInfo is not null) + placeThumbnail = thumbnailInfo.Data![0].ImageUrl!; DiscordRPC.Button[]? buttons = null; diff --git a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs index db3baac4..f9e0f910 100644 --- a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs +++ b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs @@ -51,7 +51,7 @@ public static async Task CheckInstall() return; lastReleasePublish = DateTime.Parse(releaseInfo.CreatedAt); - downloadUrl = releaseInfo.Assets[0].BrowserDownloadUrl; + downloadUrl = releaseInfo.Assets![0].BrowserDownloadUrl!; Directory.CreateDirectory(folderLocation); diff --git a/Bloxstrap/Program.cs b/Bloxstrap/Program.cs index d09277c5..5eee0b10 100644 --- a/Bloxstrap/Program.cs +++ b/Bloxstrap/Program.cs @@ -56,12 +56,6 @@ static void Main(string[] args) // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - if (Process.GetProcessesByName(ProjectName).Length > 1) - { - ShowMessageBox($"{ProjectName} is already running. Please close any currently open {ProjectName} window.\nIf you have Discord Rich Presence enabled, then close Roblox if it's running.", MessageBoxIcon.Error); - return; - } - LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); StartMenu = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", ProjectName); @@ -105,6 +99,12 @@ static void Main(string[] args) { if (args[0] == "-preferences") { + if (Process.GetProcessesByName(ProjectName).Length > 1) + { + ShowMessageBox($"{ProjectName} is already running. Please close any currently open Bloxstrap or Roblox window before opening the configuration menu.", MessageBoxIcon.Error); + return; + } + Application.Run(new Dialogs.Preferences()); } else if (args[0].StartsWith("roblox-player:")) diff --git a/README.md b/README.md index 953ac873..4914f69e 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,34 @@ # Bloxstrap +![License](https://img.shields.io/github/license/pizzaboxer/bloxstrap) ![Downloads](https://img.shields.io/github/downloads/pizzaboxer/bloxstrap/total) ![Star](https://img.shields.io/github/stars/pizzaboxer/bloxstrap?style=social) An open, customizable, feature-packed alternative bootstrapper for Roblox. -## What is this? -This is intended to be a seamless replacement for the stock Roblox bootstrapper, working more or less how you'd expect it to, while providing new and useful features. +This a seamless replacement for the stock Roblox bootstrapper, working more or less how you'd expect it to, while providing additional useful features. -Please keep in mind that **Bloxstrap is in very early development**, and you'll no doubt encounter some bugs. If you do, or you would like to suggest a feature, please submit an issue! +If you encounter a bug, or would like to suggest a feature, please submit an issue! Bloxstrap is only supported for PCs running Windows. ## Features Here's some of the features that Bloxstrap provides over the stock Roblox bootstrapper: -* Support for persistent file modifications (including re-adding the old death sound!) -* Ability to choose where Roblox is installed to -* Ability to choose which Roblox build channel to download from +* Doesn't force you to launch Roblox in the Desktop App +* Support for persistent file modifications (e.g. re-adding the old death sound) +* Lets you choose where to install Roblox to +* Gives you the ability to opt-in to pre-release testing channels * Integration with Discord Rich Presence and [rbxfpsunlocker](https://github.com/axstin/rbxfpsunlocker) -* Custom bootstrapper styles (includes old versions and dark theme) +* Bootstrapper styling ## Installing Download the [latest release of Bloxstrap](https://github.com/pizzaboxer/bloxstrap/releases/latest), and run it. Configure your preferences if needed, and install. That's about it! -Bloxstrap requires the [x86 .NET 6 Desktop Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.8-windows-x86-installer). If you don't already have it installed, you'll be prompted to install it when trying to run Bloxstrap. +You will also need the [x86 .NET 6 Desktop Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.8-windows-x86-installer). If you don't already have it installed, you'll be prompted to install it anyway. It's not unlikely that Windows Smartscreen will show a popup when you run Bloxstrap for the first time. This happens because it's an unknown program, not because it's actually detected as being malicious. To dismiss it, just click on "More info" and then "Run anyway". -Bloxstrap is added to your Start Menu, where you can change your preferences if needed. +Once installed, Bloxstrap is added to your Start Menu, where you can change your preferences if needed. ## Contributions -* [Roblox Studio Mod Manager](https://github.com/MaximumADHD/Roblox-Studio-Mod-Manager) by [MaximumADHD](https://www.roblox.com/users/2032622/profile) - some utility code was borrowed to help with Bloxstrap's bootstrapper functionality. They're all under Bloxstrap.Helpers.RSMM, with some having slight modifications. Besides, it's a great project. +* [Roblox Studio Mod Manager](https://github.com/MaximumADHD/Roblox-Studio-Mod-Manager) by [MaximumADHD](https://www.roblox.com/users/2032622/profile) - some slightly modified utility code was borrowed to help with Bloxstrap's bootstrapper functionality (Bloxstrap.Helpers.RSMM). Besides, it's a great project. * [skulyire](https://www.roblox.com/users/2485612194/profile) - Making the Bloxstrap logo -* [rbxfpsunlocker](https://github.com/axstin/rbxfpsunlocker) by axstin - FPS unlocker for Roblox. +* [rbxfpsunlocker](https://github.com/axstin/rbxfpsunlocker) by axstin - Added as a Bloxstrap integration.