pokerogue/scripts/asset-tooling/sprites/convert-ebdx.ps1
Sirz Benjie 6766940fa1
[Misc] Make the repo REUSE compliant (#6474)
* Add license information

* Add reuse lint workflow

* Add snippets for spdx

* fix: minor wording adjustments and typo fixes

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* chore: add FileContributor attributions for Bertie

Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>

* begin licensing some audio assets

* Add pokemon reborn sound affect attribution

* Annotate Leavannite's section

* Add more licensing info

* Add license info to license files ._.

* Move ps1 files out of public

* Add license for animation jsons

* Add license for bat scripts in public

* Update licensing in scripts

* Fix typo in license ref

* Fix AGPL-3.0-or-later

* Add license info to typedoc.config.js

* Add MIT license for snippets

* chore: update license info for files in scripts

* chore: update license info

* chore: update license info

* chore: update license info

* Remove licenses used only by public before linting with reuse

* Add license info to new files added by docker PR

* chore: apply biome

* fix: add back linting workflow lost during merge

* Add attribution based on Hanniel's information

* Add attribution based on Officer Porkchop and Green Ninja's information

* add attribution to unicorn_power for reshiram/zekrom/kyurem epic variant

* Fixup minor typo

* Adjust sprite test to not think REUSE.toml is a sprite json

* Add missing continue-on-error to workflow

* fix: address kev's comments from code review

* docs: minor touchups

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
2025-09-23 08:49:03 -05:00

131 lines
4.2 KiB
PowerShell

# SPDX-FileCopyrightText: 2024-2025 Pagefault Games
# SPDX-FileContributor: FlashfyreDev
#
# SPDX-License-Identifier: AGPL-3.0-only
$sourceDir = "."
$outputDir = ".\output"
if (-not (Test-Path $outputDir -PathType Container)) {
New-Item -ItemType Directory -Path $outputDir | Out-Null
}
Get-ChildItem -Path $outputDir -Include *.* -File -Recurse | foreach { $_.Delete()}
Get-ChildItem -Path "$sourceDir\*.png" | ForEach-Object {
$fileName = $_.BaseName
$destinationDir = $outputDir
if ($fileName -match "^[0-9]+fsb-?") {
$destinationDir = Join-Path $outputDir "back\shiny\female"
}
elseif ($fileName -match "^[0-9]+sb-?") {
$destinationDir = Join-Path $outputDir "back\shiny"
}
elseif ($fileName -match "^[0-9]+fb-?") {
$destinationDir = Join-Path $outputDir "back\female"
}
elseif ($fileName -match "^[0-9]+b-?") {
$destinationDir = Join-Path $outputDir "back"
}
elseif ($fileName -match "^[0-9]+fs-?") {
$destinationDir = Join-Path $outputDir "shiny\female"
}
elseif ($fileName -match "^[0-9]+s-?") {
$destinationDir = Join-Path $outputDir "shiny"
}
elseif ($fileName -match "^[0-9]+f-?") {
$destinationDir = Join-Path $outputDir "female"
}
if (-not (Test-Path $destinationDir -PathType Container)) {
New-Item -ItemType Directory -Path $destinationDir | Out-Null
}
Move-Item -Path $_.FullName -Destination $destinationDir
Write-Host "Moved: $($_.FullName) to $destinationDir"
}
$dirs = @(".\output\back\shiny\female", ".\output\back\shiny", ".\output\back\female", ".\output\back", ".\output\shiny\female", ".\output\shiny", ".\output\female")
foreach ($dir in $dirs) {
Get-ChildItem -Path $dir -Filter *.png | ForEach-Object {
$filename = $_.BaseName
$extension = $_.Extension
$newfilename = ""
$prefix, $suffix = $filename -split '-', 2
if ($suffix) {
$suffix = '-' + $suffix
}
$prefix = $prefix -replace 'b|s|sb|f|fb|fs|fsb'
$newfilename = "$prefix$suffix$extension"
if ($filename -ne $newfilename) {
Rename-Item $_.FullName -NewName $newfilename
Write-Host "Renamed: $($_.FullName) to $newfilename"
}
}
}
$env:PATH = "C:\Program Files\CodeAndWeb\TexturePacker\bin;$env:PATH"
$dirs = @(".\output", ".\output\back\shiny\female", ".\output\back\shiny", ".\output\back\female", ".\output\back", ".\output\shiny\female", ".\output\shiny", ".\output\female")
foreach ($dir in $dirs) {
Get-ChildItem $dir -Filter *.png | ForEach-Object {
$outputDir = Join-Path $_.Directory $_.BaseName
New-Item -ItemType Directory -Path $outputDir | Out-Null
ffmpeg -i $_.FullName "$outputDir\%04d.png"
}
}
$dirs = @(".\output", ".\output\back\shiny\female", ".\output\back\shiny", ".\output\back\female", ".\output\back", ".\output\shiny\female", ".\output\shiny", ".\output\female")
$configPath = "$(Get-Location)\configuration.tps"
foreach ($dir in $dirs) {
Get-ChildItem -Path $dir -Directory | Where-Object { $_.Name -match '^[0-9]+' } | ForEach-Object {
$name = $_.BaseName
Get-ChildItem -Path $_.FullName -Recurse -File | ForEach-Object {
$img = New-Object -ComObject Wia.ImageFile
echo $_.FullName
$img.LoadFile($_.FullName)
$height = $img.Height
$command = "magick.exe convert $($_.FullName) -crop $($height)x$($height) $($_.Directory)\%04d.png"
iex $command
$gifPath = "$($_.Directory)/$($name).gif"
$command = "ffmpeg -i $($_.Directory)\%04d.png $($gifPath)"
iex $command
Get-ChildItem $_.Directory -Filter *.png | ForEach-Object {
Remove-Item $_.FullName
}
magick.exe convert -layers trim-bounds $gifPath $gifPath
$command = "ffmpeg -i $($gifPath) $($_.Directory)\%04d.png"
iex $command
Remove-Item $gifPath
$command = "TexturePacker.exe $($configPath) --sheet $($dir)\$($name).png --data $($dir)\$($name).json $($dir)\$($name)"
iex $command
}
}
$folders = Get-ChildItem -Path $dir -Directory
$foldersToKeep = @('back', 'shiny', 'female')
$foldersToDelete = $folders | Where-Object { $foldersToKeep -notcontains $_.Name }
foreach ($folder in $foldersToDelete) {
Remove-Item -Path $folder.FullName -Recurse -Force
Write-Host "Deleted folder: $($folder.FullName)"
}
}