27 lines
1.6 KiB
PowerShell
27 lines
1.6 KiB
PowerShell
|
|
# Renders every visible robot part (chassis, armour, wheels, weapon, tower) with tools/partshot.html
|
||
|
|
# into sprite-generator/output/r3d_<id>_raw_00001_.png - references for the shop images:
|
||
|
|
# .\tools\partshots.ps1 all parts
|
||
|
|
# .\tools\partshots.ps1 flipper one part
|
||
|
|
# Then in sprite-generator: gen generate_variants (variants.py), gen adopt --size 192 part_<id>
|
||
|
|
param([string[]]$Ids)
|
||
|
|
$ErrorActionPreference = 'Stop'
|
||
|
|
$root = Split-Path $PSScriptRoot -Parent
|
||
|
|
$chrome = @("$env:ProgramFiles\Google\Chrome\Application\chrome.exe", "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe") |
|
||
|
|
Where-Object { Test-Path $_ } | Select-Object -First 1
|
||
|
|
if (-not $chrome) { throw 'Chrome or Edge not found' }
|
||
|
|
if (-not $Ids) {
|
||
|
|
$Ids = 'crate', 'doorstop', 'bulwark', 'scarab', 'rubber', 'bigtyre', 'tracks', 'steel', 'titan', 'hardox',
|
||
|
|
'wedge', 'flipper', 'hammer', 'saw', 'crusher', 'spinner', 'flamer', 'minigun', 'rockets'
|
||
|
|
}
|
||
|
|
$out = Join-Path $root 'sprite-generator\output'
|
||
|
|
New-Item -ItemType Directory -Force $out | Out-Null
|
||
|
|
$profileDir = Join-Path $env:TEMP 'robotclash-partshot'
|
||
|
|
$page = 'file:///' + ((Join-Path $root 'tools\partshot.html') -replace '\\', '/' -replace ' ', '%20')
|
||
|
|
$ErrorActionPreference = 'Continue' # Chrome reports "bytes written" on stderr
|
||
|
|
foreach ($id in $Ids) {
|
||
|
|
$png = Join-Path $out "r3d_${id}_raw_00001_.png"
|
||
|
|
& $chrome --headless=new --use-angle=swiftshader --enable-unsafe-swiftshader --hide-scrollbars --window-size=768,768 `
|
||
|
|
--virtual-time-budget=3000 --user-data-dir="$profileDir" --screenshot="$png" "${page}?id=$id&size=768" 2>&1 | Out-Null
|
||
|
|
if (Test-Path $png) { " r3d_$id -> $png" } else { " r3d_$id FAILED" }
|
||
|
|
}
|