From 676099b2375f8cc67c4ab1ab78d2cdf4b0de8388 Mon Sep 17 00:00:00 2001 From: wavebend Date: Tue, 19 Nov 2024 21:47:07 -0500 Subject: [PATCH 1/5] Handle registry scan errors; Fix for mod manager not closing; Shader compilation fix --- FrostyModSupport/FrostyModExecutor.cs | 10 ++++ .../Controls/FrostyHandledExceptionBox.cs | 48 +++++++++++++++++++ FrostyPlugin/FrostyCore.csproj | 1 + FrostyPlugin/Themes/Generic.xaml | 33 +++++++++++++ .../Windows/FrostyProfileSelectWindow.xaml.cs | 21 +++++--- 5 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 FrostyPlugin/Controls/FrostyHandledExceptionBox.cs diff --git a/FrostyModSupport/FrostyModExecutor.cs b/FrostyModSupport/FrostyModExecutor.cs index 39cf8497c..de1212d03 100644 --- a/FrostyModSupport/FrostyModExecutor.cs +++ b/FrostyModSupport/FrostyModExecutor.cs @@ -1426,6 +1426,16 @@ public int Run(FileSystemManager inFs, CancellationToken cancelToken, ILogger in } } + // if there is a gamedir/shader_cache folder, symlink it + if (Directory.Exists(Path.Combine(m_fs.BasePath, "shader_cache"))) + { + DirectoryInfo shaderCacheLink = new DirectoryInfo(Path.Combine(modDataPath, "shader_cache")); + if (!shaderCacheLink.Exists) + { + cmdArgs.Add(new SymLinkStruct(Path.Combine(modDataPath, "shader_cache"), Path.Combine(m_fs.BasePath, "shader_cache"), true)); + } + } + // add cas files to link foreach (string catalog in m_fs.Catalogs) { diff --git a/FrostyPlugin/Controls/FrostyHandledExceptionBox.cs b/FrostyPlugin/Controls/FrostyHandledExceptionBox.cs new file mode 100644 index 000000000..ffcca0074 --- /dev/null +++ b/FrostyPlugin/Controls/FrostyHandledExceptionBox.cs @@ -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; + } + } +} diff --git a/FrostyPlugin/FrostyCore.csproj b/FrostyPlugin/FrostyCore.csproj index b6a6eb234..764bab647 100644 --- a/FrostyPlugin/FrostyCore.csproj +++ b/FrostyPlugin/FrostyCore.csproj @@ -136,6 +136,7 @@ + diff --git a/FrostyPlugin/Themes/Generic.xaml b/FrostyPlugin/Themes/Generic.xaml index b8a271e04..d7eb6bb7a 100644 --- a/FrostyPlugin/Themes/Generic.xaml +++ b/FrostyPlugin/Themes/Generic.xaml @@ -1419,4 +1419,37 @@ + + + diff --git a/FrostyPlugin/Windows/FrostyProfileSelectWindow.xaml.cs b/FrostyPlugin/Windows/FrostyProfileSelectWindow.xaml.cs index 012e064b3..95e220d09 100644 --- a/FrostyPlugin/Windows/FrostyProfileSelectWindow.xaml.cs +++ b/FrostyPlugin/Windows/FrostyProfileSelectWindow.xaml.cs @@ -6,6 +6,7 @@ using System.Windows.Controls; using System.Windows.Input; using Frosty.Controls; +using Frosty.Core.Controls; using FrostySdk; using Microsoft.Win32; @@ -65,15 +66,22 @@ private void SelectConfiguration() private async void ScanGames() { - await Task.Run((() => + try { - using (RegistryKey lmKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node")) + await Task.Run((() => { - int totalCount = 0; + using (RegistryKey lmKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node")) + { + int totalCount = 0; - IterateSubKeys(lmKey, ref totalCount); - } - })); + IterateSubKeys(lmKey, ref totalCount); + } + })); + } + catch + { + FrostyHandledExceptionBox.Show("An error occurred while scanning for games. \n\nPlease manually set the game executable(s)."); + } } private void IterateSubKeys(RegistryKey subKey, ref int totalCount) @@ -90,6 +98,7 @@ private void IterateSubKeys(RegistryKey subKey, ref int totalCount) } } + foreach (string subKeyValue in subKey.GetValueNames()) { if (subKeyValue.IndexOf("Install Dir", StringComparison.OrdinalIgnoreCase) != -1) From f00619e8f6dc8bc1de34257ef4a96911791acfe1 Mon Sep 17 00:00:00 2001 From: wavebend Date: Tue, 19 Nov 2024 21:47:07 -0500 Subject: [PATCH 2/5] Handle registry scan errors; Fix for mod manager not closing; Shader compilation fix --- FrostyModSupport/FrostyModExecutor.cs | 10 +++++ .../Windows/FrostyProfileSelectWindow.xaml | 18 +++++++- .../Windows/FrostyProfileSelectWindow.xaml.cs | 44 ++++++++++++++++--- 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/FrostyModSupport/FrostyModExecutor.cs b/FrostyModSupport/FrostyModExecutor.cs index 39cf8497c..de1212d03 100644 --- a/FrostyModSupport/FrostyModExecutor.cs +++ b/FrostyModSupport/FrostyModExecutor.cs @@ -1426,6 +1426,16 @@ public int Run(FileSystemManager inFs, CancellationToken cancelToken, ILogger in } } + // if there is a gamedir/shader_cache folder, symlink it + if (Directory.Exists(Path.Combine(m_fs.BasePath, "shader_cache"))) + { + DirectoryInfo shaderCacheLink = new DirectoryInfo(Path.Combine(modDataPath, "shader_cache")); + if (!shaderCacheLink.Exists) + { + cmdArgs.Add(new SymLinkStruct(Path.Combine(modDataPath, "shader_cache"), Path.Combine(m_fs.BasePath, "shader_cache"), true)); + } + } + // add cas files to link foreach (string catalog in m_fs.Catalogs) { diff --git a/FrostyPlugin/Windows/FrostyProfileSelectWindow.xaml b/FrostyPlugin/Windows/FrostyProfileSelectWindow.xaml index 340c54b35..68cbc57c6 100644 --- a/FrostyPlugin/Windows/FrostyProfileSelectWindow.xaml +++ b/FrostyPlugin/Windows/FrostyProfileSelectWindow.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ctrl="clr-namespace:Frosty.Controls;assembly=FrostyControls" + xmlns:local="clr-namespace:Frosty.Core.Windows" xmlns:core="clr-namespace:Frosty.Core.Controls;assembly=FrostyCore" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" @@ -14,6 +15,7 @@ + @@ -54,7 +56,20 @@ - + + + + + + +