Skip to content

Commit

Permalink
(v1.4.4) Add support for multiple game instances
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Oct 1, 2022
1 parent dd6af1d commit e3803bc
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Bloxstrap/Bloxstrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<Platforms>AnyCPU;x86</Platforms>
<ApplicationIcon>Bloxstrap.ico</ApplicationIcon>
<Version>1.4.3</Version>
<FileVersion>1.4.3.0</FileVersion>
<Version>1.4.4</Version>
<FileVersion>1.4.4.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
39 changes: 23 additions & 16 deletions Bloxstrap/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -321,7 +330,7 @@ public static void CheckInstall()

private void Uninstall()
{
CheckIfRunning();
CheckIfRunning(true);

Dialog.Message = $"Uninstalling {Program.ProjectName}...";

Expand Down Expand Up @@ -368,8 +377,6 @@ private void Uninstall()
#region Roblox Install
private async Task InstallLatestVersion()
{
CheckIfRunning();

if (FreshInstall)
Dialog.Message = "Installing Roblox...";
else
Expand Down
8 changes: 3 additions & 5 deletions Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal class DiscordRichPresence : IDisposable

public async Task<bool> SetPresence(string placeId)
{
string placeThumbnail;
string placeThumbnail = "roblox";

var placeInfo = await Utilities.GetJson<RobloxAsset>($"https://economy.roblox.com/v2/assets/{placeId}/details");

Expand All @@ -18,10 +18,8 @@ public async Task<bool> SetPresence(string placeId)

var thumbnailInfo = await Utilities.GetJson<RobloxThumbnails>($"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;

Expand Down
2 changes: 1 addition & 1 deletion Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
12 changes: 6 additions & 6 deletions Bloxstrap/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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:"))
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
# <img src="https://github.com/pizzaboxer/bloxstrap/raw/main/Bloxstrap/Resources/IconBloxstrap-png.png" width="48"/> 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.

0 comments on commit e3803bc

Please sign in to comment.