Restructuring: Directories -> Paths

shorter and more accurate to what it's describing
This commit is contained in:
pizzaboxer 2023-07-25 19:43:30 +01:00
parent aebec51d68
commit 8bbad57eb3
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
12 changed files with 88 additions and 88 deletions

View File

@ -151,7 +151,7 @@ namespace Bloxstrap
{ {
Logger.WriteLine(LOG_IDENT, "Running first-time install"); Logger.WriteLine(LOG_IDENT, "Running first-time install");
BaseDirectory = Path.Combine(Directories.LocalAppData, ProjectName); BaseDirectory = Path.Combine(Paths.LocalAppData, ProjectName);
Logger.Initialize(true); Logger.Initialize(true);
if (!IsQuiet) if (!IsQuiet)
@ -175,7 +175,7 @@ namespace Bloxstrap
Terminate(ErrorCode.ERROR_CANCELLED); Terminate(ErrorCode.ERROR_CANCELLED);
} }
Directories.Initialize(BaseDirectory); Paths.Initialize(BaseDirectory);
// we shouldn't save settings on the first run until the first installation is finished, // 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 // just in case the user decides to cancel the install

View File

@ -52,7 +52,7 @@ namespace Bloxstrap
private readonly CancellationTokenSource _cancelTokenSource = new(); private readonly CancellationTokenSource _cancelTokenSource = new();
private static bool FreshInstall => String.IsNullOrEmpty(App.State.Prop.VersionGuid); private static bool FreshInstall => String.IsNullOrEmpty(App.State.Prop.VersionGuid);
private static string DesktopShortcutLocation => Path.Combine(Directories.Desktop, "Play Roblox.lnk"); private static string DesktopShortcutLocation => Path.Combine(Paths.Desktop, "Play Roblox.lnk");
private string _playerLocation => Path.Combine(_versionFolder, "RobloxPlayerBeta.exe"); private string _playerLocation => Path.Combine(_versionFolder, "RobloxPlayerBeta.exe");
@ -192,7 +192,7 @@ namespace Bloxstrap
ClientVersion clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel); ClientVersion clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel);
_latestVersionGuid = clientVersion.VersionGuid; _latestVersionGuid = clientVersion.VersionGuid;
_versionFolder = Path.Combine(Directories.Versions, _latestVersionGuid); _versionFolder = Path.Combine(Paths.Versions, _latestVersionGuid);
_versionPackageManifest = await PackageManifest.Get(_latestVersionGuid); _versionPackageManifest = await PackageManifest.Get(_latestVersionGuid);
} }
@ -209,7 +209,7 @@ namespace Bloxstrap
return; return;
} }
if (!File.Exists(Path.Combine(Directories.System, "mfplat.dll"))) if (!File.Exists(Path.Combine(Paths.System, "mfplat.dll")))
{ {
Controls.ShowMessageBox( Controls.ShowMessageBox(
"Roblox requires the use of Windows Media Foundation components. You appear to be missing them, likely because you are using an N edition of Windows. Please install them first, and then launch Roblox.", "Roblox requires the use of Windows Media Foundation components. You appear to be missing them, likely because you are using an N edition of Windows. Please install them first, and then launch Roblox.",
@ -337,7 +337,7 @@ namespace Bloxstrap
{ {
// clean up install // clean up install
if (App.IsFirstRun) if (App.IsFirstRun)
Directory.Delete(Directories.Base, true); Directory.Delete(Paths.Base, true);
else if (Directory.Exists(_versionFolder)) else if (Directory.Exists(_versionFolder))
Directory.Delete(_versionFolder, true); Directory.Delete(_versionFolder, true);
} }
@ -358,25 +358,25 @@ namespace Bloxstrap
using (RegistryKey applicationKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}")) using (RegistryKey applicationKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}"))
{ {
applicationKey.SetValue("InstallLocation", Directories.Base); applicationKey.SetValue("InstallLocation", Paths.Base);
} }
// set uninstall key // set uninstall key
using (RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{App.ProjectName}")) using (RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{App.ProjectName}"))
{ {
uninstallKey.SetValue("DisplayIcon", $"{Directories.Application},0"); uninstallKey.SetValue("DisplayIcon", $"{Paths.Application},0");
uninstallKey.SetValue("DisplayName", App.ProjectName); uninstallKey.SetValue("DisplayName", App.ProjectName);
uninstallKey.SetValue("DisplayVersion", App.Version); uninstallKey.SetValue("DisplayVersion", App.Version);
if (uninstallKey.GetValue("InstallDate") is null) if (uninstallKey.GetValue("InstallDate") is null)
uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd")); uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd"));
uninstallKey.SetValue("InstallLocation", Directories.Base); uninstallKey.SetValue("InstallLocation", Paths.Base);
uninstallKey.SetValue("NoRepair", 1); uninstallKey.SetValue("NoRepair", 1);
uninstallKey.SetValue("Publisher", "pizzaboxer"); uninstallKey.SetValue("Publisher", "pizzaboxer");
uninstallKey.SetValue("ModifyPath", $"\"{Directories.Application}\" -menu"); uninstallKey.SetValue("ModifyPath", $"\"{Paths.Application}\" -menu");
uninstallKey.SetValue("QuietUninstallString", $"\"{Directories.Application}\" -uninstall -quiet"); uninstallKey.SetValue("QuietUninstallString", $"\"{Paths.Application}\" -uninstall -quiet");
uninstallKey.SetValue("UninstallString", $"\"{Directories.Application}\" -uninstall"); uninstallKey.SetValue("UninstallString", $"\"{Paths.Application}\" -uninstall");
uninstallKey.SetValue("URLInfoAbout", $"https://github.com/{App.ProjectRepository}"); uninstallKey.SetValue("URLInfoAbout", $"https://github.com/{App.ProjectRepository}");
uninstallKey.SetValue("URLUpdateInfo", $"https://github.com/{App.ProjectRepository}/releases/latest"); uninstallKey.SetValue("URLUpdateInfo", $"https://github.com/{App.ProjectRepository}/releases/latest");
} }
@ -411,19 +411,19 @@ namespace Bloxstrap
string? oldInstallLocation = (string?)applicationKey?.GetValue("OldInstallLocation"); string? oldInstallLocation = (string?)applicationKey?.GetValue("OldInstallLocation");
if (applicationKey is null || oldInstallLocation is null || oldInstallLocation == Directories.Base) if (applicationKey is null || oldInstallLocation is null || oldInstallLocation == Paths.Base)
return; return;
SetStatus("Migrating install location..."); SetStatus("Migrating install location...");
if (Directory.Exists(oldInstallLocation)) if (Directory.Exists(oldInstallLocation))
{ {
App.Logger.WriteLine(LOG_IDENT, $"Moving all files in {oldInstallLocation} to {Directories.Base}..."); App.Logger.WriteLine(LOG_IDENT, $"Moving all files in {oldInstallLocation} to {Paths.Base}...");
foreach (string oldFileLocation in Directory.GetFiles(oldInstallLocation, "*.*", SearchOption.AllDirectories)) foreach (string oldFileLocation in Directory.GetFiles(oldInstallLocation, "*.*", SearchOption.AllDirectories))
{ {
string relativeFile = oldFileLocation.Substring(oldInstallLocation.Length + 1); string relativeFile = oldFileLocation.Substring(oldInstallLocation.Length + 1);
string newFileLocation = Path.Combine(Directories.Base, relativeFile); string newFileLocation = Path.Combine(Paths.Base, relativeFile);
string? newDirectory = Path.GetDirectoryName(newFileLocation); string? newDirectory = Path.GetDirectoryName(newFileLocation);
try try
@ -453,8 +453,8 @@ namespace Bloxstrap
applicationKey.DeleteValue("OldInstallLocation"); applicationKey.DeleteValue("OldInstallLocation");
// allow shortcuts to be re-registered // allow shortcuts to be re-registered
if (Directory.Exists(Directories.StartMenu)) if (Directory.Exists(Paths.StartMenu))
Directory.Delete(Directories.StartMenu, true); Directory.Delete(Paths.StartMenu, true);
if (File.Exists(DesktopShortcutLocation)) if (File.Exists(DesktopShortcutLocation))
{ {
@ -475,41 +475,41 @@ namespace Bloxstrap
// this doesn't go under register, so we check every launch // this doesn't go under register, so we check every launch
// just in case the stock bootstrapper changes it back // just in case the stock bootstrapper changes it back
ProtocolHandler.Register("roblox", "Roblox", Directories.Application); ProtocolHandler.Register("roblox", "Roblox", Paths.Application);
ProtocolHandler.Register("roblox-player", "Roblox", Directories.Application); ProtocolHandler.Register("roblox-player", "Roblox", Paths.Application);
// in case the user is reinstalling // in case the user is reinstalling
if (File.Exists(Directories.Application) && App.IsFirstRun) if (File.Exists(Paths.Application) && App.IsFirstRun)
File.Delete(Directories.Application); File.Delete(Paths.Application);
// check to make sure bootstrapper is in the install folder // check to make sure bootstrapper is in the install folder
if (!File.Exists(Directories.Application) && Environment.ProcessPath is not null) if (!File.Exists(Paths.Application) && Environment.ProcessPath is not null)
File.Copy(Environment.ProcessPath, Directories.Application); File.Copy(Environment.ProcessPath, Paths.Application);
// this SHOULD go under Register(), // this SHOULD go under Register(),
// but then people who have Bloxstrap v1.0.0 installed won't have this without a reinstall // but then people who have Bloxstrap v1.0.0 installed won't have this without a reinstall
// maybe in a later version? // maybe in a later version?
if (!Directory.Exists(Directories.StartMenu)) if (!Directory.Exists(Paths.StartMenu))
{ {
Directory.CreateDirectory(Directories.StartMenu); Directory.CreateDirectory(Paths.StartMenu);
ShellLink.Shortcut.CreateShortcut(Directories.Application, "", Directories.Application, 0) ShellLink.Shortcut.CreateShortcut(Paths.Application, "", Paths.Application, 0)
.WriteToFile(Path.Combine(Directories.StartMenu, "Play Roblox.lnk")); .WriteToFile(Path.Combine(Paths.StartMenu, "Play Roblox.lnk"));
ShellLink.Shortcut.CreateShortcut(Directories.Application, "-menu", Directories.Application, 0) ShellLink.Shortcut.CreateShortcut(Paths.Application, "-menu", Paths.Application, 0)
.WriteToFile(Path.Combine(Directories.StartMenu, $"{App.ProjectName} Menu.lnk")); .WriteToFile(Path.Combine(Paths.StartMenu, $"{App.ProjectName} Menu.lnk"));
} }
else else
{ {
// v2.0.0 - rebadge configuration menu as just "Bloxstrap Menu" // v2.0.0 - rebadge configuration menu as just "Bloxstrap Menu"
string oldMenuShortcut = Path.Combine(Directories.StartMenu, $"Configure {App.ProjectName}.lnk"); string oldMenuShortcut = Path.Combine(Paths.StartMenu, $"Configure {App.ProjectName}.lnk");
string newMenuShortcut = Path.Combine(Directories.StartMenu, $"{App.ProjectName} Menu.lnk"); string newMenuShortcut = Path.Combine(Paths.StartMenu, $"{App.ProjectName} Menu.lnk");
if (File.Exists(oldMenuShortcut)) if (File.Exists(oldMenuShortcut))
File.Delete(oldMenuShortcut); File.Delete(oldMenuShortcut);
if (!File.Exists(newMenuShortcut)) if (!File.Exists(newMenuShortcut))
ShellLink.Shortcut.CreateShortcut(Directories.Application, "-menu", Directories.Application, 0) ShellLink.Shortcut.CreateShortcut(Paths.Application, "-menu", Paths.Application, 0)
.WriteToFile(newMenuShortcut); .WriteToFile(newMenuShortcut);
} }
@ -519,7 +519,7 @@ namespace Bloxstrap
{ {
try try
{ {
ShellLink.Shortcut.CreateShortcut(Directories.Application, "", Directories.Application, 0) ShellLink.Shortcut.CreateShortcut(Paths.Application, "", Paths.Application, 0)
.WriteToFile(DesktopShortcutLocation); .WriteToFile(DesktopShortcutLocation);
} }
catch (Exception ex) catch (Exception ex)
@ -578,7 +578,7 @@ namespace Bloxstrap
// 64-bit is always the first option // 64-bit is always the first option
GithubReleaseAsset asset = releaseInfo.Assets[0]; GithubReleaseAsset asset = releaseInfo.Assets[0];
string downloadLocation = Path.Combine(Directories.LocalAppData, "Temp", asset.Name); string downloadLocation = Path.Combine(Paths.LocalAppData, "Temp", asset.Name);
App.Logger.WriteLine(LOG_IDENT, $"Downloading {releaseInfo.TagName}..."); App.Logger.WriteLine(LOG_IDENT, $"Downloading {releaseInfo.TagName}...");
@ -666,29 +666,29 @@ namespace Bloxstrap
// if the folder we're installed to does not end with "Bloxstrap", we're installed to a user-selected folder // if the folder we're installed to does not end with "Bloxstrap", we're installed to a user-selected folder
// in which case, chances are they chose to install to somewhere they didn't really mean to (prior to the added warning in 2.4.0) // in which case, chances are they chose to install to somewhere they didn't really mean to (prior to the added warning in 2.4.0)
// if so, we're walking on eggshells and have to ensure we only clean up what we need to clean up // if so, we're walking on eggshells and have to ensure we only clean up what we need to clean up
bool cautiousUninstall = !Directories.Base.EndsWith(App.ProjectName); bool cautiousUninstall = !Paths.Base.EndsWith(App.ProjectName);
var cleanupSequence = new List<Action> var cleanupSequence = new List<Action>
{ {
() => Registry.CurrentUser.DeleteSubKey($@"Software\{App.ProjectName}"), () => Registry.CurrentUser.DeleteSubKey($@"Software\{App.ProjectName}"),
() => Directory.Delete(Directories.StartMenu, true), () => Directory.Delete(Paths.StartMenu, true),
() => File.Delete(Path.Combine(Directories.Desktop, "Play Roblox.lnk")), () => File.Delete(Path.Combine(Paths.Desktop, "Play Roblox.lnk")),
() => Registry.CurrentUser.DeleteSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{App.ProjectName}") () => Registry.CurrentUser.DeleteSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{App.ProjectName}")
}; };
if (cautiousUninstall) if (cautiousUninstall)
{ {
cleanupSequence.Add(() => Directory.Delete(Directories.Downloads, true)); cleanupSequence.Add(() => Directory.Delete(Paths.Downloads, true));
cleanupSequence.Add(() => Directory.Delete(Directories.Modifications, true)); cleanupSequence.Add(() => Directory.Delete(Paths.Modifications, true));
cleanupSequence.Add(() => Directory.Delete(Directories.Versions, true)); cleanupSequence.Add(() => Directory.Delete(Paths.Versions, true));
cleanupSequence.Add(() => Directory.Delete(Directories.Logs, true)); cleanupSequence.Add(() => Directory.Delete(Paths.Logs, true));
cleanupSequence.Add(() => File.Delete(App.Settings.FileLocation)); cleanupSequence.Add(() => File.Delete(App.Settings.FileLocation));
cleanupSequence.Add(() => File.Delete(App.State.FileLocation)); cleanupSequence.Add(() => File.Delete(App.State.FileLocation));
} }
else else
{ {
cleanupSequence.Add(() => Directory.Delete(Directories.Base, true)); cleanupSequence.Add(() => Directory.Delete(Paths.Base, true));
} }
foreach (var process in cleanupSequence) foreach (var process in cleanupSequence)
@ -706,7 +706,7 @@ namespace Bloxstrap
Action? callback = null; Action? callback = null;
if (Directory.Exists(Directories.Base)) if (Directory.Exists(Paths.Base))
{ {
callback = delegate callback = delegate
{ {
@ -717,9 +717,9 @@ namespace Bloxstrap
string deleteCommand; string deleteCommand;
if (cautiousUninstall) if (cautiousUninstall)
deleteCommand = $"del /Q \"{Directories.Application}\""; deleteCommand = $"del /Q \"{Paths.Application}\"";
else else
deleteCommand = $"del /Q \"{Directories.Base}\\*\" && rmdir \"{Directories.Base}\""; deleteCommand = $"del /Q \"{Paths.Base}\\*\" && rmdir \"{Paths.Base}\"";
Process.Start(new ProcessStartInfo() Process.Start(new ProcessStartInfo()
{ {
@ -744,16 +744,16 @@ namespace Bloxstrap
SetStatus(FreshInstall ? "Installing Roblox..." : "Upgrading Roblox..."); SetStatus(FreshInstall ? "Installing Roblox..." : "Upgrading Roblox...");
Directory.CreateDirectory(Directories.Base); Directory.CreateDirectory(Paths.Base);
Directory.CreateDirectory(Directories.Downloads); Directory.CreateDirectory(Paths.Downloads);
Directory.CreateDirectory(Directories.Versions); Directory.CreateDirectory(Paths.Versions);
// package manifest states packed size and uncompressed size in exact bytes // package manifest states packed size and uncompressed size in exact bytes
// packed size only matters if we don't already have the package cached on disk // packed size only matters if we don't already have the package cached on disk
string[] cachedPackages = Directory.GetFiles(Directories.Downloads); string[] cachedPackages = Directory.GetFiles(Paths.Downloads);
int totalSizeRequired = _versionPackageManifest.Where(x => !cachedPackages.Contains(x.Signature)).Sum(x => x.PackedSize) + _versionPackageManifest.Sum(x => x.Size); int totalSizeRequired = _versionPackageManifest.Where(x => !cachedPackages.Contains(x.Signature)).Sum(x => x.PackedSize) + _versionPackageManifest.Sum(x => x.Size);
if (Utilities.GetFreeDiskSpace(Directories.Base) < totalSizeRequired) if (Utilities.GetFreeDiskSpace(Paths.Base) < totalSizeRequired)
{ {
Controls.ShowMessageBox( Controls.ShowMessageBox(
$"{App.ProjectName} does not have enough disk space to download and install Roblox. Please free up some disk space and try again.", $"{App.ProjectName} does not have enough disk space to download and install Roblox. Please free up some disk space and try again.",
@ -826,7 +826,7 @@ namespace Bloxstrap
} }
} }
string oldVersionFolder = Path.Combine(Directories.Versions, App.State.Prop.VersionGuid); string oldVersionFolder = Path.Combine(Paths.Versions, App.State.Prop.VersionGuid);
// move old compatibility flags for the old location // move old compatibility flags for the old location
using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers")) using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"))
@ -847,7 +847,7 @@ namespace Bloxstrap
// while they were launching a second instance or something idk // while they were launching a second instance or something idk
if (!Process.GetProcessesByName(App.RobloxAppName).Any()) if (!Process.GetProcessesByName(App.RobloxAppName).Any())
{ {
foreach (DirectoryInfo dir in new DirectoryInfo(Directories.Versions).GetDirectories()) foreach (DirectoryInfo dir in new DirectoryInfo(Paths.Versions).GetDirectories())
{ {
if (dir.Name == _latestVersionGuid || !dir.Name.StartsWith("version-")) if (dir.Name == _latestVersionGuid || !dir.Name.StartsWith("version-"))
continue; continue;
@ -918,14 +918,14 @@ namespace Bloxstrap
public static void MigrateIntegrations() public static void MigrateIntegrations()
{ {
// v2.2.0 - remove rbxfpsunlocker // v2.2.0 - remove rbxfpsunlocker
string rbxfpsunlocker = Path.Combine(Directories.Integrations, "rbxfpsunlocker"); string rbxfpsunlocker = Path.Combine(Paths.Integrations, "rbxfpsunlocker");
if (Directory.Exists(rbxfpsunlocker)) if (Directory.Exists(rbxfpsunlocker))
Directory.Delete(rbxfpsunlocker, true); Directory.Delete(rbxfpsunlocker, true);
// v2.3.0 - remove reshade // v2.3.0 - remove reshade
string injectorLocation = Path.Combine(Directories.Modifications, "dxgi.dll"); string injectorLocation = Path.Combine(Paths.Modifications, "dxgi.dll");
string configLocation = Path.Combine(Directories.Modifications, "ReShade.ini"); string configLocation = Path.Combine(Paths.Modifications, "ReShade.ini");
if (File.Exists(injectorLocation)) if (File.Exists(injectorLocation))
{ {
@ -992,10 +992,10 @@ namespace Bloxstrap
// handle file mods // handle file mods
App.Logger.WriteLine(LOG_IDENT, "Checking file mods..."); App.Logger.WriteLine(LOG_IDENT, "Checking file mods...");
string modFolder = Path.Combine(Directories.Modifications); string modFolder = Path.Combine(Paths.Modifications);
// manifest has been moved to State.json // manifest has been moved to State.json
File.Delete(Path.Combine(Directories.Base, "ModManifest.txt")); File.Delete(Path.Combine(Paths.Base, "ModManifest.txt"));
List<string> modFolderFiles = new(); List<string> modFolderFiles = new();
@ -1036,7 +1036,7 @@ namespace Bloxstrap
await CheckModPreset(App.Settings.Prop.UseOldAvatarBackground && !appDisabled, @"ExtraContent\places\Mobile.rbxl", "OldAvatarBackground.rbxl"); await CheckModPreset(App.Settings.Prop.UseOldAvatarBackground && !appDisabled, @"ExtraContent\places\Mobile.rbxl", "OldAvatarBackground.rbxl");
// emoji presets are downloaded remotely from github due to how large they are // emoji presets are downloaded remotely from github due to how large they are
string contentFonts = Path.Combine(Directories.Modifications, "content\\fonts"); string contentFonts = Path.Combine(Paths.Modifications, "content\\fonts");
string emojiFontLocation = Path.Combine(contentFonts, "TwemojiMozilla.ttf"); string emojiFontLocation = Path.Combine(contentFonts, "TwemojiMozilla.ttf");
string emojiFontHash = File.Exists(emojiFontLocation) ? Utility.MD5Hash.FromFile(emojiFontLocation) : ""; string emojiFontHash = File.Exists(emojiFontLocation) ? Utility.MD5Hash.FromFile(emojiFontLocation) : "";
@ -1059,15 +1059,15 @@ namespace Bloxstrap
// check custom font mod // check custom font mod
// instead of replacing the fonts themselves, we'll just alter the font family manifests // instead of replacing the fonts themselves, we'll just alter the font family manifests
string modFontFamiliesFolder = Path.Combine(Directories.Modifications, "content\\fonts\\families"); string modFontFamiliesFolder = Path.Combine(Paths.Modifications, "content\\fonts\\families");
if (App.IsFirstRun && App.CustomFontLocation is not null) if (App.IsFirstRun && App.CustomFontLocation is not null)
{ {
Directory.CreateDirectory(Path.GetDirectoryName(Directories.CustomFont)!); Directory.CreateDirectory(Path.GetDirectoryName(Paths.CustomFont)!);
File.Copy(App.CustomFontLocation, Directories.CustomFont); File.Copy(App.CustomFontLocation, Paths.CustomFont);
} }
if (File.Exists(Directories.CustomFont)) if (File.Exists(Paths.CustomFont))
{ {
App.Logger.WriteLine(LOG_IDENT, "Begin font check"); App.Logger.WriteLine(LOG_IDENT, "Begin font check");
@ -1173,7 +1173,7 @@ namespace Bloxstrap
private static async Task CheckModPreset(bool condition, string location, string name) private static async Task CheckModPreset(bool condition, string location, string name)
{ {
string fullLocation = Path.Combine(Directories.Modifications, location); string fullLocation = Path.Combine(Paths.Modifications, location);
string fileHash = File.Exists(fullLocation) ? MD5Hash.FromFile(fullLocation) : ""; string fileHash = File.Exists(fullLocation) ? MD5Hash.FromFile(fullLocation) : "";
if (!condition && fileHash == "") if (!condition && fileHash == "")
@ -1213,8 +1213,8 @@ namespace Bloxstrap
return; return;
string packageUrl = RobloxDeployment.GetLocation($"/{_latestVersionGuid}-{package.Name}"); string packageUrl = RobloxDeployment.GetLocation($"/{_latestVersionGuid}-{package.Name}");
string packageLocation = Path.Combine(Directories.Downloads, package.Signature); string packageLocation = Path.Combine(Paths.Downloads, package.Signature);
string robloxPackageLocation = Path.Combine(Directories.LocalAppData, "Roblox", "Downloads", package.Signature); string robloxPackageLocation = Path.Combine(Paths.LocalAppData, "Roblox", "Downloads", package.Signature);
if (File.Exists(packageLocation)) if (File.Exists(packageLocation))
{ {
@ -1290,7 +1290,7 @@ namespace Bloxstrap
if (_cancelFired) if (_cancelFired)
return; return;
string packageLocation = Path.Combine(Directories.Downloads, package.Signature); string packageLocation = Path.Combine(Paths.Downloads, package.Signature);
string packageFolder = Path.Combine(_versionFolder, PackageDirectories[package.Name]); string packageFolder = Path.Combine(_versionFolder, PackageDirectories[package.Name]);
string extractPath; string extractPath;
@ -1339,7 +1339,7 @@ namespace Bloxstrap
DownloadPackage(package).GetAwaiter().GetResult(); DownloadPackage(package).GetAwaiter().GetResult();
string packageLocation = Path.Combine(Directories.Downloads, package.Signature); string packageLocation = Path.Combine(Paths.Downloads, package.Signature);
string packageFolder = Path.Combine(_versionFolder, PackageDirectories[package.Name]); string packageFolder = Path.Combine(_versionFolder, PackageDirectories[package.Name]);
using ZipArchive archive = ZipFile.OpenRead(packageLocation); using ZipArchive archive = ZipFile.OpenRead(packageLocation);

View File

@ -5,7 +5,7 @@ namespace Bloxstrap
{ {
public class FastFlagManager : JsonManager<Dictionary<string, object>> public class FastFlagManager : JsonManager<Dictionary<string, object>>
{ {
public override string FileLocation => Path.Combine(Directories.Modifications, "ClientSettings\\ClientAppSettings.json"); public override string FileLocation => Path.Combine(Paths.Modifications, "ClientSettings\\ClientAppSettings.json");
// this is the value of the 'FStringPartTexturePackTablePre2022' flag // this is the value of the 'FStringPartTexturePackTablePre2022' flag
public const string OldTexturesFlagValue = "{\"foil\":{\"ids\":[\"rbxassetid://7546645012\",\"rbxassetid://7546645118\"],\"color\":[255,255,255,255]},\"brick\":{\"ids\":[\"rbxassetid://7546650097\",\"rbxassetid://7546645118\"],\"color\":[204,201,200,232]},\"cobblestone\":{\"ids\":[\"rbxassetid://7546652947\",\"rbxassetid://7546645118\"],\"color\":[212,200,187,250]},\"concrete\":{\"ids\":[\"rbxassetid://7546653951\",\"rbxassetid://7546654144\"],\"color\":[208,208,208,255]},\"diamondplate\":{\"ids\":[\"rbxassetid://7547162198\",\"rbxassetid://7546645118\"],\"color\":[170,170,170,255]},\"fabric\":{\"ids\":[\"rbxassetid://7547101130\",\"rbxassetid://7546645118\"],\"color\":[105,104,102,244]},\"glass\":{\"ids\":[\"rbxassetid://7547304948\",\"rbxassetid://7546645118\"],\"color\":[254,254,254,7]},\"granite\":{\"ids\":[\"rbxassetid://7547164710\",\"rbxassetid://7546645118\"],\"color\":[113,113,113,255]},\"grass\":{\"ids\":[\"rbxassetid://7547169285\",\"rbxassetid://7546645118\"],\"color\":[165,165,159,255]},\"ice\":{\"ids\":[\"rbxassetid://7547171356\",\"rbxassetid://7546645118\"],\"color\":[255,255,255,255]},\"marble\":{\"ids\":[\"rbxassetid://7547177270\",\"rbxassetid://7546645118\"],\"color\":[199,199,199,255]},\"metal\":{\"ids\":[\"rbxassetid://7547288171\",\"rbxassetid://7546645118\"],\"color\":[199,199,199,255]},\"pebble\":{\"ids\":[\"rbxassetid://7547291361\",\"rbxassetid://7546645118\"],\"color\":[208,208,208,255]},\"corrodedmetal\":{\"ids\":[\"rbxassetid://7547184629\",\"rbxassetid://7546645118\"],\"color\":[159,119,95,200]},\"sand\":{\"ids\":[\"rbxassetid://7547295153\",\"rbxassetid://7546645118\"],\"color\":[220,220,220,255]},\"slate\":{\"ids\":[\"rbxassetid://7547298114\",\"rbxassetid://7547298323\"],\"color\":[193,193,193,255]},\"wood\":{\"ids\":[\"rbxassetid://7547303225\",\"rbxassetid://7547298786\"],\"color\":[227,227,227,255]},\"woodplanks\":{\"ids\":[\"rbxassetid://7547332968\",\"rbxassetid://7546645118\"],\"color\":[212,209,203,255]},\"asphalt\":{\"ids\":[\"rbxassetid://9873267379\",\"rbxassetid://9438410548\"],\"color\":[123,123,123,234]},\"basalt\":{\"ids\":[\"rbxassetid://9873270487\",\"rbxassetid://9438413638\"],\"color\":[154,154,153,238]},\"crackedlava\":{\"ids\":[\"rbxassetid://9438582231\",\"rbxassetid://9438453972\"],\"color\":[74,78,80,156]},\"glacier\":{\"ids\":[\"rbxassetid://9438851661\",\"rbxassetid://9438453972\"],\"color\":[226,229,229,243]},\"ground\":{\"ids\":[\"rbxassetid://9439044431\",\"rbxassetid://9438453972\"],\"color\":[114,114,112,240]},\"leafygrass\":{\"ids\":[\"rbxassetid://9873288083\",\"rbxassetid://9438453972\"],\"color\":[121,117,113,234]},\"limestone\":{\"ids\":[\"rbxassetid://9873289812\",\"rbxassetid://9438453972\"],\"color\":[235,234,230,250]},\"mud\":{\"ids\":[\"rbxassetid://9873319819\",\"rbxassetid://9438453972\"],\"color\":[130,130,130,252]},\"pavement\":{\"ids\":[\"rbxassetid://9873322398\",\"rbxassetid://9438453972\"],\"color\":[142,142,144,236]},\"rock\":{\"ids\":[\"rbxassetid://9873515198\",\"rbxassetid://9438453972\"],\"color\":[154,154,154,248]},\"salt\":{\"ids\":[\"rbxassetid://9439566986\",\"rbxassetid://9438453972\"],\"color\":[220,220,221,255]},\"sandstone\":{\"ids\":[\"rbxassetid://9873521380\",\"rbxassetid://9438453972\"],\"color\":[174,171,169,246]},\"snow\":{\"ids\":[\"rbxassetid://9439632387\",\"rbxassetid://9438453972\"],\"color\":[218,218,218,255]}}"; public const string OldTexturesFlagValue = "{\"foil\":{\"ids\":[\"rbxassetid://7546645012\",\"rbxassetid://7546645118\"],\"color\":[255,255,255,255]},\"brick\":{\"ids\":[\"rbxassetid://7546650097\",\"rbxassetid://7546645118\"],\"color\":[204,201,200,232]},\"cobblestone\":{\"ids\":[\"rbxassetid://7546652947\",\"rbxassetid://7546645118\"],\"color\":[212,200,187,250]},\"concrete\":{\"ids\":[\"rbxassetid://7546653951\",\"rbxassetid://7546654144\"],\"color\":[208,208,208,255]},\"diamondplate\":{\"ids\":[\"rbxassetid://7547162198\",\"rbxassetid://7546645118\"],\"color\":[170,170,170,255]},\"fabric\":{\"ids\":[\"rbxassetid://7547101130\",\"rbxassetid://7546645118\"],\"color\":[105,104,102,244]},\"glass\":{\"ids\":[\"rbxassetid://7547304948\",\"rbxassetid://7546645118\"],\"color\":[254,254,254,7]},\"granite\":{\"ids\":[\"rbxassetid://7547164710\",\"rbxassetid://7546645118\"],\"color\":[113,113,113,255]},\"grass\":{\"ids\":[\"rbxassetid://7547169285\",\"rbxassetid://7546645118\"],\"color\":[165,165,159,255]},\"ice\":{\"ids\":[\"rbxassetid://7547171356\",\"rbxassetid://7546645118\"],\"color\":[255,255,255,255]},\"marble\":{\"ids\":[\"rbxassetid://7547177270\",\"rbxassetid://7546645118\"],\"color\":[199,199,199,255]},\"metal\":{\"ids\":[\"rbxassetid://7547288171\",\"rbxassetid://7546645118\"],\"color\":[199,199,199,255]},\"pebble\":{\"ids\":[\"rbxassetid://7547291361\",\"rbxassetid://7546645118\"],\"color\":[208,208,208,255]},\"corrodedmetal\":{\"ids\":[\"rbxassetid://7547184629\",\"rbxassetid://7546645118\"],\"color\":[159,119,95,200]},\"sand\":{\"ids\":[\"rbxassetid://7547295153\",\"rbxassetid://7546645118\"],\"color\":[220,220,220,255]},\"slate\":{\"ids\":[\"rbxassetid://7547298114\",\"rbxassetid://7547298323\"],\"color\":[193,193,193,255]},\"wood\":{\"ids\":[\"rbxassetid://7547303225\",\"rbxassetid://7547298786\"],\"color\":[227,227,227,255]},\"woodplanks\":{\"ids\":[\"rbxassetid://7547332968\",\"rbxassetid://7546645118\"],\"color\":[212,209,203,255]},\"asphalt\":{\"ids\":[\"rbxassetid://9873267379\",\"rbxassetid://9438410548\"],\"color\":[123,123,123,234]},\"basalt\":{\"ids\":[\"rbxassetid://9873270487\",\"rbxassetid://9438413638\"],\"color\":[154,154,153,238]},\"crackedlava\":{\"ids\":[\"rbxassetid://9438582231\",\"rbxassetid://9438453972\"],\"color\":[74,78,80,156]},\"glacier\":{\"ids\":[\"rbxassetid://9438851661\",\"rbxassetid://9438453972\"],\"color\":[226,229,229,243]},\"ground\":{\"ids\":[\"rbxassetid://9439044431\",\"rbxassetid://9438453972\"],\"color\":[114,114,112,240]},\"leafygrass\":{\"ids\":[\"rbxassetid://9873288083\",\"rbxassetid://9438453972\"],\"color\":[121,117,113,234]},\"limestone\":{\"ids\":[\"rbxassetid://9873289812\",\"rbxassetid://9438453972\"],\"color\":[235,234,230,250]},\"mud\":{\"ids\":[\"rbxassetid://9873319819\",\"rbxassetid://9438453972\"],\"color\":[130,130,130,252]},\"pavement\":{\"ids\":[\"rbxassetid://9873322398\",\"rbxassetid://9438453972\"],\"color\":[142,142,144,236]},\"rock\":{\"ids\":[\"rbxassetid://9873515198\",\"rbxassetid://9438453972\"],\"color\":[154,154,154,248]},\"salt\":{\"ids\":[\"rbxassetid://9439566986\",\"rbxassetid://9438453972\"],\"color\":[220,220,221,255]},\"sandstone\":{\"ids\":[\"rbxassetid://9873521380\",\"rbxassetid://9438453972\"],\"color\":[174,171,169,246]},\"snow\":{\"ids\":[\"rbxassetid://9439632387\",\"rbxassetid://9438453972\"],\"color\":[218,218,218,255]}}";

View File

@ -62,7 +62,7 @@
if (App.Settings.Prop.OhHeyYouFoundMe) if (App.Settings.Prop.OhHeyYouFoundMe)
delay = 250; delay = 250;
string logDirectory = Path.Combine(Directories.LocalAppData, "Roblox\\logs"); string logDirectory = Path.Combine(Paths.LocalAppData, "Roblox\\logs");
if (!Directory.Exists(logDirectory)) if (!Directory.Exists(logDirectory))
return; return;

View File

@ -5,7 +5,7 @@ namespace Bloxstrap
public class JsonManager<T> where T : new() public class JsonManager<T> where T : new()
{ {
public T Prop { get; set; } = new(); public T Prop { get; set; } = new();
public virtual string FileLocation => Path.Combine(Directories.Base, $"{typeof(T).Name}.json"); public virtual string FileLocation => Path.Combine(Paths.Base, $"{typeof(T).Name}.json");
private string LOG_IDENT_CLASS => $"JsonManager<{typeof(T).Name}>"; private string LOG_IDENT_CLASS => $"JsonManager<{typeof(T).Name}>";

View File

@ -19,7 +19,7 @@
{ {
const string LOG_IDENT = "Logger::Initialize"; const string LOG_IDENT = "Logger::Initialize";
string directory = useTempDir ? Path.Combine(Directories.LocalAppData, "Temp") : Path.Combine(Directories.Base, "Logs"); string directory = useTempDir ? Path.Combine(Paths.LocalAppData, "Temp") : Path.Combine(Paths.Base, "Logs");
string timestamp = DateTime.UtcNow.ToString("yyyyMMdd'T'HHmmss'Z'"); string timestamp = DateTime.UtcNow.ToString("yyyyMMdd'T'HHmmss'Z'");
string filename = $"{App.ProjectName}_{timestamp}.log"; string filename = $"{App.ProjectName}_{timestamp}.log";
string location = Path.Combine(directory, filename); string location = Path.Combine(directory, filename);
@ -52,9 +52,9 @@
FileLocation = location; FileLocation = location;
// clean up any logs older than a week // clean up any logs older than a week
if (Directories.Initialized && Directory.Exists(Directories.Logs)) if (Paths.Initialized && Directory.Exists(Paths.Logs))
{ {
foreach (FileInfo log in new DirectoryInfo(Directories.Logs).GetFiles()) foreach (FileInfo log in new DirectoryInfo(Paths.Logs).GetFiles())
{ {
if (log.LastWriteTimeUtc.AddDays(7) > DateTime.UtcNow) if (log.LastWriteTimeUtc.AddDays(7) > DateTime.UtcNow)
continue; continue;
@ -69,7 +69,7 @@
{ {
string timestamp = DateTime.UtcNow.ToString("s") + "Z"; string timestamp = DateTime.UtcNow.ToString("s") + "Z";
string outcon = $"{timestamp} {message}"; string outcon = $"{timestamp} {message}";
string outlog = outcon.Replace(Directories.UserProfile, "%UserProfile%"); string outlog = outcon.Replace(Paths.UserProfile, "%UserProfile%");
Debug.WriteLine(outcon); Debug.WriteLine(outcon);
WriteToLog(outlog); WriteToLog(outlog);

View File

@ -1,6 +1,6 @@
namespace Bloxstrap namespace Bloxstrap
{ {
static class Directories static class Paths
{ {
// note that these are directories that aren't tethered to the basedirectory // note that these are directories that aren't tethered to the basedirectory
// so these can safely be called before initialization // so these can safely be called before initialization

View File

@ -20,7 +20,7 @@ namespace Bloxstrap.UI.ViewModels.Bootstrapper
{ {
get get
{ {
string playerLocation = Path.Combine(Directories.Versions, App.State.Prop.VersionGuid, "RobloxPlayerBeta.exe"); string playerLocation = Path.Combine(Paths.Versions, App.State.Prop.VersionGuid, "RobloxPlayerBeta.exe");
if (!File.Exists(playerLocation)) if (!File.Exists(playerLocation))
return ""; return "";

View File

@ -31,7 +31,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
private void OpenFolder() private void OpenFolder()
{ {
Process.Start("explorer.exe", Directories.Base); Process.Start("explorer.exe", Paths.Base);
} }
public string InstallLocation public string InstallLocation

View File

@ -132,7 +132,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
using RegistryKey registryKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}"); using RegistryKey registryKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}");
registryKey.SetValue("InstallLocation", App.BaseDirectory); registryKey.SetValue("InstallLocation", App.BaseDirectory);
registryKey.SetValue("OldInstallLocation", _originalBaseDirectory); registryKey.SetValue("OldInstallLocation", _originalBaseDirectory);
Directories.Initialize(App.BaseDirectory); Paths.Initialize(App.BaseDirectory);
} }
CloseWindow(); CloseWindow();

View File

@ -9,9 +9,9 @@ namespace Bloxstrap.UI.ViewModels.Menu
{ {
public class ModsViewModel : NotifyPropertyChangedViewModel public class ModsViewModel : NotifyPropertyChangedViewModel
{ {
private void OpenModsFolder() => Process.Start("explorer.exe", Directories.Modifications); private void OpenModsFolder() => Process.Start("explorer.exe", Paths.Modifications);
private bool _usingCustomFont => App.IsFirstRun && App.CustomFontLocation is not null || !App.IsFirstRun && File.Exists(Directories.CustomFont); private bool _usingCustomFont => App.IsFirstRun && App.CustomFontLocation is not null || !App.IsFirstRun && File.Exists(Paths.CustomFont);
private void ManageCustomFont() private void ManageCustomFont()
{ {
@ -20,7 +20,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
if (App.IsFirstRun) if (App.IsFirstRun)
App.CustomFontLocation = null; App.CustomFontLocation = null;
else else
File.Delete(Directories.CustomFont); File.Delete(Paths.CustomFont);
} }
else else
{ {
@ -38,8 +38,8 @@ namespace Bloxstrap.UI.ViewModels.Menu
} }
else else
{ {
Directory.CreateDirectory(Path.GetDirectoryName(Directories.CustomFont)!); Directory.CreateDirectory(Path.GetDirectoryName(Paths.CustomFont)!);
File.Copy(dialog.FileName, Directories.CustomFont); File.Copy(dialog.FileName, Paths.CustomFont);
} }
} }

View File

@ -8,15 +8,15 @@ namespace Bloxstrap
{ {
const string LOG_IDENT = "Updater::CheckInstalledVersion"; const string LOG_IDENT = "Updater::CheckInstalledVersion";
if (Environment.ProcessPath is null || !File.Exists(Directories.Application) || Environment.ProcessPath == Directories.Application) if (Environment.ProcessPath is null || !File.Exists(Paths.Application) || Environment.ProcessPath == Paths.Application)
return; return;
// 2.0.0 downloads updates to <BaseFolder>/Updates so lol // 2.0.0 downloads updates to <BaseFolder>/Updates so lol
bool isAutoUpgrade = Environment.ProcessPath.StartsWith(Path.Combine(Directories.Base, "Updates")) || Environment.ProcessPath.StartsWith(Path.Combine(Directories.LocalAppData, "Temp")); bool isAutoUpgrade = Environment.ProcessPath.StartsWith(Path.Combine(Paths.Base, "Updates")) || Environment.ProcessPath.StartsWith(Path.Combine(Paths.LocalAppData, "Temp"));
FileVersionInfo currentVersionInfo = FileVersionInfo.GetVersionInfo(Environment.ProcessPath); FileVersionInfo currentVersionInfo = FileVersionInfo.GetVersionInfo(Environment.ProcessPath);
if (MD5Hash.FromFile(Environment.ProcessPath) == MD5Hash.FromFile(Directories.Application)) if (MD5Hash.FromFile(Environment.ProcessPath) == MD5Hash.FromFile(Paths.Application))
return; return;
MessageBoxResult result; MessageBoxResult result;
@ -47,7 +47,7 @@ namespace Bloxstrap
try try
{ {
File.Delete(Directories.Application); File.Delete(Paths.Application);
break; break;
} }
catch (Exception) catch (Exception)
@ -65,7 +65,7 @@ namespace Bloxstrap
return; return;
} }
File.Copy(Environment.ProcessPath, Directories.Application); File.Copy(Environment.ProcessPath, Paths.Application);
Bootstrapper.Register(); Bootstrapper.Register();