From a1e94b8c3d474b33ba6acbf182dfedd061c2b57d Mon Sep 17 00:00:00 2001 From: Cj <161484149+CJ-SPT@users.noreply.github.com> Date: Mon, 17 Jun 2024 18:19:17 -0400 Subject: [PATCH] Prepare settings for cross mapper --- RecodeItGUI/GUI/Main.cs | 28 +++++++------- RecodeItLib/Models/AppSettingsModel.cs | 48 ++++++++++++++++++------ RecodeItLib/Remapper/ReCodeItRemapper.cs | 8 ++-- Templates/Settings.jsonc | 27 +++++++++---- 4 files changed, 73 insertions(+), 38 deletions(-) diff --git a/RecodeItGUI/GUI/Main.cs b/RecodeItGUI/GUI/Main.cs index d24fd94..70cf70c 100644 --- a/RecodeItGUI/GUI/Main.cs +++ b/RecodeItGUI/GUI/Main.cs @@ -400,10 +400,10 @@ public partial class ReCodeItForm : Form // Remapper page TargetAssemblyPath.Text = DataProvider.Settings.Remapper.AssemblyPath; RemapperOutputDirectoryPath.Text = DataProvider.Settings.Remapper.OutputPath; - RenameFieldsCheckbox.Checked = DataProvider.Settings.Remapper.RenameFields; - RenamePropertiesCheckbox.Checked = DataProvider.Settings.Remapper.RenameProperties; - RemapperPublicicize.Checked = DataProvider.Settings.Remapper.Publicize; - RemapperUnseal.Checked = DataProvider.Settings.Remapper.Unseal; + RenameFieldsCheckbox.Checked = DataProvider.Settings.Remapper.MappingSettings.RenameFields; + RenamePropertiesCheckbox.Checked = DataProvider.Settings.Remapper.MappingSettings.RenameProperties; + RemapperPublicicize.Checked = DataProvider.Settings.Remapper.MappingSettings.Publicize; + RemapperUnseal.Checked = DataProvider.Settings.Remapper.MappingSettings.Unseal; } #region SETTINGS_BUTTONS @@ -454,13 +454,13 @@ public partial class ReCodeItForm : Form private void PublicizeCheckbox_CheckedChanged(object sender, EventArgs e) { - DataProvider.Settings.Remapper.Publicize = PublicizeCheckbox.Checked; + DataProvider.Settings.Remapper.MappingSettings.Publicize = PublicizeCheckbox.Checked; DataProvider.SaveAppSettings(); } private void UnsealCheckbox_CheckedChanged(object sender, EventArgs e) { - DataProvider.Settings.Remapper.Unseal = UnsealCheckbox.Checked; + DataProvider.Settings.Remapper.MappingSettings.Unseal = UnsealCheckbox.Checked; DataProvider.SaveAppSettings(); } @@ -489,10 +489,10 @@ public partial class ReCodeItForm : Form AutoMapperRequiredMatchesUpDown.Value = DataProvider.Settings.AutoMapper.RequiredMatches; AutoMapperMinLengthUpDown.Value = DataProvider.Settings.AutoMapper.MinLengthToMatch; AutoMapperSearchMethodsCheckBox.Checked = DataProvider.Settings.AutoMapper.SearchMethods; - AutoMapperRenameFields.Checked = DataProvider.Settings.AutoMapper.RenameFields; - AutoMapperRenameProps.Checked = DataProvider.Settings.AutoMapper.RenameProperties; - AutoMapperPublicize.Checked = DataProvider.Settings.AutoMapper.Publicize; - AutoMapperUnseal.Checked = DataProvider.Settings.AutoMapper.Unseal; + AutoMapperRenameFields.Checked = DataProvider.Settings.AutoMapper.MappingSettings.RenameFields; + AutoMapperRenameProps.Checked = DataProvider.Settings.AutoMapper.MappingSettings.RenameProperties; + AutoMapperPublicize.Checked = DataProvider.Settings.AutoMapper.MappingSettings.Publicize; + AutoMapperUnseal.Checked = DataProvider.Settings.AutoMapper.MappingSettings.Unseal; foreach (var type in DataProvider.Settings.AutoMapper.TypesToIgnore) { @@ -633,25 +633,25 @@ public partial class ReCodeItForm : Form private void AutoMapperRenameFields_CheckedChanged(object sender, EventArgs e) { - DataProvider.Settings.AutoMapper.RenameFields = AutoMapperRenameFields.Checked; + DataProvider.Settings.AutoMapper.MappingSettings.RenameFields = AutoMapperRenameFields.Checked; DataProvider.SaveAppSettings(); } private void AutoMapperRenameProps_CheckedChanged(object sender, EventArgs e) { - DataProvider.Settings.AutoMapper.RenameProperties = AutoMapperRenameProps.Checked; + DataProvider.Settings.AutoMapper.MappingSettings.RenameProperties = AutoMapperRenameProps.Checked; DataProvider.SaveAppSettings(); } private void AutoMapperPublicize_CheckedChanged(object sender, EventArgs e) { - DataProvider.Settings.AutoMapper.Publicize = AutoMapperPublicize.Checked; + DataProvider.Settings.AutoMapper.MappingSettings.Publicize = AutoMapperPublicize.Checked; DataProvider.SaveAppSettings(); } private void AutoMapperUnseal_CheckedChanged(object sender, EventArgs e) { - DataProvider.Settings.AutoMapper.Unseal = AutoMapperUnseal.Checked; + DataProvider.Settings.AutoMapper.MappingSettings.Unseal = AutoMapperUnseal.Checked; DataProvider.SaveAppSettings(); } diff --git a/RecodeItLib/Models/AppSettingsModel.cs b/RecodeItLib/Models/AppSettingsModel.cs index 8736ee8..f1a5f76 100644 --- a/RecodeItLib/Models/AppSettingsModel.cs +++ b/RecodeItLib/Models/AppSettingsModel.cs @@ -1,36 +1,41 @@ namespace ReCodeIt.Models; /// -/// Remap config +/// All settings container /// public class Settings { public AppSettings AppSettings { get; set; } public RemapperSettings Remapper { get; set; } public AutoMapperSettings AutoMapper { get; set; } + public CrossPatchingSettings CrossPatching { get; set; } } +/// +/// These are settings for the application +/// public class AppSettings { public bool Debug { get; set; } public bool SilentMode { get; set; } - public bool RenameFields { get; set; } public bool RenameProperties { get; set; } } +/// +/// These are settings for the manual remapper +/// public class RemapperSettings { public string AssemblyPath { get; set; } public string OutputPath { get; set; } public string MappingPath { get; set; } - - public bool RenameFields { get; set; } - public bool RenameProperties { get; set; } - public bool Publicize { get; set; } - public bool Unseal { get; set; } + public MappingSettings MappingSettings { get; set; } } +/// +/// These are settings for the auto mapping +/// public class AutoMapperSettings { public string AssemblyPath { get; set; } @@ -38,11 +43,7 @@ public class AutoMapperSettings public int RequiredMatches { get; set; } public int MinLengthToMatch { get; set; } public bool SearchMethods { get; set; } - public bool RenameFields { get; set; } - public bool RenameProperties { get; set; } - public bool Publicize { get; set; } - public bool Unseal { get; set; } - + public MappingSettings MappingSettings { get; set; } public List TypesToIgnore { get; set; } public List TokensToMatch { get; set; } @@ -50,4 +51,27 @@ public class AutoMapperSettings public List PropertyFieldBlackList { get; set; } public List MethodParamaterBlackList { get; set; } +} + +/// +/// These are settings for the cross patching module +/// +public class CrossPatchingSettings +{ + public string OriginalAssemblyPath { get; set; } + public string TargetProjectAssemblyBuildPath { get; set; } + public string ReferencePath { get; set; } + public string MappingPath { get; set; } + public string OutputPath { get; set; } +} + +/// +/// These are settings that all versions of the remappers use +/// +public class MappingSettings +{ + public bool RenameFields { get; set; } + public bool RenameProperties { get; set; } + public bool Publicize { get; set; } + public bool Unseal { get; set; } } \ No newline at end of file diff --git a/RecodeItLib/Remapper/ReCodeItRemapper.cs b/RecodeItLib/Remapper/ReCodeItRemapper.cs index 2985f2b..c0436fa 100644 --- a/RecodeItLib/Remapper/ReCodeItRemapper.cs +++ b/RecodeItLib/Remapper/ReCodeItRemapper.cs @@ -41,12 +41,12 @@ public class ReCodeItRemapper ChooseBestMatches(); // Dont publicize and unseal until after the remapping so we can use those as search parameters - if (!Settings.Publicize) + if (!Settings.MappingSettings.Publicize) { Publicizer.Publicize(); } - if (!Settings.Unseal) + if (!Settings.MappingSettings.Unseal) { Publicizer.Unseal(); } @@ -63,8 +63,8 @@ public class ReCodeItRemapper Logger.Log("-----------------------------------------------", ConsoleColor.Yellow); Logger.Log($"Starting remap...", ConsoleColor.Yellow); Logger.Log($"Module contains {DataProvider.ModuleDefinition.Types.Count} Types", ConsoleColor.Yellow); - Logger.Log($"Publicize: {Settings.Publicize}", ConsoleColor.Yellow); - Logger.Log($"Unseal: {Settings.Unseal}", ConsoleColor.Yellow); + Logger.Log($"Publicize: {Settings.MappingSettings.Publicize}", ConsoleColor.Yellow); + Logger.Log($"Unseal: {Settings.MappingSettings.Unseal}", ConsoleColor.Yellow); Logger.Log("-----------------------------------------------", ConsoleColor.Yellow); } diff --git a/Templates/Settings.jsonc b/Templates/Settings.jsonc index aa09b79..1062e67 100644 --- a/Templates/Settings.jsonc +++ b/Templates/Settings.jsonc @@ -7,10 +7,12 @@ "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 - "RenameFields": true, // Names of fields of the matched type will be renamed to the type name with approproiate convention - "RenameProperties": true, // Names of properties of the matched type will be renamed to the type name with approproiate convention - "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 + "MappingSettings": { + "RenameFields": true, // Names of fields of the matched type will be renamed to the type name with approproiate convention + "RenameProperties": true, // Names of properties of the matched type will be renamed to the type name with approproiate convention + "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 + } }, "AutoMapper": { "AssemblyPath": "./Data/Managed/Assembly-CSharp.dll", // Path to the assembly we want to remap @@ -18,10 +20,12 @@ "RequiredMatches": 5, // Minimum number of times a member must have this name in the assembly before considering it for remapping "MinLengthToMatch": 7, // Minimum length of the field/property name in code before it will be considered for a rename "SearchMethods": true, // Will attempt to map types from method meta data and parameters - "RenameFields": true, // Names of fields of the matched type will be renamed to the type name with approproiate convention - "RenameProperties": true, // Names of properties of the matched type will be renamed to the type name with approproiate convention - "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 + "MappingSettings": { + "RenameFields": true, // Names of fields of the matched type will be renamed to the type name with approproiate convention + "RenameProperties": true, // Names of properties of the matched type will be renamed to the type name with approproiate convention + "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 + }, "TypesToIgnore": [ // Any member name you want to ignore while iterating through the assembly "Boolean", "List", @@ -60,5 +64,12 @@ ], "MethodParamaterBlackList": [ // method parameter names to ignore in the automap, these are case sanitized so case does not matter ] + }, + "CrossPatching": { + "OriginalAssemblyPath": "", // The path to the original assembly to use as a reference, for unity games its 'Assembly-CSharp.dll' from the games Data/Managed Folder + "TargetProjectAssemblyBuildPath": "", // The build path of your project, specifically the absolute path of your projects assembly. + "ReferencePath": "", // Where should the new reference dll be placed? (This is the remapped one you reference in your project) + "MappingPath": "./Data/Mappings.jsonc", // Path to the mapping file + "OutputPath": "" // Where should the final cross patched dll be placed? (This is the one you test/distribute with) } }