Skip to content

Commit

Permalink
Merge pull request #1 from Ruhrpottpatriot/UI-Improvements
Browse files Browse the repository at this point in the history
Can and should be merged
  • Loading branch information
Ruhrpottpatriot committed Aug 14, 2015
2 parents 5290c67 + c802bc0 commit 4f1fab8
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 47 deletions.
14 changes: 8 additions & 6 deletions Compiler/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Compiler
/// <summary>The path to the compiler.</summary>
private readonly string skyrimPath;

/// <summary>Initializes a new instance of the <see cref="Compiler"/> class.</summary>
/// <summary>Initialises a new instance of the <see cref="Compiler"/> class.</summary>
/// <param name="skyrimPath">The absolute path to skyrims main folder.</param>
/// <param name="logWriter">The log writer.</param>
public Compiler(string skyrimPath, LogWriter logWriter)
Expand Down Expand Up @@ -59,7 +59,7 @@ public Compiler(string skyrimPath, LogWriter logWriter)
public bool Optimize { get; set; }

/// <summary>Gets or sets the assembly options.</summary>
public AssemblyOptions AssemblyOptions { get; set; }
public string AssemblyOptions { get; set; }

/// <summary>Gets or sets the input folders.</summary>
/// <remarks>This property lists all folders that the compiler gets the script files from.
Expand Down Expand Up @@ -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;
}
Expand All @@ -188,7 +190,7 @@ private string GenerateArgumentString()
argumentsBuilder.Append(" -flags= \"" + this.Flags + "\"");

argumentsBuilder.Append(" -output=\"" + this.OutputFolder + "\"");

return argumentsBuilder.ToString();
}

Expand Down
17 changes: 16 additions & 1 deletion SkyrimCompileHelper/Common/CompileConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ public class CompileConfiguration
public string Name { get; set; }

/// <summary>Gets or sets the compiler flags.</summary>
public string CompilerFlags { get; set; }
public string FlagFile { get; set; }

/// <summary>Gets or sets a value indicating whether the compiler should compile a folder or single file.</summary>
public bool All { get; set; }

/// <summary> Gets or sets a value indicating whether the compiler should supress the output.</summary>
public bool Quiet { get; set; }

/// <summary>Gets or sets a value indicating whether the compiler should output debug information.</summary>
public bool Debug { get; set; }

/// <summary>Gets or sets a value indicating whether the compiler optimize should optimize the scripts.</summary>
public bool Optimize { get; set; }

/// <summary>Gets or sets the assembly option.</summary>
public string AssemblyOption { get; set; }
}
}
2 changes: 1 addition & 1 deletion SkyrimCompileHelper/Common/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Solution()
public IList<CompileConfiguration> CompileConfigurations { get; set; }

/// <summary>Gets or sets the selected configuration.</summary>
public CompileConfiguration SelectedConfiguration { get; set; }
public string SelectedConfiguration { get; set; }

/// <summary>Gets or sets the version.</summary>
public SemVersion Version { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion SkyrimCompileHelper/SkyrimCompileHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<Compile Include="Common\Repositories\SettingsRepository.cs" />
<Compile Include="Common\Repositories\SolutionRepository.cs" />
<Compile Include="ViewModels\AddConfigurationViewModel.cs" />
<Compile Include="ViewModels\SolutionViewModel.cs" />
<Page Include="Views\AddConfigurationView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -139,7 +140,6 @@
<Compile Include="ViewModels\ChangeVersionViewModel.cs" />
<Compile Include="ViewModels\ConfigurationManagerViewModel.cs" />
<Compile Include="ViewModels\SolutionManagerViewModel.cs" />
<Compile Include="ViewModels\SolutionViewModel.cs" />
<Compile Include="ViewModels\NewSolutionViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
</ItemGroup>
Expand Down
8 changes: 6 additions & 2 deletions SkyrimCompileHelper/ViewModels/AddConfigurationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace SkyrimCompileHelper.ViewModels
/// <summary>ViewModel containing methods and properties to create new configurations.</summary>
public class AddConfigurationViewModel : Screen
{
/// <summary>Initializes a new instance of the <see cref="AddConfigurationViewModel"/> class.</summary>
/// <summary>Initialises a new instance of the <see cref="AddConfigurationViewModel"/> class.</summary>
public AddConfigurationViewModel()
{
if (Execute.InDesignMode)
Expand Down Expand Up @@ -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
};
}
}
Expand Down
109 changes: 97 additions & 12 deletions SkyrimCompileHelper/ViewModels/SolutionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public class SolutionViewModel : PropertyChangedBase
/// <summary>The log writer.</summary>
private readonly LogWriter logWriter;

