mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Add State file
This commit is contained in:
parent
93b082263b
commit
c1b892787a
@ -26,6 +26,7 @@ namespace Bloxstrap
|
|||||||
public const string ProjectRepository = "pizzaboxer/bloxstrap";
|
public const string ProjectRepository = "pizzaboxer/bloxstrap";
|
||||||
|
|
||||||
public static string BaseDirectory = null!;
|
public static string BaseDirectory = null!;
|
||||||
|
public static bool ShouldSaveConfigs { get; set; } = false;
|
||||||
public static bool IsSetupComplete { get; set; } = true;
|
public static bool IsSetupComplete { get; set; } = true;
|
||||||
public static bool IsFirstRun { get; private set; } = false;
|
public static bool IsFirstRun { get; private set; } = false;
|
||||||
public static bool IsQuiet { get; private set; } = false;
|
public static bool IsQuiet { get; private set; } = false;
|
||||||
@ -38,6 +39,7 @@ namespace Bloxstrap
|
|||||||
public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
||||||
|
|
||||||
public static readonly JsonManager<Settings> Settings = new();
|
public static readonly JsonManager<Settings> Settings = new();
|
||||||
|
public static readonly JsonManager<State> State = new();
|
||||||
public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All });
|
public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All });
|
||||||
|
|
||||||
// shorthand
|
// shorthand
|
||||||
@ -52,6 +54,7 @@ namespace Bloxstrap
|
|||||||
public static void Terminate(int code = Bootstrapper.ERROR_SUCCESS)
|
public static void Terminate(int code = Bootstrapper.ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
Settings.Save();
|
Settings.Save();
|
||||||
|
State.Save();
|
||||||
Environment.Exit(code);
|
Environment.Exit(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +118,9 @@ namespace Bloxstrap
|
|||||||
// just in case the user decides to cancel the install
|
// just in case the user decides to cancel the install
|
||||||
if (!IsFirstRun)
|
if (!IsFirstRun)
|
||||||
{
|
{
|
||||||
|
ShouldSaveConfigs = true;
|
||||||
Settings.Load();
|
Settings.Load();
|
||||||
Settings.ShouldSave = true;
|
State.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
|
@ -86,7 +86,7 @@ namespace Bloxstrap
|
|||||||
public Bootstrapper(string? launchCommandLine = null)
|
public Bootstrapper(string? launchCommandLine = null)
|
||||||
{
|
{
|
||||||
LaunchCommandLine = launchCommandLine;
|
LaunchCommandLine = launchCommandLine;
|
||||||
FreshInstall = String.IsNullOrEmpty(App.Settings.Prop.VersionGuid);
|
FreshInstall = String.IsNullOrEmpty(App.State.Prop.VersionGuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is called from BootstrapperStyleForm.SetupDialog()
|
// this is called from BootstrapperStyleForm.SetupDialog()
|
||||||
@ -107,11 +107,14 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
// if bloxstrap is installing for the first time but is running, prompt to close roblox
|
// 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 roblox needs updating but is running, ignore update for now
|
||||||
if (!Directory.Exists(VersionFolder) && CheckIfRunning(true) || App.Settings.Prop.VersionGuid != VersionGuid && !CheckIfRunning(false))
|
if (!Directory.Exists(VersionFolder) && CheckIfRunning(true) || App.State.Prop.VersionGuid != VersionGuid && !CheckIfRunning(false))
|
||||||
await InstallLatestVersion();
|
await InstallLatestVersion();
|
||||||
|
|
||||||
if (App.IsFirstRun)
|
if (App.IsFirstRun)
|
||||||
App.Settings.ShouldSave = true;
|
{
|
||||||
|
//App.Settings.ShouldSave = App.State.ShouldSave = true;
|
||||||
|
App.ShouldSaveConfigs = true;
|
||||||
|
}
|
||||||
|
|
||||||
await ApplyModifications();
|
await ApplyModifications();
|
||||||
|
|
||||||
@ -123,6 +126,7 @@ namespace Bloxstrap
|
|||||||
await RbxFpsUnlocker.CheckInstall();
|
await RbxFpsUnlocker.CheckInstall();
|
||||||
|
|
||||||
App.Settings.Save();
|
App.Settings.Save();
|
||||||
|
App.State.Save();
|
||||||
|
|
||||||
if (App.IsFirstRun && App.IsNoLaunch)
|
if (App.IsFirstRun && App.IsNoLaunch)
|
||||||
Dialog.ShowSuccess($"{App.ProjectName} has successfully installed");
|
Dialog.ShowSuccess($"{App.ProjectName} has successfully installed");
|
||||||
@ -413,7 +417,8 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
Dialog.Message = $"Uninstalling {App.ProjectName}...";
|
Dialog.Message = $"Uninstalling {App.ProjectName}...";
|
||||||
|
|
||||||
App.Settings.ShouldSave = false;
|
//App.Settings.ShouldSave = false;
|
||||||
|
App.ShouldSaveConfigs = false;
|
||||||
|
|
||||||
// check if stock bootstrapper is still installed
|
// check if stock bootstrapper is still installed
|
||||||
RegistryKey? bootstrapperKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\roblox-player");
|
RegistryKey? bootstrapperKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\roblox-player");
|
||||||
@ -540,9 +545,9 @@ namespace Bloxstrap
|
|||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
string oldVersionFolder = Path.Combine(Directories.Versions, App.Settings.Prop.VersionGuid);
|
string oldVersionFolder = Path.Combine(Directories.Versions, App.State.Prop.VersionGuid);
|
||||||
|
|
||||||
if (VersionGuid != App.Settings.Prop.VersionGuid && Directory.Exists(oldVersionFolder))
|
if (VersionGuid != App.State.Prop.VersionGuid && Directory.Exists(oldVersionFolder))
|
||||||
{
|
{
|
||||||
// and also to delete our old version folder
|
// and also to delete our old version folder
|
||||||
Directory.Delete(oldVersionFolder, true);
|
Directory.Delete(oldVersionFolder, true);
|
||||||
@ -551,7 +556,7 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
Dialog.CancelEnabled = false;
|
Dialog.CancelEnabled = false;
|
||||||
|
|
||||||
App.Settings.Prop.VersionGuid = VersionGuid;
|
App.State.Prop.VersionGuid = VersionGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ApplyModifications()
|
private async Task ApplyModifications()
|
||||||
|
@ -53,15 +53,14 @@ namespace Bloxstrap.Helpers.Integrations
|
|||||||
|
|
||||||
public static async Task CheckInstall()
|
public static async Task CheckInstall()
|
||||||
{
|
{
|
||||||
if (App.BaseDirectory is null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
string folderLocation = Path.Combine(App.BaseDirectory, "Integrations\\rbxfpsunlocker");
|
string folderLocation = Path.Combine(App.BaseDirectory, "Integrations\\rbxfpsunlocker");
|
||||||
string fileLocation = Path.Combine(folderLocation, "rbxfpsunlocker.exe");
|
string fileLocation = Path.Combine(folderLocation, "rbxfpsunlocker.exe");
|
||||||
string settingsLocation = Path.Combine(folderLocation, "settings");
|
string settingsLocation = Path.Combine(folderLocation, "settings");
|
||||||
|
|
||||||
if (!App.Settings.Prop.RFUEnabled)
|
if (!App.Settings.Prop.RFUEnabled)
|
||||||
{
|
{
|
||||||
|
App.State.Prop.RbxFpsUnlockerVersion = "";
|
||||||
|
|
||||||
if (Directory.Exists(folderLocation))
|
if (Directory.Exists(folderLocation))
|
||||||
{
|
{
|
||||||
CheckIfRunning();
|
CheckIfRunning();
|
||||||
@ -83,7 +82,7 @@ namespace Bloxstrap.Helpers.Integrations
|
|||||||
if (File.Exists(fileLocation))
|
if (File.Exists(fileLocation))
|
||||||
{
|
{
|
||||||
// no new release published, return
|
// no new release published, return
|
||||||
if (App.Settings.Prop.RFUVersion == releaseInfo.TagName)
|
if (App.State.Prop.RbxFpsUnlockerVersion == releaseInfo.TagName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CheckIfRunning();
|
CheckIfRunning();
|
||||||
@ -104,7 +103,7 @@ namespace Bloxstrap.Helpers.Integrations
|
|||||||
if (!File.Exists(settingsLocation))
|
if (!File.Exists(settingsLocation))
|
||||||
await File.WriteAllTextAsync(settingsLocation, Settings);
|
await File.WriteAllTextAsync(settingsLocation, Settings);
|
||||||
|
|
||||||
App.Settings.Prop.RFUVersion = releaseInfo.TagName;
|
App.State.Prop.RbxFpsUnlockerVersion = releaseInfo.TagName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ namespace Bloxstrap.Helpers.Integrations
|
|||||||
// config synchronization will be done whenever roblox updates or whenever we launch roblox
|
// config synchronization will be done whenever roblox updates or whenever we launch roblox
|
||||||
|
|
||||||
string modFolderConfigPath = ConfigLocation;
|
string modFolderConfigPath = ConfigLocation;
|
||||||
string versionFolderConfigPath = Path.Combine(Directories.Versions, App.Settings.Prop.VersionGuid, "ReShade.ini");
|
string versionFolderConfigPath = Path.Combine(Directories.Versions, App.State.Prop.VersionGuid, "ReShade.ini");
|
||||||
|
|
||||||
// we shouldn't be here if the mod config doesn't already exist
|
// we shouldn't be here if the mod config doesn't already exist
|
||||||
if (!File.Exists(modFolderConfigPath))
|
if (!File.Exists(modFolderConfigPath))
|
||||||
@ -326,7 +326,7 @@ namespace Bloxstrap.Helpers.Integrations
|
|||||||
if (!App.Settings.Prop.UseReShadeExtraviPresets)
|
if (!App.Settings.Prop.UseReShadeExtraviPresets)
|
||||||
{
|
{
|
||||||
UninstallExtraviPresets();
|
UninstallExtraviPresets();
|
||||||
App.Settings.Prop.ExtraviPresetsVersion = "";
|
App.State.Prop.ExtraviReShadePresetsVersion = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!App.Settings.Prop.UseReShade)
|
if (!App.Settings.Prop.UseReShade)
|
||||||
@ -337,7 +337,7 @@ namespace Bloxstrap.Helpers.Integrations
|
|||||||
File.Delete(injectorLocation);
|
File.Delete(injectorLocation);
|
||||||
File.Delete(ConfigLocation);
|
File.Delete(ConfigLocation);
|
||||||
|
|
||||||
App.Settings.Prop.ReShadeConfigVersion = "";
|
App.State.Prop.ReShadeConfigVersion = "";
|
||||||
|
|
||||||
//DeleteShaders("Stock");
|
//DeleteShaders("Stock");
|
||||||
if (Directory.Exists(BaseDirectory))
|
if (Directory.Exists(BaseDirectory))
|
||||||
@ -373,7 +373,7 @@ namespace Bloxstrap.Helpers.Integrations
|
|||||||
|
|
||||||
// check if we should download a fresh copy of the config
|
// check if we should download a fresh copy of the config
|
||||||
// extravi may need to update the config ota, in which case we'll redownload it
|
// extravi may need to update the config ota, in which case we'll redownload it
|
||||||
if (!File.Exists(ConfigLocation) || versionManifest is not null && App.Settings.Prop.ReShadeConfigVersion != versionManifest.ConfigFile)
|
if (!File.Exists(ConfigLocation) || versionManifest is not null && App.State.Prop.ReShadeConfigVersion != versionManifest.ConfigFile)
|
||||||
shouldFetchConfig = true;
|
shouldFetchConfig = true;
|
||||||
|
|
||||||
if (shouldFetchReShade)
|
if (shouldFetchReShade)
|
||||||
@ -393,15 +393,15 @@ namespace Bloxstrap.Helpers.Integrations
|
|||||||
await DownloadConfig();
|
await DownloadConfig();
|
||||||
|
|
||||||
if (versionManifest is not null)
|
if (versionManifest is not null)
|
||||||
App.Settings.Prop.ReShadeConfigVersion = versionManifest.ConfigFile;
|
App.State.Prop.ReShadeConfigVersion = versionManifest.ConfigFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
await DownloadShaders("Stock");
|
await DownloadShaders("Stock");
|
||||||
|
|
||||||
if (App.Settings.Prop.UseReShadeExtraviPresets && App.Settings.Prop.ExtraviPresetsVersion != versionManifest!.Presets)
|
if (App.Settings.Prop.UseReShadeExtraviPresets && App.State.Prop.ExtraviReShadePresetsVersion != versionManifest!.Presets)
|
||||||
{
|
{
|
||||||
await InstallExtraviPresets();
|
await InstallExtraviPresets();
|
||||||
App.Settings.Prop.ExtraviPresetsVersion = versionManifest.Presets;
|
App.State.Prop.ExtraviReShadePresetsVersion = versionManifest.Presets;
|
||||||
}
|
}
|
||||||
|
|
||||||
SynchronizeConfigFile();
|
SynchronizeConfigFile();
|
||||||
|
@ -16,7 +16,7 @@ namespace Bloxstrap.Helpers
|
|||||||
public class JsonManager<T> where T : new()
|
public class JsonManager<T> where T : new()
|
||||||
{
|
{
|
||||||
public T Prop { get; set; } = new T();
|
public T Prop { get; set; } = new T();
|
||||||
public bool ShouldSave { get; set; } = true;
|
//public bool ShouldSave { get; set; } = true;
|
||||||
public string FileLocation => Path.Combine(Directories.Base, $"{typeof(T).Name}.json");
|
public string FileLocation => Path.Combine(Directories.Base, $"{typeof(T).Name}.json");
|
||||||
//public string? FileLocation { get; set; } = null;
|
//public string? FileLocation { get; set; } = null;
|
||||||
|
|
||||||
@ -50,7 +50,8 @@ namespace Bloxstrap.Helpers
|
|||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (!ShouldSave)
|
//if (!ShouldSave)
|
||||||
|
if (!App.ShouldSaveConfigs)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"[JsonManager<{typeof(T).Name}>] Aborted save (ShouldSave set to false)");
|
Debug.WriteLine($"[JsonManager<{typeof(T).Name}>] Aborted save (ShouldSave set to false)");
|
||||||
return;
|
return;
|
||||||
|
@ -5,15 +5,6 @@ namespace Bloxstrap.Models
|
|||||||
{
|
{
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
// could these be moved to a separate file (something like State.json)?
|
|
||||||
// the only problem is i havent yet figured out a way to boil down the settings handler to reduce boilerplate
|
|
||||||
// as the Program class needs a Settings and a SettingsManager property
|
|
||||||
// once i figure that out, then ig i could move these
|
|
||||||
public string VersionGuid { get; set; } = "";
|
|
||||||
public string RFUVersion { get; set; } = "";
|
|
||||||
public string ReShadeConfigVersion { get; set; } = "";
|
|
||||||
public string ExtraviPresetsVersion { get; set; } = "";
|
|
||||||
|
|
||||||
// bloxstrap configuration
|
// bloxstrap configuration
|
||||||
public BootstrapperStyle BootstrapperStyle { get; set; } = BootstrapperStyle.ProgressDialog;
|
public BootstrapperStyle BootstrapperStyle { get; set; } = BootstrapperStyle.ProgressDialog;
|
||||||
public BootstrapperIcon BootstrapperIcon { get; set; } = BootstrapperIcon.IconBloxstrap;
|
public BootstrapperIcon BootstrapperIcon { get; set; } = BootstrapperIcon.IconBloxstrap;
|
||||||
|
16
Bloxstrap/Models/State.cs
Normal file
16
Bloxstrap/Models/State.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Bloxstrap.Models
|
||||||
|
{
|
||||||
|
public class State
|
||||||
|
{
|
||||||
|
public string VersionGuid { get; set; } = "";
|
||||||
|
public string RbxFpsUnlockerVersion { get; set; } = "";
|
||||||
|
public string ReShadeConfigVersion { get; set; } = "";
|
||||||
|
public string ExtraviReShadePresetsVersion { get; set; } = "";
|
||||||
|
}
|
||||||
|
}
|
@ -64,13 +64,14 @@ namespace Bloxstrap.ViewModels
|
|||||||
|
|
||||||
if (!App.IsFirstRun)
|
if (!App.IsFirstRun)
|
||||||
{
|
{
|
||||||
App.Settings.ShouldSave = true;
|
//App.Settings.ShouldSave = true;
|
||||||
|
App.ShouldSaveConfigs = true;
|
||||||
|
|
||||||
if (App.BaseDirectory != _originalBaseDirectory)
|
if (App.BaseDirectory != _originalBaseDirectory)
|
||||||
{
|
{
|
||||||
App.ShowMessageBox($"{App.ProjectName} will install to the new location you've set the next time it runs.", MessageBoxImage.Information);
|
App.ShowMessageBox($"{App.ProjectName} will install to the new location you've set the next time it runs.", MessageBoxImage.Information);
|
||||||
|
|
||||||
App.Settings.Prop.VersionGuid = "";
|
App.State.Prop.VersionGuid = "";
|
||||||
|
|
||||||
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}"))
|
using (RegistryKey registryKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}"))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user