Add transparent officer portrait cutouts

This commit is contained in:
2026-06-18 21:56:35 +09:00
parent 3add6bab4f
commit d639d356f7
9 changed files with 26 additions and 8 deletions

View File

@@ -1851,6 +1851,9 @@ function Check-Portrait-Path($Portrait, [string]$Context) {
Fail "$Context references missing file: $Portrait"
}
Check-Portrait-Image $absolutePath ([string]$Portrait) $Context
if ($relativePath -match '^art[\\/]+portraits[\\/]+.+\.png$') {
Check-Alpha-Cutout-File $absolutePath ([string]$Portrait) $Context
}
}
function Check-Portrait-Image([string]$AbsolutePath, [string]$Portrait, [string]$Context) {
@@ -1876,14 +1879,12 @@ function Check-Portrait-Image([string]$AbsolutePath, [string]$Portrait, [string]
}
}
function Check-Item-Icon-Cutout([string]$Icon, [string]$Context) {
$relativePath = $Icon.Substring("res://".Length)
$absolutePath = [System.IO.Path]::GetFullPath((Join-Path ([System.IO.Path]::GetFullPath($Root)) $relativePath))
function Check-Alpha-Cutout-File([string]$AbsolutePath, [string]$DisplayPath, [string]$Context) {
$bitmap = $null
try {
$bitmap = [System.Drawing.Bitmap]::FromFile($absolutePath)
$bitmap = [System.Drawing.Bitmap]::FromFile($AbsolutePath)
if (-not [System.Drawing.Image]::IsAlphaPixelFormat($bitmap.PixelFormat)) {
Fail "$Context must be an alpha PNG cutout: $Icon"
Fail "$Context must be an alpha PNG cutout: $DisplayPath"
}
$cornerPixels = @(
$bitmap.GetPixel(0, 0),
@@ -1893,7 +1894,7 @@ function Check-Item-Icon-Cutout([string]$Icon, [string]$Context) {
)
foreach ($pixel in $cornerPixels) {
if ($pixel.A -gt 3) {
Fail "$Context must have transparent corners: $Icon"
Fail "$Context must have transparent corners: $DisplayPath"
}
}
$transparentSamples = 0
@@ -1907,13 +1908,13 @@ function Check-Item-Icon-Cutout([string]$Icon, [string]$Context) {
}
}
if ($transparentSamples -lt [int]($totalSamples * 0.20)) {
Fail "$Context must have substantial transparent background: $Icon ($transparentSamples/$totalSamples sampled pixels)"
Fail "$Context must have substantial transparent background: $DisplayPath ($transparentSamples/$totalSamples sampled pixels)"
}
} catch {
if ($_.Exception.Message -like "$Context*") {
throw
}
Fail "$Context could not inspect alpha cutout data: $Icon"
Fail "$Context could not inspect alpha cutout data: $DisplayPath"
} finally {
if ($null -ne $bitmap) {
$bitmap.Dispose()
@@ -1921,6 +1922,12 @@ function Check-Item-Icon-Cutout([string]$Icon, [string]$Context) {
}
}
function Check-Item-Icon-Cutout([string]$Icon, [string]$Context) {
$relativePath = $Icon.Substring("res://".Length)
$absolutePath = [System.IO.Path]::GetFullPath((Join-Path ([System.IO.Path]::GetFullPath($Root)) $relativePath))
Check-Alpha-Cutout-File $absolutePath $Icon $Context
}
function Check-Post-Battle-Dialogue($Dialogue, [string]$ScenarioId) {
if ($null -eq $Dialogue) {
return