diff --git a/ModEngine2ConfigTool/ModEngine2ConfigTool.csproj b/ModEngine2ConfigTool/ModEngine2ConfigTool.csproj index 4300016..4428e75 100644 --- a/ModEngine2ConfigTool/ModEngine2ConfigTool.csproj +++ b/ModEngine2ConfigTool/ModEngine2ConfigTool.csproj @@ -5,9 +5,9 @@ net6.0-windows enable true - 1.0.1 + 1.0.2 0.0.1 - 1.0.1 + 1.0.2 true Resources\icon_07.ico ModEngine2ConfigTool.EntryPoint diff --git a/ModEngine2ConfigTool/Services/PlayManagerService.cs b/ModEngine2ConfigTool/Services/PlayManagerService.cs index 18d0113..1b5e920 100644 --- a/ModEngine2ConfigTool/Services/PlayManagerService.cs +++ b/ModEngine2ConfigTool/Services/PlayManagerService.cs @@ -192,6 +192,7 @@ await _modEngine2Service catch (InvalidOperationException e) { MessageBox.Show(e.Message); + Log.Instance.Error(e.Message); } //// pop current profile saves @@ -206,8 +207,7 @@ await _modEngine2Service catch(Exception e) { MessageBox.Show(e.Message); - var logger = Logger.GetLogger(nameof(App)); - logger.Error(e.Message); + Log.Instance.Error(e.Message); } } diff --git a/ModEngine2ConfigTool/Views/Converter/EmptyImagePathConverter.cs b/ModEngine2ConfigTool/Views/Converter/EmptyImagePathConverter.cs index 954b6d8..c7b5583 100644 --- a/ModEngine2ConfigTool/Views/Converter/EmptyImagePathConverter.cs +++ b/ModEngine2ConfigTool/Views/Converter/EmptyImagePathConverter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Globalization; using System.IO; using System.Linq; @@ -19,7 +20,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn { if(value is string imagePath && !string.IsNullOrWhiteSpace(imagePath) && File.Exists(imagePath)) { - return BitmapFrame.Create(new Uri(imagePath), BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.OnLoad); + return CreateBitmap(imagePath); } if(parameter is not string fallbackPath) @@ -27,12 +28,55 @@ public object Convert(object value, Type targetType, object parameter, CultureIn return DependencyProperty.UnsetValue; } - return BitmapFrame.Create(new Uri(Path.GetFullPath($".\\Resources\\{fallbackPath}.png")), BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.OnLoad); + return CreateBitmap($".\\Resources\\{fallbackPath}.png"); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } + + private BitmapFrame CreateBitmap(string path) + { + try + { + var encoder = new PngBitmapEncoder(); + var image = new BitmapImage(new Uri(path, UriKind.Relative)) + { + CreateOptions = BitmapCreateOptions.IgnoreImageCache, + CacheOption = BitmapCacheOption.OnLoad + }; + + encoder.Frames.Add(BitmapFrame.Create(image)); + + return encoder.Frames[0]; + } + catch + { + return BitmapFrame.Create(CreateEmptyBitmap()); + } + } + + private BitmapSource CreateEmptyBitmap() + { + int width = 128; + int height = width; + int stride = width / 8; + byte[] pixels = new byte[height * stride]; + + // Try creating a new image with a custom palette. + List colors = new List(); + colors.Add(System.Windows.Media.Colors.Black); + BitmapPalette myPalette = new BitmapPalette(colors); + + // Creates a new empty image with the pre-defined palette + return BitmapSource.Create( + width, height, + 96, 96, + PixelFormats.Indexed1, + myPalette, + pixels, + stride); + } } } diff --git a/ModEngine2ConfigTool/Views/Pages/DllsPageView.xaml b/ModEngine2ConfigTool/Views/Pages/DllsPageView.xaml index 4d7387b..0203049 100644 --- a/ModEngine2ConfigTool/Views/Pages/DllsPageView.xaml +++ b/ModEngine2ConfigTool/Views/Pages/DllsPageView.xaml @@ -20,12 +20,13 @@ mc:Ignorable="d"> + diff --git a/ModEngine2ConfigTool/Views/Pages/HomePageView.xaml b/ModEngine2ConfigTool/Views/Pages/HomePageView.xaml index 070f6d5..fd8b1fa 100644 --- a/ModEngine2ConfigTool/Views/Pages/HomePageView.xaml +++ b/ModEngine2ConfigTool/Views/Pages/HomePageView.xaml @@ -16,11 +16,14 @@ d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> + + + diff --git a/ModEngine2ConfigTool/Views/Pages/ModsPageView.xaml b/ModEngine2ConfigTool/Views/Pages/ModsPageView.xaml index 26c7aed..06889c1 100644 --- a/ModEngine2ConfigTool/Views/Pages/ModsPageView.xaml +++ b/ModEngine2ConfigTool/Views/Pages/ModsPageView.xaml @@ -20,12 +20,13 @@ mc:Ignorable="d"> + diff --git a/ModEngine2ConfigTool/Views/Pages/ProfilesPageView.xaml b/ModEngine2ConfigTool/Views/Pages/ProfilesPageView.xaml index 100979d..7223b46 100644 --- a/ModEngine2ConfigTool/Views/Pages/ProfilesPageView.xaml +++ b/ModEngine2ConfigTool/Views/Pages/ProfilesPageView.xaml @@ -18,11 +18,14 @@ d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> + + +