-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Dust off the Cyberpunk2077 code a bit and enable optional archival for the base game files * Update src/Games/NexusMods.Games.RedEngine/Cyberpunk2077Synchronizer.cs Co-authored-by: erri120 <[email protected]> --------- Co-authored-by: erri120 <[email protected]>
- Loading branch information
Showing
7 changed files
with
133 additions
and
8 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
26 changes: 26 additions & 0 deletions
26
src/Games/NexusMods.Games.RedEngine/Cyberpunk2077Settings.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 NexusMods.Abstractions.Settings; | ||
|
||
namespace NexusMods.Games.RedEngine; | ||
|
||
public class Cyberpunk2077Settings : ISettings | ||
{ | ||
/// <summary> | ||
/// If true, the contents of the Content folder will not be backed up. If the game updates | ||
/// the loadout may become invalid. If mods are installed into this folder via the app they | ||
/// will still be backed up as needed | ||
/// </summary> | ||
public bool IgnoreContentFolder { get; set; } = true; | ||
|
||
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder) | ||
{ | ||
return settingsBuilder.AddToUI<Cyberpunk2077Settings>(builder => builder | ||
.AddPropertyToUI(x => x.IgnoreContentFolder, propertyBuilder => propertyBuilder | ||
.AddToSection(Sections.GameSpecific) | ||
.WithDisplayName("Cyberpunk 2077: Ignore Content Folder") | ||
.WithDescription("Don't back up the game asset folders. If the game updates this may render the loadout invalid.") | ||
.UseBooleanContainer() | ||
) | ||
); | ||
|
||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Games/NexusMods.Games.RedEngine/Cyberpunk2077Synchronizer.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 Microsoft.Extensions.DependencyInjection; | ||
using NexusMods.Abstractions.GameLocators; | ||
using NexusMods.Abstractions.Loadouts.Synchronizers; | ||
using NexusMods.Abstractions.Settings; | ||
|
||
namespace NexusMods.Games.RedEngine; | ||
|
||
public class Cyberpunk2077Synchronizer : ALoadoutSynchronizer | ||
{ | ||
private Cyberpunk2077Settings _settings; | ||
|
||
protected internal Cyberpunk2077Synchronizer(IServiceProvider provider) : base(provider) | ||
{ | ||
var settingsManager = provider.GetRequiredService<ISettingsManager>(); | ||
|
||
_settings = settingsManager.Get<Cyberpunk2077Settings>(); | ||
settingsManager.GetChanges<Cyberpunk2077Settings>().Subscribe(value => _settings = value); | ||
} | ||
|
||
private static readonly GamePath[] IgnoredFolders = | ||
[ | ||
new GamePath(LocationId.Game, "archive/pc/content"), | ||
new GamePath(LocationId.Game, "archive/pc/ep1"), | ||
]; | ||
|
||
|
||
public override bool IsIgnoredBackupPath(GamePath path) | ||
{ | ||
if (!_settings.IgnoreContentFolder) | ||
return false; | ||
|
||
if (path.LocationId != LocationId.Game) | ||
return false; | ||
|
||
return IgnoredFolders.Any(ignore => path.Path.InFolder(ignore.Path)); | ||
} | ||
|
||
} |
Binary file modified
BIN
-266 KB
(55%)
src/Games/NexusMods.Games.RedEngine/Resources/Cyberpunk2077/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
55 changes: 55 additions & 0 deletions
55
tests/Games/NexusMods.Games.RedEngine.Tests/Cyberpunk2077SynchronizerTests.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,55 @@ | ||
using FluentAssertions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NexusMods.Abstractions.GameLocators; | ||
using NexusMods.Abstractions.Settings; | ||
using NexusMods.Extensions.Hashing; | ||
using NexusMods.Games.TestFramework; | ||
using NexusMods.Paths.Extensions; | ||
|
||
namespace NexusMods.Games.RedEngine.Tests; | ||
|
||
public class Cyberpunk2077SynchronizerTests(IServiceProvider serviceProvider) : AGameTest<Cyberpunk2077>(serviceProvider) | ||
{ | ||
|
||
[Fact] | ||
public async Task ContentIsIgnoredWhenSettingIsSet() | ||
{ | ||
// Get the settings | ||
var settings = ServiceProvider.GetRequiredService<ISettingsManager>().Get<Cyberpunk2077Settings>(); | ||
settings.IgnoreContentFolder = true; | ||
|
||
// Setup the paths we want to edit, one will be in the `Content` folder, thus not backed up | ||
var ignoredGamePath = new GamePath(LocationId.Game, "archive/pc/content/foo.dat".ToRelativePath()); | ||
var notIgnoredGamePath = new GamePath(LocationId.Game, "foo.dat".ToRelativePath()); | ||
|
||
var ignoredPath = GameInstallation.LocationsRegister.GetResolvedPath(ignoredGamePath); | ||
ignoredPath.Parent.CreateDirectory(); | ||
var notIgnoredPath = GameInstallation.LocationsRegister.GetResolvedPath(notIgnoredGamePath); | ||
|
||
// Write the files | ||
await ignoredPath.WriteAllTextAsync("Ignore me"); | ||
var ignoredHash = await ignoredPath.XxHash64Async(); | ||
await notIgnoredPath.WriteAllTextAsync("Don't you dare ignore me!"); | ||
var notIgnoredHash = await notIgnoredPath.XxHash64Async(); | ||
|
||
// Create the loadout | ||
var loadout = await CreateLoadout(); | ||
|
||
loadout.Files.Should().Contain(f => f.To == ignoredGamePath, "The file exists, but is ignored"); | ||
(await FileStore.HaveFile(ignoredHash)).Should().BeFalse("The file is ignored"); | ||
|
||
loadout.Files.Should().Contain(f => f.To == notIgnoredGamePath, "The file was not ignored"); | ||
(await FileStore.HaveFile(notIgnoredHash)).Should().BeTrue("The file was not ignored"); | ||
|
||
// Now disable the ignore setting | ||
settings.IgnoreContentFolder = false; | ||
|
||
var loadout2 = await CreateLoadout(); | ||
|
||
loadout2.Files.Should().Contain(f => f.To == ignoredGamePath, "The file exists, but is ignored"); | ||
(await FileStore.HaveFile(ignoredHash)).Should().BeTrue("The file is not ignored"); | ||
loadout2.Files.Should().Contain(f => f.To == notIgnoredGamePath, "The file was not ignored"); | ||
(await FileStore.HaveFile(notIgnoredHash)).Should().BeTrue("The file was not ignored"); | ||
} | ||
|
||
} |