Grouped installer SourceActions by ContentPackage

ContentPackages are defined in mod.yaml and list Installers that support them, but then the Installers and their SourceActions knew nothing about ContentPackages.
Also added BeforeInstall and AfterInstall sections for SourceActions in the Installers.
This commit is contained in:
penev92
2023-02-21 18:01:19 +02:00
committed by Matthias Mailänder
parent 64e84554d3
commit d0285b058b
21 changed files with 3152 additions and 2704 deletions

View File

@@ -237,12 +237,30 @@ namespace OpenRA.Mods.Common.Widgets.Logic
try
{
foreach (var i in modSource.Install)
void RunSourceActions(MiniYamlNode contentPackageYaml)
{
var sourceAction = modSource.ObjectCreator.CreateObject<ISourceAction>($"{i.Key}SourceAction");
sourceAction.RunActionOnSource(i.Value, path, modData, extracted, m => message = m);
var sourceActionListYaml = contentPackageYaml.Value.Nodes.FirstOrDefault(x => x.Key == "Actions");
if (sourceActionListYaml == null)
return;
foreach (var sourceActionNode in sourceActionListYaml.Value.Nodes)
{
var sourceAction = modSource.ObjectCreator.CreateObject<ISourceAction>($"{sourceActionNode.Key}SourceAction");
sourceAction.RunActionOnSource(sourceActionNode.Value, path, modData, extracted, m => message = m);
}
}
var beforeInstall = modSource.Install.FirstOrDefault(x => x.Key == "BeforeInstall");
if (beforeInstall != null)
RunSourceActions(beforeInstall);
foreach (var packageInstallationNode in modSource.Install.Where(x => x.Key == "ContentPackage"))
RunSourceActions(packageInstallationNode);
var afterInstall = modSource.Install.FirstOrDefault(x => x.Key == "AfterInstall");
if (afterInstall != null)
RunSourceActions(afterInstall);
Game.RunAfterTick(Ui.CloseWindow);
}
catch (Exception e)