-
Notifications
You must be signed in to change notification settings - Fork 48
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 #2233 from erri120/game-features
Add game support and feature tracking
- Loading branch information
Showing
11 changed files
with
172 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace NexusMods.Abstractions.Games; | ||
|
||
/// <summary> | ||
/// Represents a feature a game can support. | ||
/// </summary> | ||
/// <param name="Description">Description</param> | ||
[PublicAPI] | ||
public readonly record struct Feature(string Description) | ||
{ | ||
/// <summary> | ||
/// Identifier. | ||
/// </summary> | ||
public readonly Guid Id = Guid.NewGuid(); | ||
|
||
/// <inheritdoc/> | ||
public override int GetHashCode() => Id.GetHashCode(); | ||
|
||
/// <summary> | ||
/// Equality. | ||
/// </summary> | ||
public bool Equals(Feature? other) => other is not null && Id.Equals(other.Value.Id); | ||
} | ||
|
||
/// <summary> | ||
/// Status of a feature. | ||
/// </summary> | ||
/// <param name="Feature">The feature.</param> | ||
/// <param name="IsImplemented">Whether the feature is implemented or not.</param> | ||
[PublicAPI] | ||
public readonly record struct FeatureStatus(Feature Feature, bool IsImplemented); | ||
|
||
/// <summary> | ||
/// Status of all game features. | ||
/// </summary> | ||
[PublicAPI] | ||
public enum GameFeatureStatus | ||
{ | ||
/// <summary> | ||
/// Default value. | ||
/// </summary> | ||
None = 0, | ||
|
||
/// <summary> | ||
/// The minimum amount of features is implemented. | ||
/// </summary> | ||
Minimal = 1, | ||
|
||
/// <summary> | ||
/// All features are implemented. | ||
/// </summary> | ||
Full = 2, | ||
} | ||
|
||
/// <summary> | ||
/// Extension methods. | ||
/// </summary> | ||
[PublicAPI] | ||
public static class FeatureExtensions | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static GameFeatureStatus ToStatus(this HashSet<FeatureStatus> features) | ||
{ | ||
var implemented = features.Count(status => status.IsImplemented); | ||
var total = features.Count; | ||
if (implemented == total) return GameFeatureStatus.Full; | ||
|
||
return implemented switch | ||
{ | ||
0 => GameFeatureStatus.None, | ||
_ => GameFeatureStatus.Minimal, | ||
}; | ||
} | ||
} |
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,19 @@ | ||
using JetBrains.Annotations; | ||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member | ||
|
||
namespace NexusMods.Abstractions.Games; | ||
|
||
/// <summary> | ||
/// List of features. | ||
/// </summary> | ||
[PublicAPI] | ||
public static class BaseFeatures | ||
{ | ||
public static readonly Feature GameLocatable = new(Description: "The game can be located."); | ||
|
||
public static readonly Feature HasInstallers = new(Description: "The extension provides mod installers."); | ||
|
||
public static readonly Feature HasDiagnostics = new(Description: "The extension provides diagnostics."); | ||
|
||
public static readonly Feature HasLoadOrder = new(Description: "The extension provides load-order support."); | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/Abstractions/NexusMods.Abstractions.Games/SupportLevel.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,25 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace NexusMods.Abstractions.Games; | ||
|
||
/// <summary> | ||
/// Game support type. | ||
/// </summary> | ||
[PublicAPI] | ||
public enum SupportType | ||
{ | ||
/// <summary> | ||
/// The game is unsupported. | ||
/// </summary> | ||
Unsupported = 0, | ||
|
||
/// <summary> | ||
/// The game is officially supported and the extension maintained by Nexus Mods. | ||
/// </summary> | ||
Official = 1, | ||
|
||
/// <summary> | ||
/// The game is supported and the extension is maintained by the community. | ||
/// </summary> | ||
Community = 2, | ||
} |
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
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