mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-18 16:41:36 -07:00
Make dialogs for connection errors more friendly
This commit is contained in:
parent
bca6e3d21b
commit
f00de2bc2e
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -1,6 +1,4 @@
|
||||
using Bloxstrap.Exceptions;
|
||||
|
||||
namespace Bloxstrap
|
||||
namespace Bloxstrap
|
||||
{
|
||||
public static class RobloxDeployment
|
||||
{
|
||||
|
@ -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
|
||||
|
44
Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml
Normal file
44
Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml
Normal file
@ -0,0 +1,44 @@
|
||||
<ui:UiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.ConnectivityDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs"
|
||||
mc:Ignorable="d"
|
||||
Width="480"
|
||||
MinHeight="0"
|
||||
SizeToContent="Height"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ui:TitleBar Grid.Row="0" Grid.ColumnSpan="2" Padding="8" x:Name="RootTitleBar" ShowMinimize="False" ShowMaximize="False" CanMaximize="False" KeyboardNavigation.TabNavigation="None" Title="Connectivity error" />
|
||||
|
||||
<Grid Grid.Row="1" Margin="16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Grid.Column="0" Width="32" Height="32" Margin="0,0,15,0" VerticalAlignment="Top" RenderOptions.BitmapScalingMode="HighQuality" Source="pack://application:,,,/Resources/MessageBox/Error.png" />
|
||||
<StackPanel Grid.Column="1">
|
||||
<TextBlock x:Name="TitleTextBlock" Text="? is unable to connect to ?" FontSize="18" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
|
||||
<TextBlock x:Name="DescriptionTextBlock" Text="?" Margin="0,16,0,0" TextWrapping="Wrap" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
|
||||
<TextBlock Text="More information:" Margin="0,16,0,0" TextWrapping="Wrap" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
|
||||
<RichTextBox x:Name="ErrorRichTextBox" Padding="8" Margin="0,8,0,0" Block.LineHeight="2" FontFamily="Courier New" IsReadOnly="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="2" Padding="15" Background="{ui:ThemeResource SolidBackgroundFillColorSecondaryBrush}">
|
||||
<StackPanel Orientation="Horizontal" FlowDirection="LeftToRight" HorizontalAlignment="Right">
|
||||
<Button x:Name="CloseButton" MinWidth="100" Content="Close" Margin="12,0,0,0" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ui:UiWindow>
|
42
Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs
Normal file
42
Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System.Media;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace Bloxstrap.UI.Elements.Dialogs
|
||||
{
|
||||
// hmm... do i use MVVM for this?
|
||||
// this is entirely static, so i think im fine without it, and this way is just so much more efficient
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for ExceptionDialog.xaml
|
||||
/// </summary>
|
||||
public partial class ConnectivityDialog
|
||||
{
|
||||
public ConnectivityDialog(string targetName, string description, Exception exception)
|
||||
{
|
||||
Exception? innerException = exception.InnerException;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
TitleTextBlock.Text = $"{App.ProjectName} is unable to connect to {targetName}";
|
||||
DescriptionTextBlock.Text = description;
|
||||
|
||||
ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}";
|
||||
|
||||
if (innerException is not null)
|
||||
ErrorRichTextBox.Selection.Text += $"\n\n===== Inner Exception =====\n{innerException.GetType()}: {innerException.Message}";
|
||||
|
||||
CloseButton.Click += delegate
|
||||
{
|
||||
Close();
|
||||
};
|
||||
|
||||
SystemSounds.Hand.Play();
|
||||
|
||||
Loaded += delegate
|
||||
{
|
||||
IntPtr hWnd = new WindowInteropHelper(this).Handle;
|
||||
NativeMethods.FlashWindow(hWnd, true);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,4 @@
|
||||
using Bloxstrap.Exceptions;
|
||||
|
||||
namespace Bloxstrap.UI.ViewModels.Menu
|
||||
namespace Bloxstrap.UI.ViewModels.Menu
|
||||
{
|
||||
public class BehaviourViewModel : NotifyPropertyChangedViewModel
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user