Skip to content

Commit

Permalink
Support GOG
Browse files Browse the repository at this point in the history
  • Loading branch information
ProbablyManuel committed Jul 15, 2023
1 parent 5dc7149 commit ce942c7
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Reqtificator.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off
Reqtificator\app\Reqtificator.exe
Reqtificator\app\Reqtificator.exe %*
exit
5 changes: 5 additions & 0 deletions components/documentation/src/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Bug Fixes
* Weapons enchanted with Turn Undead have the same naming convention as other enchanted items.
* Imperial Dagger, Mace, and Shortsword can be tempered.

Reqtificator
------------

* Load order for GOG is automatically located. If both the Steam and GOG release are installed, GOG is prefered by default. This behavior can be overriden by the command line argument `--game=SkyrimSE` or `--game=SkyrimSEGog` respectively.

Internal Quality Improvements (only relevant for modders)
---------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions components/mutagen-reqtificator/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dotnet_sort_system_directives_first = true
dotnet_analyzer_diagnostic.severity = warning

dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary
dotnet_style_prefer_conditional_expression_over_assignment = false
dotnet_style_prefer_conditional_expression_over_return = false
csharp_style_var_when_type_is_apparent = true
csharp_style_var_elsewhere = true
Expand Down
6 changes: 5 additions & 1 deletion components/mutagen-reqtificator/Reqtificator/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ protected override void OnStartup(StartupEventArgs e)

window.Show();

var backend = new Backend(eventQueue, logContext);
if (e is null)
{
throw new ArgumentNullException(nameof(e));
}
var backend = new Backend(eventQueue, logContext, e);
Log.Debug("Gui Started");
}
catch (Exception ex)
Expand Down
19 changes: 16 additions & 3 deletions components/mutagen-reqtificator/Reqtificator/Backend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Windows;
using Hocon;
using Mutagen.Bethesda;
using Mutagen.Bethesda.Plugins;
Expand Down Expand Up @@ -33,20 +34,32 @@ namespace Reqtificator
{
internal class Backend
{
private const GameRelease Release = GameRelease.SkyrimSE;
private static readonly ModKey PatchModKey = ModKey.FromNameAndExtension("Requiem for the Indifferent.esp");
private static readonly ModKey RequiemModKey = new("Requiem", ModType.Plugin);

private readonly GameRelease _release;
private readonly InternalEvents _events;
private readonly MainLogicExecutor _executor;
private readonly ReqtificatorLogContext _logs;
private readonly GameContext _context;
private readonly RequiemVersion _version;

public Backend(InternalEvents eventsQueue, ReqtificatorLogContext logContext)
public Backend(InternalEvents eventsQueue, ReqtificatorLogContext logContext, StartupEventArgs startupEventArgs)
{
_events = eventsQueue;
_logs = logContext;
if (startupEventArgs.Args.Any("--game=SkyrimSEGog".Contains))
{
_release = GameRelease.SkyrimSEGog;
}
else if (startupEventArgs.Args.Any("--game=SkyrimSE".Contains))
{
_release = GameRelease.SkyrimSE;
}
else
{
_release = GameContext.IsAvailable(GameRelease.SkyrimSEGog) ? GameRelease.SkyrimSEGog : GameRelease.SkyrimSE;
}

var buildInfo = HoconConfigurationFactory.FromResource<Backend>("VersionInfo");
_version = new RequiemVersion(buildInfo.GetInt("versionNumber"), buildInfo.GetString("versionName"));
Expand All @@ -55,7 +68,7 @@ public Backend(InternalEvents eventsQueue, ReqtificatorLogContext logContext)
Log.Information($"build git branch: {buildInfo.GetString("gitBranch")}");
Log.Information($"build git revision: {buildInfo.GetString("gitRevision")}");

_context = GameContext.GetRequiemContext(Release, PatchModKey);
_context = GameContext.GetRequiemContext(_release, PatchModKey);

Log.Information("load order:");
_context.ActiveMods.WithIndex().ForEach(m => Log.Information($" {m.Index} - {m.Item.ModKey}"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override string Message
{
get
{
string FormatModList(string title, IImmutableSet<ModKey> mods)
static string FormatModList(string title, IImmutableSet<ModKey> mods)
{
if (mods.Count == 0)
{
Expand Down
9 changes: 5 additions & 4 deletions components/mutagen-reqtificator/Reqtificator/GameContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ namespace Reqtificator
{
public record GameContext(ImmutableList<ILoadOrderListingGetter> ActiveMods, string DataFolder, GameRelease Release)
{
public static bool IsAvailable(GameRelease release)
{
return PluginListings.TryGetListingsFile(release, out _);
}

public static GameContext GetRequiemContext(GameRelease release, ModKey patchToBeGenerated)
{
string dataFolder = Directory.GetCurrentDirectory();
if (!PluginListings.TryGetListingsFile(release, out var path))
{
throw new FileNotFoundException("Could not locate load order automatically.");
}

var loadOrderEntries = LoadOrder.GetLoadOrderListings(release, dataFolder, true);
var activeMods = loadOrderEntries.OnlyEnabled().TakeWhile(it => it.ModKey != patchToBeGenerated)
Expand Down

0 comments on commit ce942c7

Please sign in to comment.