From 9b189a4d3e8dc2a7f3b1b72262a2124bebaf4cf5 Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Tue, 6 Oct 2020 17:14:23 +0100 Subject: [PATCH] Change fileset tools to read base names and full names --- inc/filetools.ps1 | 16 +++++++++++----- ue4-package.ps1 | 4 +++- ue4-rebuild-lightmaps.ps1 | 11 ++++++----- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/inc/filetools.ps1 b/inc/filetools.ps1 index 8b83e9d..7bafc13 100644 --- a/inc/filetools.ps1 +++ b/inc/filetools.ps1 @@ -1,4 +1,4 @@ -function Find-File-Set { +function Find-Files { param ( [string]$startDir, [string]$pattern, @@ -7,19 +7,25 @@ function Find-File-Set { [array]$excludeBaseNames ) - $set = [System.Collections.Generic.HashSet[string]]::New() + $basenames = [System.Collections.ArrayList]::New() + $fullpaths = [System.Collections.ArrayList]::New() Get-ChildItem -Path $startDir -Filter $pattern -Recurse | ForEach-Object { if ($includeByDefault) { if ($excludeBaseNames -notcontains $_.BaseName) { - $set.Add($_.BaseName) > $null + $basenames.Add($_.BaseName) > $null + $fullpaths.Add($_.FullName) > $null } } else { if ($includeBaseNames -contains $_.BaseName) { - $set.Add($_.BaseName) > $null + $basenames.Add($_.BaseName) > $null + $fullpaths.Add($_.FullName) > $null } } } - return $set + return [PSCustomObject]@{ + BaseNames = $basenames + FullNames = $fullpaths + } } \ No newline at end of file diff --git a/ue4-package.ps1 b/ue4-package.ps1 index b0c1026..ab15be7 100644 --- a/ue4-package.ps1 +++ b/ue4-package.ps1 @@ -132,7 +132,9 @@ try { Write-Warning "Unknown variant(s) ignored: $($unmatchedVariants -join ", ")" } - $maps = Find-File-Set -startDir:$(Join-Path $src "Content") -pattern:*.umap -includeByDefault:$config.CookAllMaps -includeBaseNames:$config.MapsIncluded -excludeBaseNames:$config.MapsExcluded + $foundmaps = Find-Files -startDir:$(Join-Path $src "Content") -pattern:*.umap -includeByDefault:$config.CookAllMaps -includeBaseNames:$config.MapsIncluded -excludeBaseNames:$config.MapsExcluded + + $maps = $foundmaps.BaseNames Write-Output "" Write-Output "Project File : $projfile" diff --git a/ue4-rebuild-lightmaps.ps1 b/ue4-rebuild-lightmaps.ps1 index b8e87e9..bc407ad 100644 --- a/ue4-rebuild-lightmaps.ps1 +++ b/ue4-rebuild-lightmaps.ps1 @@ -17,6 +17,7 @@ param ( . $PSScriptRoot\inc\projectversion.ps1 . $PSScriptRoot\inc\uproject.ps1 . $PSScriptRoot\inc\ueinstall.ps1 +. $PSScriptRoot\inc\filetools.ps1 function Write-Usage { Write-Output "Steve's UE4 lightmap rebuilding tool" @@ -60,17 +61,17 @@ try { if ($maps) { # Explicit list of maps provided on command line - $mapsToRebuild = Find-File-Set -startDir:$(Join-Path $src "Content") -pattern:*.umap -includeByDefault:$false -includeBaseNames:$maps + $foundmaps = Find-File-Set -startDir:$(Join-Path $src "Content") -pattern:*.umap -includeByDefault:$false -includeBaseNames:$maps if ($mapsToRebuild.Count -ne $maps.Count) { Write-Warning "Ignoring missing map(s): $($maps | Where-Object { $_ -notin $mapsToRebuild })" } } else { # Derive maps from cook settings - $mapsToRebuild = Find-File-Set -startDir:$(Join-Path $src "Content") -pattern:*.umap -includeByDefault:$config.CookAllMaps -includeBaseNames:$config.MapsIncluded -excludeBaseNames:$config.MapsExcluded + $foundmaps = Find-Files -startDir:$(Join-Path $src "Content") -pattern:*.umap -includeByDefault:$config.CookAllMaps -includeBaseNames:$config.MapsIncluded -excludeBaseNames:$config.MapsExcluded } - if ($mapsToRebuild.Count -eq 0) { + if ($foundmaps.BaseNames.Count -eq 0) { throw "No maps found to rebuild" } @@ -88,7 +89,7 @@ try { Write-Output "UE Version : $ueVersion" Write-Output "UE Install : $ueinstall" Write-Output "" - Write-Output "Maps : $mapsToRebuild" + Write-Output "Maps : $($foundmaps.BaseNames)" Write-Output "Quality : $quality" Write-Output "" @@ -103,7 +104,7 @@ try { $argList.Add("-AllowCommandletRendering") > $null $argList.Add("-SkipSkinVerify") > $null $argList.Add("-Quality=$quality") > $null - $argList.Add("-Map=$($mapsToRebuild -join "+")") > $null + $argList.Add("-Map=$($foundmaps.BaseNames -join "+")") > $null $ueEditorCmd = Join-Path $ueinstall "Engine/Binaries/Win64/UE4Editor-Cmd$exeSuffix"