diff --git a/RecodeItGUI/GUI/Main.Designer.cs b/RecodeItGUI/GUI/Main.Designer.cs index 47f2d61..de4e4f1 100644 --- a/RecodeItGUI/GUI/Main.Designer.cs +++ b/RecodeItGUI/GUI/Main.Designer.cs @@ -145,6 +145,7 @@ partial class ReCodeItForm CCMappingTreeView = new TreeView(); CrossPatchRunButton = new Button(); groupBox3 = new GroupBox(); + CCAutoLoadLastProj = new CheckBox(); CCLoadProjButton = new Button(); CCRemappedOutputButton = new Button(); CCRemappedOutputText = new TextBox(); @@ -160,7 +161,6 @@ partial class ReCodeItForm groupBox2 = new GroupBox(); SilentModeCheckbox = new CheckBox(); DebugLoggingCheckbox = new CheckBox(); - CCAutoLoadLastProj = new CheckBox(); TabPageRemapper.SuspendLayout(); groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)ConstuctorCountUpDown).BeginInit(); @@ -262,6 +262,7 @@ partial class ReCodeItForm ActiveProjectMappingsCheckbox.TabIndex = 39; ActiveProjectMappingsCheckbox.Text = "Use Active Project Mappings"; ActiveProjectMappingsCheckbox.UseVisualStyleBackColor = true; + ActiveProjectMappingsCheckbox.CheckedChanged += ActiveProjectMappingsCheckbox_CheckedChanged; // // LoadedMappingFilePath // @@ -1481,6 +1482,19 @@ partial class ReCodeItForm groupBox3.TabStop = false; groupBox3.Text = "ReCodeIt Proj Settings"; // + // CCAutoLoadLastProj + // + CCAutoLoadLastProj.AutoSize = true; + CCAutoLoadLastProj.Checked = true; + CCAutoLoadLastProj.CheckState = CheckState.Checked; + CCAutoLoadLastProj.Location = new Point(6, 247); + CCAutoLoadLastProj.Name = "CCAutoLoadLastProj"; + CCAutoLoadLastProj.Size = new Size(259, 29); + CCAutoLoadLastProj.TabIndex = 34; + CCAutoLoadLastProj.Text = "Auto load last active project"; + CCAutoLoadLastProj.UseVisualStyleBackColor = true; + CCAutoLoadLastProj.CheckedChanged += CCAutoLoadLastProj_CheckedChanged_1; + // // CCLoadProjButton // CCLoadProjButton.Location = new Point(475, 247); @@ -1632,16 +1646,6 @@ partial class ReCodeItForm DebugLoggingCheckbox.UseVisualStyleBackColor = true; DebugLoggingCheckbox.CheckedChanged += DebugLoggingCheckbox_CheckedChanged; // - // CCAutoLoadLastProj - // - CCAutoLoadLastProj.AutoSize = true; - CCAutoLoadLastProj.Location = new Point(6, 247); - CCAutoLoadLastProj.Name = "CCAutoLoadLastProj"; - CCAutoLoadLastProj.Size = new Size(259, 29); - CCAutoLoadLastProj.TabIndex = 34; - CCAutoLoadLastProj.Text = "Auto load last active project"; - CCAutoLoadLastProj.UseVisualStyleBackColor = true; - // // ReCodeItForm // AutoScaleDimensions = new SizeF(10F, 25F); diff --git a/RecodeItGUI/GUI/Main.cs b/RecodeItGUI/GUI/Main.cs index 302c14e..470ff17 100644 --- a/RecodeItGUI/GUI/Main.cs +++ b/RecodeItGUI/GUI/Main.cs @@ -28,13 +28,15 @@ public partial class ReCodeItForm : Form DataProvider.LoadMappingFile(DataProvider.Settings.Remapper.MappingPath); LoadedMappingFilePath.Text = DataProvider.Settings.Remapper.MappingPath; + PopulateDomainUpDowns(); RefreshSettingsPage(); RefreshAutoMapperPage(); - RefreshCrossPatchPage(); - RemapTreeView.NodeMouseDoubleClick += EditSelectedRemap; + RefreshCrossCompilerPage(); + RemapTreeView.NodeMouseDoubleClick += EditSelectedRemap; Remapper.OnComplete += ReloadTreeView; + ReloadTreeView(this, EventArgs.Empty); } @@ -641,8 +643,29 @@ public partial class ReCodeItForm : Form #region CROSS_COMPILER - private void RefreshCrossPatchPage() + private void RefreshCrossCompilerPage() { + var ccSettings = DataProvider.Settings.CrossCompiler; + + CCAutoLoadLastProj.Checked = ccSettings.AutoLoadLastActiveProject; + + if (ccSettings.AutoLoadLastActiveProject) + { + // Dont continue if its an empty string, it hasnt been set yet + if (ccSettings.LastLoadedProject == string.Empty) + { + return; + } + + if (!File.Exists(ccSettings.LastLoadedProject)) + { + MessageBox.Show("Couldnt find last loaded project"); + return; + } + + ProjectManager.LoadProject(ccSettings.LastLoadedProject); + } + if (CrossCompiler.ActiveProject == null) { return; @@ -663,7 +686,6 @@ public partial class ReCodeItForm : Form if (result != string.Empty) { - DataProvider.Settings.CrossCompiler.OriginalAssemblyPath = result; CCOriginalAssemblyText.Text = result; DataProvider.SaveAppSettings(); } @@ -675,7 +697,6 @@ public partial class ReCodeItForm : Form if (result != string.Empty) { - DataProvider.Settings.CrossCompiler.RemappedOutput = result; CCRemappedOutputText.Text = result; DataProvider.SaveAppSettings(); } @@ -687,7 +708,6 @@ public partial class ReCodeItForm : Form if (result != string.Empty) { - DataProvider.Settings.CrossCompiler.VisualStudioSolutionPath = result; CCVisualStudioProjDirText.Text = result; DataProvider.SaveAppSettings(); } @@ -699,7 +719,6 @@ public partial class ReCodeItForm : Form if (result != string.Empty) { - DataProvider.Settings.CrossCompiler.BuildPath = result; CCBuildDirText.Text = result; DataProvider.SaveAppSettings(); } @@ -745,6 +764,18 @@ public partial class ReCodeItForm : Form } } + private void CCAutoLoadLastProj_CheckedChanged_1(object sender, EventArgs e) + { + DataProvider.Settings.CrossCompiler.AutoLoadLastActiveProject = CCAutoLoadLastProj.Checked; + DataProvider.SaveAppSettings(); + } + + // Use the projects remap list on the remap tab + private void ActiveProjectMappingsCheckbox_CheckedChanged(object sender, EventArgs e) + { + // TODO + } + #endregion CROSS_COMPILER // Reset All UI elements to default @@ -904,7 +935,7 @@ public partial class ReCodeItForm : Form private void tabPage5_Click(object sender, EventArgs e) { - RefreshCrossPatchPage(); + RefreshCrossCompilerPage(); } private void SettingsTab_Click(object sender, EventArgs e) diff --git a/RecodeItLib/CrossCompiler/ProjectManager.cs b/RecodeItLib/CrossCompiler/ProjectManager.cs index 8797532..1563cb9 100644 --- a/RecodeItLib/CrossCompiler/ProjectManager.cs +++ b/RecodeItLib/CrossCompiler/ProjectManager.cs @@ -6,21 +6,9 @@ namespace ReCodeIt.CrossCompiler; public static class ProjectManager { - /// - /// Key: Path of the project, Value: Project file - /// - public static Dictionary Projects { get; private set; } = []; - public static CrossCompilerProjectModel ActiveProject { get; private set; } - private static CrossCompilerSettings Settings => DataProvider.Settings.CrossCompiler; - private static HashSet CopyIgnoreDirectories { get; } = - [ - ".vs", - ".git" - ]; - public static void CreateProject( string OrigAssemblyPath, string RemappedAssemblyOutputPath, @@ -55,7 +43,7 @@ public static class ProjectManager Logger.Log($"Found Solution: {ActiveProject.SolutionName}", ConsoleColor.Yellow); Logger.Log($"Original Assembly Checksum: {ActiveProject.OriginalAssemblyHash}", ConsoleColor.Yellow); - Logger.Log($"Project Generated to: {DataProvider.Settings.CrossCompiler.LastActiveProjectPath}", ConsoleColor.Green); + Logger.Log($"Project Generated to: {DataProvider.Settings.CrossCompiler.LastLoadedProject}", ConsoleColor.Green); Logger.Log("-----------------------------------------------", ConsoleColor.Yellow); } @@ -119,9 +107,16 @@ public static class ProjectManager file.CopyTo(tempPath, true); } + // We dont want git and vs directories they are often locked leading to problems + List copyIgnoreDirectories = + [ + ".vs", + ".git" + ]; + foreach (DirectoryInfo subdir in dirs) { - if (CopyIgnoreDirectories.Contains(subdir.Name)) { continue; } + if (copyIgnoreDirectories.Contains(subdir.Name)) { continue; } string tempPath = Path.Combine(destinationDirPath, subdir.Name); CopyProjectRecursive(subdir.FullName, tempPath); @@ -141,7 +136,7 @@ public static class ProjectManager File.WriteAllText(path, jsonText); - DataProvider.Settings.CrossCompiler.LastActiveProjectPath = path; + DataProvider.Settings.CrossCompiler.LastLoadedProject = path; DataProvider.SaveAppSettings(); Logger.Log($"Cross Compiler project json generated to {path}", ConsoleColor.Green); @@ -158,7 +153,7 @@ public static class ProjectManager var model = JsonConvert.DeserializeObject(jsonText); - DataProvider.Settings.CrossCompiler.LastActiveProjectPath = path; + DataProvider.Settings.CrossCompiler.LastLoadedProject = path; DataProvider.SaveAppSettings(); Logger.Log($"Loaded Cross Compiler Project: {model?.RemappedAssemblyPath}"); diff --git a/RecodeItLib/CrossCompiler/ReCodeItCrossCompiler.cs b/RecodeItLib/CrossCompiler/ReCodeItCrossCompiler.cs index 7058d9f..d031944 100644 --- a/RecodeItLib/CrossCompiler/ReCodeItCrossCompiler.cs +++ b/RecodeItLib/CrossCompiler/ReCodeItCrossCompiler.cs @@ -24,7 +24,7 @@ public class ReCodeItCrossCompiler public void StartRemap() { ChangedTypes.Clear(); - Remapper.InitializeRemap(Settings.OriginalAssemblyPath, Settings.RemappedOutput, true); + Remapper.InitializeRemap(ActiveProject.OriginalAssemblyPath, ActiveProject.RemappedAssemblyPath, true); if (ActiveProject == null) { diff --git a/RecodeItLib/Models/AppSettingsModel.cs b/RecodeItLib/Models/AppSettingsModel.cs index e6c1d46..1419c0b 100644 --- a/RecodeItLib/Models/AppSettingsModel.cs +++ b/RecodeItLib/Models/AppSettingsModel.cs @@ -107,7 +107,12 @@ public class CrossCompilerSettings /// /// Last Loaded Project Path /// - public string LastActiveProjectPath { get; set; } + public string LastLoadedProject { get; set; } + + /// + /// Should the last active project be auto loaded + /// + public bool AutoLoadLastActiveProject { get; set; } } /// diff --git a/Templates/Settings.jsonc b/Templates/Settings.jsonc index 5118df9..b43faeb 100644 --- a/Templates/Settings.jsonc +++ b/Templates/Settings.jsonc @@ -66,6 +66,7 @@ ] }, "CrossCompiler": { + "AutoLoadLastActiveProject": true, // Autoload last active project "LastLoadedProject": "" // Last loaded project path } }