diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index a2a440d..438be2f 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -29,7 +29,7 @@ public class Compiler /// The path to the compiler. private readonly string skyrimPath; - /// Initializes a new instance of the class. + /// Initialises a new instance of the class. /// The absolute path to skyrims main folder. /// The log writer. public Compiler(string skyrimPath, LogWriter logWriter) @@ -59,7 +59,7 @@ public Compiler(string skyrimPath, LogWriter logWriter) public bool Optimize { get; set; } /// Gets or sets the assembly options. - public AssemblyOptions AssemblyOptions { get; set; } + public string AssemblyOptions { get; set; } /// Gets or sets the input folders. /// This property lists all folders that the compiler gets the script files from. @@ -161,15 +161,17 @@ private string GenerateArgumentString() } // Check what we want to do with the assembly files afterwards. + // The "Assemble and Delete" option will not be appended to the argument string, + // as it has no representing argument. switch (this.AssemblyOptions) { - case AssemblyOptions.NoAssembly: + case "No Assembly": argumentsBuilder.Append(" -noasm"); break; - case AssemblyOptions.AssembleAndKeep: + case "Assemble and Keep": argumentsBuilder.Append(" -keepasm"); break; - case AssemblyOptions.GenerateOnly: + case "Generate only": argumentsBuilder.Append(" -asmonly"); break; } @@ -188,7 +190,7 @@ private string GenerateArgumentString() argumentsBuilder.Append(" -flags= \"" + this.Flags + "\""); argumentsBuilder.Append(" -output=\"" + this.OutputFolder + "\""); - + return argumentsBuilder.ToString(); } diff --git a/SkyrimCompileHelper/Common/CompileConfiguration.cs b/SkyrimCompileHelper/Common/CompileConfiguration.cs index 40e7a87..13e2a5f 100644 --- a/SkyrimCompileHelper/Common/CompileConfiguration.cs +++ b/SkyrimCompileHelper/Common/CompileConfiguration.cs @@ -18,6 +18,21 @@ public class CompileConfiguration public string Name { get; set; } /// Gets or sets the compiler flags. - public string CompilerFlags { get; set; } + public string FlagFile { get; set; } + + /// Gets or sets a value indicating whether the compiler should compile a folder or single file. + public bool All { get; set; } + + /// Gets or sets a value indicating whether the compiler should supress the output. + public bool Quiet { get; set; } + + /// Gets or sets a value indicating whether the compiler should output debug information. + public bool Debug { get; set; } + + /// Gets or sets a value indicating whether the compiler optimize should optimize the scripts. + public bool Optimize { get; set; } + + /// Gets or sets the assembly option. + public string AssemblyOption { get; set; } } } \ No newline at end of file diff --git a/SkyrimCompileHelper/Common/Solution.cs b/SkyrimCompileHelper/Common/Solution.cs index ce9bfb9..2b50c07 100644 --- a/SkyrimCompileHelper/Common/Solution.cs +++ b/SkyrimCompileHelper/Common/Solution.cs @@ -22,7 +22,7 @@ public Solution() public IList CompileConfigurations { get; set; } /// Gets or sets the selected configuration. - public CompileConfiguration SelectedConfiguration { get; set; } + public string SelectedConfiguration { get; set; } /// Gets or sets the version. public SemVersion Version { get; set; } diff --git a/SkyrimCompileHelper/SkyrimCompileHelper.csproj b/SkyrimCompileHelper/SkyrimCompileHelper.csproj index cd17e56..b8ea92a 100644 --- a/SkyrimCompileHelper/SkyrimCompileHelper.csproj +++ b/SkyrimCompileHelper/SkyrimCompileHelper.csproj @@ -102,6 +102,7 @@ + Designer MSBuild:Compile @@ -139,7 +140,6 @@ - diff --git a/SkyrimCompileHelper/ViewModels/AddConfigurationViewModel.cs b/SkyrimCompileHelper/ViewModels/AddConfigurationViewModel.cs index a145f02..d4fb390 100644 --- a/SkyrimCompileHelper/ViewModels/AddConfigurationViewModel.cs +++ b/SkyrimCompileHelper/ViewModels/AddConfigurationViewModel.cs @@ -18,7 +18,7 @@ namespace SkyrimCompileHelper.ViewModels /// ViewModel containing methods and properties to create new configurations. public class AddConfigurationViewModel : Screen { - /// Initializes a new instance of the class. + /// Initialises a new instance of the class. public AddConfigurationViewModel() { if (Execute.InDesignMode) @@ -49,7 +49,11 @@ public CompileConfiguration GetConfiguration() return new CompileConfiguration { Name = this.ConfigurationName, - CompilerFlags = "TESV_Papyrus_Flags.flg" + FlagFile = "TESV_Papyrus_Flags.flg", + All = true, + Quiet = false, + Debug = true, + Optimize = false }; } } diff --git a/SkyrimCompileHelper/ViewModels/SolutionViewModel.cs b/SkyrimCompileHelper/ViewModels/SolutionViewModel.cs index f5cf3ac..b2e9517 100644 --- a/SkyrimCompileHelper/ViewModels/SolutionViewModel.cs +++ b/SkyrimCompileHelper/ViewModels/SolutionViewModel.cs @@ -43,14 +43,14 @@ public class SolutionViewModel : PropertyChangedBase /// The log writer. private readonly LogWriter logWriter; - /// Initializes a new instance of the class. + /// Initialises a new instance of the class. public SolutionViewModel() { if (Execute.InDesignMode) { this.SolutionName = "Outfits of Skyrim"; this.Version = new SemVersion(0, 1); - this.CompilerFlags = "Flags"; + this.FlagsFile = "Flags"; this.SolutionPath = @"C:\Test"; this.Configurations = new List { @@ -61,7 +61,7 @@ public SolutionViewModel() } } - /// Initializes a new instance of the class. + /// Initialises a new instance of the class. /// The window manager. /// The settings repository. /// The solution repository. @@ -69,15 +69,27 @@ public SolutionViewModel() /// The log writer. public SolutionViewModel(IWindowManager windowManager, ISettingsRepository settingsRepository, ISolutionRepository solutionRepository, Solution solution, LogWriter logWriter) { + // Initilaize readonly fields this.windowManager = windowManager; this.settingsRepository = settingsRepository; this.solutionRepository = solutionRepository; this.logWriter = logWriter; - this.Configurations = solution.CompileConfigurations ?? new List(); - this.Configurations.Add(new CompileConfiguration { Name = Constants.EditConst }); + + // Init the parameters this.SolutionName = solution.Name; this.SolutionPath = solution.Path; this.Version = solution.Version; + this.CompilerAll = true; + this.CompilerAssemblyOptions = new List + { + "Assemble and Delete", + "Assemble and Keep", + "Generate only", + "No Assembly" + }; + + // Initialize the configuration parameters + this.IntConfigParameter(solution); } /// Gets or sets the solution name. @@ -89,15 +101,33 @@ public SolutionViewModel(IWindowManager windowManager, ISettingsRepository setti /// Gets or sets the solution version. public SemVersion Version { get; set; } - /// Gets or sets the compiler flags. - public string CompilerFlags { get; set; } - /// Gets or sets the compile configurations. public IList Configurations { get; set; } /// Gets or sets the selected configuration. public CompileConfiguration SelectedConfiguration { get; set; } + /// Gets or sets the compiler flags. + public string FlagsFile { get; set; } + + /// Gets or sets a value indicating whether the compiler should compile a whole directory. + public bool CompilerAll { get; set; } + + /// Gets or sets a value indicating whether the compiler should supress output. + public bool CompilerQuiet { get; set; } + + /// Gets or sets a value indicating whether the compiler should print debug information. + public bool CompilerDebug { get; set; } + + /// Gets or sets a value indicating whether the compiler should optimize the script files. + public bool CompilerOptimize { get; set; } + + /// Gets or sets the compiler assembly options. + public IList CompilerAssemblyOptions { get; set; } + + /// Gets or sets the selected assembly option. + public string SelectedAssemblyOption { get; set; } + /// Opens the solution folder in the windows explorer. /// Not yet implemented public void OpenSolutionFolder() @@ -155,7 +185,36 @@ public void ChangeConfiguration(ComboBox sender) } CompileConfiguration configuration = this.Configurations.SingleOrDefault(c => c.Name == configurationName); - this.CompilerFlags = configuration != null ? configuration.CompilerFlags : string.Empty; + if (configuration != null) + { + this.CompilerAll = configuration.All; + this.CompilerDebug = configuration.Debug; + this.CompilerOptimize = configuration.Optimize; + this.SelectedAssemblyOption = configuration.AssemblyOption; + this.CompilerQuiet = configuration.Quiet; + this.FlagsFile = configuration.FlagFile; + } + + this.SelectedConfiguration = configuration; + + this.SaveSolution(); + } + + /// Saves a configuration to the repository. + public void SaveConfiguration() + { + CompileConfiguration compConfig = this.SelectedConfiguration; + + compConfig.All = this.CompilerAll; + compConfig.AssemblyOption = this.SelectedAssemblyOption; + compConfig.Debug = this.CompilerDebug; + compConfig.FlagFile = this.FlagsFile; + compConfig.Optimize = this.CompilerOptimize; + compConfig.Quiet = this.CompilerQuiet; + + this.SelectedConfiguration = compConfig; + this.Configurations.Remove(compConfig); + this.Configurations.Add(compConfig); this.SaveSolution(); } @@ -170,10 +229,14 @@ public void Compile() Compiler compiler = new Compiler(this.settingsRepository.Read()["SkyrimPath"].ToString(), this.logWriter) { - Flags = this.CompilerFlags, + Flags = this.FlagsFile, InputFolders = inputFolders.ToList(), OutputFolder = Path.Combine(this.SolutionPath, "bin", this.SelectedConfiguration.Name), - All = true + All = this.CompilerAll, + Quiet = this.CompilerQuiet, + Debug = this.CompilerDebug, + Optimize = this.CompilerOptimize, + AssemblyOptions = this.SelectedAssemblyOption }; int build = Convert.ToInt32(string.IsNullOrEmpty(this.Version.Build) ? "0" : this.Version.Build) + 1; @@ -195,7 +258,7 @@ private void SaveSolution() Path = this.SolutionPath, Version = this.Version, CompileConfigurations = this.Configurations.Where(c => c.Name != Constants.EditConst).ToList(), - SelectedConfiguration = this.SelectedConfiguration + SelectedConfiguration = this.SelectedConfiguration.Name ?? string.Empty } } }; @@ -222,5 +285,27 @@ private void OpenConfigurationManager() this.Configurations = viewModel.Configurations; } } + + /// Initialises the config parameters. + /// The selected solution. + private void IntConfigParameter(Solution solution) + { + this.Configurations = solution.CompileConfigurations ?? new List(); + this.Configurations.Add(new CompileConfiguration { Name = Constants.EditConst }); + this.SelectedConfiguration = this.Configurations.SingleOrDefault(c => c.Name == solution.SelectedConfiguration); + + // If there is no selected configuration, we do nothing. + if (this.SelectedConfiguration == null) + { + return; + } + + this.CompilerAll = this.SelectedConfiguration.All; + this.CompilerDebug = this.SelectedConfiguration.Debug; + this.CompilerOptimize = this.SelectedConfiguration.Optimize; + this.CompilerQuiet = this.SelectedConfiguration.Quiet; + this.FlagsFile = this.SelectedConfiguration.FlagFile; + this.SelectedAssemblyOption = this.SelectedConfiguration.AssemblyOption; + } } } diff --git a/SkyrimCompileHelper/Views/SolutionView.xaml b/SkyrimCompileHelper/Views/SolutionView.xaml index a031bfa..b20a294 100644 --- a/SkyrimCompileHelper/Views/SolutionView.xaml +++ b/SkyrimCompileHelper/Views/SolutionView.xaml @@ -1,12 +1,12 @@  @@ -21,11 +21,11 @@ - - - - - + + + + + - - - - - @@ -56,11 +52,11 @@ Margin="0,3,0,3" Grid.ColumnSpan="2"> - +