diff --git a/AssemblyRemapper/Models/AppSettingsModel.cs b/AssemblyRemapper/Models/AppSettingsModel.cs
index 6138a51..74daef8 100644
--- a/AssemblyRemapper/Models/AppSettingsModel.cs
+++ b/AssemblyRemapper/Models/AppSettingsModel.cs
@@ -3,16 +3,35 @@
///
/// Remap config
///
+internal class Settings
+{
+ public AppSettings AppSettings { get; set; }
+ public RemapperSettings RemapperSettings { get; set; }
+
+ public AutoMapperSettings AutoMapperSettings { get; set; }
+}
+
internal class AppSettings
{
- public bool Debug { get; set; }
- public bool SilentMode { get; set; }
- public int MaxMatchCount { get; set; }
- public bool ScoringMode { get; set; }
- public bool Publicize { get; set; }
- public bool Unseal { get; set; }
+ public bool Debug { get; set; } = false;
+ public bool SilentMode { get; set; } = true;
+ public bool MatchMode { get; set; } = false;
+}
- public string AssemblyPath { get; set; }
- public string OutputPath { get; set; }
- public string MappingPath { get; set; }
+internal class RemapperSettings
+{
+ public int MaxMatchCount { get; set; } = 5;
+
+ public bool Publicize { get; set; } = false;
+ public bool Unseal { get; set; } = false;
+
+ public string AssemblyPath { get; set; } = string.Empty;
+ public string OutputPath { get; set; } = string.Empty;
+ public string MappingPath { get; set; } = string.Empty;
+}
+
+internal class AutoMapperSettings
+{
+ public bool Publicize { get; set; } = false;
+ public bool Unseal { get; set; } = false;
}
\ No newline at end of file
diff --git a/AssemblyRemapper/Remapper/Publicizer.cs b/AssemblyRemapper/Remapper/Publicizer.cs
index 70abae2..e5dca63 100644
--- a/AssemblyRemapper/Remapper/Publicizer.cs
+++ b/AssemblyRemapper/Remapper/Publicizer.cs
@@ -6,8 +6,6 @@ internal static class Publicizer
{
public static void Publicize()
{
- if (!DataProvider.AppSettings.Publicize) { return; }
-
Logger.Log("Starting publicization...", ConsoleColor.Green);
foreach (var type in DataProvider.ModuleDefinition.Types)
@@ -44,8 +42,6 @@ internal static class Publicizer
public static void Unseal()
{
- if (!DataProvider.AppSettings.Unseal) { return; }
-
Logger.Log("Starting unseal...", ConsoleColor.Green);
foreach (var type in DataProvider.ModuleDefinition.Types)
diff --git a/AssemblyRemapper/Remapper/Remapper.cs b/AssemblyRemapper/Remapper/Remapper.cs
index b16f98c..e33f0d6 100644
--- a/AssemblyRemapper/Remapper/Remapper.cs
+++ b/AssemblyRemapper/Remapper/Remapper.cs
@@ -29,11 +29,18 @@ internal class Remapper
ChooseBestMatches();
- if (DataProvider.AppSettings.ScoringMode) { return; }
+ if (DataProvider.Settings.AppSettings.MatchMode) { return; }
// Dont publicize and unseal until after the remapping so we can use those as search parameters
- Publicizer.Publicize();
- Publicizer.Unseal();
+ if (!DataProvider.Settings.RemapperSettings.Publicize)
+ {
+ Publicizer.Publicize();
+ }
+
+ if (!DataProvider.Settings.RemapperSettings.Unseal)
+ {
+ Publicizer.Unseal();
+ }
// We are done, write the assembly
WriteAssembly();
@@ -47,8 +54,8 @@ internal class Remapper
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
Logger.Log($"Starting remap...", ConsoleColor.Yellow);
Logger.Log($"Module contains {DataProvider.ModuleDefinition.Types.Count} Types", ConsoleColor.Yellow);
- Logger.Log($"Publicize: {DataProvider.AppSettings.Publicize}", ConsoleColor.Yellow);
- Logger.Log($"Unseal: {DataProvider.AppSettings.Unseal}", ConsoleColor.Yellow);
+ Logger.Log($"Publicize: {DataProvider.Settings.RemapperSettings.Publicize}", ConsoleColor.Yellow);
+ Logger.Log($"Unseal: {DataProvider.Settings.RemapperSettings.Unseal}", ConsoleColor.Yellow);
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
}
@@ -192,7 +199,7 @@ internal class Remapper
var filteredScores = scores
.OrderByDescending(score => score.Score)
- .Take(DataProvider.AppSettings.MaxMatchCount);
+ .Take(DataProvider.Settings.RemapperSettings.MaxMatchCount);
var highestScore = filteredScores.FirstOrDefault();
@@ -213,6 +220,8 @@ internal class Remapper
}
}
+ if (DataProvider.Settings.AppSettings.MatchMode) { return; }
+
highestScore.ReMap.OriginalTypeName = highestScore.Definition.Name;
// Rename type and all associated type members
@@ -226,7 +235,7 @@ internal class Remapper
///
private void WriteAssembly()
{
- var filename = Path.GetFileNameWithoutExtension(DataProvider.AppSettings.AssemblyPath);
+ var filename = Path.GetFileNameWithoutExtension(DataProvider.Settings.RemapperSettings.AssemblyPath);
var strippedPath = Path.GetDirectoryName(filename);
filename = $"{filename}-Remapped.dll";
diff --git a/AssemblyRemapper/Utils/DataProvider.cs b/AssemblyRemapper/Utils/DataProvider.cs
index 6c9ee09..02d154b 100644
--- a/AssemblyRemapper/Utils/DataProvider.cs
+++ b/AssemblyRemapper/Utils/DataProvider.cs
@@ -15,7 +15,7 @@ internal static class DataProvider
public static Dictionary> ScoringModels { get; set; } = [];
- public static AppSettings AppSettings { get; private set; }
+ public static Settings Settings { get; private set; }
public static AssemblyDefinition AssemblyDefinition { get; private set; }
@@ -37,17 +37,17 @@ internal static class DataProvider
NullValueHandling = NullValueHandling.Ignore
};
- AppSettings = JsonConvert.DeserializeObject(jsonText, settings);
+ Settings = JsonConvert.DeserializeObject(jsonText, settings);
}
public static void LoadMappingFile()
{
- if (!File.Exists(AppSettings.MappingPath))
+ if (!File.Exists(Settings.RemapperSettings.MappingPath))
{
- throw new InvalidOperationException($"path `{AppSettings.MappingPath}` does not exist...");
+ throw new InvalidOperationException($"path `{Settings.RemapperSettings.MappingPath}` does not exist...");
}
- var jsonText = File.ReadAllText(AppSettings.MappingPath);
+ var jsonText = File.ReadAllText(Settings.RemapperSettings.MappingPath);
Remaps = [];
ScoringModels = [];
@@ -70,9 +70,9 @@ internal static class DataProvider
public static void UpdateMapping()
{
- if (!File.Exists(AppSettings.MappingPath))
+ if (!File.Exists(Settings.RemapperSettings.MappingPath))
{
- throw new InvalidOperationException($"path `{AppSettings.MappingPath}` does not exist...");
+ throw new InvalidOperationException($"path `{Settings.RemapperSettings.MappingPath}` does not exist...");
}
JsonSerializerSettings settings = new JsonSerializerSettings
@@ -100,23 +100,23 @@ internal static class DataProvider
var jsonText = JsonConvert.SerializeObject(Remaps, settings);
- File.WriteAllText(AppSettings.MappingPath, jsonText);
+ File.WriteAllText(Settings.RemapperSettings.MappingPath, jsonText);
}
public static void LoadAssemblyDefinition()
{
DefaultAssemblyResolver resolver = new();
- resolver.AddSearchDirectory(Path.GetDirectoryName(AppSettings.AssemblyPath)); // Replace with the correct path
+ resolver.AddSearchDirectory(Path.GetDirectoryName(Settings.RemapperSettings.AssemblyPath)); // Replace with the correct path
ReaderParameters parameters = new() { AssemblyResolver = resolver };
- AssemblyDefinition = AssemblyDefinition.ReadAssembly(AppSettings.AssemblyPath, parameters);
+ AssemblyDefinition = AssemblyDefinition.ReadAssembly(Settings.RemapperSettings.AssemblyPath, parameters);
if (AssemblyDefinition is null)
{
throw new InvalidOperationException("AssemblyDefinition was null...");
}
- var fileName = Path.GetFileName(AppSettings.AssemblyPath);
+ var fileName = Path.GetFileName(Settings.RemapperSettings.AssemblyPath);
foreach (var module in AssemblyDefinition.Modules.ToArray())
{
diff --git a/AssemblyRemapper/Utils/Logger.cs b/AssemblyRemapper/Utils/Logger.cs
index db305d0..4df1fc1 100644
--- a/AssemblyRemapper/Utils/Logger.cs
+++ b/AssemblyRemapper/Utils/Logger.cs
@@ -44,7 +44,7 @@ internal static class Logger
return;
}
- if (DataProvider.AppSettings.Debug)
+ if (DataProvider.Settings.AppSettings.Debug)
{
Console.ForegroundColor = color;
Console.WriteLine(message);
diff --git a/Templates/Settings.jsonc b/Templates/Settings.jsonc
index f276309..5915295 100644
--- a/Templates/Settings.jsonc
+++ b/Templates/Settings.jsonc
@@ -1,14 +1,19 @@
{
"AppSettings": {
- "Debug": false, // Enables extra debug logging, slows down the program by alot
- "SilentMode": true // The tool will stop and prompt you to continue on every remapping if disabled
+ "Debug": false, // Enables extra debug logging, slows down the program by alot
+ "SilentMode": true, // The tool will stop and prompt you to continue on every remapping if disabled
+ "MatchMode": false // The assembly will not be written back to disk used only to score mappings
},
"Remapper": {
- "MaxMatchCount": 5, // Max matches the remapper will return
- "Publicize": true, // Publicize all types, methods, and properties : NOTE: Not run until after the remap has completed
- "Unseal": true, // Unseal all types : NOTE: Not run until after the remap has completed
- "AssemblyPath": "./Data/Managed/Assembly-CSharp.dll", // Path to the assembly we want to remap
- "OutputPath": "./Data/Assembly-CSharp-Remapped.dll", // Path including the filename and extension we want to write the changes to
- "MappingPath": "./Data/Mappings.jsonc" // Path to the mapping file
+ "MaxMatchCount": 5, // Max matches the remapper will return
+ "Publicize": true, // Publicize all types, methods, and properties : NOTE: Not run until after the remap has completed
+ "Unseal": true, // Unseal all types : NOTE: Not run until after the remap has completed
+ "AssemblyPath": "./Data/Managed/Assembly-CSharp.dll", // Path to the assembly we want to remap
+ "OutputPath": "./Data/Assembly-CSharp-Remapped.dll", // Path including the filename and extension we want to write the changes to
+ "MappingPath": "./Data/Mappings.jsonc" // Path to the mapping file
+ },
+ "AutoMapper": {
+ "Publicize": true, // Publicize all types, methods, and properties : NOTE: Not run until after the remap has completed
+ "Unseal": true, // Unseal all types : NOTE: Not run until after the remap has completed
}
}