Skip to content

Commit

Permalink
build: extract assets from the game install so we don't have to inclu…
Browse files Browse the repository at this point in the history
…de them in this repository
  • Loading branch information
YoRyan committed Jul 3, 2024
1 parent 6d0ff13 commit 943cef6
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 608 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
/dist
/src/build.json

yarn.lock
.vscode
Expand All @@ -10,4 +9,7 @@ yarn.lock
/BuildAssets.config.ps1
/build.js
/build-worker.js
/payware
/src/build.json
/src/mod/Assets/RSC/AcelaPack01/InputMappers/AcelaExpert.xml
*.dds
86 changes: 76 additions & 10 deletions BuildAssets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,78 @@ if (Test-Path .\BuildAssets.config.ps1) {
. .\BuildAssets.config.ps1
}

Add-Type -Assembly System.IO.Compression.FileSystem

# Step 1: Extract and modify payware assets.

function Mkdir {
param(
[string]$Path
)
New-Item $Path -ItemType Directory -ErrorAction SilentlyContinue
}

function ExtractFromZip {
param(
[string]$Zip,
[string]$Entry,
[string]$Out
)
try {
Mkdir $(Split-Path -Path $Out -Parent)
$ZipFile = [IO.Compression.ZipFile]::OpenRead($Zip)
$ZipEntry = $ZipFile.Entries | Where-Object FullName -EQ $Entry
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($ZipEntry, $Out, $True)
} finally {
$ZipFile.Dispose()
}
}

function UnSerz {
[CmdletBinding()]
param(
[string]$In,
[string]$Out
)
& "$RailWorks\serz.exe" $In "/xml:$Out"
}

ExtractFromZip "$RailWorks\Assets\RSC\AcelaPack01\AcelaPack01Assets.ap" `
"InputMappers/AcelaExpert.bin" `
".\payware\Assets\RSC\AcelaPack01\InputMappers\AcelaExpert.bin"
UnSerz ".\payware\Assets\RSC\AcelaPack01\InputMappers\AcelaExpert.bin" `
".\payware\Assets\RSC\AcelaPack01\InputMappers\AcelaExpert.xml"
(Get-Content -Path ".\payware\Assets\RSC\AcelaPack01\InputMappers\AcelaExpert.xml").Replace(
"</Map>",
@"
<!-- Make the Q key operate the acknowledge plunger. -->
<iInputMapper-cInputMapEntry d:id="43587">
<State d:type="sInt32">0</State>
<Device d:type="cDeltaString">Keyboard</Device>
<ButtonState d:type="cDeltaString">ButtonDown</ButtonState>
<Button d:type="cDeltaString">Key_Q</Button>
<ShiftButton d:type="cDeltaString">NoShift</ShiftButton>
<Axis d:type="cDeltaString">NoAxis</Axis>
<Name d:type="cDeltaString">IncreaseControlStart</Name>
<Parameter d:type="cDeltaString">AWSReset</Parameter>
<NewState d:type="sInt32">0</NewState>
</iInputMapper-cInputMapEntry>
<iInputMapper-cInputMapEntry d:id="43597">
<State d:type="sInt32">0</State>
<Device d:type="cDeltaString">Keyboard</Device>
<ButtonState d:type="cDeltaString">ButtonUp</ButtonState>
<Button d:type="cDeltaString">Key_Q</Button>
<ShiftButton d:type="cDeltaString">NoShift</ShiftButton>
<Axis d:type="cDeltaString">NoAxis</Axis>
<Name d:type="cDeltaString">DecreaseControlStart</Name>
<Parameter d:type="cDeltaString">AWSReset</Parameter>
<NewState d:type="sInt32">0</NewState>
</iInputMapper-cInputMapEntry>
</Map>
"@) | Set-Content -Path ".\src\mod\Assets\RSC\AcelaPack01\InputMappers\AcelaExpert.xml"

# Step 2: Build our new assets.

function FindModPaths {
[CmdletBinding()]
param(
Expand All @@ -37,7 +109,7 @@ function ToDist {
)
foreach ($ModPath in $Input) {
$OutDir = ".\dist\$(Split-Path -Path $ModPath -Parent)"
New-Item $OutDir -ItemType Directory -ErrorAction SilentlyContinue
Mkdir $OutDir
$Build.Invoke(".\src\mod\$ModPath", ".\dist\$( $ModPath -replace '\.[\w]*$',$Extension )")
}
}
Expand Down Expand Up @@ -84,23 +156,17 @@ function ConvertToTg {
}

function CopyOutput {
New-Item `
"dist\Assets\DTG\WashingtonBaltimore\InputMapper" `
-Type Directory -Force
Mkdir "dist\Assets\DTG\WashingtonBaltimore\InputMapper"
Copy-Item `
"dist\Assets\RSC\AcelaPack01\InputMappers\AcelaExpert.bin" `
"dist\Assets\DTG\WashingtonBaltimore\InputMapper\AcelaExpert.bin"

New-Item `
"dist\Assets\DTG\WashingtonBaltimore\Audio\RailVehicles\Electric\Acela\Cab" `
-Type Directory -Force
Mkdir "dist\Assets\DTG\WashingtonBaltimore\Audio\RailVehicles\Electric\Acela\Cab"
Copy-Item `
"dist\Assets\RSC\AcelaPack01\Audio\RailVehicles\Electric\Acela\Cab\*" `
"dist\Assets\DTG\WashingtonBaltimore\Audio\RailVehicles\Electric\Acela\Cab"

New-Item `
"dist\Assets\DTG\WashingtonBaltimore\RailVehicles\Electric\Acela\Default\FirstCar\destinations" `
-Type Directory -Force
Mkdir "dist\Assets\DTG\WashingtonBaltimore\RailVehicles\Electric\Acela\Default\FirstCar\destinations"
Copy-Item `
"dist\Assets\RSC\AcelaPack01\RailVehicles\Electric\Acela\Default\FirstCar\destinations\*" `
"dist\Assets\DTG\WashingtonBaltimore\RailVehicles\Electric\Acela\Default\FirstCar\destinations"
Expand Down
Loading

0 comments on commit 943cef6

Please sign in to comment.