Autotest: load through the Spielen screen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
401e20b1f2
commit
10c97f75e1
3 files changed
+19
-13
No files matched your search
+3
-2
@@ -28,7 +28,8 @@ $env:GHIDRA_HEADLESS_MAXMEM = "8G"
|
|||||||
## Automated in-game test
|
## Automated in-game test
|
||||||
|
|
||||||
`autotest-load.ps1` starts the game through the launcher, clicks
|
`autotest-load.ps1` starts the game through the launcher, clicks
|
||||||
"Spiel laden" -> "Laden" -> "Ok" (first save game), takes screenshots in-game
|
"Spielen" -> a character (`-Save`: row in the character list) -> "Spielen"
|
||||||
|
(its last world), takes screenshots in-game
|
||||||
and with the ESC menu open, and stops the game. `-Ini` appends temporary
|
and with the ESC menu open, and stops the game. `-Ini` appends temporary
|
||||||
settings to `build\x86-debug\sacredK.ini` (restored afterwards), e.g.
|
settings to `build\x86-debug\sacredK.ini` (restored afterwards), e.g.
|
||||||
|
|
||||||
@@ -36,6 +37,6 @@ settings to `build\x86-debug\sacredK.ini` (restored afterwards), e.g.
|
|||||||
.\tools\autotest-load.ps1 -Name ws_off -Ini "[widescreen]`r`nEnabled=0"
|
.\tools\autotest-load.ps1 -Name ws_off -Ini "[widescreen]`r`nEnabled=0"
|
||||||
```
|
```
|
||||||
|
|
||||||
Click positions assume the classic menu layout scaled onto a 3440x1440
|
Click positions are for the menu screens (2026-10-25) on a 3440x1440
|
||||||
monitor. `game-input.ps1` has the building blocks (start, click, key, hold key,
|
monitor. `game-input.ps1` has the building blocks (start, click, key, hold key,
|
||||||
screenshot). Don't touch mouse/keyboard while a test runs.
|
screenshot). Don't touch mouse/keyboard while a test runs.
|
||||||
+8
-10
@@ -1,18 +1,18 @@
|
|||||||
# Automated smoke test: start the game, load a save game (-Save: its row in
|
# Automated smoke test: start the game, load a character's last world (-Save:
|
||||||
# the list, 1 = the first, selected by default), take
|
# 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.
|
# 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_on # current sacredK.ini
|
||||||
# .\tools\autotest-load.ps1 -Name ws_off -Ini "[widescreen]`r`nEnabled=0"
|
# .\tools\autotest-load.ps1 -Name ws_off -Ini "[widescreen]`r`nEnabled=0"
|
||||||
#
|
#
|
||||||
# -Ini temporarily appends settings to build\x86-debug\sacredK.ini.
|
# -Ini temporarily appends settings to build\x86-debug\sacredK.ini.
|
||||||
# Click positions are for the classic (menu) layout scaled onto a 3440x1440
|
# 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.
|
# monitor; adjust for other monitors. Don't touch mouse/keyboard while it runs.
|
||||||
param(
|
param(
|
||||||
[string]$Name = "autotest",
|
[string]$Name = "autotest",
|
||||||
[string]$Ini = "",
|
[string]$Ini = "",
|
||||||
[int]$LoadTimeoutSeconds = 60,
|
[int]$LoadTimeoutSeconds = 60,
|
||||||
# Row of the save game in the load screen's list (1-3 visible rows).
|
# Row of the character in the Spielen screen's list (its last world loads).
|
||||||
[int]$Save = 1,
|
[int]$Save = 1,
|
||||||
# Runs in-game after loading, before the screenshots (e.g. clicks).
|
# Runs in-game after loading, before the screenshots (e.g. clicks).
|
||||||
[scriptblock]$InGame = $null
|
[scriptblock]$InGame = $null
|
||||||
@@ -28,12 +28,10 @@ if ($Ini) { Set-Content $iniPath ($iniBackup + "`r`n" + $Ini + "`r`n") -Encoding
|
|||||||
$game = $null
|
$game = $null
|
||||||
try {
|
try {
|
||||||
$game = Start-Sacred
|
$game = Start-Sacred
|
||||||
Click-At 1720 779 -AfterMs 1500 # main menu: "Spiel laden"
|
Click-At 1717 538 -AfterMs 2000 # main menu: "Spielen"
|
||||||
if ($Save -gt 1) {
|
Click-At 817 (509 + ($Save - 1) * 105) -AfterMs 1000 # character list row (105 px apart)
|
||||||
Click-At 1342 (609 + ($Save - 1) * 254) -AfterMs 800 # load screen: the save's name (rows 254 px apart)
|
Click-At 2714 1347 -AfterMs 1500 # "Spielen": the character's last world
|
||||||
}
|
Click-At 1548 824 -AfterMs 0 # "Spielstand laden?": "Ok"
|
||||||
Click-At 2382 568 -AfterMs 2000 # load screen: "Laden"
|
|
||||||
Click-At 1551 826 -AfterMs 0 # confirm: "Ok"
|
|
||||||
Wait-Log "cEngine End and exit constructor" -TimeoutSeconds $LoadTimeoutSeconds -AfterMs 1500 -Game $game
|
Wait-Log "cEngine End and exit constructor" -TimeoutSeconds $LoadTimeoutSeconds -AfterMs 1500 -Game $game
|
||||||
if ($InGame) { & $InGame }
|
if ($InGame) { & $InGame }
|
||||||
Save-Screen "screenshots\${Name}_ingame.png" | Out-Null
|
Save-Screen "screenshots\${Name}_ingame.png" | Out-Null
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
# Click-At 1720 779 # screen pixels (left click)
|
# Click-At 1720 779 # screen pixels (left click)
|
||||||
# Press-Key 0x1B # virtual key (ESC)
|
# Press-Key 0x1B # virtual key (ESC)
|
||||||
# Hold-Key 0x27 -Ms 1500 # hold a key (right arrow)
|
# Hold-Key 0x27 -Ms 1500 # hold a key (right arrow)
|
||||||
|
# Scroll-Wheel -3 # mouse wheel, 3 notches down
|
||||||
# Save-Screen screenshots\x.png # primary monitor area of the game
|
# Save-Screen screenshots\x.png # primary monitor area of the game
|
||||||
# Stop-Sacred $game # only the given process
|
# Stop-Sacred $game # only the given process
|
||||||
#
|
#
|
||||||
@@ -25,7 +26,7 @@ $script:Root = Split-Path $PSScriptRoot
|
|||||||
# synthetic Alt press lifts that restriction for SetForegroundWindow.
|
# synthetic Alt press lifts that restriction for SetForegroundWindow.
|
||||||
function Focus-Sacred($Game) {
|
function Focus-Sacred($Game) {
|
||||||
$Game.Refresh()
|
$Game.Refresh()
|
||||||
if ($Game.MainWindowHandle -eq [IntPtr]::Zero) { return $false }
|
if (-not $Game.MainWindowHandle -or $Game.MainWindowHandle -eq [IntPtr]::Zero) { return $false }
|
||||||
[SacredRe.Input]::keybd_event(0x12, 0, 0, [UIntPtr]::Zero)
|
[SacredRe.Input]::keybd_event(0x12, 0, 0, [UIntPtr]::Zero)
|
||||||
[SacredRe.Input]::keybd_event(0x12, 0, 2, [UIntPtr]::Zero)
|
[SacredRe.Input]::keybd_event(0x12, 0, 2, [UIntPtr]::Zero)
|
||||||
[SacredRe.Input]::SetForegroundWindow($Game.MainWindowHandle)
|
[SacredRe.Input]::SetForegroundWindow($Game.MainWindowHandle)
|
||||||
@@ -116,3 +117,9 @@ function Hold-Key([byte]$VirtualKey, [int]$Ms = 1500, [int]$AfterMs = 500) {
|
|||||||
[SacredRe.Input]::keybd_event($VirtualKey, 0, 2, [UIntPtr]::Zero)
|
[SacredRe.Input]::keybd_event($VirtualKey, 0, 2, [UIntPtr]::Zero)
|
||||||
Start-Sleep -Milliseconds $AfterMs
|
Start-Sleep -Milliseconds $AfterMs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Turns the mouse wheel by $Notches (negative: towards the user, "down").
|
||||||
|
function Scroll-Wheel([int]$Notches, [int]$AfterMs = 500) {
|
||||||
|
[SacredRe.Input]::mouse_event(0x0800, 0, 0, [BitConverter]::ToUInt32([BitConverter]::GetBytes([int]($Notches * 120)), 0), [UIntPtr]::Zero)
|
||||||
|
Start-Sleep -Milliseconds $AfterMs
|
||||||
|
}
|
||||||
Reference in new issue
Block a user