2020-06-29 10:23:45 +09:00
|
|
|
# Stop on errors
|
2020-03-09 17:49:36 +09:00
|
|
|
$ErrorActionPreference = "Stop";
|
|
|
|
|
2020-06-29 10:23:45 +09:00
|
|
|
# Hide progress bars
|
|
|
|
$global:ProgressPreference = 'SilentlyContinue'
|
2020-03-09 17:49:36 +09:00
|
|
|
|
2020-07-10 12:04:22 +09:00
|
|
|
# Move to script directory
|
|
|
|
$rootDirectory = (Get-Item $PSScriptRoot).Parent.FullName
|
|
|
|
Set-Location $rootDirectory;
|
|
|
|
|
2020-03-09 17:49:36 +09:00
|
|
|
# Start build
|
2020-06-29 10:23:45 +09:00
|
|
|
Write-Host "Packing archives...";
|
2020-03-09 17:49:36 +09:00
|
|
|
|
|
|
|
# Setup workspace
|
2020-06-29 10:23:45 +09:00
|
|
|
New-Item -ItemType directory -Path "./tmp" > $null;
|
2020-07-10 12:04:22 +09:00
|
|
|
Copy-Item "Codes.xml" "./tmp/";
|
2020-06-29 10:23:45 +09:00
|
|
|
Set-Location "./tmp";
|
2020-03-09 17:49:36 +09:00
|
|
|
|
|
|
|
# Helper function to convert the XML files to the GCM txt format
|
|
|
|
function XmlToGcm($source, $destination, $versionname) {
|
|
|
|
[xml]$xml = Get-Content $source;
|
|
|
|
|
|
|
|
Add-Content $destination $versionname;
|
|
|
|
Add-Content $destination "Super Mario Sunshine" -NoNewline;
|
|
|
|
|
|
|
|
foreach ($code in $xml.codes.code) {
|
2020-07-10 12:04:22 +09:00
|
|
|
$codeTitle = ($code.title | Where-Object { $_.lang -eq 'en-US' }).'#text';
|
|
|
|
$codeSource = ($code.source | Where-Object { $_.version -eq $versionname }).'#text';
|
|
|
|
|
|
|
|
Write-Host "$versionname`: $codeTitle";
|
|
|
|
Write-Host $codeSource;
|
|
|
|
|
|
|
|
if (!$codeSource || [string]::IsNullOrWhiteSpace($codeSource.'#text')) {
|
|
|
|
Write-Host "No source found, skipping";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-03-09 17:49:36 +09:00
|
|
|
Add-Content $destination "";
|
|
|
|
Add-Content $destination "";
|
2020-07-10 12:04:22 +09:00
|
|
|
Add-Content $destination "$codeTitle ($($code.date)) [$($code.author)]";
|
|
|
|
$codeSource = $codeSource -replace " +$", "" -replace "^? [^a-zA-Z0-9]", "";
|
2020-03-09 17:49:36 +09:00
|
|
|
Add-Content $destination $codeSource.Trim() -NoNewline;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-03-09 23:35:43 +09:00
|
|
|
# Helper function to convert the XML files to the Dolphin INI format
|
|
|
|
function XmlToIni($source, $destination, $versionname) {
|
|
|
|
[xml]$xml = Get-Content $source;
|
|
|
|
|
|
|
|
Add-Content $destination "Paste the following on top of your games .ini file:"
|
|
|
|
Add-Content $destination "[Gecko]" -NoNewline
|
|
|
|
|
|
|
|
foreach ($code in $xml.codes.code) {
|
2020-07-10 12:04:22 +09:00
|
|
|
$codeTitle = ($code.title | Where-Object { $_.lang -eq 'en-US' }).'#text';
|
|
|
|
$codeSource = ($code.source | Where-Object { $_.version -eq $versionname }).'#text';
|
|
|
|
|
|
|
|
Write-Host "$versionname`: $codeTitle";
|
|
|
|
Write-Host $codeSource;
|
|
|
|
|
|
|
|
if (!$codeSource || [string]::IsNullOrWhiteSpace($codeSource.'#text')) {
|
|
|
|
Write-Host "No source found, skipping";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-03-09 23:35:43 +09:00
|
|
|
Add-Content $destination "";
|
2020-07-10 12:04:22 +09:00
|
|
|
Add-Content $destination "`$$codeTitle ($($code.date)) [$($code.author)]";
|
|
|
|
$codeSource = $codeSource -replace " +$", "" -replace "^? [^a-zA-Z0-9]", "";
|
2020-03-09 23:35:43 +09:00
|
|
|
Add-Content $destination $codeSource.Trim() -NoNewline;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
# Convert files to GCM format
|
|
|
|
Write-Host "Converting XML files to GCM format..";
|
2020-07-10 12:04:22 +09:00
|
|
|
XmlToGcm "Codes.xml" "GMSE01.txt" "GMSE01";
|
|
|
|
XmlToGcm "Codes.xml" "GMSP01.txt" "GMSP01";
|
|
|
|
XmlToGcm "Codes.xml" "GMSJ01.txt" "GMSJ01";
|
|
|
|
XmlToGcm "Codes.xml" "GMSJ01 (A).txt" "GMSJ01";
|
2020-03-09 17:49:36 +09:00
|
|
|
|
|
|
|
# Replace zip file
|
2020-06-29 10:23:45 +09:00
|
|
|
Write-Host "Compressing GCM archive..";
|
2020-07-01 13:55:31 +09:00
|
|
|
Compress-Archive "./*.txt" "../site/.vuepress/public/files/GCMCodes.zip";
|
2020-06-29 10:23:45 +09:00
|
|
|
Write-Host "GCM Archive built";
|
2020-03-09 23:35:43 +09:00
|
|
|
|
|
|
|
# Convert files to Dolphin format
|
|
|
|
Remove-Item *.txt;
|
|
|
|
|
|
|
|
Write-Host "Converting XML files to Dolphin INI format..";
|
2020-07-10 12:04:22 +09:00
|
|
|
XmlToIni "Codes.xml" "GMSE01.txt" "GMSE01";
|
|
|
|
XmlToIni "Codes.xml" "GMSP01.txt" "GMSP01";
|
|
|
|
XmlToIni "Codes.xml" "GMSJ01.txt" "GMSJ01";
|
|
|
|
XmlToIni "Codes.xml" "GMSJ01 (A).txt" "GMSJ01";
|
2020-03-09 23:35:43 +09:00
|
|
|
|
2020-06-29 10:23:45 +09:00
|
|
|
Write-Host "Compressing Dolphin archive..";
|
2020-07-01 13:55:31 +09:00
|
|
|
Compress-Archive "./*.txt" "../site/.vuepress/public/files/DolphinCodes.zip";
|
2020-03-09 23:35:43 +09:00
|
|
|
|
2020-06-29 10:23:45 +09:00
|
|
|
Write-Host "Dolphin Archive built";
|
2020-03-09 23:35:43 +09:00
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
Write-Host "Cleaning up..";
|
2020-03-09 17:49:36 +09:00
|
|
|
Set-Location ..;
|
2020-06-29 10:23:45 +09:00
|
|
|
Remove-Item "./tmp" -Recurse;
|
|
|
|
Write-Host "Done";
|