Check if preferred channel is still being updated

This commit is contained in:
pizzaboxer 2023-04-26 13:37:35 +01:00
parent 8a250391d0
commit 580173d31c
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
3 changed files with 68 additions and 48 deletions

View File

@ -263,8 +263,7 @@ namespace Bloxstrap
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");

View File

@ -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<string> 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}");
}
}
}

View File

@ -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;
}
}
}