From f00de2bc2efd0e66521fd02f560f99e746e36a97 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Tue, 1 Aug 2023 14:16:11 +0100 Subject: [PATCH] Make dialogs for connection errors more friendly --- Bloxstrap/App.xaml.cs | 13 +++--- Bloxstrap/Bootstrapper.cs | 20 ++++++++- Bloxstrap/GlobalUsings.cs | 1 + Bloxstrap/RobloxDeployment.cs | 4 +- Bloxstrap/UI/Controls.cs | 8 ++++ .../Elements/Dialogs/ConnectivityDialog.xaml | 44 +++++++++++++++++++ .../Dialogs/ConnectivityDialog.xaml.cs | 42 ++++++++++++++++++ .../UI/ViewModels/Menu/BehaviourViewModel.cs | 4 +- 8 files changed, 120 insertions(+), 16 deletions(-) create mode 100644 Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml create mode 100644 Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 1d85017..f2b9421 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -165,16 +165,13 @@ namespace Bloxstrap if (ex.GetType() == typeof(AggregateException)) ex = ex.InnerException!; - Controls.ShowMessageBox( - "Bloxstrap is unable to connect to the internet. Please check your network configuration and try again.\n" + - "\n" + - "More information:\n" + - ex.Message, - MessageBoxImage.Error, - MessageBoxButton.OK + Controls.ShowConnectivityDialog( + "the internet", + $"Something may be preventing {ProjectName} from connecting to the internet, or you are currently offline. Please check and try again.", + ex ); - Terminate(); + Terminate(ErrorCode.ERROR_CANCELLED); } } diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index ce8f537..85eaaf2 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -4,7 +4,6 @@ using System.Windows.Forms; using Microsoft.Win32; using Bloxstrap.Integrations; -using System; namespace Bloxstrap { @@ -190,7 +189,24 @@ namespace Bloxstrap { SetStatus("Connecting to Roblox..."); - ClientVersion clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel); + ClientVersion clientVersion; + + try + { + clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel); + } + catch (Exception ex) + { + string message = "It's possible that Roblox is being blocked by a firewall. Please check and try again."; + + if (ex.GetType() == typeof(HttpResponseException)) + message = "Roblox may be down right now. See status.roblox.com for more information. Please try again later."; + + Controls.ShowConnectivityDialog("Roblox", message, ex); + + App.Terminate(ErrorCode.ERROR_CANCELLED); + return; + } if (clientVersion.IsBehindDefaultChannel) { diff --git a/Bloxstrap/GlobalUsings.cs b/Bloxstrap/GlobalUsings.cs index e66b091..105c8d9 100644 --- a/Bloxstrap/GlobalUsings.cs +++ b/Bloxstrap/GlobalUsings.cs @@ -15,6 +15,7 @@ global using System.Threading; global using System.Threading.Tasks; global using Bloxstrap.Enums; +global using Bloxstrap.Exceptions; global using Bloxstrap.Extensions; global using Bloxstrap.Models; global using Bloxstrap.Models.BloxstrapRPC; diff --git a/Bloxstrap/RobloxDeployment.cs b/Bloxstrap/RobloxDeployment.cs index 70efe89..30267d2 100644 --- a/Bloxstrap/RobloxDeployment.cs +++ b/Bloxstrap/RobloxDeployment.cs @@ -1,6 +1,4 @@ -using Bloxstrap.Exceptions; - -namespace Bloxstrap +namespace Bloxstrap { public static class RobloxDeployment { diff --git a/Bloxstrap/UI/Controls.cs b/Bloxstrap/UI/Controls.cs index bb42bfe..74786b1 100644 --- a/Bloxstrap/UI/Controls.cs +++ b/Bloxstrap/UI/Controls.cs @@ -39,6 +39,14 @@ namespace Bloxstrap.UI }); } + public static void ShowConnectivityDialog(string targetName, string description, Exception exception) + { + Application.Current.Dispatcher.Invoke(() => + { + new ConnectivityDialog(targetName, description, exception).ShowDialog(); + }); + } + public static IBootstrapperDialog GetBootstrapperDialog(BootstrapperStyle style) { return style switch diff --git a/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml new file mode 100644 index 0000000..9a9f464 --- /dev/null +++ b/Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +