diff --git a/ReCodeItCLI/Commands/BuildCommand.cs b/ReCodeItCLI/Commands/BuildCommand.cs index d960c53..f22fa46 100644 --- a/ReCodeItCLI/Commands/BuildCommand.cs +++ b/ReCodeItCLI/Commands/BuildCommand.cs @@ -35,6 +35,9 @@ public class BuildCommand : ICommand DataProvider.LoadAppSettings(); ProjectManager.LoadProject(RegistryHelper.GetRegistryValue("LastLoadedProject"), true); + + if (!Validate(console)) { return default; } + CrossCompiler.StartCrossCompile(); DataProvider.SaveAppSettings(); @@ -43,4 +46,27 @@ public class BuildCommand : ICommand return default; } + + private bool Validate(IConsole console) + { + if (ProjectManager.ActiveProject == null) + { + console.Output.WriteLine("No project loaded, go create or load a project in the gui first"); + return false; + } + + if (ProjectManager.ActiveProject.RemapModels.Count == 0) + { + console.Output.WriteLine("No Remaps present, go to the gui and create some first"); + return false; + } + + if (ProjectManager.ActiveProject.ChangedTypes.Count == 0) + { + console.Output.WriteLine("There are no changed types, have you created and used a remapped reference? \nRun the command `buildRef` to generate a project reference"); + return false; + } + + return true; + } } \ No newline at end of file diff --git a/ReCodeItCLI/Commands/BuildRef.cs b/ReCodeItCLI/Commands/BuildRef.cs new file mode 100644 index 0000000..94bc0b2 --- /dev/null +++ b/ReCodeItCLI/Commands/BuildRef.cs @@ -0,0 +1,54 @@ +using CliFx; +using CliFx.Attributes; +using CliFx.Infrastructure; +using ReCodeIt.CrossCompiler; +using ReCodeIt.Utils; +using ReCodeItLib.Utils; + +namespace ReCodeIt.Commands; + +[Command("BuildRef", Description = "Builds or rebuilds a new reference DLL for your project")] +public class BuildRef : ICommand +{ + private ReCodeItCrossCompiler CrossCompiler { get; set; } + + public ValueTask ExecuteAsync(IConsole console) + { + console.Output.WriteLine(RegistryHelper.GetRegistryValue("LastLoadedProject")); + + if (RegistryHelper.GetRegistryValue("LastLoadedProject") != null) + { + CrossCompiler = new(); + + DataProvider.LoadAppSettings(); + + ProjectManager.LoadProject(RegistryHelper.GetRegistryValue("LastLoadedProject"), true); + + if (!Validate(console)) { return default; } + + CrossCompiler.StartRemap(); + + DataProvider.SaveAppSettings(); + return default; + } + + return default; + } + + private bool Validate(IConsole console) + { + if (ProjectManager.ActiveProject == null) + { + console.Output.WriteLine("No project loaded, please load a project first"); + return false; + } + + if (ProjectManager.ActiveProject.RemapModels.Count == 0) + { + console.Output.WriteLine("No Remaps present, go to the gui and create some first"); + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/RecodeItGUI/GUI/Main.cs b/RecodeItGUI/GUI/Main.cs index 5622603..365f0e9 100644 --- a/RecodeItGUI/GUI/Main.cs +++ b/RecodeItGUI/GUI/Main.cs @@ -306,7 +306,10 @@ public partial class ReCodeItForm : Form DataProvider.SaveMapping(); } - RemapTreeView.Nodes.Add(GUIHelpers.GenerateTreeNode(newRemap, this)); + var node = GUIHelpers.GenerateTreeNode(newRemap, this); + + RemapTreeView.Nodes.Add(node); + CCMappingTreeView.Nodes.Add(node); ResetAllRemapFields(); } @@ -432,6 +435,7 @@ public partial class ReCodeItForm : Form if (!MethodIncludeBox.Items.Contains(IncludeMethodTextBox.Text)) { MethodIncludeBox.Items.Add(IncludeMethodTextBox.Text); + IncludeMethodTextBox.Clear(); } } @@ -448,6 +452,7 @@ public partial class ReCodeItForm : Form if (!MethodExcludeBox.Items.Contains(ExcludeMethodTextBox.Text)) { MethodExcludeBox.Items.Add(ExcludeMethodTextBox.Text); + ExcludeMethodTextBox.Clear(); } } @@ -464,6 +469,7 @@ public partial class ReCodeItForm : Form if (!FieldIncludeBox.Items.Contains(FieldsIncludeTextInput.Text)) { FieldIncludeBox.Items.Add(FieldsIncludeTextInput.Text); + FieldsIncludeTextInput.Clear(); } } @@ -480,6 +486,7 @@ public partial class ReCodeItForm : Form if (!FieldExcludeBox.Items.Contains(FieldsExcludeTextInput.Text)) { FieldExcludeBox.Items.Add(FieldsExcludeTextInput.Text); + FieldsExcludeTextInput.Clear(); } } @@ -496,6 +503,7 @@ public partial class ReCodeItForm : Form if (!PropertiesIncludeBox.Items.Contains(PropertiesIncludeTextField.Text)) { PropertiesIncludeBox.Items.Add(PropertiesIncludeTextField.Text); + PropertiesIncludeTextField.Clear(); } } @@ -512,6 +520,7 @@ public partial class ReCodeItForm : Form if (!PropertiesExcludeBox.Items.Contains(PropertiesExcludeTextField.Text)) { PropertiesExcludeBox.Items.Add(PropertiesExcludeTextField.Text); + PropertiesExcludeTextField.Clear(); } } @@ -528,6 +537,7 @@ public partial class ReCodeItForm : Form if (!NestedTypesIncludeBox.Items.Contains(NestedTypesIncludeTextField.Text)) { NestedTypesIncludeBox.Items.Add(NestedTypesIncludeTextField.Text); + NestedTypesIncludeTextField.Clear(); } } @@ -544,6 +554,7 @@ public partial class ReCodeItForm : Form if (!NestedTypesExcludeBox.Items.Contains(NestedTypesExcludeTextField.Text)) { NestedTypesExcludeBox.Items.Add(NestedTypesExcludeTextField.Text); + NestedTypesExcludeTextField.Clear(); } } diff --git a/RecodeItLib/Remapper/ReCodeItRemapper.cs b/RecodeItLib/Remapper/ReCodeItRemapper.cs index 00876d2..92ac4b3 100644 --- a/RecodeItLib/Remapper/ReCodeItRemapper.cs +++ b/RecodeItLib/Remapper/ReCodeItRemapper.cs @@ -296,20 +296,10 @@ public class ReCodeItRemapper Logger.Log($"Remap took {Stopwatch.Elapsed.TotalSeconds:F1} seconds", ConsoleColor.Green); Logger.Log("-----------------------------------------------", ConsoleColor.Green); - Reset(); + DataProvider.ScoringModels = []; + Stopwatch.Reset(); + IsRunning = false; OnComplete?.Invoke(); } - - private void Reset() - { - Logger.Log("-----------------------------------------------", ConsoleColor.Yellow); - Logger.Log("Reloading assembly definitions", ConsoleColor.Yellow); - Logger.Log("-----------------------------------------------", ConsoleColor.Yellow); - - DataProvider.LoadAssemblyDefinition(Settings.AssemblyPath); - DataProvider.ScoringModels = []; - - Stopwatch.Reset(); - } } \ No newline at end of file diff --git a/RecodeItLib/Utils/DataProvider.cs b/RecodeItLib/Utils/DataProvider.cs index 63c452b..f2b719a 100644 --- a/RecodeItLib/Utils/DataProvider.cs +++ b/RecodeItLib/Utils/DataProvider.cs @@ -173,6 +173,8 @@ public static class DataProvider DefaultAssemblyResolver resolver = new(); + Console.WriteLine(path); + resolver.AddSearchDirectory(Path.GetDirectoryName(path)); // Replace with the correct path : (6/14) I have no idea what I met by that ReaderParameters parameters = new() { AssemblyResolver = resolver };