46 lines
3.4 KiB
PowerShell
46 lines
3.4 KiB
PowerShell
param(
|
|
[string]$PluginsDir='C:\Program Files (x86)\DODI-Repacks\American Truck Simulator\bin\win_x64\plugins',
|
|
[string]$ModDir=(Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'American Truck Simulator/mod'),
|
|
[switch]$EnableDisplay,
|
|
[switch]$PlanOnly
|
|
)
|
|
$ErrorActionPreference='Stop'
|
|
if (Get-Process amtrucks -ErrorAction SilentlyContinue) { throw 'Close ATS before installing its screen add-on and DLL.' }
|
|
$taskRoot=Split-Path $PSScriptRoot -Parent
|
|
$taskPackage=Join-Path $taskRoot 'diagnostics/tesla-screen-addon/ATS_OP_Tesla_Screens.scs'
|
|
$taskReport=Get-Content -LiteralPath ([IO.Path]::ChangeExtension($taskPackage,'.inspection.json')) -Raw | ConvertFrom-Json
|
|
if ((Get-FileHash -LiteralPath $taskPackage).Hash.ToLowerInvariant() -ne $taskReport.sha256 -or $taskReport.original_modified -ne $false) {
|
|
throw 'Screen package differs from its reviewed build.'
|
|
}
|
|
$taskModDir=[IO.Path]::GetFullPath($ModDir)
|
|
if ((Split-Path $taskModDir -Leaf) -ne 'mod' -or (Split-Path (Split-Path $taskModDir -Parent) -Leaf) -ne 'American Truck Simulator') {
|
|
throw 'Expected the American Truck Simulator mod directory.'
|
|
}
|
|
$taskOriginal=Join-Path $taskModDir 'ATS_1.61_TRUCK_TESLA_SEMI_TRUCK_2019__TRAILER_v3.0_LITE__by_CyrusTheVirus.scs'
|
|
if ((Get-FileHash -LiteralPath $taskOriginal).Hash.ToLowerInvariant() -ne $taskReport.expected_original_mod_sha256) {
|
|
throw 'Installed Tesla mod differs from the archive used to prepare this add-on.'
|
|
}
|
|
$taskDestination=Join-Path $taskModDir 'ATS_OP_Tesla_Screens.scs'
|
|
if ($PlanOnly) {
|
|
& (Join-Path $taskRoot 'native/truck_screen/install.ps1') -PluginsDir $PluginsDir -EnableDisplayTest:$EnableDisplay -PlanOnly
|
|
@{addon=$taskDestination;addon_sha256=$taskReport.sha256;original_modified=$false;live_verified=$false} | ConvertTo-Json
|
|
exit 0
|
|
}
|
|
# Native installer checks the exact DLL/source hashes and backs up only its
|
|
# own DLL/settings. Protected-folder failure leaves the mod list untouched.
|
|
& (Join-Path $taskRoot 'native/truck_screen/install.ps1') -PluginsDir $PluginsDir -EnableDisplayTest:$EnableDisplay
|
|
if (Test-Path -LiteralPath $taskDestination) {
|
|
$taskBackup=Join-Path $taskRoot ('diagnostics/tesla-screen-addon-backup-'+(Get-Date -Format 'yyyyMMdd-HHmmss-fffffff'))
|
|
New-Item -ItemType Directory -Path $taskBackup | Out-Null
|
|
Copy-Item -LiteralPath $taskDestination -Destination (Join-Path $taskBackup 'ATS_OP_Tesla_Screens.scs')
|
|
Write-Output "Existing screen add-on backed up to $taskBackup"
|
|
}
|
|
Copy-Item -LiteralPath $taskPackage -Destination $taskDestination -Force
|
|
if ((Get-FileHash -LiteralPath $taskDestination).Hash.ToLowerInvariant() -ne $taskReport.sha256) { throw 'Copied add-on hash mismatch.' }
|
|
Write-Output "Screen add-on copied: $taskDestination"
|
|
Write-Output 'Start ATS. In Mod Manager, activate ATS OP Tesla screens ABOVE the original Tesla mod, apply, then enter the parked cabin with F8 off.'
|
|
Write-Output 'The right screen should show the live road/map panel; a dark surface before its first frame is expected.'
|
|
Write-Output 'The left screen keeps native truck instruments above the live app status tile. APP OFFLINE before the producer starts is expected.'
|
|
Write-Output 'After two seconds without producer frames, the right screen dims and says DISPLAY OFFLINE; the left tile returns to APP OFFLINE.'
|
|
Write-Output 'Removing the companion add-on restores the original dashboard/map. The original Tesla archive was not changed.'
|