From 16dc60b90a76bf340ec6e15d301f01c22832b759 Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Thu, 16 Nov 2023 00:40:27 -0600 Subject: [PATCH] Run key change script in InstallController --- .../InstallController.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/LANCommander.Playnite.Extension/InstallController.cs b/LANCommander.Playnite.Extension/InstallController.cs index 1be1388..bd27e7b 100644 --- a/LANCommander.Playnite.Extension/InstallController.cs +++ b/LANCommander.Playnite.Extension/InstallController.cs @@ -119,6 +119,7 @@ namespace LANCommander.PlaynitePlugin RunInstallScript(installDirectory); RunNameChangeScript(installDirectory); + RunKeyChangeScript(installDirectory); InvokeOnInstalled(new GameInstalledEventArgs(installInfo)); } @@ -166,5 +167,23 @@ namespace LANCommander.PlaynitePlugin return script.Execute(); } + + private int RunKeyChangeScript(string installDirectory) + { + var manifest = ManifestHelper.Read(installDirectory); + var script = new PowerShellScript(); + + var key = Plugin.LANCommanderClient.GetAllocatedKey(manifest.Id); + + script.AddVariable("InstallDirectory", installDirectory); + script.AddVariable("GameManifest", manifest); + script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory); + script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress); + script.AddVariable("AllocatedKey", key); + + script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.KeyChange)); + + return script.Execute(); + } } }