# Automated smoke test: start the game, load a character's last world (-Save: # its row in the Spielen screen's character list, 1 = the first), take # screenshots in-game and with the ESC menu open, then stop the game. # # .\tools\autotest-load.ps1 -Name ws_on # current sacredK.ini # .\tools\autotest-load.ps1 -Name ws_off -Ini "[widescreen]`r`nEnabled=0" # # -Ini temporarily appends settings to build\x86-debug\sacredK.ini. # Click positions are for the menu screens (2026-10-25) on a 3440x1440 # monitor; adjust for other monitors. Don't touch mouse/keyboard while it runs. param( [string]$Name = "autotest", [string]$Ini = "", [int]$LoadTimeoutSeconds = 60, # Row of the character in the Spielen screen's list (its last world loads). [int]$Save = 1, # Runs in-game after loading, before the screenshots (e.g. clicks). [scriptblock]$InGame = $null ) $ErrorActionPreference = "Stop" . (Join-Path $PSScriptRoot "game-input.ps1") $root = Split-Path $PSScriptRoot $iniPath = Join-Path $root "build\x86-debug\sacredK.ini" $iniBackup = if (Test-Path $iniPath) { Get-Content $iniPath -Raw } else { "" } if ($Ini) { Set-Content $iniPath ($iniBackup + "`r`n" + $Ini + "`r`n") -Encoding ASCII } $game = $null try { $game = Start-Sacred Click-At 1717 538 -AfterMs 2000 # main menu: "Spielen" Click-At 817 (509 + ($Save - 1) * 105) -AfterMs 1000 # character list row (105 px apart) Click-At 2714 1347 -AfterMs 1500 # "Spielen": the character's last world Click-At 1548 824 -AfterMs 0 # "Spielstand laden?": "Ok" Wait-Log "cEngine End and exit constructor" -TimeoutSeconds $LoadTimeoutSeconds -AfterMs 1500 -Game $game if ($InGame) { & $InGame } Save-Screen "screenshots\${Name}_ingame.png" | Out-Null Press-Key 0x1B -AfterMs 2500 # ESC menu Save-Screen "screenshots\${Name}_esc.png" | Out-Null "game alive at end: $(-not $game.HasExited)" } finally { Stop-Sacred $game if ($Ini) { Set-Content $iniPath $iniBackup -Encoding ASCII -NoNewline } }