mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Reorganize stuff
moved around stuff to better reflect the regions they're supposed to be in
This commit is contained in:
parent
6cc701f6a2
commit
826b0a04ca
@ -163,6 +163,9 @@ namespace Bloxstrap
|
||||
ShowMessageBox(message, MessageBoxImage.Warning);
|
||||
}
|
||||
|
||||
// this needs to be loaded this early for the menu and also to check for default values
|
||||
FastFlags.Load();
|
||||
|
||||
// check if installed
|
||||
using (RegistryKey? registryKey = Registry.CurrentUser.OpenSubKey($@"Software\{ProjectName}"))
|
||||
{
|
||||
|
@ -117,6 +117,19 @@ namespace Bloxstrap
|
||||
Dialog.Message = message;
|
||||
}
|
||||
|
||||
private void UpdateProgressbar()
|
||||
{
|
||||
int newProgress = (int)Math.Floor(_progressIncrement * _totalDownloadedBytes);
|
||||
|
||||
// bugcheck: if we're restoring a file from a package, it'll incorrectly increment the progress beyond 100
|
||||
// too lazy to fix properly so lol
|
||||
if (newProgress > 100)
|
||||
return;
|
||||
|
||||
if (Dialog is not null)
|
||||
Dialog.ProgressValue = newProgress;
|
||||
}
|
||||
|
||||
public async Task Run()
|
||||
{
|
||||
App.Logger.WriteLine("[Bootstrapper::Run] Running bootstrapper");
|
||||
@ -175,12 +188,12 @@ namespace Bloxstrap
|
||||
if (App.IsFirstRun)
|
||||
App.ShouldSaveConfigs = true;
|
||||
|
||||
IntegrationMigrator.Execute();
|
||||
App.FastFlags.Save();
|
||||
MigrateIntegrations();
|
||||
|
||||
if (ShouldInstallWebView2)
|
||||
await InstallWebView2();
|
||||
|
||||
App.FastFlags.Save();
|
||||
await ApplyModifications();
|
||||
|
||||
if (App.IsFirstRun || FreshInstall)
|
||||
@ -201,60 +214,6 @@ namespace Bloxstrap
|
||||
await StartRoblox();
|
||||
}
|
||||
|
||||
private async Task CheckForUpdates()
|
||||
{
|
||||
// don't update if there's another instance running (likely running in the background)
|
||||
if (Utilities.GetProcessCount(App.ProjectName) > 1)
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] More than one Bloxstrap instance running, aborting update check");
|
||||
return;
|
||||
}
|
||||
|
||||
string currentVersion = $"{App.ProjectName} v{App.Version}";
|
||||
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] Checking for {App.ProjectName} updates...");
|
||||
|
||||
var releaseInfo = await Utilities.GetJson<GithubRelease>($"https://api.github.com/repos/{App.ProjectRepository}/releases/latest");
|
||||
|
||||
if (releaseInfo?.Assets is null || currentVersion == releaseInfo.Name)
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] No updates found");
|
||||
return;
|
||||
}
|
||||
|
||||
SetStatus($"Getting the latest {App.ProjectName}...");
|
||||
|
||||
// 64-bit is always the first option
|
||||
GithubReleaseAsset asset = releaseInfo.Assets[Environment.Is64BitOperatingSystem ? 0 : 1];
|
||||
string downloadLocation = Path.Combine(Directories.LocalAppData, "Temp", asset.Name);
|
||||
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] Downloading {releaseInfo.Name}...");
|
||||
|
||||
if (!File.Exists(downloadLocation))
|
||||
{
|
||||
var response = await App.HttpClient.GetAsync(asset.BrowserDownloadUrl);
|
||||
|
||||
await using var fileStream = new FileStream(downloadLocation, FileMode.CreateNew);
|
||||
await response.Content.CopyToAsync(fileStream);
|
||||
}
|
||||
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] Starting {releaseInfo.Name}...");
|
||||
|
||||
ProcessStartInfo startInfo = new()
|
||||
{
|
||||
FileName = downloadLocation,
|
||||
};
|
||||
|
||||
foreach (string arg in App.LaunchArgs)
|
||||
startInfo.ArgumentList.Add(arg);
|
||||
|
||||
App.Settings.Save();
|
||||
|
||||
Process.Start(startInfo);
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private async Task CheckLatestVersion()
|
||||
{
|
||||
SetStatus("Connecting to Roblox...");
|
||||
@ -265,69 +224,6 @@ namespace Bloxstrap
|
||||
_versionPackageManifest = await PackageManifest.Get(_latestVersionGuid);
|
||||
}
|
||||
|
||||
private void CheckInstallMigration()
|
||||
{
|
||||
// check if we've changed our install location since the last time we started
|
||||
// in which case, we'll have to copy over all our folders so we don't lose any mods and stuff
|
||||
|
||||
using RegistryKey? applicationKey = Registry.CurrentUser.OpenSubKey($@"Software\{App.ProjectName}", true);
|
||||
|
||||
string? oldInstallLocation = (string?)applicationKey?.GetValue("OldInstallLocation");
|
||||
|
||||
if (applicationKey is null || oldInstallLocation is null || oldInstallLocation == Directories.Base)
|
||||
return;
|
||||
|
||||
SetStatus("Migrating install location...");
|
||||
|
||||
if (Directory.Exists(oldInstallLocation))
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckInstallMigration] Moving all files in {oldInstallLocation} to {Directories.Base}...");
|
||||
|
||||
foreach (string oldFileLocation in Directory.GetFiles(oldInstallLocation, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
string relativeFile = oldFileLocation.Substring(oldInstallLocation.Length + 1);
|
||||
string newFileLocation = Path.Combine(Directories.Base, relativeFile);
|
||||
string? newDirectory = Path.GetDirectoryName(newFileLocation);
|
||||
|
||||
try
|
||||
{
|
||||
if (!String.IsNullOrEmpty(newDirectory))
|
||||
Directory.CreateDirectory(newDirectory);
|
||||
|
||||
File.Move(oldFileLocation, newFileLocation, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckInstallMigration] Failed to move {oldFileLocation} to {newFileLocation}! {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(oldInstallLocation, true);
|
||||
App.Logger.WriteLine("[Bootstrapper::CheckInstallMigration] Deleted old install location");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckInstallMigration] Failed to delete old install location! {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
applicationKey.DeleteValue("OldInstallLocation");
|
||||
|
||||
// allow shortcuts to be re-registered
|
||||
if (Directory.Exists(Directories.StartMenu))
|
||||
Directory.Delete(Directories.StartMenu, true);
|
||||
|
||||
if (File.Exists(DesktopShortcutLocation))
|
||||
{
|
||||
File.Delete(DesktopShortcutLocation);
|
||||
App.Settings.Prop.CreateDesktopIcon = true;
|
||||
}
|
||||
|
||||
App.Logger.WriteLine("[Bootstrapper::CheckInstallMigration] Finished migrating install location!");
|
||||
}
|
||||
|
||||
private async Task StartRoblox()
|
||||
{
|
||||
string startEventName = App.ProjectName.Replace(" ", "") + "StartEvent";
|
||||
@ -497,6 +393,69 @@ namespace Bloxstrap
|
||||
App.Logger.WriteLine("[Bootstrapper::StartRoblox] Registered application");
|
||||
}
|
||||
|
||||
private void CheckInstallMigration()
|
||||
{
|
||||
// check if we've changed our install location since the last time we started
|
||||
// in which case, we'll have to copy over all our folders so we don't lose any mods and stuff
|
||||
|
||||
using RegistryKey? applicationKey = Registry.CurrentUser.OpenSubKey($@"Software\{App.ProjectName}", true);
|
||||
|
||||
string? oldInstallLocation = (string?)applicationKey?.GetValue("OldInstallLocation");
|
||||
|
||||
if (applicationKey is null || oldInstallLocation is null || oldInstallLocation == Directories.Base)
|
||||
return;
|
||||
|
||||
SetStatus("Migrating install location...");
|
||||
|
||||
if (Directory.Exists(oldInstallLocation))
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckInstallMigration] Moving all files in {oldInstallLocation} to {Directories.Base}...");
|
||||
|
||||
foreach (string oldFileLocation in Directory.GetFiles(oldInstallLocation, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
string relativeFile = oldFileLocation.Substring(oldInstallLocation.Length + 1);
|
||||
string newFileLocation = Path.Combine(Directories.Base, relativeFile);
|
||||
string? newDirectory = Path.GetDirectoryName(newFileLocation);
|
||||
|
||||
try
|
||||
{
|
||||
if (!String.IsNullOrEmpty(newDirectory))
|
||||
Directory.CreateDirectory(newDirectory);
|
||||
|
||||
File.Move(oldFileLocation, newFileLocation, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckInstallMigration] Failed to move {oldFileLocation} to {newFileLocation}! {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(oldInstallLocation, true);
|
||||
App.Logger.WriteLine("[Bootstrapper::CheckInstallMigration] Deleted old install location");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckInstallMigration] Failed to delete old install location! {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
applicationKey.DeleteValue("OldInstallLocation");
|
||||
|
||||
// allow shortcuts to be re-registered
|
||||
if (Directory.Exists(Directories.StartMenu))
|
||||
Directory.Delete(Directories.StartMenu, true);
|
||||
|
||||
if (File.Exists(DesktopShortcutLocation))
|
||||
{
|
||||
File.Delete(DesktopShortcutLocation);
|
||||
App.Settings.Prop.CreateDesktopIcon = true;
|
||||
}
|
||||
|
||||
App.Logger.WriteLine("[Bootstrapper::CheckInstallMigration] Finished migrating install location!");
|
||||
}
|
||||
|
||||
public static void CheckInstall()
|
||||
{
|
||||
App.Logger.WriteLine("[Bootstrapper::StartRoblox] Checking install");
|
||||
@ -556,6 +515,60 @@ namespace Bloxstrap
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CheckForUpdates()
|
||||
{
|
||||
// don't update if there's another instance running (likely running in the background)
|
||||
if (Utilities.GetProcessCount(App.ProjectName) > 1)
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] More than one Bloxstrap instance running, aborting update check");
|
||||
return;
|
||||
}
|
||||
|
||||
string currentVersion = $"{App.ProjectName} v{App.Version}";
|
||||
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] Checking for {App.ProjectName} updates...");
|
||||
|
||||
var releaseInfo = await Utilities.GetJson<GithubRelease>($"https://api.github.com/repos/{App.ProjectRepository}/releases/latest");
|
||||
|
||||
if (releaseInfo?.Assets is null || currentVersion == releaseInfo.Name)
|
||||
{
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] No updates found");
|
||||
return;
|
||||
}
|
||||
|
||||
SetStatus($"Getting the latest {App.ProjectName}...");
|
||||
|
||||
// 64-bit is always the first option
|
||||
GithubReleaseAsset asset = releaseInfo.Assets[Environment.Is64BitOperatingSystem ? 0 : 1];
|
||||
string downloadLocation = Path.Combine(Directories.LocalAppData, "Temp", asset.Name);
|
||||
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] Downloading {releaseInfo.Name}...");
|
||||
|
||||
if (!File.Exists(downloadLocation))
|
||||
{
|
||||
var response = await App.HttpClient.GetAsync(asset.BrowserDownloadUrl);
|
||||
|
||||
await using var fileStream = new FileStream(downloadLocation, FileMode.CreateNew);
|
||||
await response.Content.CopyToAsync(fileStream);
|
||||
}
|
||||
|
||||
App.Logger.WriteLine($"[Bootstrapper::CheckForUpdates] Starting {releaseInfo.Name}...");
|
||||
|
||||
ProcessStartInfo startInfo = new()
|
||||
{
|
||||
FileName = downloadLocation,
|
||||
};
|
||||
|
||||
foreach (string arg in App.LaunchArgs)
|
||||
startInfo.ArgumentList.Add(arg);
|
||||
|
||||
App.Settings.Save();
|
||||
|
||||
Process.Start(startInfo);
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void Uninstall()
|
||||
{
|
||||
// prompt to shutdown roblox if its currently running
|
||||
@ -631,19 +644,6 @@ namespace Bloxstrap
|
||||
#endregion
|
||||
|
||||
#region Roblox Install
|
||||
private void UpdateProgressbar()
|
||||
{
|
||||
int newProgress = (int)Math.Floor(_progressIncrement * _totalDownloadedBytes);
|
||||
|
||||
// bugcheck: if we're restoring a file from a package, it'll incorrectly increment the progress beyond 100
|
||||
// too lazy to fix properly so lol
|
||||
if (newProgress > 100)
|
||||
return;
|
||||
|
||||
if (Dialog is not null)
|
||||
Dialog.ProgressValue = newProgress;
|
||||
}
|
||||
|
||||
private async Task InstallLatestVersion()
|
||||
{
|
||||
_isInstalling = true;
|
||||
@ -792,6 +792,32 @@ namespace Bloxstrap
|
||||
App.Logger.WriteLine($"[Bootstrapper::InstallWebView2] Finished installing runtime");
|
||||
}
|
||||
|
||||
public static void MigrateIntegrations()
|
||||
{
|
||||
// v2.2.0 - remove rbxfpsunlocker
|
||||
string rbxfpsunlocker = Path.Combine(Directories.Integrations, "rbxfpsunlocker");
|
||||
|
||||
if (Directory.Exists(rbxfpsunlocker))
|
||||
Directory.Delete(rbxfpsunlocker, true);
|
||||
|
||||
// v2.2.0 - remove reshade
|
||||
string reshadeLocation = Path.Combine(Directories.Modifications, "dxgi.dll");
|
||||
|
||||
if (File.Exists(reshadeLocation))
|
||||
{
|
||||
App.ShowMessageBox(
|
||||
"As of April 18th, Roblox has started out rolling out the Byfron anticheat as well as 64-bit support. Because of this, ReShade will no longer work, and will be deactivated from now on.\n\n" +
|
||||
$"Your ReShade configs and files will still be kept, which are all located in the {App.ProjectName} folder.",
|
||||
MessageBoxImage.Warning
|
||||
);
|
||||
|
||||
File.Delete(reshadeLocation);
|
||||
|
||||
if (App.FastFlags.GetValue(FastFlagManager.RenderingModes["Direct3D 11"]) == "True" && App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") != "False")
|
||||
App.FastFlags.SetRenderingMode("Automatic");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ApplyModifications()
|
||||
{
|
||||
SetStatus("Applying Roblox modifications...");
|
||||
|
@ -1,34 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
namespace Bloxstrap.Helpers
|
||||
{
|
||||
static class IntegrationMigrator
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
// v2.2.0 - remove rbxfpsunlocker
|
||||
string rbxfpsunlocker = Path.Combine(Directories.Integrations, "rbxfpsunlocker");
|
||||
|
||||
if (Directory.Exists(rbxfpsunlocker))
|
||||
Directory.Delete(rbxfpsunlocker, true);
|
||||
|
||||
// v2.2.0 - remove reshade
|
||||
string reshadeLocation = Path.Combine(Directories.Modifications, "dxgi.dll");
|
||||
|
||||
if (File.Exists(reshadeLocation))
|
||||
{
|
||||
App.ShowMessageBox(
|
||||
"As of April 18th, Roblox has started out rolling out the Byfron anticheat as well as 64-bit support. Because of this, ReShade will no longer work, and will be deactivated from now on.\n\n" +
|
||||
$"Your ReShade configs and files will still be kept, which are all located in the {App.ProjectName} folder.",
|
||||
MessageBoxImage.Warning
|
||||
);
|
||||
|
||||
File.Delete(reshadeLocation);
|
||||
|
||||
if (App.FastFlags.GetValue(FastFlagManager.RenderingModes["Direct3D 11"]) == "True" && App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") != "False")
|
||||
App.FastFlags.SetRenderingMode("Automatic");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,8 +13,6 @@ namespace Bloxstrap.Views.Pages
|
||||
{
|
||||
public ModsPage()
|
||||
{
|
||||
App.FastFlags.Load();
|
||||
|
||||
DataContext = new ModsViewModel();
|
||||
InitializeComponent();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user