-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add diagnostic for mods that overwrite game files (#1481)
- Loading branch information
Showing
5 changed files
with
66 additions
and
1 deletion.
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
38 changes: 38 additions & 0 deletions
38
src/Games/NexusMods.Games.StardewValley/Emitters/ModOverwritesGameFilesEmitter.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,38 @@ | ||
using System.Runtime.CompilerServices; | ||
using NexusMods.Abstractions.Diagnostics; | ||
using NexusMods.Abstractions.Diagnostics.Emitters; | ||
using NexusMods.Abstractions.Diagnostics.References; | ||
using NexusMods.Abstractions.Diagnostics.Values; | ||
using NexusMods.Abstractions.GameLocators; | ||
using NexusMods.Abstractions.Loadouts; | ||
using NexusMods.Abstractions.Loadouts.Extensions; | ||
|
||
namespace NexusMods.Games.StardewValley.Emitters; | ||
|
||
public class ModOverwritesGameFilesEmitter : ILoadoutDiagnosticEmitter | ||
{ | ||
private static readonly NamedLink SMAPIWikiLink = new("SMAPI Wiki", new Uri("https://stardewvalleywiki.com/Modding:Using_XNB_mods")); | ||
private static readonly NamedLink SMAPIWikiTableLink = new("SMAPI Wiki", new Uri("https://stardewvalleywiki.com/Modding:Using_XNB_mods#Alternatives_using_Content_Patcher")); | ||
|
||
private static readonly GamePath ContentDirectoryPath = new(LocationId.Game, "Content"); | ||
|
||
public async IAsyncEnumerable<Diagnostic> Diagnose(Loadout.Model loadout, [EnumeratorCancellation] CancellationToken cancellationToken) | ||
{ | ||
await Task.Yield(); | ||
|
||
var mods = loadout | ||
.GetEnabledMods() | ||
.Where(mod => mod.Files.Any(file => file.To.StartsWith(ContentDirectoryPath))) | ||
.ToArray(); | ||
|
||
foreach (var mod in mods) | ||
{ | ||
yield return Diagnostics.CreateModOverwritesGameFiles( | ||
Mod: mod.ToReference(loadout), | ||
ModName: mod.Name, | ||
SMAPIWikiLink: SMAPIWikiLink, | ||
SMAPIWikiTableLink: SMAPIWikiTableLink | ||
); | ||
} | ||
} | ||
} |
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