Skip to content

Commit

Permalink
Merge branch 'dev' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Apr 12, 2024
2 parents 5d33059 + 3df4bf5 commit 1bc32b2
Show file tree
Hide file tree
Showing 27 changed files with 204 additions and 47 deletions.
14 changes: 7 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@
<Version>17.9.0</Version>
</PackageVersion>
<PackageVersion Include="Mutagen.Bethesda">
<Version>[0.43.3]</Version>
<Version>[0.44]</Version>
</PackageVersion>
<PackageVersion Include="Mutagen.Bethesda.Autofac">
<Version>[0.43.3]</Version>
<Version>[0.44]</Version>
</PackageVersion>
<PackageVersion Include="Mutagen.Bethesda.Core">
<Version>[0.43.3]</Version>
<Version>[0.44]</Version>
</PackageVersion>
<PackageVersion Include="Mutagen.Bethesda.Json">
<Version>[0.43.3]</Version>
<Version>[0.44]</Version>
</PackageVersion>
<PackageVersion Include="Mutagen.Bethesda.Kernel">
<Version>[0.43.3]</Version>
<Version>[0.44]</Version>
</PackageVersion>
<PackageVersion Include="Mutagen.Bethesda.Testing">
<Version>[0.43.3]</Version>
<Version>[0.44]</Version>
</PackageVersion>
<PackageVersion Include="Mutagen.Bethesda.WPF">
<Version>[0.43.3]</Version>
<Version>[0.44]</Version>
</PackageVersion>
<PackageVersion Include="Newtonsoft.Json">
<Version>13.0.3</Version>
Expand Down
9 changes: 9 additions & 0 deletions Mutagen.Bethesda.Synthesis/CLI/RunSynthesisMutagenPatcher.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommandLine;
using Mutagen.Bethesda.Strings;
using Synthesis.Bethesda;

namespace Mutagen.Bethesda.Synthesis.CLI;

Expand Down Expand Up @@ -51,6 +52,12 @@ public class RunSynthesisMutagenPatcher
[Option("UseUtf8ForEmbeddedStrings", Required = false, HelpText = "Use UTF8 encoding when reading/writing localizable mod strings that are embedded")]
public bool UseUtf8ForEmbeddedStrings { get; set; }

[Option("HeaderVersionOverride", Required = false, HelpText = "Whether to override the header version when making a new mod object")]
public float? HeaderVersionOverride { get; set; }

[Option("FormIDRangeMode", Required = false, HelpText = "Whether to override the header version when making a new mod object")]
public FormIDRangeMode FormIDRangeMode { get; set; }

