Skip to content

Commit b4128d0

Browse files
author
James Brundage
committed
feat: Shader Commands now Prefer a ShaderFile ( Fixes #163 )
1 parent 18a7fa2 commit b4128d0

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

Build/obs--shaders.build.ps1

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ $($myAttribute.ScriptBlock)
5959
Out-File -Path $env:GITHUB_STEP_SUMMARY -Append
6060

6161
}
62-
Write-Warning "Skipping $($MyInvocation.MyCommand) :The last commit did not match $($myRegex)"
62+
Write-Warning "Skipping $($MyInvocation.MyCommand) : The $CheckIfThisIsValid was not valid"
6363
return
6464
}
6565
}
@@ -342,6 +342,15 @@ switch -regex ($myVerb) {
342342
Where-Object FilterName -Match $FilterNamePattern
343343
}
344344
}
345+
'Remove' {
346+
if ($SourceName) {
347+
Get-OBSInput |
348+
Where-Object InputName -eq $SourceName |
349+
Get-OBSSourceFilterList |
350+
Where-Object FilterName -Match $FilterNamePattern |
351+
Remove-OBSSourceFilter
352+
}
353+
}
345354
'(?>Add|Set)' {
346355
$ShaderSettings = [Ordered]@{}
347356
:nextParameter foreach ($parameterMetadata in $MyInvocation.MyCommand.Parameters[@($psBoundParameters.Keys)]) {
@@ -368,8 +377,23 @@ switch -regex ($myVerb) {
368377
}
369378
}
370379

371-
if ($myVerb -eq 'Add') {
380+
if (-not $script:CachedShaderFilesFromCommand) {
381+
$script:CachedShaderFilesFromCommand = @{}
382+
}
383+
384+
if ($Home -and -not $script:CachedShaderFilesFromCommand[$shaderName]) {
385+
$MyObsPowerShellPath = Join-Path $home ".obs-powershell"
386+
$ThisShaderPath = Join-Path $MyObsPowerShellPath "$shaderName.shader"
387+
$shaderText | Set-Content -LiteralPath $ThisShaderPath
388+
$script:CachedShaderFilesFromCommand[$shaderName] = Get-Item -LiteralPath $ThisShaderPath
389+
}
390+
if ($script:CachedShaderFilesFromCommand[$shaderName]) {
391+
$ShaderFilterSplat.ShaderFile = $script:CachedShaderFilesFromCommand[$shaderName].FullName
392+
} else {
372393
$ShaderFilterSplat.ShaderText = $shaderText
394+
}
395+
396+
if ($myVerb -eq 'Add') {
373397
Add-OBSShaderFilter @ShaderFilterSplat
374398
} else {
375399
Set-OBSShaderFilter @ShaderFilterSplat

0 commit comments

Comments
 (0)