From 5fdb3419185c42f71a4b24c5608dfb8824c3f914 Mon Sep 17 00:00:00 2001 From: Matthew Brown <97983689+bluepilledgreat@users.noreply.github.com> Date: Sat, 12 Nov 2022 22:50:27 +0000 Subject: [PATCH 01/24] reuse httpclient --- Bloxstrap/Bootstrapper.cs | 2 +- Bloxstrap/Helpers/DeployManager.cs | 17 +++++++---------- .../Helpers/Integrations/RbxFpsUnlocker.cs | 13 +++++-------- Bloxstrap/Helpers/RSMM/PackageManifest.cs | 7 ++----- Bloxstrap/Helpers/Utilities.cs | 13 +++++++------ 5 files changed, 22 insertions(+), 30 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 15ee22e..1f75481 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -66,7 +66,7 @@ namespace Bloxstrap "By default, two mod presets are provided for restoring the old death\n" + "sound and the old mouse cursor.\n"; - private static readonly HttpClient Client = new(); + public static readonly HttpClient Client = new(); private string? LaunchCommandLine; diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index b537bec..6d2c971 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -102,19 +102,16 @@ namespace Bloxstrap.Helpers string baseUrl = BuildBaseUrl(channel); string lastDeploy = ""; - using (HttpClient client = new()) + string deployHistory = await Bootstrapper.Client.GetStringAsync($"{baseUrl}/DeployHistory.txt"); + + using (StringReader reader = new(deployHistory)) { - string deployHistory = await client.GetStringAsync($"{baseUrl}/DeployHistory.txt"); + string? line; - using (StringReader reader = new(deployHistory)) + while ((line = await reader.ReadLineAsync()) is not null) { - string? line; - - while ((line = await reader.ReadLineAsync()) is not null) - { - if (line.Contains("WindowsPlayer")) - lastDeploy = line; - } + if (line.Contains("WindowsPlayer")) + lastDeploy = line; } } diff --git a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs index 2139872..66b362d 100644 --- a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs +++ b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs @@ -97,15 +97,12 @@ namespace Bloxstrap.Helpers.Integrations Debug.WriteLine("Installing/Updating rbxfpsunlocker..."); - using (HttpClient client = new()) - { - byte[] bytes = await client.GetByteArrayAsync(downloadUrl); + byte[] bytes = await Bootstrapper.Client.GetByteArrayAsync(downloadUrl); - using (MemoryStream zipStream = new(bytes)) - { - ZipArchive zip = new(zipStream); - zip.ExtractToDirectory(folderLocation, true); - } + using (MemoryStream zipStream = new(bytes)) + { + ZipArchive zip = new(zipStream); + zip.ExtractToDirectory(folderLocation, true); } if (!File.Exists(settingsLocation)) diff --git a/Bloxstrap/Helpers/RSMM/PackageManifest.cs b/Bloxstrap/Helpers/RSMM/PackageManifest.cs index bacfabd..51c6a40 100644 --- a/Bloxstrap/Helpers/RSMM/PackageManifest.cs +++ b/Bloxstrap/Helpers/RSMM/PackageManifest.cs @@ -75,11 +75,8 @@ namespace Bloxstrap.Helpers.RSMM string pkgManifestUrl = $"{DeployManager.BaseUrl}/{versionGuid}-rbxPkgManifest.txt"; string pkgManifestData; - using (HttpClient http = new()) - { - var getData = http.GetStringAsync(pkgManifestUrl); - pkgManifestData = await getData.ConfigureAwait(false); - } + var getData = Bootstrapper.Client.GetStringAsync(pkgManifestUrl); + pkgManifestData = await getData.ConfigureAwait(false); return new PackageManifest(pkgManifestData); } diff --git a/Bloxstrap/Helpers/Utilities.cs b/Bloxstrap/Helpers/Utilities.cs index 22a60d4..86d1b37 100644 --- a/Bloxstrap/Helpers/Utilities.cs +++ b/Bloxstrap/Helpers/Utilities.cs @@ -15,13 +15,14 @@ namespace Bloxstrap.Helpers public static async Task GetJson(string url) { - using (HttpClient client = new()) + var request = await Bootstrapper.Client.SendAsync(new() { - client.DefaultRequestHeaders.Add("User-Agent", Program.ProjectRepository); - - string json = await client.GetStringAsync(url); - return JsonSerializer.Deserialize(json); - } + Headers = { + { "User-Agent", Program.ProjectRepository } + } + }); + var json = await request.Content.ReadAsStringAsync(); + return JsonSerializer.Deserialize(json); } public static string MD5File(string filename) From bdcd58f4cbed2a74c09555d4e8c400366a4ca91b Mon Sep 17 00:00:00 2001 From: Matthew Brown <97983689+bluepilledgreat@users.noreply.github.com> Date: Sat, 12 Nov 2022 22:58:13 +0000 Subject: [PATCH 02/24] enable httpclient decompression --- Bloxstrap/Bootstrapper.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 1f75481..b660fcf 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.IO; using System.IO.Compression; +using System.Net; using System.Net.Http; using Microsoft.Win32; @@ -66,7 +67,7 @@ namespace Bloxstrap "By default, two mod presets are provided for restoring the old death\n" + "sound and the old mouse cursor.\n"; - public static readonly HttpClient Client = new(); + public static readonly HttpClient Client = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }); private string? LaunchCommandLine; From 5d4fc39475482494c9368f6ec179d9ef1cb31cde Mon Sep 17 00:00:00 2001 From: Matthew Brown <97983689+bluepilledgreat@users.noreply.github.com> Date: Sun, 13 Nov 2022 09:47:02 +0000 Subject: [PATCH 03/24] forgot uri --- Bloxstrap/Helpers/Utilities.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Bloxstrap/Helpers/Utilities.cs b/Bloxstrap/Helpers/Utilities.cs index 86d1b37..9f260d8 100644 --- a/Bloxstrap/Helpers/Utilities.cs +++ b/Bloxstrap/Helpers/Utilities.cs @@ -17,6 +17,7 @@ namespace Bloxstrap.Helpers { var request = await Bootstrapper.Client.SendAsync(new() { + RequestUri = new Uri(url), Headers = { { "User-Agent", Program.ProjectRepository } } From 7295a8eec7c4ac81ae8cca96b58ca84ded3441eb Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Mon, 14 Nov 2022 17:40:00 +0000 Subject: [PATCH 04/24] Revert "Merge pull request #45 from bluepilledgreat/reuse-httpclient" This reverts commit c6410eb4074d0ffc77a9cc46cc5c2e8bdbf74e54, reversing changes made to 5b94b2741a6fe9ca3257ec807789db3ad960c802. --- Bloxstrap/Bootstrapper.cs | 3 +-- Bloxstrap/Helpers/DeployManager.cs | 17 ++++++++++------- .../Helpers/Integrations/RbxFpsUnlocker.cs | 13 ++++++++----- Bloxstrap/Helpers/RSMM/PackageManifest.cs | 7 +++++-- Bloxstrap/Helpers/Utilities.cs | 14 ++++++-------- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 3c2d3a9..883f760 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using System.IO; using System.IO.Compression; -using System.Net; using System.Net.Http; using Microsoft.Win32; @@ -67,7 +66,7 @@ namespace Bloxstrap "By default, two mod presets are provided for restoring the old death\n" + "sound and the old mouse cursor.\n"; - public static readonly HttpClient Client = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }); + private static readonly HttpClient Client = new(); private string? LaunchCommandLine; diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index 8f3d549..d794dbd 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -104,16 +104,19 @@ namespace Bloxstrap.Helpers string baseUrl = BuildBaseUrl(channel); string lastDeploy = ""; - string deployHistory = await Bootstrapper.Client.GetStringAsync($"{baseUrl}/DeployHistory.txt"); - - using (StringReader reader = new(deployHistory)) + using (HttpClient client = new()) { - string? line; + string deployHistory = await client.GetStringAsync($"{baseUrl}/DeployHistory.txt"); - while ((line = await reader.ReadLineAsync()) is not null) + using (StringReader reader = new(deployHistory)) { - if (line.Contains("WindowsPlayer")) - lastDeploy = line; + string? line; + + while ((line = await reader.ReadLineAsync()) is not null) + { + if (line.Contains("WindowsPlayer")) + lastDeploy = line; + } } } diff --git a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs index 66b362d..2139872 100644 --- a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs +++ b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs @@ -97,12 +97,15 @@ namespace Bloxstrap.Helpers.Integrations Debug.WriteLine("Installing/Updating rbxfpsunlocker..."); - byte[] bytes = await Bootstrapper.Client.GetByteArrayAsync(downloadUrl); - - using (MemoryStream zipStream = new(bytes)) + using (HttpClient client = new()) { - ZipArchive zip = new(zipStream); - zip.ExtractToDirectory(folderLocation, true); + byte[] bytes = await client.GetByteArrayAsync(downloadUrl); + + using (MemoryStream zipStream = new(bytes)) + { + ZipArchive zip = new(zipStream); + zip.ExtractToDirectory(folderLocation, true); + } } if (!File.Exists(settingsLocation)) diff --git a/Bloxstrap/Helpers/RSMM/PackageManifest.cs b/Bloxstrap/Helpers/RSMM/PackageManifest.cs index 51c6a40..bacfabd 100644 --- a/Bloxstrap/Helpers/RSMM/PackageManifest.cs +++ b/Bloxstrap/Helpers/RSMM/PackageManifest.cs @@ -75,8 +75,11 @@ namespace Bloxstrap.Helpers.RSMM string pkgManifestUrl = $"{DeployManager.BaseUrl}/{versionGuid}-rbxPkgManifest.txt"; string pkgManifestData; - var getData = Bootstrapper.Client.GetStringAsync(pkgManifestUrl); - pkgManifestData = await getData.ConfigureAwait(false); + using (HttpClient http = new()) + { + var getData = http.GetStringAsync(pkgManifestUrl); + pkgManifestData = await getData.ConfigureAwait(false); + } return new PackageManifest(pkgManifestData); } diff --git a/Bloxstrap/Helpers/Utilities.cs b/Bloxstrap/Helpers/Utilities.cs index 9f260d8..22a60d4 100644 --- a/Bloxstrap/Helpers/Utilities.cs +++ b/Bloxstrap/Helpers/Utilities.cs @@ -15,15 +15,13 @@ namespace Bloxstrap.Helpers public static async Task GetJson(string url) { - var request = await Bootstrapper.Client.SendAsync(new() + using (HttpClient client = new()) { - RequestUri = new Uri(url), - Headers = { - { "User-Agent", Program.ProjectRepository } - } - }); - var json = await request.Content.ReadAsStringAsync(); - return JsonSerializer.Deserialize(json); + client.DefaultRequestHeaders.Add("User-Agent", Program.ProjectRepository); + + string json = await client.GetStringAsync(url); + return JsonSerializer.Deserialize(json); + } } public static string MD5File(string filename) From a39ce6bf8162f7e63b245ecd0f106ea863dfb350 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Mon, 14 Nov 2022 18:07:02 +0000 Subject: [PATCH 05/24] Make rbxfpsunlocker updating more reliable (#46) depending on file timestamps suck --- Bloxstrap/Bootstrapper.cs | 5 ++++- Bloxstrap/Dialogs/Preferences.xaml | 2 +- .../Helpers/Integrations/DiscordRichPresence.cs | 1 - Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs | 12 ++++-------- Bloxstrap/Models/GithubRelease.cs | 3 +++ Bloxstrap/Models/SettingsFormat.cs | 2 ++ Bloxstrap/Program.cs | 1 - 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 883f760..96c3798 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -121,7 +121,10 @@ namespace Bloxstrap //if (Program.IsFirstRun) // Dialog.ShowSuccess($"{Program.ProjectName} has been installed"); //else - await StartRoblox(); + + Program.SettingsManager.Save(); + + await StartRoblox(); Program.Exit(); } diff --git a/Bloxstrap/Dialogs/Preferences.xaml b/Bloxstrap/Dialogs/Preferences.xaml index 2b6b4bf..09fdf82 100644 --- a/Bloxstrap/Dialogs/Preferences.xaml +++ b/Bloxstrap/Dialogs/Preferences.xaml @@ -34,7 +34,7 @@ - + diff --git a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs index 141864a..5dd97e1 100644 --- a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs @@ -71,7 +71,6 @@ namespace Bloxstrap.Helpers.Integrations ActivityMachineAddress = ""; await SetPresence(); } - } public async void MonitorGameActivity() diff --git a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs index 2139872..2507dd5 100644 --- a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs +++ b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs @@ -70,25 +70,19 @@ namespace Bloxstrap.Helpers.Integrations return; } - DateTime lastReleasePublish; - string downloadUrl; - var releaseInfo = await Utilities.GetJson($"https://api.github.com/repos/{ProjectRepository}/releases/latest"); if (releaseInfo is null || releaseInfo.Assets is null) return; - lastReleasePublish = DateTime.Parse(releaseInfo.CreatedAt); - downloadUrl = releaseInfo.Assets[0].BrowserDownloadUrl; + string downloadUrl = releaseInfo.Assets[0].BrowserDownloadUrl; Directory.CreateDirectory(folderLocation); if (File.Exists(fileLocation)) { - DateTime lastDownload = File.GetCreationTimeUtc(fileLocation); - // no new release published, return - if (lastDownload > lastReleasePublish) + if (Program.Settings.RFUVersion == releaseInfo.TagName) return; CheckIfRunning(); @@ -112,6 +106,8 @@ namespace Bloxstrap.Helpers.Integrations { await File.WriteAllTextAsync(settingsLocation, Settings); } + + Program.Settings.RFUVersion = releaseInfo.TagName; } } } diff --git a/Bloxstrap/Models/GithubRelease.cs b/Bloxstrap/Models/GithubRelease.cs index 45f9d32..fccb971 100644 --- a/Bloxstrap/Models/GithubRelease.cs +++ b/Bloxstrap/Models/GithubRelease.cs @@ -4,6 +4,9 @@ namespace Bloxstrap.Models { public class GithubRelease { + [JsonPropertyName("tag_name")] + public string TagName { get; set; } = null!; + [JsonPropertyName("name")] public string Name { get; set; } = null!; diff --git a/Bloxstrap/Models/SettingsFormat.cs b/Bloxstrap/Models/SettingsFormat.cs index 75e1b88..6ed82b2 100644 --- a/Bloxstrap/Models/SettingsFormat.cs +++ b/Bloxstrap/Models/SettingsFormat.cs @@ -19,6 +19,8 @@ namespace Bloxstrap.Models public bool RFUEnabled { get; set; } = false; public bool RFUAutoclose { get; set; } = false; + public string RFUVersion { get; set; } = ""; + public bool UseOldDeathSound { get; set; } = true; public bool UseOldMouseCursor { get; set; } = false; } diff --git a/Bloxstrap/Program.cs b/Bloxstrap/Program.cs index f8c9426..fea6524 100644 --- a/Bloxstrap/Program.cs +++ b/Bloxstrap/Program.cs @@ -132,7 +132,6 @@ namespace Bloxstrap } #endif - if (!String.IsNullOrEmpty(commandLine)) { DeployManager.Channel = Settings.Channel; From 170c6e588491c876e364fe376dff92e05cd360f8 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Mon, 14 Nov 2022 18:24:50 +0000 Subject: [PATCH 06/24] HttpClient - Use singleton and enable gzip Rework of #45 as it kept crashing on release --- Bloxstrap/Bootstrapper.cs | 8 +- Bloxstrap/Dialogs/Preferences.xaml | 2 +- Bloxstrap/Helpers/DeployManager.cs | 31 +- .../Helpers/Integrations/RbxFpsUnlocker.cs | 13 +- Bloxstrap/Helpers/RSMM/PackageManifest.cs | 7 +- Bloxstrap/Helpers/ReverseLineReader.cs | 288 ------------------ Bloxstrap/Helpers/Updater.cs | 2 +- Bloxstrap/Helpers/Utilities.cs | 9 +- Bloxstrap/Program.cs | 6 + 9 files changed, 34 insertions(+), 332 deletions(-) delete mode 100644 Bloxstrap/Helpers/ReverseLineReader.cs diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 96c3798..5db507b 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -10,6 +10,7 @@ using Bloxstrap.Dialogs.BootstrapperDialogs; using Bloxstrap.Helpers; using Bloxstrap.Helpers.Integrations; using Bloxstrap.Helpers.RSMM; +using System.Net; namespace Bloxstrap { @@ -66,8 +67,6 @@ namespace Bloxstrap "By default, two mod presets are provided for restoring the old death\n" + "sound and the old mouse cursor.\n"; - private static readonly HttpClient Client = new(); - private string? LaunchCommandLine; private string VersionGuid = null!; @@ -87,7 +86,6 @@ namespace Bloxstrap { LaunchCommandLine = launchCommandLine; FreshInstall = String.IsNullOrEmpty(Program.Settings.VersionGuid); - Client.Timeout = TimeSpan.FromMinutes(10); } // this is called from BootstrapperStyleForm.SetupDialog() @@ -133,7 +131,7 @@ namespace Bloxstrap { Dialog.Message = "Connecting to Roblox..."; - VersionGuid = await Client.GetStringAsync($"{DeployManager.BaseUrl}/version"); + VersionGuid = await Program.HttpClient.GetStringAsync($"{DeployManager.BaseUrl}/version"); VersionFolder = Path.Combine(Directories.Versions, VersionGuid); VersionPackageManifest = await PackageManifest.Get(VersionGuid); } @@ -611,7 +609,7 @@ namespace Bloxstrap { Debug.WriteLine($"Downloading {package.Name}..."); - var response = await Client.GetAsync(packageUrl); + var response = await Program.HttpClient.GetAsync(packageUrl); if (CancelFired) return; diff --git a/Bloxstrap/Dialogs/Preferences.xaml b/Bloxstrap/Dialogs/Preferences.xaml index 09fdf82..c10019a 100644 --- a/Bloxstrap/Dialogs/Preferences.xaml +++ b/Bloxstrap/Dialogs/Preferences.xaml @@ -34,7 +34,7 @@ - + diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index d794dbd..aa5241f 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -104,19 +104,16 @@ namespace Bloxstrap.Helpers string baseUrl = BuildBaseUrl(channel); string lastDeploy = ""; - using (HttpClient client = new()) + string deployHistory = await Program.HttpClient.GetStringAsync($"{baseUrl}/DeployHistory.txt"); + + using (StringReader reader = new(deployHistory)) { - string deployHistory = await client.GetStringAsync($"{baseUrl}/DeployHistory.txt"); + string? line; - using (StringReader reader = new(deployHistory)) + while ((line = await reader.ReadLineAsync()) is not null) { - string? line; - - while ((line = await reader.ReadLineAsync()) is not null) - { - if (line.Contains("WindowsPlayer")) - lastDeploy = line; - } + if (line.Contains("WindowsPlayer")) + lastDeploy = line; } } @@ -132,10 +129,10 @@ namespace Bloxstrap.Helpers lastDeploy = lastDeploy[18..]; // 'version-29fb7cdd06e84001 at 8/23/2022 2:07:27 PM, file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...' string versionGuid = lastDeploy[..lastDeploy.IndexOf(" at")]; // 'version-29fb7cdd06e84001' - + lastDeploy = lastDeploy[(versionGuid.Length + 4)..]; // '8/23/2022 2:07:27 PM, file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...' string strTimestamp = lastDeploy[..lastDeploy.IndexOf(", file")]; // '8/23/2022 2:07:27 PM' - + lastDeploy = lastDeploy[(strTimestamp.Length + 16)..]; // '0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...' string fileVersion = ""; @@ -157,11 +154,11 @@ namespace Bloxstrap.Helpers // convert to traditional version format fileVersion = fileVersion.Replace(" ", "").Replace(',', '.'); - return new VersionDeploy - { - VersionGuid = versionGuid, - Timestamp = dtTimestamp, - FileVersion = fileVersion + return new VersionDeploy + { + VersionGuid = versionGuid, + Timestamp = dtTimestamp, + FileVersion = fileVersion }; } } diff --git a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs index 2507dd5..2be5620 100644 --- a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs +++ b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs @@ -91,15 +91,12 @@ namespace Bloxstrap.Helpers.Integrations Debug.WriteLine("Installing/Updating rbxfpsunlocker..."); - using (HttpClient client = new()) - { - byte[] bytes = await client.GetByteArrayAsync(downloadUrl); + byte[] bytes = await Program.HttpClient.GetByteArrayAsync(downloadUrl); - using (MemoryStream zipStream = new(bytes)) - { - ZipArchive zip = new(zipStream); - zip.ExtractToDirectory(folderLocation, true); - } + using (MemoryStream zipStream = new(bytes)) + { + ZipArchive zip = new(zipStream); + zip.ExtractToDirectory(folderLocation, true); } if (!File.Exists(settingsLocation)) diff --git a/Bloxstrap/Helpers/RSMM/PackageManifest.cs b/Bloxstrap/Helpers/RSMM/PackageManifest.cs index bacfabd..4404809 100644 --- a/Bloxstrap/Helpers/RSMM/PackageManifest.cs +++ b/Bloxstrap/Helpers/RSMM/PackageManifest.cs @@ -75,11 +75,8 @@ namespace Bloxstrap.Helpers.RSMM string pkgManifestUrl = $"{DeployManager.BaseUrl}/{versionGuid}-rbxPkgManifest.txt"; string pkgManifestData; - using (HttpClient http = new()) - { - var getData = http.GetStringAsync(pkgManifestUrl); - pkgManifestData = await getData.ConfigureAwait(false); - } + var getData = Program.HttpClient.GetStringAsync(pkgManifestUrl); + pkgManifestData = await getData.ConfigureAwait(false); return new PackageManifest(pkgManifestData); } diff --git a/Bloxstrap/Helpers/ReverseLineReader.cs b/Bloxstrap/Helpers/ReverseLineReader.cs deleted file mode 100644 index 864e2c0..0000000 --- a/Bloxstrap/Helpers/ReverseLineReader.cs +++ /dev/null @@ -1,288 +0,0 @@ -using System.Collections; -using System.IO; -using System.Text; - -// taken from MiscUtil: https://github.com/loory/MiscUtil -// the proper usage of MiscUtil nowadays is to *not* use the library and rather copy the code you need so lol - -namespace Bloxstrap.Helpers -{ - /// - /// Takes an encoding (defaulting to UTF-8) and a function which produces a seekable stream - /// (or a filename for convenience) and yields lines from the end of the stream backwards. - /// Only single byte encodings, and UTF-8 and Unicode, are supported. The stream - /// returned by the function must be seekable. - /// - public sealed class ReverseLineReader : IEnumerable - { - /// - /// Buffer size to use by default. Classes with internal access can specify - /// a different buffer size - this is useful for testing. - /// - private const int DefaultBufferSize = 4096; - - /// - /// Means of creating a Stream to read from. - /// - private readonly Func streamSource; - - /// - /// Encoding to use when converting bytes to text - /// - private readonly Encoding encoding; - - /// - /// Size of buffer (in bytes) to read each time we read from the - /// stream. This must be at least as big as the maximum number of - /// bytes for a single character. - /// - private readonly int bufferSize; - - /// - /// Function which, when given a position within a file and a byte, states whether - /// or not the byte represents the start of a character. - /// - private Func characterStartDetector; - - /// - /// Creates a LineReader from a stream source. The delegate is only - /// called when the enumerator is fetched. UTF-8 is used to decode - /// the stream into text. - /// - /// Data source - public ReverseLineReader(Func streamSource) - : this(streamSource, Encoding.UTF8) - { - } - - /// - /// Creates a LineReader from a filename. The file is only opened - /// (or even checked for existence) when the enumerator is fetched. - /// UTF8 is used to decode the file into text. - /// - /// File to read from - public ReverseLineReader(string filename) - : this(filename, Encoding.UTF8) - { - } - - /// - /// Creates a LineReader from a filename. The file is only opened - /// (or even checked for existence) when the enumerator is fetched. - /// - /// File to read from - /// Encoding to use to decode the file into text - public ReverseLineReader(string filename, Encoding encoding) - : this(() => File.OpenRead(filename), encoding) - { - } - - /// - /// Creates a LineReader from a stream source. The delegate is only - /// called when the enumerator is fetched. - /// - /// Data source - /// Encoding to use to decode the stream into text - public ReverseLineReader(Func streamSource, Encoding encoding) - : this(streamSource, encoding, DefaultBufferSize) - { - } - - internal ReverseLineReader(Func streamSource, Encoding encoding, int bufferSize) - { - this.streamSource = streamSource; - this.encoding = encoding; - this.bufferSize = bufferSize; - if (encoding.IsSingleByte) - { - // For a single byte encoding, every byte is the start (and end) of a character - characterStartDetector = (pos, data) => true; - } - else if (encoding is UnicodeEncoding) - { - // For UTF-16, even-numbered positions are the start of a character. - // TODO: This assumes no surrogate pairs. More work required - // to handle that. - characterStartDetector = (pos, data) => (pos & 1) == 0; - } - else if (encoding is UTF8Encoding) - { - // For UTF-8, bytes with the top bit clear or the second bit set are the start of a character - // See http://www.cl.cam.ac.uk/~mgk25/unicode.html - characterStartDetector = (pos, data) => (data & 0x80) == 0 || (data & 0x40) != 0; - } - else - { - throw new ArgumentException("Only single byte, UTF-8 and Unicode encodings are permitted"); - } - } - - /// - /// Returns the enumerator reading strings backwards. If this method discovers that - /// the returned stream is either unreadable or unseekable, a NotSupportedException is thrown. - /// - public IEnumerator GetEnumerator() - { - Stream stream = streamSource(); - if (!stream.CanSeek) - { - stream.Dispose(); - throw new NotSupportedException("Unable to seek within stream"); - } - if (!stream.CanRead) - { - stream.Dispose(); - throw new NotSupportedException("Unable to read within stream"); - } - return GetEnumeratorImpl(stream); - } - - private IEnumerator GetEnumeratorImpl(Stream stream) - { - try - { - long position = stream.Length; - - if (encoding is UnicodeEncoding && (position & 1) != 0) - { - throw new InvalidDataException("UTF-16 encoding provided, but stream has odd length."); - } - - // Allow up to two bytes for data from the start of the previous - // read which didn't quite make it as full characters - byte[] buffer = new byte[bufferSize + 2]; - char[] charBuffer = new char[encoding.GetMaxCharCount(buffer.Length)]; - int leftOverData = 0; - String? previousEnd = null; - // TextReader doesn't return an empty string if there's line break at the end - // of the data. Therefore we don't return an empty string if it's our *first* - // return. - bool firstYield = true; - - // A line-feed at the start of the previous buffer means we need to swallow - // the carriage-return at the end of this buffer - hence this needs declaring - // way up here! - bool swallowCarriageReturn = false; - - while (position > 0) - { - int bytesToRead = Math.Min(position > int.MaxValue ? bufferSize : (int)position, bufferSize); - - position -= bytesToRead; - stream.Position = position; - StreamUtil.ReadExactly(stream, buffer, bytesToRead); - // If we haven't read a full buffer, but we had bytes left - // over from before, copy them to the end of the buffer - if (leftOverData > 0 && bytesToRead != bufferSize) - { - // Buffer.BlockCopy doesn't document its behaviour with respect - // to overlapping data: we *might* just have read 7 bytes instead of - // 8, and have two bytes to copy... - Array.Copy(buffer, bufferSize, buffer, bytesToRead, leftOverData); - } - // We've now *effectively* read this much data. - bytesToRead += leftOverData; - - int firstCharPosition = 0; - while (!characterStartDetector(position + firstCharPosition, buffer[firstCharPosition])) - { - firstCharPosition++; - // Bad UTF-8 sequences could trigger this. For UTF-8 we should always - // see a valid character start in every 3 bytes, and if this is the start of the file - // so we've done a short read, we should have the character start - // somewhere in the usable buffer. - if (firstCharPosition == 3 || firstCharPosition == bytesToRead) - { - throw new InvalidDataException("Invalid UTF-8 data"); - } - } - leftOverData = firstCharPosition; - - int charsRead = encoding.GetChars(buffer, firstCharPosition, bytesToRead - firstCharPosition, charBuffer, 0); - int endExclusive = charsRead; - - for (int i = charsRead - 1; i >= 0; i--) - { - char lookingAt = charBuffer[i]; - if (swallowCarriageReturn) - { - swallowCarriageReturn = false; - if (lookingAt == '\r') - { - endExclusive--; - continue; - } - } - // Anything non-line-breaking, just keep looking backwards - if (lookingAt != '\n' && lookingAt != '\r') - { - continue; - } - // End of CRLF? Swallow the preceding CR - if (lookingAt == '\n') - { - swallowCarriageReturn = true; - } - int start = i + 1; - string bufferContents = new string(charBuffer, start, endExclusive - start); - endExclusive = i; - string stringToYield = previousEnd == null ? bufferContents : bufferContents + previousEnd; - if (!firstYield || stringToYield.Length != 0) - { - yield return stringToYield; - } - firstYield = false; - previousEnd = null; - } - - previousEnd = endExclusive == 0 ? null : (new string(charBuffer, 0, endExclusive) + previousEnd); - - // If we didn't decode the start of the array, put it at the end for next time - if (leftOverData != 0) - { - Buffer.BlockCopy(buffer, 0, buffer, bufferSize, leftOverData); - } - } - if (leftOverData != 0) - { - // At the start of the final buffer, we had the end of another character. - throw new InvalidDataException("Invalid UTF-8 data at start of stream"); - } - if (firstYield && string.IsNullOrEmpty(previousEnd)) - { - yield break; - } - yield return previousEnd ?? ""; - } - finally - { - stream.Dispose(); - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } - - public static class StreamUtil - { - public static void ReadExactly(Stream input, byte[] buffer, int bytesToRead) - { - int index = 0; - while (index < bytesToRead) - { - int read = input.Read(buffer, index, bytesToRead - index); - if (read == 0) - { - throw new EndOfStreamException - (String.Format("End of stream reached with {0} byte{1} left to read.", - bytesToRead - index, - bytesToRead - index == 1 ? "s" : "")); - } - index += read; - } - } - } -} \ No newline at end of file diff --git a/Bloxstrap/Helpers/Updater.cs b/Bloxstrap/Helpers/Updater.cs index 316a898..942376a 100644 --- a/Bloxstrap/Helpers/Updater.cs +++ b/Bloxstrap/Helpers/Updater.cs @@ -42,7 +42,7 @@ namespace Bloxstrap.Helpers new Preferences().ShowDialog(); - Environment.Exit(0); + Program.Exit(); } } diff --git a/Bloxstrap/Helpers/Utilities.cs b/Bloxstrap/Helpers/Utilities.cs index 22a60d4..a37d9ad 100644 --- a/Bloxstrap/Helpers/Utilities.cs +++ b/Bloxstrap/Helpers/Utilities.cs @@ -15,13 +15,8 @@ namespace Bloxstrap.Helpers public static async Task GetJson(string url) { - using (HttpClient client = new()) - { - client.DefaultRequestHeaders.Add("User-Agent", Program.ProjectRepository); - - string json = await client.GetStringAsync(url); - return JsonSerializer.Deserialize(json); - } + string json = await Program.HttpClient.GetStringAsync(url); + return JsonSerializer.Deserialize(json); } public static string MD5File(string filename) diff --git a/Bloxstrap/Program.cs b/Bloxstrap/Program.cs index fea6524..980fc82 100644 --- a/Bloxstrap/Program.cs +++ b/Bloxstrap/Program.cs @@ -8,6 +8,8 @@ using Bloxstrap.Enums; using Bloxstrap.Helpers; using Bloxstrap.Models; using Bloxstrap.Dialogs; +using System.Net.Http; +using System.Net; namespace Bloxstrap { @@ -34,6 +36,7 @@ namespace Bloxstrap public static SettingsManager SettingsManager = new(); public static SettingsFormat Settings = SettingsManager.Settings; + public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }); // shorthand public static DialogResult ShowMessageBox(string message, MessageBoxIcon icon = MessageBoxIcon.None, MessageBoxButtons buttons = MessageBoxButtons.OK) @@ -57,6 +60,9 @@ namespace Bloxstrap // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); + HttpClient.Timeout = TimeSpan.FromMinutes(5); + HttpClient.DefaultRequestHeaders.Add("User-Agent", ProjectRepository); + LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); StartMenu = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", ProjectName); From 947993e4465b5f561ef22b236334c9e2b4e3078e Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Mon, 14 Nov 2022 18:35:01 +0000 Subject: [PATCH 07/24] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b0f3d9e..2f56045 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ An open, customizable, feature-packed alternative bootstrapper for Roblox. -This a drop-in replacement for the stock Roblox bootstrapper, working more or less how you'd expect it to, while providing additional useful features. This does not touch or modify the game client itself. It merely just serves as a launcher, so there's no risk of being banned for using this. +This a drop-in replacement for the stock Roblox bootstrapper, working more or less how you'd expect it to, while providing additional useful features. Keep in mind - this does not touch or modify the game client itself, it's just a launcher! If you encounter a bug, or would like to suggest a feature, please submit an issue! @@ -29,4 +29,4 @@ Once installed, Bloxstrap is added to your Start Menu, where you can change your * [Roblox Studio Mod Manager](https://github.com/MaximumADHD/Roblox-Studio-Mod-Manager) - 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) - Added as a Bloxstrap integration. -* [WPFDarkTheme](https://github.com/AngryCarrot789/WPFDarkTheme) - Used for making the Preferences menu. \ No newline at end of file +* [WPFDarkTheme](https://github.com/AngryCarrot789/WPFDarkTheme) - Used for making the Preferences menu. From 502cfe6605873bd6f654abfa765ecfd4976f928b Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sat, 19 Nov 2022 15:23:24 +0000 Subject: [PATCH 08/24] Add NuGet reference for DiscordRPC NuGet package for DiscordRPC has finally been updated, submodule isn't needed anymore. --- .gitmodules | 3 --- Bloxstrap.sln | 6 ------ Bloxstrap/Bloxstrap.csproj | 5 +---- Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs | 3 +-- Bloxstrap/Helpers/Updater.cs | 4 ---- DiscordRPC | 1 - 6 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 .gitmodules delete mode 160000 DiscordRPC diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index dc74b79..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "DiscordRPC"] - path = DiscordRPC - url = https://github.com/Lachee/discord-rpc-csharp.git diff --git a/Bloxstrap.sln b/Bloxstrap.sln index ec42cc7..62d830d 100644 --- a/Bloxstrap.sln +++ b/Bloxstrap.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 17.0.32014.148 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bloxstrap", "Bloxstrap\Bloxstrap.csproj", "{646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordRPC", "DiscordRPC\DiscordRPC\DiscordRPC.csproj", "{BDB66971-35FA-45BD-ABD6-70B814D2E55C}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -17,10 +15,6 @@ Global {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Debug|Any CPU.Build.0 = Debug|Any CPU {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Release|Any CPU.ActiveCfg = Release|Any CPU {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Release|Any CPU.Build.0 = Release|Any CPU - {BDB66971-35FA-45BD-ABD6-70B814D2E55C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BDB66971-35FA-45BD-ABD6-70B814D2E55C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BDB66971-35FA-45BD-ABD6-70B814D2E55C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BDB66971-35FA-45BD-ABD6-70B814D2E55C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj index 6eb15f9..1c9091f 100644 --- a/Bloxstrap/Bloxstrap.csproj +++ b/Bloxstrap/Bloxstrap.csproj @@ -19,13 +19,10 @@ + - - - - diff --git a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs index 5dd97e1..b3b59fd 100644 --- a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; using System.IO; using System.Text.RegularExpressions; diff --git a/Bloxstrap/Helpers/Updater.cs b/Bloxstrap/Helpers/Updater.cs index 942376a..1a6870a 100644 --- a/Bloxstrap/Helpers/Updater.cs +++ b/Bloxstrap/Helpers/Updater.cs @@ -1,9 +1,5 @@ using System.Diagnostics; using System.IO; -using System.Net.Http; -using System.Text.Json; - -using Newtonsoft.Json.Linq; using Bloxstrap.Models; using Bloxstrap.Dialogs; diff --git a/DiscordRPC b/DiscordRPC deleted file mode 160000 index a9fcc8d..0000000 --- a/DiscordRPC +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a9fcc8d1e85738bc6493474a62a961842fa8dbc3 From dfc73ead8eb9fa65a72c0ec38573c7c996294647 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 20 Nov 2022 10:30:41 +0000 Subject: [PATCH 09/24] Revert "Add NuGet reference for DiscordRPC" This reverts commit 502cfe6605873bd6f654abfa765ecfd4976f928b. --- .gitmodules | 3 +++ Bloxstrap.sln | 6 ++++++ Bloxstrap/Bloxstrap.csproj | 5 ++++- Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs | 3 ++- Bloxstrap/Helpers/Updater.cs | 4 ++++ DiscordRPC | 1 + 6 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 160000 DiscordRPC diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..dc74b79 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "DiscordRPC"] + path = DiscordRPC + url = https://github.com/Lachee/discord-rpc-csharp.git diff --git a/Bloxstrap.sln b/Bloxstrap.sln index 62d830d..ec42cc7 100644 --- a/Bloxstrap.sln +++ b/Bloxstrap.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.32014.148 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bloxstrap", "Bloxstrap\Bloxstrap.csproj", "{646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordRPC", "DiscordRPC\DiscordRPC\DiscordRPC.csproj", "{BDB66971-35FA-45BD-ABD6-70B814D2E55C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Debug|Any CPU.Build.0 = Debug|Any CPU {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Release|Any CPU.ActiveCfg = Release|Any CPU {646D1D58-C9CA-48C9-BBCD-30585A1DAAF1}.Release|Any CPU.Build.0 = Release|Any CPU + {BDB66971-35FA-45BD-ABD6-70B814D2E55C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BDB66971-35FA-45BD-ABD6-70B814D2E55C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BDB66971-35FA-45BD-ABD6-70B814D2E55C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BDB66971-35FA-45BD-ABD6-70B814D2E55C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj index 1c9091f..6eb15f9 100644 --- a/Bloxstrap/Bloxstrap.csproj +++ b/Bloxstrap/Bloxstrap.csproj @@ -19,10 +19,13 @@ - + + + + diff --git a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs index b3b59fd..5dd97e1 100644 --- a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.IO; using System.Text.RegularExpressions; diff --git a/Bloxstrap/Helpers/Updater.cs b/Bloxstrap/Helpers/Updater.cs index 1a6870a..942376a 100644 --- a/Bloxstrap/Helpers/Updater.cs +++ b/Bloxstrap/Helpers/Updater.cs @@ -1,5 +1,9 @@ using System.Diagnostics; using System.IO; +using System.Net.Http; +using System.Text.Json; + +using Newtonsoft.Json.Linq; using Bloxstrap.Models; using Bloxstrap.Dialogs; diff --git a/DiscordRPC b/DiscordRPC new file mode 160000 index 0000000..a9fcc8d --- /dev/null +++ b/DiscordRPC @@ -0,0 +1 @@ +Subproject commit a9fcc8d1e85738bc6493474a62a961842fa8dbc3 From 1b27bfb3514b4b7cdffe4af36ea956179a36ab89 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 20 Nov 2022 10:36:37 +0000 Subject: [PATCH 10/24] Update DiscordRPC Submodule reverted back to submodule as nuget package just throws errors... mfw --- DiscordRPC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DiscordRPC b/DiscordRPC index a9fcc8d..db3667e 160000 --- a/DiscordRPC +++ b/DiscordRPC @@ -1 +1 @@ -Subproject commit a9fcc8d1e85738bc6493474a62a961842fa8dbc3 +Subproject commit db3667e9749a82a3690539e622ff921771164af0 From 66f6cd16cd9afa3a56b17190e8db2861ea48946d Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 20 Nov 2022 10:51:36 +0000 Subject: [PATCH 11/24] Don't hide details button on rich presence (#48) --- .../Integrations/DiscordRichPresence.cs | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs index 5dd97e1..3bbf5dd 100644 --- a/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Helpers/Integrations/DiscordRichPresence.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; using System.IO; using System.Text.RegularExpressions; @@ -147,24 +146,22 @@ namespace Bloxstrap.Helpers.Integrations if (thumbnailInfo is not null) placeThumbnail = thumbnailInfo.Data![0].ImageUrl!; - DiscordRPC.Button[]? buttons = null; + List buttons = new() + { + new DiscordRPC.Button() + { + Label = "See Details", + Url = $"https://www.roblox.com/games/{ActivityPlaceId}" + } + }; if (!Program.Settings.HideRPCButtons) { - buttons = new DiscordRPC.Button[] + buttons.Insert(0, new DiscordRPC.Button() { - new DiscordRPC.Button() - { - Label = "Join", - Url = $"https://www.roblox.com/games/start?placeId={ActivityPlaceId}&gameInstanceId={ActivityJobId}&launchData=%7B%7D" - }, - - new DiscordRPC.Button() - { - Label = "See Details", - Url = $"https://www.roblox.com/games/{ActivityPlaceId}" - } - }; + Label = "Join", + Url = $"https://www.roblox.com/games/start?placeId={ActivityPlaceId}&gameInstanceId={ActivityJobId}&launchData=%7B%7D" + }); } RichPresence.SetPresence(new RichPresence() @@ -172,7 +169,7 @@ namespace Bloxstrap.Helpers.Integrations Details = placeInfo.Name, State = $"by {placeInfo.Creator.Name}", Timestamps = new Timestamps() { Start = DateTime.UtcNow }, - Buttons = buttons, + Buttons = buttons.ToArray(), Assets = new Assets() { LargeImageKey = placeThumbnail, From 92442348605ade59319080ccf248cb37ce82fef1 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 20 Nov 2022 11:16:51 +0000 Subject: [PATCH 12/24] Set uninstall version on install/update (#47) Version has also been bumped to v1.5.4 --- Bloxstrap/Bloxstrap.csproj | 4 ++-- Bloxstrap/Bootstrapper.cs | 6 +++++- Bloxstrap/Helpers/Directories.cs | 2 +- Bloxstrap/Helpers/Updater.cs | 2 ++ Bloxstrap/Program.cs | 3 +++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj index 6eb15f9..9a8e830 100644 --- a/Bloxstrap/Bloxstrap.csproj +++ b/Bloxstrap/Bloxstrap.csproj @@ -10,8 +10,8 @@ AnyCPU AnyCPU;x86 Bloxstrap.ico - 1.5.3 - 1.5.3.0 + 1.5.4 + 1.5.4.0 diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 5db507b..e2b20aa 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -284,7 +284,11 @@ namespace Bloxstrap RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{Program.ProjectName}"); uninstallKey.SetValue("DisplayIcon", $"{Directories.App},0"); uninstallKey.SetValue("DisplayName", Program.ProjectName); - uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd")); + uninstallKey.SetValue("DisplayVersion", Program.Version); + + if (uninstallKey.GetValue("InstallDate") is null) + uninstallKey.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd")); + uninstallKey.SetValue("InstallLocation", Directories.Base); uninstallKey.SetValue("NoRepair", 1); uninstallKey.SetValue("Publisher", Program.ProjectName); diff --git a/Bloxstrap/Helpers/Directories.cs b/Bloxstrap/Helpers/Directories.cs index 3d49b0f..93462e2 100644 --- a/Bloxstrap/Helpers/Directories.cs +++ b/Bloxstrap/Helpers/Directories.cs @@ -2,7 +2,7 @@ namespace Bloxstrap.Helpers { - internal class Directories + class Directories { public static string Base { get; private set; } = ""; public static string Downloads { get; private set; } = ""; diff --git a/Bloxstrap/Helpers/Updater.cs b/Bloxstrap/Helpers/Updater.cs index 942376a..a6a8695 100644 --- a/Bloxstrap/Helpers/Updater.cs +++ b/Bloxstrap/Helpers/Updater.cs @@ -34,6 +34,8 @@ namespace Bloxstrap.Helpers File.Delete(Directories.App); File.Copy(Environment.ProcessPath, Directories.App); + Bootstrapper.Register(); + Program.ShowMessageBox( $"{Program.ProjectName} has been updated to v{currentVersionInfo.ProductVersion}", MessageBoxIcon.Information, diff --git a/Bloxstrap/Program.cs b/Bloxstrap/Program.cs index 980fc82..3292d79 100644 --- a/Bloxstrap/Program.cs +++ b/Bloxstrap/Program.cs @@ -10,6 +10,7 @@ using Bloxstrap.Models; using Bloxstrap.Dialogs; using System.Net.Http; using System.Net; +using System.Reflection; namespace Bloxstrap { @@ -34,6 +35,8 @@ namespace Bloxstrap public static string LocalAppData { get; private set; } = null!; public static string StartMenu { get; private set; } = null!; + public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2]; + public static SettingsManager SettingsManager = new(); public static SettingsFormat Settings = SettingsManager.Settings; public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }); From db762429cf33f79a94de4caed02817a1789c083c Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 20 Nov 2022 14:17:50 +0000 Subject: [PATCH 13/24] Work on implementing quiet installing Just got to work on hiding the bootstrapper dialog -- might have to rework how the bootstrapper class is instantiated. --- Bloxstrap/Bootstrapper.cs | 16 ++++++++--- .../BootstrapperDialogForm.cs | 7 +++-- .../VistaDialog.Designer.cs | 2 +- .../BootstrapperDialogs/VistaDialog.cs | 15 ++++++---- Bloxstrap/Helpers/Updater.cs | 4 +-- Bloxstrap/Program.cs | 28 ++++++++++++++++--- 6 files changed, 54 insertions(+), 18 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index e2b20aa..7e8f66c 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -17,6 +17,13 @@ namespace Bloxstrap public partial class Bootstrapper { #region Properties + + // https://learn.microsoft.com/en-us/windows/win32/msi/error-codes + public const int ERROR_SUCCESS = 0; + public const int ERROR_INSTALL_USEREXIT = 1602; + public const int ERROR_INSTALL_FAILURE = 1603; + public const int ERROR_PRODUCT_UNINSTALLED = 1614; + // in case a new package is added, you can find the corresponding directory // by opening the stock bootstrapper in a hex editor // TODO - there ideally should be a less static way to do this that's not hardcoded? @@ -91,7 +98,7 @@ namespace Bloxstrap // this is called from BootstrapperStyleForm.SetupDialog() public async Task Run() { - if (LaunchCommandLine == "-uninstall") + if (Program.IsUninstall) { Uninstall(); return; @@ -122,7 +129,8 @@ namespace Bloxstrap Program.SettingsManager.Save(); - await StartRoblox(); + if (!Program.IsQuiet) + await StartRoblox(); Program.Exit(); } @@ -239,7 +247,7 @@ namespace Bloxstrap { if (!Dialog.CancelEnabled) { - Program.Exit(); + Program.Exit(ERROR_INSTALL_USEREXIT); return; } @@ -254,7 +262,7 @@ namespace Bloxstrap } catch (Exception) { } - Program.Exit(); + Program.Exit(ERROR_INSTALL_USEREXIT); } #endregion diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/BootstrapperDialogForm.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/BootstrapperDialogForm.cs index 8e28406..adac9b6 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/BootstrapperDialogForm.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/BootstrapperDialogForm.cs @@ -61,6 +61,9 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs public void SetupDialog() { + if (Program.IsQuiet) + this.Hide(); + this.Text = Program.ProjectName; this.Icon = Program.Settings.BootstrapperIcon.GetIcon(); @@ -107,7 +110,7 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs public virtual void ShowError(string message) { Program.ShowMessageBox($"An error occurred while starting Roblox\n\nDetails: {message}", MessageBoxIcon.Error); - Program.Exit(); + Program.Exit(Bootstrapper.ERROR_INSTALL_FAILURE); } public virtual void CloseDialog() @@ -127,7 +130,7 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs ); if (result != DialogResult.OK) - Environment.Exit(0); + Environment.Exit(Bootstrapper.ERROR_INSTALL_USEREXIT); } public void ButtonCancel_Click(object? sender, EventArgs e) diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.Designer.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.Designer.cs index 8f1d397..e2d27d5 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.Designer.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.Designer.cs @@ -41,7 +41,7 @@ this.ShowInTaskbar = false; this.Text = "VistaDialog"; this.WindowState = System.Windows.Forms.FormWindowState.Minimized; - this.Load += new System.EventHandler(this.TestDialog_Load); + this.Load += new System.EventHandler(this.VistaDialog_Load); this.ResumeLayout(false); } diff --git a/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.cs b/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.cs index c49a6f4..e1e8e0a 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogs/VistaDialog.cs @@ -101,7 +101,9 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs successDialog.Buttons[0].Click += (sender, e) => Program.Exit(); - Dialog.Navigate(successDialog); + if (!Program.IsQuiet) + Dialog.Navigate(successDialog); + Dialog = successDialog; } } @@ -129,9 +131,11 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs } }; - errorDialog.Buttons[0].Click += (sender, e) => Program.Exit(); + errorDialog.Buttons[0].Click += (sender, e) => Program.Exit(Bootstrapper.ERROR_INSTALL_FAILURE); + + if (!Program.IsQuiet) + Dialog.Navigate(errorDialog); - Dialog.Navigate(errorDialog); Dialog = errorDialog; } } @@ -152,9 +156,10 @@ namespace Bloxstrap.Dialogs.BootstrapperDialogs } - private void TestDialog_Load(object sender, EventArgs e) + private void VistaDialog_Load(object sender, EventArgs e) { - TaskDialog.ShowDialog(Dialog); + if (!Program.IsQuiet) + TaskDialog.ShowDialog(Dialog); } } } diff --git a/Bloxstrap/Helpers/Updater.cs b/Bloxstrap/Helpers/Updater.cs index a6a8695..c3964aa 100644 --- a/Bloxstrap/Helpers/Updater.cs +++ b/Bloxstrap/Helpers/Updater.cs @@ -53,7 +53,7 @@ namespace Bloxstrap.Helpers public static async Task Check() { - if (Environment.ProcessPath is null) + if (Environment.ProcessPath is null || Program.IsUninstall || Program.IsQuiet && Program.IsFirstRun) return; if (!Program.IsFirstRun) @@ -86,7 +86,7 @@ namespace Bloxstrap.Helpers if (result == DialogResult.Yes) { Utilities.OpenWebsite($"https://github.com/{Program.ProjectRepository}/releases/latest"); - Program.Exit(); + Program.Exit(Bootstrapper.ERROR_INSTALL_USEREXIT); } } } diff --git a/Bloxstrap/Program.cs b/Bloxstrap/Program.cs index 3292d79..2697786 100644 --- a/Bloxstrap/Program.cs +++ b/Bloxstrap/Program.cs @@ -11,6 +11,8 @@ using Bloxstrap.Dialogs; using System.Net.Http; using System.Net; using System.Reflection; +using Newtonsoft.Json.Linq; +using System; namespace Bloxstrap { @@ -31,6 +33,8 @@ namespace Bloxstrap public static string BaseDirectory = null!; public static bool IsFirstRun { get; private set; } = false; + public static bool IsQuiet { get; private set; } = false; + public static bool IsUninstall { get; private set; } = false; public static string LocalAppData { get; private set; } = null!; public static string StartMenu { get; private set; } = null!; @@ -44,13 +48,16 @@ namespace Bloxstrap // shorthand public static DialogResult ShowMessageBox(string message, MessageBoxIcon icon = MessageBoxIcon.None, MessageBoxButtons buttons = MessageBoxButtons.OK) { + if (IsQuiet) + return DialogResult.None; + return MessageBox.Show(message, ProjectName, buttons, icon); } - public static void Exit() + public static void Exit(int code = Bootstrapper.ERROR_SUCCESS) { SettingsManager.Save(); - Environment.Exit(0); + Environment.Exit(code); } /// @@ -69,14 +76,27 @@ namespace Bloxstrap LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); StartMenu = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", ProjectName); - // check if installed + if (args.Length > 0) + { + if (Array.IndexOf(args, "-quiet") != -1) + IsQuiet = true; + + if (Array.IndexOf(args, "-uninstall") != -1) + IsUninstall = true; + } + + // check if installed RegistryKey? registryKey = Registry.CurrentUser.OpenSubKey($@"Software\{ProjectName}"); if (registryKey is null) { IsFirstRun = true; Settings = SettingsManager.Settings; - new Preferences().ShowDialog(); + + if (IsQuiet) + BaseDirectory = Path.Combine(LocalAppData, ProjectName); + else + new Preferences().ShowDialog(); } else { From ecc9ec3f9fcf2bb7d140939e91f6549b78e1b828 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 20 Nov 2022 15:56:42 +0000 Subject: [PATCH 14/24] Finalize quiet launching (#47) Added two new args: -uninstall and -nolaunch --- Bloxstrap/Bootstrapper.cs | 15 +++++++++------ Bloxstrap/Program.cs | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 7e8f66c..a18d652 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -98,6 +98,9 @@ namespace Bloxstrap // this is called from BootstrapperStyleForm.SetupDialog() public async Task Run() { + if (Program.IsQuiet) + Dialog.CloseDialog(); + if (Program.IsUninstall) { Uninstall(); @@ -122,14 +125,13 @@ namespace Bloxstrap CheckInstall(); await RbxFpsUnlocker.CheckInstall(); - - //if (Program.IsFirstRun) - // Dialog.ShowSuccess($"{Program.ProjectName} has been installed"); - //else - + Program.SettingsManager.Save(); - if (!Program.IsQuiet) + + if (Program.IsFirstRun && Program.IsNoLaunch) + Dialog.ShowSuccess($"{Program.ProjectName} has successfully installed"); + else if (!Program.IsNoLaunch) await StartRoblox(); Program.Exit(); @@ -301,6 +303,7 @@ namespace Bloxstrap uninstallKey.SetValue("NoRepair", 1); uninstallKey.SetValue("Publisher", Program.ProjectName); uninstallKey.SetValue("ModifyPath", $"\"{Directories.App}\" -preferences"); + uninstallKey.SetValue("QuietUninstallString", $"\"{Directories.App}\" -uninstall -quiet"); uninstallKey.SetValue("UninstallString", $"\"{Directories.App}\" -uninstall"); uninstallKey.SetValue("URLInfoAbout", $"https://github.com/{Program.ProjectRepository}"); uninstallKey.SetValue("URLUpdateInfo", $"https://github.com/{Program.ProjectRepository}/releases/latest"); diff --git a/Bloxstrap/Program.cs b/Bloxstrap/Program.cs index 2697786..0ed51b6 100644 --- a/Bloxstrap/Program.cs +++ b/Bloxstrap/Program.cs @@ -35,6 +35,7 @@ namespace Bloxstrap public static bool IsFirstRun { get; private set; } = false; public static bool IsQuiet { get; private set; } = false; public static bool IsUninstall { get; private set; } = false; + public static bool IsNoLaunch { get; private set; } = false; public static string LocalAppData { get; private set; } = null!; public static string StartMenu { get; private set; } = null!; @@ -83,6 +84,9 @@ namespace Bloxstrap if (Array.IndexOf(args, "-uninstall") != -1) IsUninstall = true; + + if (Array.IndexOf(args, "-nolaunch") != -1) + IsNoLaunch = true; } // check if installed From 18f46cdad5ec39f4b10f479525cb9053a14ed6c0 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 20 Nov 2022 16:00:23 +0000 Subject: [PATCH 15/24] Update publisher info --- Bloxstrap/Bootstrapper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index a18d652..22656b7 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -301,7 +301,7 @@ namespace Bloxstrap uninstallKey.SetValue("InstallLocation", Directories.Base); uninstallKey.SetValue("NoRepair", 1); - uninstallKey.SetValue("Publisher", Program.ProjectName); + uninstallKey.SetValue("Publisher", "pizzaboxer"); uninstallKey.SetValue("ModifyPath", $"\"{Directories.App}\" -preferences"); uninstallKey.SetValue("QuietUninstallString", $"\"{Directories.App}\" -uninstall -quiet"); uninstallKey.SetValue("UninstallString", $"\"{Directories.App}\" -uninstall"); From a58bdd4abcade09a6d2df240af0a9fe56a2cbe74 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 20 Nov 2022 16:08:50 +0000 Subject: [PATCH 16/24] Fix uninstallation returning wrong exit code --- Bloxstrap/Bootstrapper.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 22656b7..dca4083 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -385,6 +385,8 @@ namespace Bloxstrap catch (Exception) { } Dialog.ShowSuccess($"{Program.ProjectName} has been uninstalled"); + + Environment.Exit(ERROR_PRODUCT_UNINSTALLED); } #endregion From 168e20afb1e81ed9169a9ef1c5de8deb58f68b54 Mon Sep 17 00:00:00 2001 From: Ryan Caezar Itang Date: Mon, 21 Nov 2022 14:34:07 +0800 Subject: [PATCH 17/24] Add dependabot and build workflow --- .github/dependabot.yml | 14 ++++++++++++++ .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..44fbb83 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "nuget" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "gitsubmodule" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2aed9ed --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + strategy: + matrix: + configuration: [Debug, Release] + platform: [x64, x86] + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: actions/setup-dotnet@v3 + with: + dotnet-version: '6.x' + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Publish + run: dotnet publish -p:PublishSingleFile=true -r win-${{ matrix.platform }} -c ${{ matrix.configuration }} --self-contained false .\Bloxstrap\Bloxstrap.csproj + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: Bloxstrap (${{ matrix.configuration }}, ${{ matrix.platform }}) + path: | + .\Bloxstrap\bin\${{ matrix.configuration }}\net6.0-windows\win-${{ matrix.platform }}\publish\* \ No newline at end of file From 40d764236ec71b23df88afe078dbb4c038c0be98 Mon Sep 17 00:00:00 2001 From: Ryan Caezar Itang Date: Mon, 21 Nov 2022 15:02:44 +0800 Subject: [PATCH 18/24] Add release job --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2aed9ed..102d14a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,10 @@ name: CI on: push: - branches: [ main ] + tags: + - 'v*' + branches: + - main pull_request: branches: [ main ] @@ -31,4 +34,33 @@ jobs: with: name: Bloxstrap (${{ matrix.configuration }}, ${{ matrix.platform }}) path: | - .\Bloxstrap\bin\${{ matrix.configuration }}\net6.0-windows\win-${{ matrix.platform }}\publish\* \ No newline at end of file + .\Bloxstrap\bin\${{ matrix.configuration }}\net6.0-windows\win-${{ matrix.platform }}\publish\* + + release: + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Download x64 release artifact + uses: actions/download-artifact@v3 + with: + name: Bloxstrap (Release, x64) + path: x64 + - name: Download x86 release artifact + uses: actions/download-artifact@v3 + with: + name: Bloxstrap (Release, x86) + path: x86 + - name: Rename binaries + run: | + mv x64/Bloxstrap.exe Bloxstrap-${{ github.ref_name }}-x64.exe + mv x86/Bloxstrap.exe Bloxstrap-${{ github.ref_name }}-x86.exe + - name: Release + uses: softprops/action-gh-release@v1 + with: + draft: true + files: | + Bloxstrap-${{ github.ref_name }}-x64.exe + Bloxstrap-${{ github.ref_name }}-x86.exe + name: Bloxstrap ${{ github.ref_name }} From e77f8c1c65527c4e3e6fb2f94292632969f6d9c1 Mon Sep 17 00:00:00 2001 From: Matthew Brown <97983689+bluepilledgreat@users.noreply.github.com> Date: Thu, 24 Nov 2022 18:22:18 +0000 Subject: [PATCH 19/24] use clientsettings to fetch version --- Bloxstrap/Bootstrapper.cs | 4 +- Bloxstrap/Dialogs/Preferences.xaml.cs | 6 +- Bloxstrap/Helpers/DeployManager.cs | 80 ++++++++------------------- Bloxstrap/Models/ClientVersion.cs | 18 ++++++ Bloxstrap/Models/VersionDeploy.cs | 15 ----- 5 files changed, 48 insertions(+), 75 deletions(-) create mode 100644 Bloxstrap/Models/ClientVersion.cs delete mode 100644 Bloxstrap/Models/VersionDeploy.cs diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 5db507b..4be7785 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -10,6 +10,7 @@ using Bloxstrap.Dialogs.BootstrapperDialogs; using Bloxstrap.Helpers; using Bloxstrap.Helpers.Integrations; using Bloxstrap.Helpers.RSMM; +using Bloxstrap.Models; using System.Net; namespace Bloxstrap @@ -131,7 +132,8 @@ namespace Bloxstrap { Dialog.Message = "Connecting to Roblox..."; - VersionGuid = await Program.HttpClient.GetStringAsync($"{DeployManager.BaseUrl}/version"); + ClientVersion clientVersion = await DeployManager.GetLastDeploy(Program.Settings.Channel); + VersionGuid = clientVersion.VersionGuid; VersionFolder = Path.Combine(Directories.Versions, VersionGuid); VersionPackageManifest = await PackageManifest.Get(VersionGuid); } diff --git a/Bloxstrap/Dialogs/Preferences.xaml.cs b/Bloxstrap/Dialogs/Preferences.xaml.cs index 3758696..c522001 100644 --- a/Bloxstrap/Dialogs/Preferences.xaml.cs +++ b/Bloxstrap/Dialogs/Preferences.xaml.cs @@ -343,10 +343,10 @@ namespace Bloxstrap.Dialogs { ChannelInfo = "Getting latest version info, please wait...\n"; - VersionDeploy info = await DeployManager.GetLastDeploy(channel); - string strTimestamp = info.Timestamp.ToString("MM/dd/yyyy h:mm:ss tt", Program.CultureFormat); + ClientVersion info = await DeployManager.GetLastDeploy(channel, true); + string? strTimestamp = info.Timestamp?.ToString("MM/dd/yyyy h:mm:ss tt", Program.CultureFormat); - ChannelInfo = $"Version: v{info.FileVersion} ({info.VersionGuid})\nDeployed: {strTimestamp}"; + ChannelInfo = $"Version: v{info.Version} ({info.VersionGuid})\nDeployed: {strTimestamp}"; } } } diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index aa5241f..eb4a2ae 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -1,6 +1,5 @@ -using System.IO; -using System.Net.Http; - +using System.Net.Http; +using System.Text.Json; using Bloxstrap.Models; namespace Bloxstrap.Helpers @@ -99,67 +98,36 @@ namespace Bloxstrap.Helpers return $"{DefaultBaseUrl}/channel/{channel.ToLower()}"; } - public static async Task GetLastDeploy(string channel) + public static async Task GetLastDeploy(string channel, bool timestamp = false) { - string baseUrl = BuildBaseUrl(channel); - string lastDeploy = ""; + HttpResponseMessage deployInfoResponse = await Program.HttpClient.GetAsync($"https://clientsettings.roblox.com/v2/client-version/WindowsPlayer/channel/{channel}"); - string deployHistory = await Program.HttpClient.GetStringAsync($"{baseUrl}/DeployHistory.txt"); - - using (StringReader reader = new(deployHistory)) + if (!deployInfoResponse.IsSuccessStatusCode) { - string? line; + // 400 = Invalid binaryType. + // 404 = Could not find version details for binaryType. + // 500 = Error while fetching version information. + // either way, we throw + throw new Exception($"Could not get latest deploy for channel {channel}"); + } - while ((line = await reader.ReadLineAsync()) is not null) + string rawJson = await deployInfoResponse.Content.ReadAsStringAsync(); + ClientVersion clientVersion = JsonSerializer.Deserialize(rawJson)!; + + // for preferences + if (timestamp) + { + string channelUrl = BuildBaseUrl(channel); + + HttpResponseMessage pkgMessage = await Program.HttpClient.GetAsync($"{channelUrl}/{clientVersion.VersionGuid}-rbxPkgManifest.txt"); + if (pkgMessage.Content.Headers.TryGetValues("last-modified", out var values)) { - if (line.Contains("WindowsPlayer")) - lastDeploy = line; + string lastModified = values.First(); + clientVersion.Timestamp = DateTime.Parse(lastModified); } } - if (String.IsNullOrEmpty(lastDeploy)) - throw new Exception($"Could not get latest deploy for channel {channel}"); - - // here's to hoping roblox doesn't change their deployment entry format - // (last time they did so was may 2021 so we should be fine?) - // example entry: 'New WindowsPlayer version-29fb7cdd06e84001 at 8/23/2022 2:07:27 PM, file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...' - - // there's a proper way, and then there's the lazy way - // this here is the lazy way but it should just work™ - - lastDeploy = lastDeploy[18..]; // 'version-29fb7cdd06e84001 at 8/23/2022 2:07:27 PM, file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...' - string versionGuid = lastDeploy[..lastDeploy.IndexOf(" at")]; // 'version-29fb7cdd06e84001' - - lastDeploy = lastDeploy[(versionGuid.Length + 4)..]; // '8/23/2022 2:07:27 PM, file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...' - string strTimestamp = lastDeploy[..lastDeploy.IndexOf(", file")]; // '8/23/2022 2:07:27 PM' - - lastDeploy = lastDeploy[(strTimestamp.Length + 16)..]; // '0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...' - string fileVersion = ""; - - if (lastDeploy.Contains("git hash")) - { - // ~may 2021 entry: ends like 'file version: 0, 542, 100, 5420251, git hash: b98d6b2bea36fa2161f48cca979fb620bb0c24fd ...' - fileVersion = lastDeploy[..lastDeploy.IndexOf(", git")]; // '0, 542, 100, 5420251' - } - else - { - // pre-may 2021 entry: ends like 'file version: 0, 448, 0, 411122...' - fileVersion = lastDeploy[..lastDeploy.IndexOf("...")]; // '0, 448, 0, 411122' - } - - // deployment timestamps are UTC-5 - strTimestamp += " -05"; - DateTime dtTimestamp = DateTime.ParseExact(strTimestamp, "M/d/yyyy h:mm:ss tt zz", Program.CultureFormat).ToLocalTime(); - - // convert to traditional version format - fileVersion = fileVersion.Replace(" ", "").Replace(',', '.'); - - return new VersionDeploy - { - VersionGuid = versionGuid, - Timestamp = dtTimestamp, - FileVersion = fileVersion - }; + return clientVersion; } } } diff --git a/Bloxstrap/Models/ClientVersion.cs b/Bloxstrap/Models/ClientVersion.cs new file mode 100644 index 0000000..ee7c422 --- /dev/null +++ b/Bloxstrap/Models/ClientVersion.cs @@ -0,0 +1,18 @@ +using System.Text.Json.Serialization; + +namespace Bloxstrap.Models +{ + public class ClientVersion + { + [JsonPropertyName("version")] + public string Version { get; set; } = null!; + + [JsonPropertyName("clientVersionUpload")] + public string VersionGuid { get; set; } = null!; + + [JsonPropertyName("bootstrapperVersion")] + public string BootstrapperVersion { get; set; } = null!; + + public DateTime? Timestamp { get; set; } + } +} diff --git a/Bloxstrap/Models/VersionDeploy.cs b/Bloxstrap/Models/VersionDeploy.cs deleted file mode 100644 index 8ab7d04..0000000 --- a/Bloxstrap/Models/VersionDeploy.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Bloxstrap.Models -{ - public class VersionDeploy - { - public string VersionGuid { get; set; } = null!; - public string FileVersion { get; set; } = null!; - public DateTime Timestamp { get; set; } - } -} From b82129af00306dc10249b24c02ab163f6e6123cb Mon Sep 17 00:00:00 2001 From: Matthew Brown <97983689+bluepilledgreat@users.noreply.github.com> Date: Sat, 26 Nov 2022 17:19:10 +0000 Subject: [PATCH 20/24] add comment --- Bloxstrap/Helpers/DeployManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index eb4a2ae..d23ae09 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -119,8 +119,9 @@ namespace Bloxstrap.Helpers { string channelUrl = BuildBaseUrl(channel); - HttpResponseMessage pkgMessage = await Program.HttpClient.GetAsync($"{channelUrl}/{clientVersion.VersionGuid}-rbxPkgManifest.txt"); - if (pkgMessage.Content.Headers.TryGetValues("last-modified", out var values)) + // get an approximate deploy time from rbxpkgmanifest's last modified date + HttpResponseMessage pkgResponse = await Program.HttpClient.GetAsync($"{channelUrl}/{clientVersion.VersionGuid}-rbxPkgManifest.txt"); + if (pkgResponse.Content.Headers.TryGetValues("last-modified", out var values)) { string lastModified = values.First(); clientVersion.Timestamp = DateTime.Parse(lastModified); From 9df34c785eb1a07f7b22b58e438e36be39a6ffc9 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sat, 3 Dec 2022 17:40:34 +0000 Subject: [PATCH 21/24] Update README.md Add workflow status badge and elaborate on features --- README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2f56045..6bee4f4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # 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) +![License](https://img.shields.io/github/license/pizzaboxer/bloxstrap) +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/pizzaboxer/bloxstrap/CI) +![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. +An open-source, feature-packed alternative bootstrapper for Roblox. This a drop-in replacement for the stock Roblox bootstrapper, working more or less how you'd expect it to, while providing additional useful features. Keep in mind - this does not touch or modify the game client itself, it's just a launcher! @@ -12,9 +15,11 @@ 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 (e.g. re-adding the old death sound) -* Gives you the ability to opt-in to pre-release testing channels -* Integration with Discord Rich Presence and [rbxfpsunlocker](https://github.com/axstin/rbxfpsunlocker) +* A customizable launcher (including dark theme!) +* Persistent file modifications (re-adds the old death sound!) +* Support for opting in to pre-release testing channels +* Painless Discord Rich Presence support +* Support for silent automatic FPS unlocking with [rbxfpsunlocker](https://github.com/axstin/rbxfpsunlocker) ## 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! @@ -26,7 +31,7 @@ It's not unlikely that Windows Smartscreen will show a popup when you run Bloxst 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) - some slightly modified utility code was borrowed to help with Bloxstrap's bootstrapper functionality (Bloxstrap.Helpers.RSMM). Besides, it's a great project. +* [Roblox Studio Mod Manager](https://github.com/MaximumADHD/Roblox-Studio-Mod-Manager) - some utilities was borrowed to help with Bloxstrap's bootstrapper functionality. Besides, it's a great project. * [skulyire](https://www.roblox.com/users/2485612194/profile) - Making the Bloxstrap logo. -* [rbxfpsunlocker](https://github.com/axstin/rbxfpsunlocker) - Added as a Bloxstrap integration. +* [rbxfpsunlocker](https://github.com/axstin/rbxfpsunlocker) - Used for Bloxstrap's FPS unlocking. * [WPFDarkTheme](https://github.com/AngryCarrot789/WPFDarkTheme) - Used for making the Preferences menu. From 3dde0c898c29d342220c1f099f9f74749f100be5 Mon Sep 17 00:00:00 2001 From: Matthew Brown <97983689+bluepilledgreat@users.noreply.github.com> Date: Sun, 4 Dec 2022 09:38:40 +0000 Subject: [PATCH 22/24] update channels less confusing for new users --- Bloxstrap/Helpers/DeployManager.cs | 46 ++---------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index d23ae09..5d93058 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -19,12 +19,10 @@ namespace Bloxstrap.Helpers "LIVE", "ZAvatarTeam", "ZCanary", - //"ZFeatureHarmony", last updated 9/20, shouldn't be here anymore "ZFlag", "ZIntegration", "ZLive", "ZNext", - //"ZPublic", "ZSocialTeam" }; @@ -32,61 +30,21 @@ namespace Bloxstrap.Helpers public static readonly List ChannelsAll = new List() { "LIVE", - "Ganesh", "ZAvatarTeam", - "ZBugFixBoost-Mutex-Revert", - "ZBugFixCLI-54676-Test", - "ZBugFixCLI-55214-Master", + "ZAvatarRelease", "ZCanary", "ZCanary1", "ZCanary2", "ZCanaryApps", - "ZClientIntegration", - "ZClientWatcher", - "ZFeatureBaseline", - "ZFeatureBoost_Removal_Test_In_Prod", - "ZFeatureFMOD-20115", - "ZFeatureFMOD-Recording-Test", - "ZFeatureHarmony", - "ZFeatureHSR2CDNPlayTest", - "ZFeatureHSR2CDNPlayTest2", - "ZFeatureInstance-Parent-Weak-Ptr", - "ZFeatureInstance-Parent-Weak-Ptr-2", - "ZFeatureLTCG1", - "ZFeatureLuaIInline1", - "ZFeatureQt5.15", - "ZFeatureRail", - "ZFeatureRetchecksV2", - "ZFeatureSubsystemAtomic", - "ZFeatureSubsystemHttpClient", - "ZFeatureTelemLife", - "ZFeatureUse-New-RapidJson-In-Flag-Loading", "ZFlag", "ZIntegration", "ZIntegration1", - "ZLang", "ZLive", "ZLive1", - "ZLoom", "ZNext", - "ZProject512-Boost-Remove-Mutex-1", - "ZProject516-Boost-Remove-Mutex-Network", - "ZPublic", - "ZQtitanStudio", - "ZQTitanStudioRelease", - "ZReleaseVS2019", "ZSocialTeam", - "ZStIntegration", "ZStudioInt1", - "ZStudioInt2", - "ZStudioInt3", - "ZStudioInt4", - "ZStudioInt5", - "ZStudioInt6", - "ZStudioInt7", - "ZStudioInt8", - "ZTesting", - "ZVS2019" + "ZStudioInt2" }; #endregion From 59a9c6de0e3574f6b2b248ccee617ff45bd2b0b0 Mon Sep 17 00:00:00 2001 From: Matthew Brown <97983689+bluepilledgreat@users.noreply.github.com> Date: Sun, 4 Dec 2022 09:41:49 +0000 Subject: [PATCH 23/24] update abstracted channels list --- Bloxstrap/Helpers/DeployManager.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index 5d93058..df7f23c 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -17,13 +17,9 @@ namespace Bloxstrap.Helpers public static readonly List ChannelsAbstracted = new List() { "LIVE", - "ZAvatarTeam", - "ZCanary", - "ZFlag", - "ZIntegration", - "ZLive", "ZNext", - "ZSocialTeam" + "ZCanary", + "ZIntegration" }; // why not? From 8adde37725ab8a53a3d29474f5b307a77e297ba3 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Mon, 19 Dec 2022 09:16:12 +0000 Subject: [PATCH 24/24] Fix workflow badge in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6bee4f4..8d41f90 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Bloxstrap ![License](https://img.shields.io/github/license/pizzaboxer/bloxstrap) -![GitHub Workflow Status](https://img.shields.io/github/workflow/status/pizzaboxer/bloxstrap/CI) +![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/pizzaboxer/bloxstrap/ci.yml?branch=main) ![Downloads](https://img.shields.io/github/downloads/pizzaboxer/bloxstrap/total) ![Star](https://img.shields.io/github/stars/pizzaboxer/bloxstrap?style=social)