add/remove action rows

This commit is contained in:
2024-09-09 09:20:24 +02:00
parent 333f5011de
commit 7e5acd413e
6 changed files with 54 additions and 11 deletions

View File

@@ -104,8 +104,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
foreach (var action in checkingVersion.Actions)
{
// Resolve inherits
if (!string.IsNullOrWhiteSpace(action.InheritFrom) && installInfos.Actions.FirstOrDefault(a => a.Id == action.InheritFrom) is InstallAction iaction)
JsonConvert.PopulateObject(JsonConvert.SerializeObject(iaction), action);
ResolveInherit(action, installInfos);
// Check & add
if (action.Side.IsSide(options.Side) && (!action.IsExtra || options.IncludeExtras) && !result.Actions.Any(n => n.DestPath == action.DestPath))
@@ -125,6 +124,17 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
return result;
}
public static void ResolveInherit(UpdateAction action, InstallInfos installInfos)
{
if (!string.IsNullOrWhiteSpace(action.InheritFrom) && installInfos.Actions.FirstOrDefault(a => a.Id == action.InheritFrom) is InstallAction iaction)
DuplicateTo(iaction, action);
}
public static void DuplicateTo(InstallAction source, InstallAction destination)
{
JsonConvert.PopulateObject(JsonConvert.SerializeObject(source), destination);
}
public async Task<bool?> Install(UpdateCheckResult checkResult)
{
var processed = 0;