This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNew-MissionPbo.ps1
47 lines (43 loc) · 1.58 KB
/
New-MissionPbo.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter(Mandatory)]
[ValidateScript({ if (Test-Path $_ -PathType Container) { $true } else { Throw '-Source must ba a valid directory' } })]
[string]
$Source,
[Parameter(Mandatory)]
[ValidateScript({ if (Test-Path $_ -PathType Container) { $true } else { Throw '-Target must ba a valid directory' } })]
[string]
$Target,
[Parameter()]
[string]
$BriefingName = ''
)
Begin {
if (-Not (Test-Path -Path ${env:ARMA3TOOLS} -PathType Container)) {
Throw 'Arma 3 Tools not found'
}
$cfgConvertExe = Join-Path -Path ${env:ARMA3TOOLS} -ChildPath 'CfgConvert/CfgConvert.exe'
if (-Not (Test-Path -Path $cfgConvertExe -PathType Leaf)) {
Throw 'CfgConvert.exe not found'
}
$fileBankExe = Join-Path -Path ${env:ARMA3TOOLS} -ChildPath 'FileBank/FileBank.exe'
if (-Not (Test-Path -Path $fileBankExe -PathType Leaf)) {
Throw 'FileBank.exe not found'
}
$missionFilename = Join-Path $Source -ChildPath 'mission.sqm'
if (-Not (Test-Path -Path $missionFilename -PathType Leaf)) {
Throw 'mission.sqm file not found'
}
$Source = Resolve-Path $Source.TrimEnd('/\')
$BriefingName = $BriefingName -Replace ( '"', '' )
}
Process {
if($BriefingName -ne '') {
$(Get-Content $missionFilename) -Replace (
'briefingName="[^"]*";',
"briefingName=""$BriefingName"";"
) | Set-Content -LiteralPath $missionFilename
}
& $cfgConvertExe -bin -dst "$missionFilename" "$missionFilename"
& $fileBankExe -dst $Target $Source
}