From 580173d31c457ae99f1faf9a5eb3d3f3df656297 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 26 Apr 2023 13:37:35 +0100 Subject: [PATCH] Check if preferred channel is still being updated --- Bloxstrap/App.xaml.cs | 5 +- Bloxstrap/Helpers/DeployManager.cs | 80 ++++++++++++++++++++++++------ Bloxstrap/Integrations/ReShade.cs | 31 ------------ 3 files changed, 68 insertions(+), 48 deletions(-) diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 221abeb..fb79aa2 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -262,9 +262,8 @@ namespace Bloxstrap ShouldSaveConfigs = true; DeployManager.Channel = Settings.Prop.Channel; - - if (Settings.Prop.UseReShade) - ReShade.CheckRobloxReleaseChannel().Wait(); + + DeployManager.CheckReleaseChannel().Wait(); // start bootstrapper and show the bootstrapper modal if we're not running silently Logger.WriteLine($"[App::OnStartup] Initializing bootstrapper"); diff --git a/Bloxstrap/Helpers/DeployManager.cs b/Bloxstrap/Helpers/DeployManager.cs index 0795738..70e1eef 100644 --- a/Bloxstrap/Helpers/DeployManager.cs +++ b/Bloxstrap/Helpers/DeployManager.cs @@ -4,30 +4,20 @@ using System.Linq; using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; +using System.Windows; using Bloxstrap.Models; -using DiscordRPC; namespace Bloxstrap.Helpers { + // TODO - make this functional and into a helper instead of a singleton, this really doesn't need to be OOP + public class DeployManager { #region Properties public const string DefaultChannel = "LIVE"; - private string _channel = DefaultChannel; - - public string Channel - { - get => _channel; - set - { - if (_channel != value) - App.Logger.WriteLine($"[DeployManager::SetChannel] Changed channel to {value}"); - - _channel = value; - } - } + public string Channel = DefaultChannel; // a list of roblox delpoyment locations that we check for, in case one of them don't work private List BaseUrls = new() @@ -138,5 +128,67 @@ namespace Bloxstrap.Helpers return clientVersion; } + + public async Task CheckReleaseChannel() + { + App.Logger.WriteLine($"[DeployManager::CheckReleaseChannel] Checking current Roblox release channel ({App.Settings.Prop.Channel})..."); + + if (App.Settings.Prop.Channel.ToLower() == DefaultChannel.ToLower()) + { + App.Logger.WriteLine($"[DeployManager::CheckReleaseChannel] Channel is already {DefaultChannel}"); + return; + } + + ClientVersion versionInfo = await App.DeployManager.GetLastDeploy().ConfigureAwait(false); + + if (App.Settings.Prop.UseReShade) + { + string manifest = await App.HttpClient.GetStringAsync($"{App.DeployManager.BaseUrl}/{versionInfo.VersionGuid}-rbxManifest.txt"); + + if (manifest.Contains("RobloxPlayerBeta.dll")) + { + MessageBoxResult result = !App.Settings.Prop.PromptChannelChange ? MessageBoxResult.Yes : App.ShowMessageBox( + $"You currently have ReShade enabled, however your current preferred channel ({App.Settings.Prop.Channel}) does not support ReShade. Would you like to switch to {DefaultChannel}? ", + MessageBoxImage.Question, + MessageBoxButton.YesNo + ); + + if (result == MessageBoxResult.Yes) + { + SwitchToDefault(); + return; + } + } + } + + // this SUCKS + ClientVersion defaultChannelInfo = await new DeployManager().GetLastDeploy().ConfigureAwait(false); + int defaultChannelVersion = Int32.Parse(defaultChannelInfo.Version.Split('.')[1]); + int currentChannelVersion = Int32.Parse(versionInfo.Version.Split('.')[1]); + + if (currentChannelVersion < defaultChannelVersion) + { + MessageBoxResult result = !App.Settings.Prop.PromptChannelChange ? MessageBoxResult.Yes : App.ShowMessageBox( + $"Your current preferred channel ({App.Settings.Prop.Channel}) appears to no longer be receiving updates. Would you like to switch to {DefaultChannel}? ", + MessageBoxImage.Question, + MessageBoxButton.YesNo + ); + + if (result == MessageBoxResult.Yes) + { + SwitchToDefault(); + return; + } + } + } + + public static void SwitchToDefault() + { + if (App.Settings.Prop.Channel.ToLower() == DefaultChannel.ToLower()) + return; + + App.DeployManager.Channel = App.Settings.Prop.Channel = DefaultChannel; + App.Logger.WriteLine($"[DeployManager::CheckReleaseChannel] Changed Roblox release channel from {App.Settings.Prop.Channel} to {DefaultChannel}"); + } } } diff --git a/Bloxstrap/Integrations/ReShade.cs b/Bloxstrap/Integrations/ReShade.cs index 0b71900..ee409b9 100644 --- a/Bloxstrap/Integrations/ReShade.cs +++ b/Bloxstrap/Integrations/ReShade.cs @@ -5,7 +5,6 @@ using System.IO; using System.IO.Compression; using System.Linq; using System.Threading.Tasks; -using System.Windows; using Bloxstrap.Helpers; using Bloxstrap.Models; @@ -500,35 +499,5 @@ namespace Bloxstrap.Integrations SynchronizeConfigFile(); } - - public static async Task CheckRobloxReleaseChannel() - { - App.Logger.WriteLine($"[ReShade::CheckRobloxReleaseChannel] Checking current Roblox release channel ({App.Settings.Prop.Channel})..."); - - if (App.Settings.Prop.Channel.ToLower() == DeployManager.DefaultChannel.ToLower()) - { - App.Logger.WriteLine($"[App::OnStartup] Channel is already {DeployManager.DefaultChannel}"); - return; - } - - ClientVersion versionInfo = await App.DeployManager.GetLastDeploy().ConfigureAwait(false); - string manifest = await App.HttpClient.GetStringAsync($"{App.DeployManager.BaseUrl}/{versionInfo.VersionGuid}-rbxManifest.txt"); - - if (!manifest.Contains("RobloxPlayerBeta.dll")) - return; - - MessageBoxResult result = !App.Settings.Prop.PromptChannelChange ? MessageBoxResult.Yes : App.ShowMessageBox( - $"You currently have ReShade enabled, however your current preferred channel ({App.Settings.Prop.Channel}) does not support ReShade. Would you like to switch to {DeployManager.DefaultChannel}? ", - MessageBoxImage.Question, - MessageBoxButton.YesNo - ); - - if (result != MessageBoxResult.Yes) - return; - - App.Logger.WriteLine($"[App::OnStartup] Changed Roblox build channel from {App.Settings.Prop.Channel} to {DeployManager.DefaultChannel}"); - App.DeployManager.Channel = App.Settings.Prop.Channel = DeployManager.DefaultChannel; - } - } }