From dffb92e918b97efd03e1ee4ea47cc347429a80b1 Mon Sep 17 00:00:00 2001 From: pmx Date: Thu, 28 Apr 2022 00:27:15 -0600 Subject: [PATCH 1/2] Personal fixes Signed-off-by: pmx --- SatisfactorySaveEditor/App.config | 8 +++-- SatisfactorySaveEditor/NLog.xsd | 18 ++++++++++++ .../SatisfactorySaveEditor.csproj | 29 ++++++++++--------- .../View/PropertyTemplateDictionary.xaml | 19 ++++++++---- .../ViewModel/MainViewModel.cs | 13 +++++++++ SatisfactorySaveEditor/packages.config | 20 +++++++------ .../SatisfactorySaveParser.Tests.csproj | 2 +- 7 files changed, 79 insertions(+), 30 deletions(-) diff --git a/SatisfactorySaveEditor/App.config b/SatisfactorySaveEditor/App.config index 601c1414..1ba27eb7 100644 --- a/SatisfactorySaveEditor/App.config +++ b/SatisfactorySaveEditor/App.config @@ -34,11 +34,15 @@ - + - + + + + + diff --git a/SatisfactorySaveEditor/NLog.xsd b/SatisfactorySaveEditor/NLog.xsd index 578682a8..eefeec81 100644 --- a/SatisfactorySaveEditor/NLog.xsd +++ b/SatisfactorySaveEditor/NLog.xsd @@ -1101,6 +1101,7 @@ + @@ -1139,6 +1140,11 @@ Type of the parameter. + + + Whether empty value should translate into DbNull. Requires database column to allow NULL values. + + Convert format of the database parameter value. @@ -2757,6 +2763,7 @@ + @@ -2810,6 +2817,11 @@ Web service URL. + + + Value of the User-agent HTTP header. + + Value whether escaping be done according to the old NLog style (Very non-standard) @@ -2978,6 +2990,7 @@ + @@ -3000,6 +3013,11 @@ Option to suppress the extra spaces in the output json + + + Option to exclude null/empty properties from the log event (as JSON) + + List of property names to exclude when is true diff --git a/SatisfactorySaveEditor/SatisfactorySaveEditor.csproj b/SatisfactorySaveEditor/SatisfactorySaveEditor.csproj index 27d262ee..4cff77d4 100644 --- a/SatisfactorySaveEditor/SatisfactorySaveEditor.csproj +++ b/SatisfactorySaveEditor/SatisfactorySaveEditor.csproj @@ -41,14 +41,14 @@ satisfactorysaveeditorlogo_powershard.ico - - ..\packages\AsyncAwaitBestPractices.4.2.0\lib\netstandard1.0\AsyncAwaitBestPractices.dll + + ..\packages\AsyncAwaitBestPractices.6.0.4\lib\netstandard2.0\AsyncAwaitBestPractices.dll - - ..\packages\AsyncAwaitBestPractices.MVVM.4.2.0\lib\netstandard1.0\AsyncAwaitBestPractices.MVVM.dll + + ..\packages\AsyncAwaitBestPractices.MVVM.6.0.4\lib\netstandard2.0\AsyncAwaitBestPractices.MVVM.dll - - ..\packages\CommonServiceLocator.2.0.5\lib\net47\CommonServiceLocator.dll + + ..\packages\CommonServiceLocator.2.0.6\lib\net47\CommonServiceLocator.dll ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll @@ -59,14 +59,17 @@ ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll - - ..\packages\gong-wpf-dragdrop.2.2.0\lib\net47\GongSolutions.WPF.DragDrop.dll + + ..\packages\gong-wpf-dragdrop.3.1.1\lib\net47\GongSolutions.WPF.DragDrop.dll - - ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + + ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.39\lib\net45\Microsoft.Xaml.Behaviors.dll + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - ..\packages\NLog.4.7.2\lib\net45\NLog.dll + ..\packages\NLog.4.7.13\lib\net45\NLog.dll @@ -74,8 +77,8 @@ - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll diff --git a/SatisfactorySaveEditor/View/PropertyTemplateDictionary.xaml b/SatisfactorySaveEditor/View/PropertyTemplateDictionary.xaml index b22eba27..9ab00766 100644 --- a/SatisfactorySaveEditor/View/PropertyTemplateDictionary.xaml +++ b/SatisfactorySaveEditor/View/PropertyTemplateDictionary.xaml @@ -5,7 +5,10 @@ xmlns:structs="clr-namespace:SatisfactorySaveParser.PropertyTypes.Structs;assembly=SatisfactorySaveParser" xmlns:control="clr-namespace:SatisfactorySaveEditor.View.Control" xmlns:struct="clr-namespace:SatisfactorySaveEditor.ViewModel.Struct" - xmlns:converter="clr-namespace:SatisfactorySaveEditor.Converter"> + xmlns:converter="clr-namespace:SatisfactorySaveEditor.Converter" + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" + xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" + xmlns:b="http://schemas.microsoft.com/xaml/behaviors"> @@ -130,8 +133,12 @@ - - @@ -150,8 +157,10 @@ - - diff --git a/SatisfactorySaveEditor/ViewModel/MainViewModel.cs b/SatisfactorySaveEditor/ViewModel/MainViewModel.cs index 3e34c4bd..59fec96e 100644 --- a/SatisfactorySaveEditor/ViewModel/MainViewModel.cs +++ b/SatisfactorySaveEditor/ViewModel/MainViewModel.cs @@ -380,6 +380,9 @@ private void CreateBackupAsync(bool manual) /// True if rootItem contains the EntitiyName, false otherwise. private bool CanJump(string target) { + if (target == null) + return false; + return rootItem.FindChild(target, false) != null; } @@ -706,6 +709,11 @@ private void ResetSearch() SearchText = null; } + public void DragEnter(IDropInfo dropInfo) + { + // Do nothing + } + public void DragOver(IDropInfo dropInfo) { if (!(dropInfo.Data is DataObject data)) return; @@ -717,6 +725,11 @@ public void DragOver(IDropInfo dropInfo) dropInfo.Effects = DragDropEffects.Copy; } + public void DragLeave(IDropInfo dropInfo) + { + // Do nothing + } + /// /// Handle drag and drop opening of save files /// diff --git a/SatisfactorySaveEditor/packages.config b/SatisfactorySaveEditor/packages.config index 40d93e5d..eee31dd4 100644 --- a/SatisfactorySaveEditor/packages.config +++ b/SatisfactorySaveEditor/packages.config @@ -1,15 +1,17 @@  - - - - + + + + + - - - - - + + + + + + \ No newline at end of file diff --git a/SatisfactorySaveParser.Tests/SatisfactorySaveParser.Tests.csproj b/SatisfactorySaveParser.Tests/SatisfactorySaveParser.Tests.csproj index bdddd280..349bcffd 100644 --- a/SatisfactorySaveParser.Tests/SatisfactorySaveParser.Tests.csproj +++ b/SatisfactorySaveParser.Tests/SatisfactorySaveParser.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + net5.0 false From 7c3df6837c1e7fd1262515290e1c406b7b855248 Mon Sep 17 00:00:00 2001 From: pmx Date: Fri, 29 Apr 2022 17:24:21 -0600 Subject: [PATCH 2/2] Adding a cache to "CanJump" - This function terribly slows down the app. Signed-off-by: pmx --- .../ViewModel/MainViewModel.cs | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/SatisfactorySaveEditor/ViewModel/MainViewModel.cs b/SatisfactorySaveEditor/ViewModel/MainViewModel.cs index 59fec96e..6ecdba3b 100644 --- a/SatisfactorySaveEditor/ViewModel/MainViewModel.cs +++ b/SatisfactorySaveEditor/ViewModel/MainViewModel.cs @@ -22,6 +22,7 @@ using AsyncAwaitBestPractices.MVVM; using NLog; using System.ComponentModel; +using System.Collections.Generic; namespace SatisfactorySaveEditor.ViewModel { @@ -373,6 +374,35 @@ private void CreateBackupAsync(bool manual) MessageBox.Show("Backup created. Find it in your save file folder."); } + class CachedCanJumpItem + { + public bool Result; + public DateTime LastQueried; + } + + + class CachedCanJump + { + public bool SeekCanJump(SaveObjectModel rootItem, string Target) + { + if (CachedCanJumpRecord.ContainsKey(Target)) + { + var time_diff = DateTime.Now - CachedCanJumpRecord[Target].LastQueried; + if (time_diff.TotalSeconds <= 600) // Only check every 10 minutes. + return CachedCanJumpRecord[Target].Result; + } + else + { + CachedCanJumpRecord.Add(Target, new CachedCanJumpItem()); + } + CachedCanJumpRecord[Target].Result = rootItem.FindChild(Target, false) != null; + CachedCanJumpRecord[Target].LastQueried = DateTime.Now; + return CachedCanJumpRecord[Target].Result; + } + private Dictionary CachedCanJumpRecord = new Dictionary(); + } + + CachedCanJump CanJumpCache = new CachedCanJump(); /// /// Checks if it's possible to jump to the passed EntityName string /// @@ -382,8 +412,11 @@ private bool CanJump(string target) { if (target == null) return false; + return CanJumpCache.SeekCanJump(rootItem, target); + //if (target.Contains("/Recipes/")) + // return false; - return rootItem.FindChild(target, false) != null; + //return rootItem.FindChild(target, false) != null; } ///