Prepare settings for cross mapper

This commit is contained in:
Cj 2024-06-17 18:19:17 -04:00
parent 8bcf3c8bd4
commit a1e94b8c3d
4 changed files with 73 additions and 38 deletions

View File

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

View File

@ -1,36 +1,41 @@
namespace ReCodeIt.Models;
/// <summary>
/// Remap config
/// All settings container
/// </summary>
public class Settings
{
public AppSettings AppSettings { get; set; }
public RemapperSettings Remapper { get; set; }
public AutoMapperSettings AutoMapper { get; set; }
public CrossPatchingSettings CrossPatching { get; set; }
}
/// <summary>
/// These are settings for the application
/// </summary>
public class AppSettings
{
public bool Debug { get; set; }
public bool SilentMode { get; set; }
public bool RenameFields { get; set; }
public bool RenameProperties { get; set; }
}
/// <summary>
/// These are settings for the manual remapper
/// </summary>
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; }
}
/// <summary>
/// These are settings for the auto mapping
/// </summary>
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<string> TypesToIgnore { get; set; }
public List<string> TokensToMatch { get; set; }
@ -51,3 +52,26 @@ public class AutoMapperSettings
public List<string> MethodParamaterBlackList { get; set; }
}
/// <summary>
/// These are settings for the cross patching module
/// </summary>
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; }
}
/// <summary>
/// These are settings that all versions of the remappers use
/// </summary>
public class MappingSettings
{
public bool RenameFields { get; set; }
public bool RenameProperties { get; set; }
public bool Publicize { get; set; }
public bool Unseal { get; set; }
}

View File

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

View File

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