Merge branch 'main' into user-pfp-discord-rpc

This commit is contained in:
axel 2024-09-21 23:47:59 +02:00 committed by GitHub
commit cf11cd87ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 3 deletions

View File

@ -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 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(); using MemoryStream stream = new();
icon.Save(stream); 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);
}
} }
} }
} }

View File

@ -272,7 +272,7 @@ namespace Bloxstrap.Integrations
_currentPresence = new DiscordRPC.RichPresence _currentPresence = new DiscordRPC.RichPresence
{ {
Details = $"Playing {universeName}", Details = universeName,
State = status, State = status,
Timestamps = new Timestamps { Start = timeStarted.ToUniversalTime() }, Timestamps = new Timestamps { Start = timeStarted.ToUniversalTime() },
Buttons = GetButtons(), Buttons = GetButtons(),

View File

@ -976,6 +976,17 @@ namespace Bloxstrap.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to The chosen bootstrapper icon could not be loaded.
///
///{0}.
/// </summary>
public static string Dialog_IconLoadFailed {
get {
return ResourceManager.GetString("Dialog.IconLoadFailed", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Choose preferred language. /// Looks up a localized string similar to Choose preferred language.
/// </summary> /// </summary>

View File

@ -1204,4 +1204,9 @@ Please manually delete Bloxstrap.exe from the install location or try restarting
<data name="Bootstrapper.JsonManagerSaveFailed" xml:space="preserve"> <data name="Bootstrapper.JsonManagerSaveFailed" xml:space="preserve">
<value>Failed to save {0}: {1}</value> <value>Failed to save {0}: {1}</value>
</data> </data>
<data name="Dialog.IconLoadFailed" xml:space="preserve">
<value>The chosen bootstrapper icon could not be loaded.
{0}</value>
</data>
</root> </root>

View File

@ -172,6 +172,7 @@
<controls:Expander Grid.Column="0" Margin="0,0,4,0" HeaderIcon="Code24" HeaderText="{x:Static resources:Strings.Menu_About_Contributors_Code}" IsExpanded="True"> <controls:Expander Grid.Column="0" Margin="0,0,4,0" HeaderIcon="Code24" HeaderText="{x:Static resources:Strings.Menu_About_Contributors_Code}" IsExpanded="True">
<StackPanel> <StackPanel>
<controls:MarkdownTextBlock MarkdownText="[Matt](https://github.com/bluepilledgreat)" /> <controls:MarkdownTextBlock MarkdownText="[Matt](https://github.com/bluepilledgreat)" />
<controls:MarkdownTextBlock MarkdownText="[lolmanurfunny](https://github.com/lolmanurfunny)" />
<controls:MarkdownTextBlock MarkdownText="[1011025m](https://github.com/1011025m)" /> <controls:MarkdownTextBlock MarkdownText="[1011025m](https://github.com/1011025m)" />
<controls:MarkdownTextBlock MarkdownText="[EasternBloxxer](https://github.com/EasternBloxxer)" /> <controls:MarkdownTextBlock MarkdownText="[EasternBloxxer](https://github.com/EasternBloxxer)" />
<controls:MarkdownTextBlock MarkdownText="[sitiom](https://github.com/sitiom)" /> <controls:MarkdownTextBlock MarkdownText="[sitiom](https://github.com/sitiom)" />