Skip to content

Commit

Permalink
Show custom bootfiles in mod list (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloambrosio committed Feb 24, 2024
1 parent 128f7d7 commit 7058b94
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Core/IModFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace Core;

public interface IModFactory
{
IMod ManualInstallMod(string packageName, string extractedPath);
IMod ManualInstallMod(string packageName, int packageFsHash, string extractedPath);
IMod GeneratedBootfiles(string generationBasePath);
}
4 changes: 2 additions & 2 deletions src/Core/ModFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public ModFactory(IConfig config, IGame game)
this.game = game;
}

public IMod ManualInstallMod(string packageName, string extractedPath) =>
new ManualInstallMod(packageName, extractedPath, config);
public IMod ManualInstallMod(string packageName, int packageFsHash, string extractedPath) =>
new ManualInstallMod(packageName, packageFsHash, extractedPath, config);

public IMod GeneratedBootfiles(string generationBasePath) =>
new GeneratedBootfiles(game.InstallationDirectory, generationBasePath);
Expand Down
8 changes: 4 additions & 4 deletions src/Core/ModManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public List<ModState> FetchState()
});

var allPackageNames = installedMods.Keys
.Where(_ => !IsBootFiles(_))
.Concat(enabledModPackages.Keys)
.Concat(disabledModPackages.Keys)
.Where(_ => !IsBootFiles(_))
.Distinct();

return allPackageNames
Expand Down Expand Up @@ -297,7 +297,7 @@ private void InstallAllModFiles(CancellationToken cancellationToken)
finally
{
installedFilesByMod.Add(mod.PackageName, new(
FsHash: modPackage.FsHash,
FsHash: mod.PackageFsHash,
Partial: mod.Installed == IMod.InstalledState.PartiallyInstalled,
Files: mod.InstalledFiles
));
Expand All @@ -324,7 +324,7 @@ private void InstallAllModFiles(CancellationToken cancellationToken)
finally
{
installedFilesByMod.Add(bootfilesMod.PackageName, new(
FsHash: null,
FsHash: bootfilesMod.PackageFsHash,
Partial: bootfilesMod.Installed == IMod.InstalledState.PartiallyInstalled || !postProcessingDone,
Files: bootfilesMod.InstalledFiles
));
Expand Down Expand Up @@ -361,7 +361,7 @@ private IMod ExtractMod(ModPackage modPackage)
using var extractor = new SevenZipExtractor(modPackage.FullPath);
extractor.ExtractArchive(extractionDir);

return modFactory.ManualInstallMod(modPackage.PackageName, extractionDir);
return modFactory.ManualInstallMod(modPackage.PackageName, modPackage.FsHash, extractionDir);
}

private IMod BootfilesMod()
Expand Down
8 changes: 7 additions & 1 deletion src/Core/Mods/ExtractedMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ public abstract class ExtractedMod : IMod
protected readonly string extractedPath;
protected readonly List<string> installedFiles = new();

internal ExtractedMod(string packageName, string extractedPath)
internal ExtractedMod(string packageName, int? packageFsHash, string extractedPath)
{
PackageName = packageName;
PackageFsHash = packageFsHash;
this.extractedPath = extractedPath;
}

Expand All @@ -16,6 +17,11 @@ public string PackageName
get;
}

public int? PackageFsHash
{
get;
}

public IMod.InstalledState Installed
{
get;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Mods/GeneratedBootfiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class GeneratedBootfiles : ExtractedMod
Path.Combine("vehicles", "_data", "effects", "backfire", "*.bmt");

public GeneratedBootfiles(string gamePath, string generationBasePath)
: base(VirtualPackageName, Path.Combine(generationBasePath, VirtualPackageName))
: base(VirtualPackageName, null, Path.Combine(generationBasePath, VirtualPackageName))
{
pakPath = Path.Combine(gamePath, PakfilesDirectory);
GenerateBootfiles();
Expand Down
1 change: 1 addition & 0 deletions src/Core/Mods/IMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public interface IMod
string PackageName { get; }
InstalledState Installed { get; }
IReadOnlyCollection<string> InstalledFiles { get; }
int? PackageFsHash { get; }

ConfigEntries Install(string dstPath, JsgmeFileInstaller.BeforeFileCallback beforeFileCallback);

Expand Down
4 changes: 2 additions & 2 deletions src/Core/Mods/ManualInstallMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public interface IConfig
private readonly Matcher filesToConfigureMatcher;
private readonly List<string> dirsAtRootLowerCase;

internal ManualInstallMod(string packageName, string extractedPath, IConfig config)
: base(packageName, extractedPath)
internal ManualInstallMod(string packageName, int packageFsHash, string extractedPath, IConfig config)
: base(packageName, packageFsHash, extractedPath)
{
dirsAtRootLowerCase = config.DirsAtRoot.Select(dir => dir.ToLowerInvariant()).ToList();
filesToInstallMatcher = MatcherExcluding(config.ExcludedFromInstall);
Expand Down

0 comments on commit 7058b94

Please sign in to comment.