/// <summary>Initializes a new instance of the <see cref="SolutionViewModel"/> class.</summary>
/// <summary>Initialises a new instance of the <see cref="SolutionViewModel"/> class.</summary>
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<CompileConfiguration>
{
Expand All @@ -61,23 +61,35 @@ public SolutionViewModel()
}
}

/// <summary>Initializes a new instance of the <see cref="SolutionViewModel"/> class.</summary>
/// <summary>Initialises a new instance of the <see cref="SolutionViewModel"/> class.</summary>
/// <param name="windowManager">The window manager.</param>
/// <param name="settingsRepository">The settings repository.</param>
/// <param name="solutionRepository">The solution repository.</param>
/// <param name="solution">The solution to work with.</param>
/// <param name="logWriter">The log writer.</param>
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<CompileConfiguration>();
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<string>
{
"Assemble and Delete",
"Assemble and Keep",
"Generate only",
"No Assembly"
};

// Initialize the configuration parameters
this.IntConfigParameter(solution);
}

/// <summary>Gets or sets the solution name.</summary>
Expand All @@ -89,15 +101,33 @@ public SolutionViewModel(IWindowManager windowManager, ISettingsRepository setti
/// <summary>Gets or sets the solution version.</summary>
public SemVersion Version { get; set; }

/// <summary>Gets or sets the compiler flags.</summary>
public string CompilerFlags { get; set; }

/// <summary>Gets or sets the compile configurations.</summary>
public IList<CompileConfiguration> Configurations { get; set; }

/// <summary>Gets or sets the selected configuration.</summary>
public CompileConfiguration SelectedConfiguration { get; set; }

/// <summary>Gets or sets the compiler flags.</summary>
public string FlagsFile { get; set; }

/// <summary>Gets or sets a value indicating whether the compiler should compile a whole directory.</summary>
public bool CompilerAll { get; set; }

/// <summary>Gets or sets a value indicating whether the compiler should supress output.</summary>
public bool CompilerQuiet { get; set; }

/// <summary>Gets or sets a value indicating whether the compiler should print debug information.</summary>
public bool CompilerDebug { get; set; }

/// <summary>Gets or sets a value indicating whether the compiler should optimize the script files.</summary>
public bool CompilerOptimize { get; set; }

/// <summary>Gets or sets the compiler assembly options.</summary>
public IList<string> CompilerAssemblyOptions { get; set; }

/// <summary>Gets or sets the selected assembly option.</summary>
public string SelectedAssemblyOption { get; set; }

/// <summary>Opens the solution folder in the windows explorer.</summary>
/// <exception cref="NotImplementedException">Not yet implemented</exception>
public void OpenSolutionFolder()
Expand Down Expand Up @@ -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();
}

/// <summary>Saves a configuration to the repository.</summary>
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();
}

Expand All @@ -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;
Expand All @@ -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
}
}
};
Expand All @@ -222,5 +285,27 @@ private void OpenConfigurationManager()
this.Configurations = viewModel.Configurations;
}
}

/// <summary>Initialises the config parameters.</summary>
/// <param name="solution">The selected solution.</param>
private void IntConfigParameter(Solution solution)
{
this.Configurations = solution.CompileConfigurations ?? new List<CompileConfiguration>();
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;
}
}
}
Loading

0 comments on commit 4f1fab8

Please sign in to comment.