PortValhalla/scripts/Windows/Software/tm-united-forever/Manage.ps1

69 lines
2 KiB
PowerShell
Raw Permalink Normal View History

2024-09-24 16:15:06 +00:00
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
2024-08-08 02:36:35 +00:00
2024-09-24 16:15:06 +00:00
<#
.SYNOPSIS
Generates the components for installing a TrackMania Forever game.
2024-08-08 02:36:35 +00:00
2024-09-24 16:15:06 +00:00
.PARAMETER Installer
The script to execute for installing the game.
2024-08-08 02:36:35 +00:00
2024-09-24 16:15:06 +00:00
.PARAMETER UserDirectory
The directory containing the user data.
#>
function Get-TMForeverInstallerComponents {
param(
[string] $IconName,
[string] $UserDirectory,
[scriptblock] $Installer
)
@{
2024-10-06 19:25:34 +00:00
context = @{
iconName = $IconName;
2024-09-24 16:15:06 +00:00
userDirectory = $UserDirectory;
2024-10-06 19:25:34 +00:00
installer = $Installer;
2024-09-24 16:15:06 +00:00
};
2024-10-06 19:25:34 +00:00
installer = {
param([hashtable] $Context)
$iconName = $Context.IconName;
2024-08-08 02:36:35 +00:00
2024-09-03 10:02:09 +00:00
foreach ($feature in @("DirectPlay", "NetFx3")) {
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
Write-Information "Enabling the ``$feature`` feature…";
choco install --source windowsFeatures -y $feature;
}
}
2024-08-08 02:36:35 +00:00
& $Context.Installer;
2024-09-24 16:15:06 +00:00
Remove-DesktopIcon "*$iconName*";
};
2024-10-06 19:25:34 +00:00
userBackup = {
param(
[string] $Name,
[hashtable] $Context
)
Add-BackupArtifacts -User $Context.Name -Source $Context.UserDirectory -Path "$Name" `
2024-09-03 10:02:09 +00:00
-Include @(
"ChallengeMusics",
"MediaTracker",
"MenuMusics",
2024-09-24 16:15:06 +00:00
"Painter",
2024-09-03 10:02:09 +00:00
"Scores",
"Skins",
"Tracks"
);
2024-09-24 16:15:06 +00:00
};
userConfigurator = {
param(
[string] $Name,
[hashtable] $Context
)
$user = $Context.Name;
2024-09-24 16:15:06 +00:00
Expand-BackupArtifacts -User $user -Path "$Name" -Target $path;
2024-09-03 10:02:09 +00:00
};
2024-09-24 16:15:06 +00:00
};
}