-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2120 from Nexus-Mods/collection-install-updates
Binary patching and FOMOD Presets
- Loading branch information
Showing
27 changed files
with
635 additions
and
118 deletions.
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.