-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70b8d8f
commit 063882a
Showing
2 changed files
with
60 additions
and
0 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
58 changes: 58 additions & 0 deletions
58
src/Games/NexusMods.Games.Obsidian/FalloutNewVegas/Installers/NVSEInstaller.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,58 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using NexusMods.Abstractions.GameLocators; | ||
using NexusMods.Abstractions.Library.Installers; | ||
using NexusMods.Abstractions.Library.Models; | ||
using NexusMods.Abstractions.Loadouts; | ||
using NexusMods.MnemonicDB.Abstractions; | ||
using NexusMods.Paths; | ||
using NexusMods.Paths.Trees; | ||
using NexusMods.Paths.Trees.Traits; | ||
|
||
namespace NexusMods.Games.Obsidian.FalloutNewVegas.Installers; | ||
|
||
public class NVSEInstaller(IServiceProvider serviceProvider) : ALibraryArchiveInstaller(serviceProvider, serviceProvider.GetRequiredService<ILogger<NVSEInstaller>>()) | ||
{ | ||
public override ValueTask<InstallerResult> ExecuteAsync( | ||
LibraryArchive.ReadOnly libraryArchive, | ||
LoadoutItemGroup.New loadoutGroup, | ||
ITransaction transaction, | ||
Loadout.ReadOnly loadout, | ||
CancellationToken cancellationToken) | ||
{ | ||
var tree = libraryArchive.GetTree(); | ||
var keys = new[] { "nvse_1_4.dll", "nvse_editor_1_4.dll", "nvse_loader.exe", "nvse_steam_loader.dll" }; | ||
|
||
|
||
List<LoadoutFile.New> results = []; | ||
foreach (var fileNode in tree.EnumerateFilesBfs()) | ||
{ | ||
var relativePath = new RelativePath(fileNode.Value.Item.Path.Name); | ||
if (!keys.Contains(relativePath.Name.ToString())) | ||
{ | ||
continue; | ||
}; | ||
|
||
var loadoutFile = new LoadoutFile.New(transaction, out var id) | ||
{ | ||
LoadoutItemWithTargetPath = new LoadoutItemWithTargetPath.New(transaction, id) | ||
{ | ||
TargetPath = (loadout.Id, LocationId.Game, relativePath), | ||
LoadoutItem = new LoadoutItem.New(transaction, id) | ||
{ | ||
Name = relativePath.Name, | ||
LoadoutId = loadout.Id, | ||
ParentId = loadoutGroup.Id, | ||
}, | ||
}, | ||
Hash = fileNode.Value.Item.LibraryFile.Value.Hash, | ||
Size = fileNode.Value.Item.LibraryFile.Value.Size, | ||
}; | ||
results.Add(loadoutFile); | ||
} | ||
|
||
return results.Count > 0 | ||
? ValueTask.FromResult<InstallerResult>(new Success()) | ||
: ValueTask.FromResult<InstallerResult>(new NotSupported()); | ||
} | ||
} |