-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binary patching and FOMOD Presets #2120
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
14baa81
Supports binary patching
halgari f4916b7
It works, by some fel magic of the abyss, it works
halgari 908f9fd
Add verification files
halgari 42bd0fb
Add comments
halgari 4242432
Didn't end up needing Newtonsoft.JSON for dynamic JSON parsing, remov…
halgari 63d9ad3
Match FOMOD options by name, not index
halgari 4c1738e
better doc string
halgari 0997188
Fix NUGET packaging of the FOMOD project
halgari 55060c3
Merge branch 'main' into collection-install-updates
halgari 11c31c0
Merge main
halgari 6444ae4
Handle PR feedback
halgari 226a855
More optimized file extraction for Nx
halgari f5604e9
Set `MaxNumThreads=1` for now, we can change it in the future if needed
halgari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Abstractions/NexusMods.Abstractions.Collections/Json/PatchHash.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Globalization; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using TransparentValueObjects; | ||
|
||
namespace NexusMods.Abstractions.Collections.Json; | ||
|
||
[JsonConverter(typeof(PatchHashJsonConverter))] | ||
[ValueObject<uint>] | ||
public readonly partial struct PatchHash | ||
{ | ||
|
||
} | ||
|
||
public class PatchHashJsonConverter : JsonConverter<PatchHash> | ||
{ | ||
public override PatchHash Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
return PatchHash.From(uint.Parse(reader.GetString()!, NumberStyles.HexNumber)); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, PatchHash value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Value.ToString("X")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Abstractions/NexusMods.Abstractions.Collections/Types/HashMapping.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using NexusMods.Hashing.xxHash64; | ||
using NexusMods.Paths; | ||
|
||
namespace NexusMods.Abstractions.Collections.Types; | ||
|
||
/// <summary> | ||
/// Metadata about a mapping from a MD5 hash to a xxHash64 hash and the size of the file. | ||
/// </summary> | ||
public struct HashMapping | ||
{ | ||
/// <summary> | ||
/// The xxHash64 hash of the file. | ||
/// </summary> | ||
public required Hash Hash { get; init; } | ||
|
||
/// <summary> | ||
/// The size of the file. | ||
/// </summary> | ||
public required Size Size { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/Games/NexusMods.Games.FOMOD/CoreDelegates/PresetGuidedInstaller.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Diagnostics; | ||
using NexusMods.Abstractions.Activities; | ||
using NexusMods.Abstractions.GuidedInstallers; | ||
|
||
namespace NexusMods.Games.FOMOD.CoreDelegates; | ||
|
||
/// <summary> | ||
/// A IGuidedInstaller implementation that uses a preset list of steps to make the same choices | ||
/// a user previously made for specific steps. | ||
/// </summary> | ||
public class PresetGuidedInstaller : IGuidedInstaller | ||
{ | ||
private readonly FomodOption[] _steps; | ||
private int _currentStep = 0; | ||
|
||
public PresetGuidedInstaller(FomodOption[] steps) | ||
{ | ||
_steps = steps; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
} | ||
|
||
public void SetupInstaller(string name) | ||
{ | ||
} | ||
|
||
public void CleanupInstaller() | ||
{ | ||
} | ||
|
||
public Task<UserChoice> RequestUserChoice(GuidedInstallationStep installationStep, Percent progress, CancellationToken cancellationToken) | ||
{ | ||
var step = _steps[_currentStep]; | ||
|
||
// This looks gross, but it's fairly simple we map through the two trees matching by name, and it's cleaner than 4 nested loops. | ||
var choices = | ||
from srcGroup in step.groups | ||
from installGroup in installationStep.Groups | ||
where installGroup.Name == srcGroup.name | ||
from srcChoice in srcGroup.choices | ||
from installChoice in installGroup.Options | ||
where installChoice.Name == srcChoice.name | ||
select new SelectedOption(installGroup.Id, installChoice.Id); | ||
|
||
_currentStep++; | ||
return Task.FromResult(new UserChoice(new UserChoice.GoToNextStep(choices.ToArray()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace NexusMods.Games.FOMOD; | ||
|
||
public class FomodOption | ||
{ | ||
[JsonPropertyName("name")] | ||
public string name { get; init; } = string.Empty; | ||
|
||
[JsonPropertyName("groups")] | ||
public FomodGroup[] groups { get; init; } = []; | ||
} | ||
|
||
public class FomodGroup | ||
{ | ||
[JsonPropertyName("name")] | ||
public string name { get; init; } = string.Empty; | ||
|
||
[JsonPropertyName("choices")] | ||
public FomodChoice[] choices { get; init; } = []; | ||
} | ||
|
||
public class FomodChoice | ||
{ | ||
[JsonPropertyName("name")] | ||
public string name { get; init; } = string.Empty; | ||
|
||
[JsonPropertyName("idx")] | ||
public int idx { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Networking/NexusMods.Networking.NexusWebApi/GraphQL/CollectionsForGame.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
query CollectionsForGame($gameDomain: String!, $offset: Int!, $count: Int!) | ||
{ | ||
collections(viewAdultContent: true, filter: {gameDomain: {value: $gameDomain, op: EQUALS}}, offset: $offset, count: $count) | ||
{ | ||
totalCount | ||
nodesCount | ||
nodes { | ||
slug | ||
name | ||
latestPublishedRevision { | ||
id | ||
revisionNumber | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know if the names are case sensitive? I imagine the preset choices aren't set by humans, but if they can be modified by humans, a case insensitive comparison may be better here.
Edit:
Do we also know if the group names are supposed to be unique?
This code assumes that there may be multiple groups with the same name.
i.e. The input does not terminate when
installGroup.Name == srcGroup.name
, instead, it continues to process all other possible pairs of groups.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to talk with the Vortex devs and figure out these questions, it's not entirely clear to me what the interpretation should be. This works in the cases I tested, but we should find out more