Only execute scripts if they exists on the disk
parent
986fb87db1
commit
a9f3b7a39d
|
@ -7,6 +7,7 @@ using Playnite.SDK.Models;
|
||||||
using Playnite.SDK.Plugins;
|
using Playnite.SDK.Plugins;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace LANCommander.PlaynitePlugin
|
namespace LANCommander.PlaynitePlugin
|
||||||
|
@ -139,51 +140,72 @@ namespace LANCommander.PlaynitePlugin
|
||||||
private int RunInstallScript(string installDirectory)
|
private int RunInstallScript(string installDirectory)
|
||||||
{
|
{
|
||||||
var manifest = ManifestHelper.Read(installDirectory);
|
var manifest = ManifestHelper.Read(installDirectory);
|
||||||
var script = new PowerShellScript();
|
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install);
|
||||||
|
|
||||||
script.AddVariable("InstallDirectory", installDirectory);
|
if (File.Exists(path))
|
||||||
script.AddVariable("GameManifest", manifest);
|
{
|
||||||
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
var script = new PowerShellScript();
|
||||||
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
|
||||||
|
|
||||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install));
|
script.AddVariable("InstallDirectory", installDirectory);
|
||||||
|
script.AddVariable("GameManifest", manifest);
|
||||||
|
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
||||||
|
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
||||||
|
|
||||||
return script.Execute();
|
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install));
|
||||||
|
|
||||||
|
return script.Execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int RunNameChangeScript(string installDirectory)
|
private int RunNameChangeScript(string installDirectory)
|
||||||
{
|
{
|
||||||
var manifest = ManifestHelper.Read(installDirectory);
|
var manifest = ManifestHelper.Read(installDirectory);
|
||||||
var script = new PowerShellScript();
|
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.NameChange);
|
||||||
|
|
||||||
script.AddVariable("InstallDirectory", installDirectory);
|
if (File.Exists(path))
|
||||||
script.AddVariable("GameManifest", manifest);
|
{
|
||||||
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
var script = new PowerShellScript();
|
||||||
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
|
||||||
script.AddVariable("OldPlayerAlias", "");
|
|
||||||
script.AddVariable("NewPlayerAlias", Plugin.Settings.PlayerName);
|
|
||||||
|
|
||||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.NameChange));
|
script.AddVariable("InstallDirectory", installDirectory);
|
||||||
|
script.AddVariable("GameManifest", manifest);
|
||||||
|
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
||||||
|
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
||||||
|
script.AddVariable("OldPlayerAlias", "");
|
||||||
|
script.AddVariable("NewPlayerAlias", Plugin.Settings.PlayerName);
|
||||||
|
|
||||||
return script.Execute();
|
script.UseFile(path);
|
||||||
|
|
||||||
|
return script.Execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int RunKeyChangeScript(string installDirectory)
|
private int RunKeyChangeScript(string installDirectory)
|
||||||
{
|
{
|
||||||
var manifest = ManifestHelper.Read(installDirectory);
|
var manifest = ManifestHelper.Read(installDirectory);
|
||||||
var script = new PowerShellScript();
|
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.KeyChange);
|
||||||
|
|
||||||
var key = Plugin.LANCommanderClient.GetAllocatedKey(manifest.Id);
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
var script = new PowerShellScript();
|
||||||
|
|
||||||
script.AddVariable("InstallDirectory", installDirectory);
|
var key = Plugin.LANCommanderClient.GetAllocatedKey(manifest.Id);
|
||||||
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));
|
script.AddVariable("InstallDirectory", installDirectory);
|
||||||
|
script.AddVariable("GameManifest", manifest);
|
||||||
|
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
||||||
|
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
||||||
|
script.AddVariable("AllocatedKey", key);
|
||||||
|
|
||||||
return script.Execute();
|
script.UseFile(path);
|
||||||
|
|
||||||
|
return script.Execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -538,52 +538,73 @@ namespace LANCommander.PlaynitePlugin
|
||||||
private int RunInstallScript(string installDirectory)
|
private int RunInstallScript(string installDirectory)
|
||||||
{
|
{
|
||||||
var manifest = ManifestHelper.Read(installDirectory);
|
var manifest = ManifestHelper.Read(installDirectory);
|
||||||
var script = new PowerShellScript();
|
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install);
|
||||||
|
|
||||||
script.AddVariable("InstallDirectory", installDirectory);
|
if (File.Exists(path))
|
||||||
script.AddVariable("GameManifest", manifest);
|
{
|
||||||
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
var script = new PowerShellScript();
|
||||||
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
|
||||||
|
|
||||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install));
|
script.AddVariable("InstallDirectory", installDirectory);
|
||||||
|
script.AddVariable("GameManifest", manifest);
|
||||||
|
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
||||||
|
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
||||||
|
|
||||||
return script.Execute();
|
script.UseFile(path);
|
||||||
|
|
||||||
|
return script.Execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int RunNameChangeScript(string installDirectory, string oldPlayerAlias, string newPlayerAlias)
|
private int RunNameChangeScript(string installDirectory, string oldPlayerAlias, string newPlayerAlias)
|
||||||
{
|
{
|
||||||
var manifest = ManifestHelper.Read(installDirectory);
|
var manifest = ManifestHelper.Read(installDirectory);
|
||||||
var script = new PowerShellScript();
|
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.NameChange);
|
||||||
|
|
||||||
script.AddVariable("InstallDirectory", installDirectory);
|
if (File.Exists(path))
|
||||||
script.AddVariable("GameManifest", manifest);
|
{
|
||||||
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
var script = new PowerShellScript();
|
||||||
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
|
||||||
script.AddVariable("OldPlayerAlias", oldPlayerAlias);
|
|
||||||
script.AddVariable("NewPlayerAlias", newPlayerAlias);
|
|
||||||
|
|
||||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.NameChange));
|
script.AddVariable("InstallDirectory", installDirectory);
|
||||||
|
script.AddVariable("GameManifest", manifest);
|
||||||
|
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
||||||
|
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
||||||
|
script.AddVariable("OldPlayerAlias", oldPlayerAlias);
|
||||||
|
script.AddVariable("NewPlayerAlias", newPlayerAlias);
|
||||||
|
|
||||||
return script.Execute();
|
script.UseFile(path);
|
||||||
|
|
||||||
|
return script.Execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int RunKeyChangeScript(string installDirectory, string key = "")
|
private int RunKeyChangeScript(string installDirectory, string key = "")
|
||||||
{
|
{
|
||||||
var manifest = ManifestHelper.Read(installDirectory);
|
var manifest = ManifestHelper.Read(installDirectory);
|
||||||
var script = new PowerShellScript();
|
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.KeyChange);
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(key))
|
if (File.Exists(path))
|
||||||
key = LANCommanderClient.GetAllocatedKey(manifest.Id);
|
{
|
||||||
|
var script = new PowerShellScript();
|
||||||
|
|
||||||
script.AddVariable("InstallDirectory", installDirectory);
|
if (String.IsNullOrEmpty(key))
|
||||||
script.AddVariable("GameManifest", manifest);
|
key = LANCommanderClient.GetAllocatedKey(manifest.Id);
|
||||||
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
|
||||||
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
|
||||||
script.AddVariable("AllocatedKey", key);
|
|
||||||
|
|
||||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.KeyChange));
|
script.AddVariable("InstallDirectory", installDirectory);
|
||||||
|
script.AddVariable("GameManifest", manifest);
|
||||||
|
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
||||||
|
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
||||||
|
script.AddVariable("AllocatedKey", key);
|
||||||
|
|
||||||
return script.Execute();
|
script.UseFile(path);
|
||||||
|
|
||||||
|
return script.Execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace LANCommander.PlaynitePlugin
|
||||||
{
|
{
|
||||||
var scriptPath = ScriptHelper.GetScriptFilePath(Game.InstallDirectory, SDK.Enums.ScriptType.Uninstall);
|
var scriptPath = ScriptHelper.GetScriptFilePath(Game.InstallDirectory, SDK.Enums.ScriptType.Uninstall);
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(scriptPath))
|
if (!String.IsNullOrEmpty(scriptPath) && File.Exists(scriptPath))
|
||||||
{
|
{
|
||||||
var manifest = ManifestHelper.Read(Game.InstallDirectory);
|
var manifest = ManifestHelper.Read(Game.InstallDirectory);
|
||||||
var script = new PowerShellScript();
|
var script = new PowerShellScript();
|
||||||
|
|
Loading…
Reference in New Issue