From 94be084d7eb806e16f3e3977a24719ef6ee67abf Mon Sep 17 00:00:00 2001 From: Cj <161484149+CJ-SPT@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:14:51 -0400 Subject: [PATCH] Fixed edit crashing when renaming an existing remap, fix publicizer and renamer running when not suppose too --- RecodeItGUI/GUI/Main.cs | 26 ++++++++++++++++++++++++ RecodeItLib/Remapper/ReCodeItRemapper.cs | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/RecodeItGUI/GUI/Main.cs b/RecodeItGUI/GUI/Main.cs index 365f0e9..0c03690 100644 --- a/RecodeItGUI/GUI/Main.cs +++ b/RecodeItGUI/GUI/Main.cs @@ -22,6 +22,8 @@ public partial class ReCodeItForm : Form private int _selectedRemapTreeIndex = 0; private int _selectedCCRemapTreeIndex = 0; + private List _cachedNewTypeNames = []; + public ReCodeItForm() { InitializeComponent(); @@ -44,6 +46,11 @@ public partial class ReCodeItForm : Form #region MANUAL_REMAPPER + NewTypeName.GotFocus += (sender, e) => + { + _cachedNewTypeNames.Add(NewTypeName.Text); + }; + IncludeMethodTextBox.KeyDown += (sender, e) => { if (e.KeyCode == Keys.Enter) @@ -271,6 +278,13 @@ public partial class ReCodeItForm : Form .Where(remap => remap.NewTypeName == newRemap.NewTypeName) .FirstOrDefault(); + if (existingRemap == null) + { + existingRemap = remaps + .Where(remap => _cachedNewTypeNames.Contains(remap.NewTypeName)) + .FirstOrDefault(); + } + // Handle overwriting an existing remap if (existingRemap != null) { @@ -291,6 +305,9 @@ public partial class ReCodeItForm : Form DataProvider.SaveMapping(); } + ReloadRemapTreeView(remaps); + ReloadCCRemapTreeView(remaps); + ResetAllRemapFields(); return; } @@ -308,8 +325,17 @@ public partial class ReCodeItForm : Form var node = GUIHelpers.GenerateTreeNode(newRemap, this); + //RemapTreeView.Nodes.Remove(node); RemapTreeView.Nodes.Add(node); + + //CCMappingTreeView.Nodes.Remove(node); CCMappingTreeView.Nodes.Add(node); + + _cachedNewTypeNames.Clear(); + + ReloadRemapTreeView(remaps); + ReloadCCRemapTreeView(remaps); + ResetAllRemapFields(); } diff --git a/RecodeItLib/Remapper/ReCodeItRemapper.cs b/RecodeItLib/Remapper/ReCodeItRemapper.cs index 92ac4b3..25c872e 100644 --- a/RecodeItLib/Remapper/ReCodeItRemapper.cs +++ b/RecodeItLib/Remapper/ReCodeItRemapper.cs @@ -67,12 +67,12 @@ public class ReCodeItRemapper ChooseBestMatches(); // Dont publicize and unseal until after the remapping so we can use those as search parameters - if (!Settings.MappingSettings.Publicize) + if (Settings.MappingSettings.Publicize) { Publicizer.Publicize(); } - if (!Settings.MappingSettings.Unseal) + if (Settings.MappingSettings.Unseal) { Publicizer.Unseal(); }