Skip to content

Commit

Permalink
import mappings allow override, refresh list on mappings error
Browse files Browse the repository at this point in the history
  • Loading branch information
atenfyr committed Aug 9, 2024
1 parent c5ef13d commit eb4e7bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
15 changes: 11 additions & 4 deletions UAssetGUI/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,8 @@ private void OpenFileContainerForm(string path = null)
test.Show();
}

private void UpdateMappings(string newSelection = null, bool alsoCheckVersion = true)
internal void UpdateMappings(string newSelection = null, bool alsoCheckVersion = true)
{
UAGConfig.MappingsToSuppressWarningsFor.Clear();
UAGConfig.LoadMappings();
UAGUtils.InvokeUI(() =>
{
Expand Down Expand Up @@ -2053,8 +2052,16 @@ private void importMappingsToolStripMenuItem_Click(object sender, EventArgs e)
replacementPrompt.Dispose();
}

File.Copy(importPath, Path.ChangeExtension(Path.Combine(UAGConfig.MappingsFolder, newFileName), ".usmap"));
UpdateMappings(newFileName);
try
{
File.Copy(importPath, Path.ChangeExtension(Path.Combine(UAGConfig.MappingsFolder, newFileName), ".usmap"), true);
if (UAGConfig.AllMappings.ContainsKey(newFileName)) UAGConfig.AllMappings.Remove(newFileName);
UpdateMappings(newFileName);
}
catch
{
MessageBox.Show("Failed to import mappings!", "Uh oh!");
}
});
}

Expand Down
15 changes: 13 additions & 2 deletions UAssetGUI/UAGConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public static class UAGConfig
public readonly static string MappingsFolder = Path.Combine(ConfigFolder, "Mappings");
public readonly static string StagingFolder = Path.Combine(ConfigFolder, "Staging");
public readonly static string ExtractedFolder = Path.Combine(ConfigFolder, "Extracted");
public static ISet<string> MappingsToSuppressWarningsFor = new HashSet<string>();

internal static bool DifferentStagingPerPak = false;

Expand Down Expand Up @@ -163,7 +162,19 @@ public static bool TryGetMappings(string name, out Usmap mappings)
}
catch
{
UAGUtils.InvokeUI(() => MessageBox.Show("Failed to parse " + name + " mappings", "Notice"));
UAGUtils.InvokeUI(() =>
{
MessageBox.Show("Failed to parse mappings: " + name, "Notice");

// update list of mappings for good measure
foreach (var form in Application.OpenForms)
{
if (form is Form1 form1)
{
form1.UpdateMappings("No mappings", false);
}
}
});
}
}

Expand Down

0 comments on commit eb4e7bf

Please sign in to comment.