Fixed edit crashing when renaming an existing remap, fix publicizer and renamer running when not suppose too

This commit is contained in:
Cj 2024-06-19 23:14:51 -04:00
parent 9a2f83abf9
commit 94be084d7e
2 changed files with 28 additions and 2 deletions

View File

@ -22,6 +22,8 @@ public partial class ReCodeItForm : Form
private int _selectedRemapTreeIndex = 0;
private int _selectedCCRemapTreeIndex = 0;
private List<string> _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();
}

View File

@ -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();
}