From 0109e55281331b01155a41416f483ed731a6ce2d Mon Sep 17 00:00:00 2001 From: Cj <161484149+CJ-SPT@users.noreply.github.com> Date: Mon, 17 Jun 2024 20:25:53 -0400 Subject: [PATCH] Finish up cross mapper UI for now --- RecodeItGUI/GUI/Main.Designer.cs | 255 ++++++++++++------------- RecodeItGUI/GUI/Main.cs | 102 ++++++++++ RecodeItLib/Models/AppSettingsModel.cs | 18 +- Templates/Settings.jsonc | 9 +- 4 files changed, 234 insertions(+), 150 deletions(-) diff --git a/RecodeItGUI/GUI/Main.Designer.cs b/RecodeItGUI/GUI/Main.Designer.cs index 39a7354..2faa79c 100644 --- a/RecodeItGUI/GUI/Main.Designer.cs +++ b/RecodeItGUI/GUI/Main.Designer.cs @@ -141,18 +141,17 @@ partial class ReCodeItForm AutoMapperTypesExcludeBox = new ListBox(); tabPage5 = new TabPage(); groupBox4 = new GroupBox(); - CrossPatcherUnsealEnabled = new CheckBox(); - CrossPatchingPublicizeEnabled = new CheckBox(); - groupBox3 = new GroupBox(); - CrossPatchingRunButton = new Button(); - textBox4 = new TextBox(); - CrossPatchingBuildDirButton = new Button(); - textBox3 = new TextBox(); - textBox1 = new TextBox(); - textBox2 = new TextBox(); - CrossPatchingMappingChooseButton = new Button(); - CrossPatchingOrigAssemblyButton = new Button(); + CrossPatchRunButton = new Button(); + CrossMapperProjectBuildPath = new TextBox(); + CrossPatchingProjectBuildDirButton = new Button(); + CrossMapperProjTargetAssembly = new TextBox(); CrossMappingOutputChooseButton = new Button(); + groupBox3 = new GroupBox(); + CrossPatchRemapOutputButton = new Button(); + CrossMapperReferencePath = new TextBox(); + CrossPatchRemapButton = new Button(); + CrossMapperOriginalAssembly = new TextBox(); + CrossPatchingOrigAssemblyButton = new Button(); SettingsTab = new TabPage(); groupBox2 = new GroupBox(); SilentModeCheckbox = new CheckBox(); @@ -1416,140 +1415,131 @@ partial class ReCodeItForm tabPage5.Size = new Size(1336, 953); tabPage5.TabIndex = 4; tabPage5.Text = "Cross Patching"; + tabPage5.Click += tabPage5_Click; // // groupBox4 // - groupBox4.Controls.Add(CrossPatcherUnsealEnabled); - groupBox4.Controls.Add(CrossPatchingPublicizeEnabled); - groupBox4.Location = new Point(490, 6); + groupBox4.Controls.Add(CrossPatchRunButton); + groupBox4.Controls.Add(CrossMapperProjectBuildPath); + groupBox4.Controls.Add(CrossPatchingProjectBuildDirButton); + groupBox4.Controls.Add(CrossMapperProjTargetAssembly); + groupBox4.Controls.Add(CrossMappingOutputChooseButton); + groupBox4.Location = new Point(13, 174); groupBox4.Name = "groupBox4"; - groupBox4.Size = new Size(445, 350); + groupBox4.Size = new Size(631, 151); groupBox4.TabIndex = 22; groupBox4.TabStop = false; - groupBox4.Text = "Patch Settings"; + groupBox4.Text = "Reverse Patch"; // - // CrossPatcherUnsealEnabled + // CrossPatchRunButton // - CrossPatcherUnsealEnabled.AutoSize = true; - CrossPatcherUnsealEnabled.Checked = true; - CrossPatcherUnsealEnabled.CheckState = CheckState.Checked; - CrossPatcherUnsealEnabled.Location = new Point(6, 65); - CrossPatcherUnsealEnabled.Name = "CrossPatcherUnsealEnabled"; - CrossPatcherUnsealEnabled.Size = new Size(90, 29); - CrossPatcherUnsealEnabled.TabIndex = 12; - CrossPatcherUnsealEnabled.Text = "Unseal"; - CrossPatcherUnsealEnabled.UseVisualStyleBackColor = true; + CrossPatchRunButton.Location = new Point(475, 104); + CrossPatchRunButton.Name = "CrossPatchRunButton"; + CrossPatchRunButton.Size = new Size(150, 34); + CrossPatchRunButton.TabIndex = 24; + CrossPatchRunButton.Text = "Reverse Patch"; + CrossPatchRunButton.UseVisualStyleBackColor = true; + CrossPatchRunButton.Click += CrossPatchRunButton_Click; // - // CrossPatchingPublicizeEnabled + // CrossMapperProjectBuildPath // - CrossPatchingPublicizeEnabled.AutoSize = true; - CrossPatchingPublicizeEnabled.Checked = true; - CrossPatchingPublicizeEnabled.CheckState = CheckState.Checked; - CrossPatchingPublicizeEnabled.Location = new Point(6, 30); - CrossPatchingPublicizeEnabled.Name = "CrossPatchingPublicizeEnabled"; - CrossPatchingPublicizeEnabled.Size = new Size(106, 29); - CrossPatchingPublicizeEnabled.TabIndex = 11; - CrossPatchingPublicizeEnabled.Text = "Publicize"; - CrossPatchingPublicizeEnabled.UseVisualStyleBackColor = true; + CrossMapperProjectBuildPath.Location = new Point(6, 30); + CrossMapperProjectBuildPath.Name = "CrossMapperProjectBuildPath"; + CrossMapperProjectBuildPath.PlaceholderText = "Input Assembly that was built against the remap assembly"; + CrossMapperProjectBuildPath.ReadOnly = true; + CrossMapperProjectBuildPath.Size = new Size(501, 31); + CrossMapperProjectBuildPath.TabIndex = 15; // - // groupBox3 + // CrossPatchingProjectBuildDirButton // - groupBox3.Controls.Add(CrossPatchingRunButton); - groupBox3.Controls.Add(textBox4); - groupBox3.Controls.Add(CrossPatchingBuildDirButton); - groupBox3.Controls.Add(textBox3); - groupBox3.Controls.Add(textBox1); - groupBox3.Controls.Add(textBox2); - groupBox3.Controls.Add(CrossPatchingMappingChooseButton); - groupBox3.Controls.Add(CrossPatchingOrigAssemblyButton); - groupBox3.Controls.Add(CrossMappingOutputChooseButton); - groupBox3.Location = new Point(13, 6); - groupBox3.Name = "groupBox3"; - groupBox3.Size = new Size(445, 350); - groupBox3.TabIndex = 21; - groupBox3.TabStop = false; - groupBox3.Text = "General"; + CrossPatchingProjectBuildDirButton.Location = new Point(513, 27); + CrossPatchingProjectBuildDirButton.Name = "CrossPatchingProjectBuildDirButton"; + CrossPatchingProjectBuildDirButton.Size = new Size(112, 34); + CrossPatchingProjectBuildDirButton.TabIndex = 20; + CrossPatchingProjectBuildDirButton.Text = "Choose"; + CrossPatchingProjectBuildDirButton.UseVisualStyleBackColor = true; + CrossPatchingProjectBuildDirButton.Click += CrossPatchingProjectBuildDirButton_Click; // - // CrossPatchingRunButton + // CrossMapperProjTargetAssembly // - CrossPatchingRunButton.Location = new Point(308, 310); - CrossPatchingRunButton.Name = "CrossPatchingRunButton"; - CrossPatchingRunButton.Size = new Size(112, 34); - CrossPatchingRunButton.TabIndex = 21; - CrossPatchingRunButton.Text = "Run"; - CrossPatchingRunButton.UseVisualStyleBackColor = true; - // - // textBox4 - // - textBox4.Location = new Point(6, 39); - textBox4.Name = "textBox4"; - textBox4.PlaceholderText = "Original Assembly"; - textBox4.ReadOnly = true; - textBox4.Size = new Size(296, 31); - textBox4.TabIndex = 13; - // - // CrossPatchingBuildDirButton - // - CrossPatchingBuildDirButton.Location = new Point(308, 73); - CrossPatchingBuildDirButton.Name = "CrossPatchingBuildDirButton"; - CrossPatchingBuildDirButton.Size = new Size(112, 34); - CrossPatchingBuildDirButton.TabIndex = 20; - CrossPatchingBuildDirButton.Text = "Choose"; - CrossPatchingBuildDirButton.UseVisualStyleBackColor = true; - // - // textBox3 - // - textBox3.Location = new Point(6, 113); - textBox3.Name = "textBox3"; - textBox3.PlaceholderText = "Output Directory"; - textBox3.ReadOnly = true; - textBox3.Size = new Size(296, 31); - textBox3.TabIndex = 14; - // - // textBox1 - // - textBox1.Location = new Point(6, 76); - textBox1.Name = "textBox1"; - textBox1.PlaceholderText = "VS build path including file name"; - textBox1.ReadOnly = true; - textBox1.Size = new Size(296, 31); - textBox1.TabIndex = 19; - // - // textBox2 - // - textBox2.Location = new Point(6, 150); - textBox2.Name = "textBox2"; - textBox2.PlaceholderText = "Mapping.json path"; - textBox2.ReadOnly = true; - textBox2.Size = new Size(296, 31); - textBox2.TabIndex = 15; - // - // CrossPatchingMappingChooseButton - // - CrossPatchingMappingChooseButton.Location = new Point(308, 147); - CrossPatchingMappingChooseButton.Name = "CrossPatchingMappingChooseButton"; - CrossPatchingMappingChooseButton.Size = new Size(112, 34); - CrossPatchingMappingChooseButton.TabIndex = 18; - CrossPatchingMappingChooseButton.Text = "Choose"; - CrossPatchingMappingChooseButton.UseVisualStyleBackColor = true; - // - // CrossPatchingOrigAssemblyButton - // - CrossPatchingOrigAssemblyButton.Location = new Point(308, 39); - CrossPatchingOrigAssemblyButton.Name = "CrossPatchingOrigAssemblyButton"; - CrossPatchingOrigAssemblyButton.Size = new Size(112, 34); - CrossPatchingOrigAssemblyButton.TabIndex = 16; - CrossPatchingOrigAssemblyButton.Text = "Choose"; - CrossPatchingOrigAssemblyButton.UseVisualStyleBackColor = true; + CrossMapperProjTargetAssembly.Location = new Point(6, 67); + CrossMapperProjTargetAssembly.Name = "CrossMapperProjTargetAssembly"; + CrossMapperProjTargetAssembly.PlaceholderText = "Output directory"; + CrossMapperProjTargetAssembly.ReadOnly = true; + CrossMapperProjTargetAssembly.Size = new Size(501, 31); + CrossMapperProjTargetAssembly.TabIndex = 19; // // CrossMappingOutputChooseButton // - CrossMappingOutputChooseButton.Location = new Point(308, 110); + CrossMappingOutputChooseButton.Location = new Point(513, 66); CrossMappingOutputChooseButton.Name = "CrossMappingOutputChooseButton"; CrossMappingOutputChooseButton.Size = new Size(112, 34); CrossMappingOutputChooseButton.TabIndex = 17; CrossMappingOutputChooseButton.Text = "Choose"; CrossMappingOutputChooseButton.UseVisualStyleBackColor = true; + CrossMappingOutputChooseButton.Click += CrossMappingOutputChooseButton_Click; + // + // groupBox3 + // + groupBox3.Controls.Add(CrossPatchRemapOutputButton); + groupBox3.Controls.Add(CrossMapperReferencePath); + groupBox3.Controls.Add(CrossPatchRemapButton); + groupBox3.Controls.Add(CrossMapperOriginalAssembly); + groupBox3.Controls.Add(CrossPatchingOrigAssemblyButton); + groupBox3.Location = new Point(13, 6); + groupBox3.Name = "groupBox3"; + groupBox3.Size = new Size(631, 162); + groupBox3.TabIndex = 21; + groupBox3.TabStop = false; + groupBox3.Text = "Remap"; + // + // CrossPatchRemapOutputButton + // + CrossPatchRemapOutputButton.Location = new Point(513, 75); + CrossPatchRemapOutputButton.Name = "CrossPatchRemapOutputButton"; + CrossPatchRemapOutputButton.Size = new Size(112, 34); + CrossPatchRemapOutputButton.TabIndex = 23; + CrossPatchRemapOutputButton.Text = "Choose"; + CrossPatchRemapOutputButton.UseVisualStyleBackColor = true; + CrossPatchRemapOutputButton.Click += CrossPatchingProjectReferncePath_Click; + // + // CrossMapperReferencePath + // + CrossMapperReferencePath.Location = new Point(6, 77); + CrossMapperReferencePath.Name = "CrossMapperReferencePath"; + CrossMapperReferencePath.PlaceholderText = "Remapped Assembly Output (Assembly-CSharp-Remapped)"; + CrossMapperReferencePath.ReadOnly = true; + CrossMapperReferencePath.Size = new Size(501, 31); + CrossMapperReferencePath.TabIndex = 14; + // + // CrossPatchRemapButton + // + CrossPatchRemapButton.Location = new Point(513, 115); + CrossPatchRemapButton.Name = "CrossPatchRemapButton"; + CrossPatchRemapButton.Size = new Size(112, 34); + CrossPatchRemapButton.TabIndex = 21; + CrossPatchRemapButton.Text = "Remap"; + CrossPatchRemapButton.UseVisualStyleBackColor = true; + CrossPatchRemapButton.Click += CrossPatchRemapButton_Click; + // + // CrossMapperOriginalAssembly + // + CrossMapperOriginalAssembly.Location = new Point(6, 39); + CrossMapperOriginalAssembly.Name = "CrossMapperOriginalAssembly"; + CrossMapperOriginalAssembly.PlaceholderText = "Original Input Target Assembly (Assembly-CSharp)"; + CrossMapperOriginalAssembly.ReadOnly = true; + CrossMapperOriginalAssembly.Size = new Size(501, 31); + CrossMapperOriginalAssembly.TabIndex = 13; + // + // CrossPatchingOrigAssemblyButton + // + CrossPatchingOrigAssemblyButton.Location = new Point(513, 37); + CrossPatchingOrigAssemblyButton.Name = "CrossPatchingOrigAssemblyButton"; + CrossPatchingOrigAssemblyButton.Size = new Size(112, 34); + CrossPatchingOrigAssemblyButton.TabIndex = 16; + CrossPatchingOrigAssemblyButton.Text = "Choose"; + CrossPatchingOrigAssemblyButton.UseVisualStyleBackColor = true; + CrossPatchingOrigAssemblyButton.Click += CrossPatchingOrigAssemblyButton_Click; // // SettingsTab // @@ -1743,19 +1733,15 @@ partial class ReCodeItForm private TabPage tabPage5; private Button PickNameMangledPathButton; private TextBox NameMangledAssemblyTextBox; - private Button CrossPatchingBuildDirButton; - private TextBox textBox1; - private Button CrossPatchingMappingChooseButton; + private Button CrossPatchingProjectBuildDirButton; + private TextBox CrossMapperProjTargetAssembly; private Button CrossMappingOutputChooseButton; private Button CrossPatchingOrigAssemblyButton; - private TextBox textBox2; - private TextBox textBox3; - private TextBox textBox4; - private GroupBox groupBox4; - private CheckBox CrossPatcherUnsealEnabled; - private CheckBox CrossPatchingPublicizeEnabled; + private TextBox CrossMapperProjectBuildPath; + private TextBox CrossMapperReferencePath; + private TextBox CrossMapperOriginalAssembly; private GroupBox groupBox3; - private Button CrossPatchingRunButton; + private Button CrossPatchRemapButton; private CheckBox UnsealCheckbox; private CheckBox RenamePropertiesCheckbox; private CheckBox PublicizeCheckbox; @@ -1778,4 +1764,7 @@ partial class ReCodeItForm private CheckBox AutoMapperPublicize; private CheckBox AutoMapperRenameProps; private CheckBox AutoMapperRenameFields; + private Button CrossPatchRemapOutputButton; + private Button CrossPatchRunButton; + private GroupBox groupBox4; } diff --git a/RecodeItGUI/GUI/Main.cs b/RecodeItGUI/GUI/Main.cs index 1786e7b..28650fa 100644 --- a/RecodeItGUI/GUI/Main.cs +++ b/RecodeItGUI/GUI/Main.cs @@ -22,6 +22,7 @@ public partial class ReCodeItForm : Form PopulateDomainUpDowns(); RefreshSettingsPage(); RefreshAutoMapperPage(); + RefreshCrossPatchPage(); RemapTreeView.NodeMouseDoubleClick += EditSelectedRemap; Remapper.OnComplete += ReloadTreeView; @@ -638,6 +639,98 @@ public partial class ReCodeItForm : Form #endregion AUTOMAPPER + #region CROSSPATCHER + + /// + /// Remapper Input + /// + /// + /// + private void CrossPatchingOrigAssemblyButton_Click(object sender, EventArgs e) + { + var result = GUIHelpers.OpenFileDialog("Select the original assembly", + "DLL Files (*.dll)|*.dll|All Files (*.*)|*.*"); + + if (result != string.Empty) + { + DataProvider.Settings.CrossPatching.OriginalAssemblyPath = result; + CrossMapperOriginalAssembly.Text = result; + DataProvider.SaveAppSettings(); + } + } + + /// + /// Remapper Output + /// + /// + /// + private void CrossPatchingProjectReferncePath_Click(object sender, EventArgs e) + { + var result = GUIHelpers.OpenFileDialog("Output path of the Remapped assembly", + "DLL Files (*.dll)|*.dll|All Files (*.*)|*.*"); + + if (result != string.Empty) + { + DataProvider.Settings.CrossPatching.RemappedOutput = result; + CrossMapperReferencePath.Text = result; + DataProvider.SaveAppSettings(); + } + } + + /// + /// Reverse Patch Input - The input path of the assembly referenced by the remapped dll + /// + /// + /// + private void CrossPatchingProjectBuildDirButton_Click(object sender, EventArgs e) + { + var result = GUIHelpers.OpenFileDialog("Select the assembly that referenced the remapped dll", + "DLL Files (*.dll)|*.dll|All Files (*.*)|*.*"); + + if (result != string.Empty) + { + DataProvider.Settings.CrossPatching.ReversePatchInputPath = result; + CrossMapperProjectBuildPath.Text = result; + DataProvider.SaveAppSettings(); + } + } + + /// + /// Reverse Patch output + /// + /// + /// + private void CrossMappingOutputChooseButton_Click(object sender, EventArgs e) + { + var result = GUIHelpers.OpenFileDialog("Output location of the final unmapped dll", + "DLL Files (*.dll)|*.dll|All Files (*.*)|*.*"); + + if (result != string.Empty) + { + DataProvider.Settings.CrossPatching.ReversePatchOutputPath = result; + CrossMapperProjTargetAssembly.Text = result; + DataProvider.SaveAppSettings(); + } + } + + private void CrossPatchRemapButton_Click(object sender, EventArgs e) + { + } + + private void CrossPatchRunButton_Click(object sender, EventArgs e) + { + } + + private void RefreshCrossPatchPage() + { + CrossMapperOriginalAssembly.Text = DataProvider.Settings.CrossPatching.OriginalAssemblyPath; + CrossMapperReferencePath.Text = DataProvider.Settings.CrossPatching.RemappedOutput; + CrossMapperProjectBuildPath.Text = DataProvider.Settings.CrossPatching.ReversePatchInputPath; + CrossMapperProjTargetAssembly.Text = DataProvider.Settings.CrossPatching.ReversePatchOutputPath; + } + + #endregion CROSSPATCHER + // Reset All UI elements to default private void ResetAll() { @@ -786,16 +879,25 @@ public partial class ReCodeItForm : Form HasGenericParametersUpDown.BuildStringList("HasGenericParams"); } + #region TAB_REFRESH + private void AutoMapperTab_Click(object sender, EventArgs e) { RefreshAutoMapperPage(); } + private void tabPage5_Click(object sender, EventArgs e) + { + RefreshCrossPatchPage(); + } + private void SettingsTab_Click(object sender, EventArgs e) { RefreshSettingsPage(); } + #endregion TAB_REFRESH + /// /// Subscribes the the remappers OnComplete event /// diff --git a/RecodeItLib/Models/AppSettingsModel.cs b/RecodeItLib/Models/AppSettingsModel.cs index 1462e7a..abce993 100644 --- a/RecodeItLib/Models/AppSettingsModel.cs +++ b/RecodeItLib/Models/AppSettingsModel.cs @@ -111,25 +111,19 @@ public class CrossPatchingSettings public string OriginalAssemblyPath { get; set; } /// - /// Where should the new reference dll be placed? (This is the remapped one you reference in - /// your project) + /// The output path of the remapped assembly /// - public string ReferencePath { get; set; } + public string RemappedOutput { get; set; } /// - /// Path to the mapping file + /// The input path of the assembly referenced by the remapped dll /// - public string MappingPath { get; set; } + public string ReversePatchInputPath { get; set; } /// - /// The build path of your project, specifically the absolute path of your projects output assembly. + /// Where should the de-patched dll be placed? (This is the one you test/distribute with) /// - public string TargetProjectAssemblyBuildPath { get; set; } - - /// - /// Where should the final cross patched dll be placed? (This is the one you test/distribute with) - /// - public string OutputPath { get; set; } + public string ReversePatchOutputPath { get; set; } } /// diff --git a/Templates/Settings.jsonc b/Templates/Settings.jsonc index 0eaa244..e8242e7 100644 --- a/Templates/Settings.jsonc +++ b/Templates/Settings.jsonc @@ -66,10 +66,9 @@ ] }, "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 - "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 - "TargetProjectAssemblyBuildPath": "", // The build path of your project, specifically the absolute path of your projects output assembly. - "OutputPath": "" // Where should the final cross patched dll be placed? (This is the one you test/distribute with) + "OriginalAssemblyPath": "G:\\3.8.0 - Dev\\EscapeFromTarkov_Data\\Managed\\Assembly-CSharp.dll", // INPUT: The path to the original assembly to use as a reference, for unity games its 'Assembly-CSharp.dll' from the games Data/Managed Folder + "RemappedOutput": "G:\\development\\SPT-MODS\\StashSearch\\dependencies\\Assembly-CSharp.dll", // OUTPUT: The output path of the remapped assembly + "ReversePatchInputPath": "G:\\development\\SPT-MODS\\StashSearch\\StashSearch\\bin\\Debug\\net472\\StashSearch.dll", // INPUT: The input path of the assembly referenced by the remapped dll + "ReversePatchOutputPath": "G:\\3.8.0 - Dev\\BepInEx\\Plugins\\StashSearch\\StashSearch.dll" // OUTPUT/TEST/PROD: Where should the de-patched dll be placed? (This is the one you test/distribute with) } }