-
Notifications
You must be signed in to change notification settings - Fork 53
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 #2052 from Nexus-Mods/feat/bg3-support
Basic BG3 support
- Loading branch information
Showing
10 changed files
with
182 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
70 changes: 70 additions & 0 deletions
70
src/Games/NexusMods.Games.Larian/BaldursGate3/BaldursGate3.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,70 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NexusMods.Abstractions.GameLocators; | ||
using NexusMods.Abstractions.GameLocators.GameCapabilities; | ||
using NexusMods.Abstractions.GameLocators.Stores.GOG; | ||
using NexusMods.Abstractions.GameLocators.Stores.Steam; | ||
using NexusMods.Abstractions.Games; | ||
using NexusMods.Abstractions.Games.DTO; | ||
using NexusMods.Abstractions.IO; | ||
using NexusMods.Abstractions.IO.StreamFactories; | ||
using NexusMods.Abstractions.Loadouts.Synchronizers; | ||
using NexusMods.Paths; | ||
|
||
namespace NexusMods.Games.Larian.BaldursGate3; | ||
|
||
public class BaldursGate3 : AGame, ISteamGame, IGogGame | ||
{ | ||
private readonly IServiceProvider _serviceProvider; | ||
private readonly IOSInformation _osInformation; | ||
public override string Name => "Baldur's Gate 3"; | ||
|
||
public IEnumerable<uint> SteamIds => [1086940u]; | ||
public IEnumerable<long> GogIds => [1456460669]; | ||
|
||
public static GameDomain GameDomain => GameDomain.From("baldursgate3"); | ||
public override GameDomain Domain => GameDomain; | ||
|
||
public BaldursGate3(IServiceProvider provider) : base(provider) | ||
{ | ||
_serviceProvider = provider; | ||
_osInformation = provider.GetRequiredService<IOSInformation>(); | ||
} | ||
|
||
public override GamePath GetPrimaryFile(GameStore store) | ||
{ | ||
if (_osInformation.IsOSX) | ||
return new GamePath(LocationId.Game, "Contents/MacOS/Baldur's Gate 3"); | ||
return new GamePath(LocationId.Game, "bin/bg3.exe"); | ||
} | ||
|
||
protected override IReadOnlyDictionary<LocationId, AbsolutePath> GetLocations(IFileSystem fileSystem, GameLocatorResult installation) | ||
{ | ||
var result = new Dictionary<LocationId, AbsolutePath>() | ||
{ | ||
{ LocationId.Game, installation.Path }, | ||
{ LocationId.From("Mods"), fileSystem.GetKnownPath(KnownPath.HomeDirectory).Combine("Larian Studios/Baldur's Gate 3/Mods") }, | ||
{ LocationId.From("PlayerProfiles"), fileSystem.GetKnownPath(KnownPath.HomeDirectory).Combine("Larian Studios/Baldur's Gate 3/PlayerProfiles/Public") }, | ||
{ LocationId.From("ScriptExtenderConfig"), fileSystem.GetKnownPath(KnownPath.HomeDirectory).Combine("Larian Studios/Baldur's Gate 3/ScriptExtender") }, | ||
}; | ||
return result; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override List<IModInstallDestination> GetInstallDestinations(IReadOnlyDictionary<LocationId, AbsolutePath> locations) | ||
{ | ||
// TODO: fill this in for Generic installer | ||
return []; | ||
} | ||
|
||
protected override ILoadoutSynchronizer MakeSynchronizer(IServiceProvider provider) | ||
{ | ||
return new BaldursGate3Synchronizer(provider); | ||
} | ||
|
||
// TODO: We are using Icon for both Spine and GameWidget and GameImage is unused. We should use GameImage for the GameWidget, but need to update all the games to have better images. | ||
public override IStreamFactory Icon => | ||
new EmbededResourceStreamFactory<BaldursGate3>("NexusMods.Games.Larian.Resources.BaldursGate3.icon.png"); | ||
|
||
public override IStreamFactory GameImage => | ||
new EmbededResourceStreamFactory<BaldursGate3>("NexusMods.Games.Larian.Resources.BaldursGate3.icon.png"); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Games/NexusMods.Games.Larian/BaldursGate3/BaldursGate3Settings.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,27 @@ | ||
using NexusMods.Abstractions.Settings; | ||
|
||
namespace NexusMods.Games.Larian.BaldursGate3; | ||
|
||
public class BaldursGate3Settings : ISettings | ||
{ | ||
|
||
/// <summary> | ||
/// If true, the contents of the game folder will 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 DoFullGameBackup { get; set; } = false; | ||
|
||
public static ISettingsBuilder Configure(ISettingsBuilder settingsBuilder) | ||
{ | ||
return settingsBuilder.AddToUI<BaldursGate3Settings>(builder => builder | ||
.AddPropertyToUI(x => x.DoFullGameBackup, propertyBuilder => propertyBuilder | ||
.AddToSection(Sections.Experimental) | ||
.WithDisplayName("Full game backup: Baldur's Gate 3") | ||
.WithDescription("Backup all game folders, this will greatly increase disk space usage. Should only be changed before managing the game.") | ||
.UseBooleanContainer() | ||
) | ||
); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/Games/NexusMods.Games.Larian/BaldursGate3/BaldursGate3Synchronizer.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.Larian.BaldursGate3; | ||
|
||
public class BaldursGate3Synchronizer : ALoadoutSynchronizer | ||
{ | ||
private readonly BaldursGate3Settings _settings; | ||
|
||
private static GamePath GameFolder => new(LocationId.Game, ""); | ||
private static GamePath PublicPlayerProfiles => new(LocationId.From("PlayerProfiles"), ""); | ||
|
||
private static GamePath ModSettingsFile => new(LocationId.From("PlayerProfiles"), "modsettings.lsx"); | ||
|
||
|
||
public BaldursGate3Synchronizer(IServiceProvider provider) : base(provider) | ||
{ | ||
var settingsManager = provider.GetRequiredService<ISettingsManager>(); | ||
_settings = settingsManager.Get<BaldursGate3Settings>(); | ||
} | ||
|
||
public override bool IsIgnoredPath(GamePath path) | ||
{ | ||
// Always ignore all PlayerProfile files except the modsettings file. | ||
return path.InFolder(PublicPlayerProfiles) && path.Path != ModSettingsFile.Path; | ||
} | ||
|
||
public override bool IsIgnoredBackupPath(GamePath path) | ||
{ | ||
if (_settings.DoFullGameBackup) return false; | ||
|
||
// Optionally ignore all game folder files for size reasons | ||
return path.InFolder(GameFolder) || | ||
(path.InFolder(PublicPlayerProfiles) && path.Path != ModSettingsFile.Path); | ||
} | ||
} |
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 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NexusMods.Abstractions.Games; | ||
using NexusMods.Abstractions.Settings; | ||
|
||
namespace NexusMods.Games.Larian.BaldursGate3; | ||
|
||
public static class Services | ||
{ | ||
public static IServiceCollection AddBaldursGate3(this IServiceCollection services) | ||
{ | ||
services | ||
.AddGame<BaldursGate3>() | ||
.AddSettings<BaldursGate3Settings>(); | ||
|
||
return services; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Games/NexusMods.Games.Larian/NexusMods.Games.Larian.csproj
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Abstractions\NexusMods.Abstractions.Games\NexusMods.Abstractions.Games.csproj" /> | ||
<ProjectReference Include="..\..\Abstractions\NexusMods.Abstractions.Settings\NexusMods.Abstractions.Settings.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Resources\BaldursGate3\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="Resources\BaldursGate3\game_image.jpg" /> | ||
<EmbeddedResource Include="Resources\BaldursGate3\game_image.jpg" /> | ||
<None Remove="Resources\BaldursGate3\icon.png" /> | ||
<EmbeddedResource Include="Resources\BaldursGate3\icon.png" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+132 KB
src/Games/NexusMods.Games.Larian/Resources/BaldursGate3/game_image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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