Create universal TrackMania script

This commit is contained in:
Manuel Thalmann 2024-09-24 18:15:06 +02:00
parent 1dcba0a71a
commit 1e3fd33924
5 changed files with 91 additions and 87 deletions

View file

@ -291,8 +291,8 @@ function Deploy-SoftwareAction {
Remove-DesktopIcon "EA.*";
}
& "$softwarePath/TrackMania Nations Forever/Manage.ps1" @arguments;
& "$softwarePath/TrackMania United Forever/Manage.ps1" @arguments;
& "$softwarePath/TrackMania Nations Forever/Main.ps1" @arguments;
& "$softwarePath/TrackMania United Forever/Main.ps1" @arguments;
& "$softwarePath/ManiaPlanet/Manage.ps1" @arguments;
& "$softwarePath/osu!/Manage.ps1" @arguments;
& "$softwarePath/osu!lazer/Manage.ps1" @arguments;

View file

@ -0,0 +1,21 @@
param(
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/../TrackMania United Forever/Manage.ps1";
. "$PSScriptRoot/../../Scripts/SoftwareManagement.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
$parameters = Get-TMForeverInstallerComponents `
-IconName "TmNationsForever" `
-UserDirectory "$HOME/Documents/TmForever" `
-Installer {
Install-WingetPackage Nadeo.TrackManiaNationsForever;
};
foreach ($key in $PSBoundParameters.Keys) {
$parameters.Add($key, $PSBoundParameters[$key]);
}
Start-SoftwareInstaller @parameters;

View file

@ -1,54 +0,0 @@
param(
$Action,
[hashtable] $Arguments
)
& {
param($Parameters)
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
. "$PSScriptRoot/../../Scripts/SoftwareManagement.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
$path = "$HOME/Documents/TmForever";
Start-SoftwareInstaller @Parameters `
-Installer {
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;
}
}
Install-WingetPackage Nadeo.TrackManiaNationsForever;
Remove-DesktopIcon "*TmNationsForever*";
} `
-UserBackup {
param(
[string] $Name,
[hashtable] $Arguments
)
$name = $Arguments.Name;
Add-BackupArtifacts -User $name -Source $path -Path "$Name" `
-Include @(
"ChallengeMusics",
"MediaTracker",
"MenuMusics",
"Painter",
"Scores",
"Skins",
"Tracks"
);
} `
-UserConfigurator {
param(
[string] $Name,
[hashtable] $Arguments
)
$user = $Arguments.Name;
Expand-BackupArtifacts -User $user -Path "$Name" -Target $path;
};
} $PSBoundParameters;

View file

@ -0,0 +1,30 @@
param(
$Action,
[hashtable] $Arguments
)
. "$PSScriptRoot/Manage.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
$parameters = Get-TMForeverInstallerComponents `
-IconName "TmUnitedForever" `
-UserDirectory "$HOME/Documents/TrackMania" `
-Installer {
$file = "TmUnitedForever.exe";
$dir = New-TemporaryDirectory;
$null = Push-Location $dir;
Write-Host "Downloading TrackMania United Forever…";
Invoke-WebRequest "http://files.trackmaniaforever.com/tmunitedforever_setup.exe" -OutFile "$file";
Write-Host "Starting installation…";
Start-Process -Wait -FilePath "$file" -ArgumentList "/Silent";
$null = Pop-Location;
Remove-Item -Recurse $dir;
};
foreach ($key in $PSBoundParameters.Keys) {
$parameters.Add($key, $PSBoundParameters[$key]);
}
Start-SoftwareInstaller @parameters;

View file

@ -1,20 +1,32 @@
param(
$Action,
[hashtable] $Arguments
)
& {
param($Parameters)
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
$path = "$HOME/Documents/TrackMania";
Start-SoftwareInstaller @Parameters `
-Installer {
$file = "TmUnitedForever.exe";
$dir = New-TemporaryDirectory;
<#
.SYNOPSIS
Generates the components for installing a TrackMania Forever game.
.PARAMETER Installer
The script to execute for installing the game.
.PARAMETER UserDirectory
The directory containing the user data.
#>
function Get-TMForeverInstallerComponents {
param(
[string] $IconName,
[string] $UserDirectory,
[scriptblock] $Installer
)
@{
arguments = @{
iconName = $IconName;
userDirectory = $UserDirectory;
installer = $Installer;
};
installer = {
param([hashtable] $Arguments)
$iconName = $Arguments.IconName;
foreach ($feature in @("DirectPlay", "NetFx3")) {
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
@ -23,39 +35,34 @@ param(
}
}
$null = Push-Location $dir;
Write-Host "Downloading TrackMania United Forever…";
Invoke-WebRequest "http://files.trackmaniaforever.com/tmunitedforever_setup.exe" -OutFile "$file";
Write-Host "Starting installation…";
Start-Process -Wait -FilePath $file -ArgumentList "/Silent";
Remove-DesktopIcon "*TmUnitedForever*";
$null = Pop-Location;
Remove-Item -Recurse $dir;
} `
-UserBackup {
& $Arguments.Installer;
Remove-DesktopIcon "*$iconName*";
};
userBackup = {
param(
[string] $Name,
[hashtable] $Arguments
)
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "$Name" `
Add-BackupArtifacts -User $Arguments.Name -Source $Arguments.UserDirectory -Path "$Name" `
-Include @(
"ChallengeMusics",
"MediaTracker",
"MenuMusics",
"Painter",
"Scores",
"Skins",
"Tracks"
);
} `
-UserConfigurator {
};
userConfigurator = {
param(
[string] $Name,
[hashtable] $Arguments
)
Expand-BackupArtifacts -User $Arguments.Name -Path "$Name" -Target $path;
$user = $Arguments.Name;
Expand-BackupArtifacts -User $user -Path "$Name" -Target $path;
};
} $PSBoundParameters;
};
}