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(); + } } }