diff --git a/Bloxstrap/Extensions/IconEx.cs b/Bloxstrap/Extensions/IconEx.cs index 2cd48af..516899d 100644 --- a/Bloxstrap/Extensions/IconEx.cs +++ b/Bloxstrap/Extensions/IconEx.cs @@ -8,11 +8,28 @@ namespace Bloxstrap.Extensions { public static Icon GetSized(this Icon icon, int width, int height) => new(icon, new Size(width, height)); - public static ImageSource GetImageSource(this Icon icon) + public static ImageSource GetImageSource(this Icon icon, bool handleException = true) { using MemoryStream stream = new(); icon.Save(stream); - return BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + + if (handleException) + { + try + { + return BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + } + catch (Exception ex) + { + App.Logger.WriteException("IconEx::GetImageSource", ex); + Frontend.ShowMessageBox(String.Format(Strings.Dialog_IconLoadFailed, ex.Message)); + return BootstrapperIcon.IconBloxstrap.GetIcon().GetImageSource(false); + } + } + else + { + return BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + } } } } diff --git a/Bloxstrap/Integrations/DiscordRichPresence.cs b/Bloxstrap/Integrations/DiscordRichPresence.cs index e814e87..3861918 100644 --- a/Bloxstrap/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Integrations/DiscordRichPresence.cs @@ -272,7 +272,7 @@ namespace Bloxstrap.Integrations _currentPresence = new DiscordRPC.RichPresence { - Details = $"Playing {universeName}", + Details = universeName, State = status, Timestamps = new Timestamps { Start = timeStarted.ToUniversalTime() }, Buttons = GetButtons(), diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 5279440..967c55c 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -976,6 +976,17 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to The chosen bootstrapper icon could not be loaded. + /// + ///{0}. + /// + public static string Dialog_IconLoadFailed { + get { + return ResourceManager.GetString("Dialog.IconLoadFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Choose preferred language. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index 57ddfd4..a8e3a95 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -1204,4 +1204,9 @@ Please manually delete Bloxstrap.exe from the install location or try restarting Failed to save {0}: {1} + + The chosen bootstrapper icon could not be loaded. + +{0} + diff --git a/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml b/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml index 88c4aa9..0fdccb2 100644 --- a/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml +++ b/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml @@ -172,6 +172,7 @@ +