Install redistributables after game is installed

pull/32/head
Pat Hartl 2023-11-12 01:27:15 -06:00
parent 81e4848407
commit 6f7c17493c
1 changed files with 23 additions and 4 deletions

View File

@ -5,6 +5,7 @@ using Playnite.SDK;
using Playnite.SDK.Models;
using Playnite.SDK.Plugins;
using System;
using System.Linq;
namespace LANCommander.PlaynitePlugin
{
@ -66,6 +67,24 @@ namespace LANCommander.PlaynitePlugin
Cancelable = true,
});
// Install any redistributables
var game = Plugin.LANCommanderClient.GetGame(gameId);
if (game.Redistributables != null && game.Redistributables.Count() > 0)
{
Plugin.PlayniteApi.Dialogs.ActivateGlobalProgress(progress =>
{
var redistributableManager = new RedistributableManager(Plugin.LANCommanderClient);
redistributableManager.Install(game);
},
new GlobalProgressOptions("Installing redistributables...")
{
IsIndeterminate = true,
Cancelable = false,
});
}
if (!result.Canceled && result.Error == null && !String.IsNullOrWhiteSpace(installDirectory))
{
var manifest = ManifestHelper.Read(installDirectory);
@ -81,12 +100,12 @@ namespace LANCommander.PlaynitePlugin
}
else if (result.Canceled)
{
var game = Plugin.PlayniteApi.Database.Games.Get(Game.Id);
var dbGame = Plugin.PlayniteApi.Database.Games.Get(Game.Id);
game.IsInstalling = false;
game.IsInstalled = false;
dbGame.IsInstalling = false;
dbGame.IsInstalled = false;
Plugin.PlayniteApi.Database.Games.Update(game);
Plugin.PlayniteApi.Database.Games.Update(dbGame);
}
else if (result.Error != null)
throw result.Error;