Skip to content

Commit

Permalink
handle registry scan fail
Browse files Browse the repository at this point in the history
  • Loading branch information
wavebend committed Nov 20, 2024
1 parent 3fa492c commit 27c0096
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
48 changes: 48 additions & 0 deletions FrostyPlugin/Controls/FrostyHandledExceptionBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Frosty.Controls;
using System.Windows;

namespace Frosty.Core.Controls
{
public class FrostyHandledExceptionBox : FrostyDockableWindow
{
#region -- Properties --

#region -- WarningText --
public static readonly DependencyProperty WarningTextProperty = DependencyProperty.Register("WarningText", typeof(string), typeof(FrostyHandledExceptionBox), new PropertyMetadata(""));
public string WarningText {
get => (string)GetValue(WarningTextProperty);
set => SetValue(WarningTextProperty, value);
}
#endregion

#endregion

public FrostyHandledExceptionBox()
{
Title = "Warning";
Topmost = true;
ShowInTaskbar = false;

Height = 180;
Width = 400;

WindowStartupLocation = WindowStartupLocation.CenterOwner;
Window mainWin = Application.Current.MainWindow;
}

public override void OnApplyTemplate()
{
base.OnApplyTemplate();
}

public static MessageBoxResult Show(string warning)
{
FrostyHandledExceptionBox window = new FrostyHandledExceptionBox
{
WarningText = warning
};

return (window.ShowDialog() == true) ? MessageBoxResult.OK : MessageBoxResult.Cancel;
}
}
}
1 change: 1 addition & 0 deletions FrostyPlugin/FrostyCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<Compile Include="Attributes\RegisterUserShaderAttribute.cs" />
<Compile Include="CodingStandards\FrostyCodingStandards.cs" />
<Compile Include="Controls\FrostyBaseAssetEditor.cs" />
<Compile Include="Controls\FrostyHandledExceptionBox.cs" />
<Compile Include="Controls\FrostyExceptionBox.cs" />
<Compile Include="Controls\FrostyNotification.cs" />
<Compile Include="Controls\VirtualizingTilePanel.cs" />
Expand Down
33 changes: 33 additions & 0 deletions FrostyPlugin/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1419,4 +1419,37 @@
</Setter>
</Style>

<!-- FrostyHandledExceptionBox -->
<Style TargetType="{x:Type local:FrostyHandledExceptionBox}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<DataTemplate.Resources>
<ctrl:WindowCloseCommand x:Key="CloseCommand"/>
</DataTemplate.Resources>
<Grid Background="{StaticResource ListBackground}">
<Grid.RowDefinitions>
<RowDefinition Height="26"/>
<RowDefinition Height="*"/>
<RowDefinition Height="38"/>
</Grid.RowDefinitions>

<!-- Warning text -->
<TextBlock Grid.Row="0" Text="Warning" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource FontColor}" FontFamily="Global User Interface" FontSize="14" FontWeight="Bold"/>

<!-- Crash text -->
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="8,0,8,0" BorderThickness="1" Padding="4">
<TextBlock Text="{Binding WarningText, RelativeSource={RelativeSource AncestorType={x:Type local:FrostyHandledExceptionBox}}}" TextWrapping="Wrap" Foreground="White" FontFamily="Global User Interface" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</ScrollViewer>

<!-- Ok button -->
<StackPanel Grid.Row="2" Margin="8" FlowDirection="RightToLeft" Orientation="Horizontal">
<Button Content="Ok" Width="75" Command="{StaticResource CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
</StackPanel>
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>
12 changes: 10 additions & 2 deletions FrostyPlugin/Windows/FrostyProfileSelectWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Input;
using System.Windows.Threading;
using Frosty.Controls;
using Frosty.Core.Controls;
using FrostySdk;
using Microsoft.Win32;

Expand All @@ -26,8 +27,15 @@ private async void ProfileSelectWindow_Loaded(object sender, RoutedEventArgs e)
{
RefreshConfigurationList();

// TODO: @techdebt only call this once or when needed
await ScanGames();
try
{
// TODO: @techdebt only call this once or when needed
await ScanGames();
}
catch
{
FrostyHandledExceptionBox.Show("An error occurred while scanning for games.\n\nPlease manually set the game executable(s).");
}

RefreshConfigurationList();
}
Expand Down

0 comments on commit 27c0096

Please sign in to comment.