public override string ToString()
{
return $"{nameof(RunSynthesisMutagenPatcher)} => \n"
Expand All @@ -68,6 +75,8 @@ public override string ToString()
+ $" {nameof(TargetLanguage)} => {TargetLanguage}\n"
+ $" {nameof(Localize)} => {Localize}\n"
+ $" {nameof(ModKey)} => {ModKey}\n"
+ $" {nameof(HeaderVersionOverride)} => {HeaderVersionOverride}\n"
+ $" {nameof(FormIDRangeMode)} => {FormIDRangeMode}\n"
+ $" {nameof(UseUtf8ForEmbeddedStrings)} => {UseUtf8ForEmbeddedStrings}";
}
}
10 changes: 7 additions & 3 deletions Mutagen.Bethesda.Synthesis/Pipeline/SynthesisPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -786,15 +786,17 @@ public void Patch<TMod, TModGetter>(
#endregion

private BinaryWriteParameters GetWriteParams(RunSynthesisMutagenPatcher args, IEnumerable<ModKey> loadOrder)
{
{
return new BinaryWriteParameters()
{
ModKey = ModKeyOption.NoCheck,
MastersListOrdering = new MastersListOrderingByLoadOrder(loadOrder),
TargetLanguageOverride = args.TargetLanguage,
Encodings = args.UseUtf8ForEmbeddedStrings
? new EncodingBundle(NonTranslated: MutagenEncoding._1252, NonLocalized: MutagenEncoding._utf8)
: null
: null,
LowerRangeDisallowedHandler = ALowerRangeDisallowedHandlerOption.AddPlaceholder(loadOrder),
MinimumFormID = AMinimumFormIdOption.Force(args.FormIDRangeMode.ToForceBool())
};
}

Expand Down Expand Up @@ -856,7 +858,9 @@ private static RunSynthesisMutagenPatcher GetDefaultRun(
InternalDataFolder = LocateInternalData(fileSystem),
TargetLanguage = extraParameters.TargetLanguage,
Localize = extraParameters.Localize,
UseUtf8ForEmbeddedStrings = extraParameters.UseUtf8ForEmbeddedStrings
UseUtf8ForEmbeddedStrings = extraParameters.UseUtf8ForEmbeddedStrings,
FormIDRangeMode = extraParameters.FormIDRangeMode,
HeaderVersionOverride = extraParameters.HeaderVersionOverride,
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.IO.Abstractions;
using Mutagen.Bethesda.Strings;
using Synthesis.Bethesda;

namespace Mutagen.Bethesda.Synthesis.Pipeline;

Expand All @@ -8,4 +8,6 @@ public record TypicalOpenExtraParameters
public Language TargetLanguage { get; init; } = Language.English;
public bool Localize { get; init; }
public bool UseUtf8ForEmbeddedStrings { get; init; }
public float? HeaderVersionOverride { get; init; }
public FormIDRangeMode FormIDRangeMode { get; init; }
}
24 changes: 22 additions & 2 deletions Mutagen.Bethesda.Synthesis/States/DI/PatcherStateFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.IO.Abstractions;
using System.IO.Abstractions;
using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Plugins.Allocators;
using Mutagen.Bethesda.Plugins.Cache;
Expand All @@ -8,6 +8,7 @@
using Mutagen.Bethesda.Strings;
using Mutagen.Bethesda.Strings.DI;
using Mutagen.Bethesda.Synthesis.CLI;
using Synthesis.Bethesda;

namespace Mutagen.Bethesda.Synthesis.States.DI;

Expand Down Expand Up @@ -118,7 +119,26 @@ public SynthesisState<TModSetter, TModGetter> ToState<TModSetter, TModGetter>(Ru
{
if (settings.SourcePath == null)
{
patchMod = ModInstantiator<TModSetter>.Activator(exportKey, settings.GameRelease);
Console.WriteLine("Creating new mod:");
Console.WriteLine($" ModKey: {exportKey}");
Console.WriteLine($" GameRelease: {settings.GameRelease}");
if (settings.HeaderVersionOverride != null)
{
Console.WriteLine($" HeaderVersion: {settings.HeaderVersionOverride}");
}

var forceFormIdLowerRange = settings.FormIDRangeMode.ToForceBool();

if (forceFormIdLowerRange != null)
{
Console.WriteLine($" Force FormID Lower Range: {forceFormIdLowerRange}");
}
patchMod = ModInstantiator<TModSetter>.Activator(
exportKey,
settings.GameRelease,
headerVersion: settings.HeaderVersionOverride,
forceUseLowerFormIDRanges: forceFormIdLowerRange);
Console.WriteLine($" Next FormID: {patchMod.NextFormID}");
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion Synthesis.Bethesda.CLI/RunPipeline/RunPatcherPipeline.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Synthesis.Bethesda.Execution.Commands;
using Synthesis.Bethesda.Execution.Commands;
using Synthesis.Bethesda.Execution.Running.Runner;
using Synthesis.Bethesda.Execution.Settings;

Expand Down Expand Up @@ -40,6 +40,8 @@ await ExecuteRun
TargetLanguage: ProfileSettings.TargetLanguage,
Localize: ProfileSettings.Localize,
UseUtf8ForEmbeddedStrings: ProfileSettings.UseUtf8ForEmbeddedStrings,
HeaderVersionOverride: ProfileSettings.HeaderVersionOverride,
FormIDRangeMode: ProfileSettings.FormIDRangeMode,
PersistenceMode: Instructions.PersistenceMode ?? PersistenceMode.None,
PersistencePath: Instructions.PersistencePath)).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Mutagen.Bethesda.Strings;
using Mutagen.Bethesda.Synthesis.CLI;
using Synthesis.Bethesda.Commands;
Expand Down Expand Up @@ -37,7 +37,9 @@ public RunSynthesisMutagenPatcher Convert(RunSynthesisPatcher settings)
Localize = settings.Localize,
TargetLanguage = Enum.Parse<Language>(settings.TargetLanguage),
ModKey = settings.ModKey,
UseUtf8ForEmbeddedStrings = settings.UseUtf8ForEmbeddedStrings
UseUtf8ForEmbeddedStrings = settings.UseUtf8ForEmbeddedStrings,
FormIDRangeMode = settings.FormIDRangeMode,
HeaderVersionOverride = settings.HeaderVersionOverride,
};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.IO.Abstractions;
using System.IO.Abstractions;
using Mutagen.Bethesda.Strings;
using Mutagen.Bethesda.Synthesis.CLI;
using Synthesis.Bethesda.Commands;
Expand Down Expand Up @@ -50,7 +50,9 @@ public RunSynthesisMutagenPatcher Construct(RunSynthesisPatcher settings)
TargetLanguage = Enum.Parse<Language>(settings.TargetLanguage),
Localize = settings.Localize,
ModKey = settings.ModKey,
UseUtf8ForEmbeddedStrings = settings.UseUtf8ForEmbeddedStrings
UseUtf8ForEmbeddedStrings = settings.UseUtf8ForEmbeddedStrings,
HeaderVersionOverride = settings.HeaderVersionOverride,
FormIDRangeMode = settings.FormIDRangeMode,
};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Serilog;
using Serilog;
using Synthesis.Bethesda.Execution.DotNet.Builder;
using Synthesis.Bethesda.Execution.Patchers.Solution;

Expand Down Expand Up @@ -33,19 +33,19 @@ public async Task Prep(CancellationToken cancel)
await Task.WhenAll(
Task.Run(async () =>
{
_logger.Information("Compiling");
_logger.Information("Compiling solution {Path}", PathToProjProvider.Path);
try
{
var resp = await Build.Compile(PathToProjProvider.Path, cancel).ConfigureAwait(false);
if (!resp.Succeeded)
{
throw new SynthesisBuildFailure(resp.Reason);
}
_logger.Information("Compiled");
_logger.Information("Compiled solution {Path}", PathToProjProvider.Path);
}
catch (Exception e)
{
_logger.Error(e, "Failed to compile");
_logger.Error(e, $"Failed to compile solution {PathToProjProvider.Path}");
throw;
}
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Mutagen.Bethesda.Environments.DI;
using Mutagen.Bethesda.Environments.DI;
using Noggog;
using Synthesis.Bethesda.Commands;
using Synthesis.Bethesda.Execution.Groups;
Expand Down Expand Up @@ -68,7 +68,9 @@ public RunSynthesisPatcher GetArgs(
PersistencePath = runParameters.PersistenceMode == PersistenceMode.None ? null : runParameters.PersistencePath,
PatcherName = fileName,
ModKey = groupRun.ModKey.FileName,
UseUtf8ForEmbeddedStrings = runParameters.UseUtf8ForEmbeddedStrings
UseUtf8ForEmbeddedStrings = runParameters.UseUtf8ForEmbeddedStrings,
HeaderVersionOverride = runParameters.HeaderVersionOverride,
FormIDRangeMode = runParameters.FormIDRangeMode,
};
}
}
4 changes: 3 additions & 1 deletion Synthesis.Bethesda.Execution/Running/Runner/RunParameters.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Mutagen.Bethesda.Strings;
using Mutagen.Bethesda.Strings;
using Synthesis.Bethesda.Execution.Settings;

namespace Synthesis.Bethesda.Execution.Running.Runner;
Expand All @@ -7,5 +7,7 @@ public record RunParameters(
Language TargetLanguage,
bool Localize,
bool UseUtf8ForEmbeddedStrings,
float? HeaderVersionOverride,
FormIDRangeMode FormIDRangeMode,
PersistenceMode PersistenceMode,
string? PersistencePath);
6 changes: 6 additions & 0 deletions Synthesis.Bethesda.Execution/Settings/FormIDRangeMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public enum FormIDRangeMode
{
Auto = 1,
Off = 2,
On = 3,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Mutagen.Bethesda;
using Mutagen.Bethesda;
using Mutagen.Bethesda.Strings;
using Synthesis.Bethesda.Execution.Profile;
using Synthesis.Bethesda.Execution.Settings.V2;
Expand All @@ -23,4 +23,6 @@ public interface ISynthesisProfileSettings : IProfileIdentifier
bool Localize { get; set; }
Language TargetLanguage { get; set; }
public bool UseUtf8ForEmbeddedStrings { get; set; }
public FormIDRangeMode FormIDRangeMode { get; set; }
public float? HeaderVersionOverride { get; set; }
}
2 changes: 2 additions & 0 deletions Synthesis.Bethesda.Execution/Settings/V2/SynthesisProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ public class SynthesisProfile : ISynthesisProfileSettings

GameRelease IGameReleaseContext.Release => TargetRelease;
public bool UseUtf8ForEmbeddedStrings { get; set; }
public FormIDRangeMode FormIDRangeMode { get; set; } = FormIDRangeMode.Auto;
public float? HeaderVersionOverride { get; set; }
}
2 changes: 2 additions & 0 deletions Synthesis.Bethesda.GUI/Services/Main/ProfileFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public ProfileVm Get(ISynthesisProfileSettings settings)
profile.TargetLanguage = settings.TargetLanguage;
profile.Localize = settings.Localize;
profile.UseUtf8InEmbedded = settings.UseUtf8ForEmbeddedStrings;
profile.FormIDRangeMode = settings.FormIDRangeMode;
profile.HeaderVersionOverride = settings.HeaderVersionOverride;

profile.Groups.AddRange(settings.Groups.Select(x => factory.Get(x)));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using System.Reactive.Linq;
using Noggog;
using ReactiveUI;
Expand Down Expand Up @@ -41,7 +41,7 @@ public CompilationProvider(

try
{
logger.Information("Compiling");
logger.Information("Compiling {Target}", state.Item);
// Return early with the values, but mark not complete
observer.OnNext(new ConfigurationState<RunnerRepoInfo>(state.Item)
{
Expand All @@ -53,7 +53,7 @@ public CompilationProvider(
var compileResp = await build.Compile(state.Item, cancel).ConfigureAwait(false);
if (compileResp.Failed)
{
logger.Information("Compiling failed: {Reason}", compileResp.Reason);
logger.Information("Compiling {Target} failed: {Reason}", state.Item, compileResp.Reason);
var errs = new List<string>();
printErrorMessage.Print(compileResp.Reason,
$"{Path.GetDirectoryName(state.Item.Project.ProjPath)}\\", (s, _) =>
Expand All @@ -66,7 +66,7 @@ public CompilationProvider(
}

// Return things again, without error
logger.Information("Finished compiling");
logger.Information("Finished compiling {Target}", state.Item);
observer.OnNext(state);
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using Mutagen.Bethesda.Environments.DI;
using Mutagen.Bethesda.Strings;
using Synthesis.Bethesda.Execution.Groups;
Expand All @@ -15,6 +15,8 @@ Task Run(
PersistenceMode persistenceMode,
bool localize,
bool utf8InEmbeddedStrings,
float? headerVersionOverride,
FormIDRangeMode formIDRangeMode,
Language targetLanguage,
CancellationToken cancel);
}
Expand All @@ -40,6 +42,8 @@ public async Task Run(
PersistenceMode persistenceMode,
bool localize,
bool utf8InEmbeddedStrings,
float? headerVersionOverride,
FormIDRangeMode formIDRangeMode,
Language targetLanguage,
CancellationToken cancel)
{
Expand All @@ -52,6 +56,8 @@ await _executeRun.Run(
TargetLanguage: targetLanguage,
Localize: localize,
UseUtf8ForEmbeddedStrings: utf8InEmbeddedStrings,
FormIDRangeMode: formIDRangeMode,
HeaderVersionOverride: headerVersionOverride,
PersistenceMode: persistenceMode,
PersistencePath: Path.Combine(_profileDirectories.ProfileDirectory, "Persistence"))).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class ProfileDisplayVm : ViewModel

public ObservableCollectionExtended<Language> Languages { get; } = new(Enums<Language>.Values);

public ObservableCollectionExtended<FormIDRangeMode> FormIDRangeModes { get; } = new(Enums<FormIDRangeMode>.Values);

private readonly ObservableAsPropertyHelper<string> _dataFolderWatermark;
public string DataFolderWatermark => _dataFolderWatermark.Value;

Expand Down
Loading

0 comments on commit 1bc32b2

Please sign in to comment.