Skip to content

Commit 7cfc8a8

Browse files
Merge pull request #138 from StartAutomating/obs-powershell-updates
obs-powershell 0.1.9
2 parents 7d3fead + 9836d53 commit 7cfc8a8

File tree

63 files changed

+1869
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1869
-90
lines changed

Assets/obs-powershell-animated-icon.svg

Lines changed: 2 additions & 1 deletion
Loading

Assets/obs-powershell-icon.svg

Lines changed: 2 additions & 1 deletion
Loading

Assets/obs-powershell-text-and-animated-icon.svg

Lines changed: 2 additions & 1 deletion
Loading

Assets/obs-powershell-text-and-icon.svg

Lines changed: 2 additions & 1 deletion
Loading

Assets/obs-powershell.svg

Lines changed: 2 additions & 1 deletion
Loading

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## obs-powershell 0.1.9:
2+
3+
* New Filters!
4+
* @exeldro makes some excellent obs plugins
5+
* obs-powershell now supports a couple of them:
6+
* Set-OBS3DFilter (#137) - Transform an object in 3D!
7+
* Set-OBSShaderFilter (#134) - Apply _any_ PixelShader!
8+
* New Effects!
9+
* LeftToRight (#125) / RightToLeft (#126)
10+
* TopToBottom (#127) / BottomToTop (#128)
11+
* ZoomIn (#129) / ZoomOut (#130)
12+
* Effect Fixes
13+
* Start-OBSEffect - Adding -LoopCount (#133)
14+
* FadeIn/FadeOut no longer conflict (#119) (thanks @I-Am-Jakoby)!
15+
16+
---
17+
118
## obs-powershell 0.1.8:
219

320
* Added Sponsorship, Please support obs-powershell (#78)

Commands/Effects/Start-OBSEffect.ps1

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,31 @@ function Start-OBSEffect
1313
[CmdletBinding(PositionalBinding=$false)]
1414
param(
1515
# The name of the effect.
16+
[ArgumentCompleter({
17+
param ( $commandName,
18+
$parameterName,
19+
$wordToComplete,
20+
$commandAst,
21+
$fakeBoundParameters )
22+
$effectNames = @(Get-OBSEffect|
23+
Select-Object -Unique -ExpandProperty EffectName)
24+
if ($wordToComplete) {
25+
$toComplete = $wordToComplete -replace "^'" -replace "'$"
26+
return @($effectNames -like "$toComplete*" -replace '^', "'" -replace '$',"'")
27+
} else {
28+
return @($effectNames -replace '^', "'" -replace '$',"'")
29+
}
30+
})]
1631
[Parameter(Mandatory)]
1732
[string[]]
1833
$EffectName,
1934

35+
# The duration of the effect.
36+
# If provided, all effects should use this duration.
37+
# If not provided, each effect should use it's own duration.
38+
[Timespan]
39+
$Duration,
40+
2041
# The parameters passed to the effect.
2142
[Parameter(ValueFromPipelineByPropertyName)]
2243
[Alias('EffectParameters')]
@@ -59,7 +80,11 @@ function Start-OBSEffect
5980
[switch]
6081
$Loop,
6182

62-
# If set, will bounce the effect
83+
# If provided, will loop the effect a number of times.
84+
[int]
85+
$LoopCount,
86+
87+
# If set, will bounce the effect (flip it / reverse it)
6388
[switch]
6489
$Bounce
6590
)
@@ -68,10 +93,20 @@ function Start-OBSEffect
6893
foreach ($NameOfEffect in $EffectName) {
6994
$obsEffect = Get-OBSEffect -EffectName $NameOfEffect
7095

71-
if (-not $obsEffect) { continue }
96+
if (-not $obsEffect) {
97+
Write-Warning "No Effect named '$NameOfEffect'"
98+
continue
99+
}
100+
101+
if ($LoopCount) {
102+
$obsEffect | Add-Member -MemberType NoteProperty LoopCount $LoopCount -Force
103+
}
72104

73105
if ($loop -or $Bounce) {
74106
$obsEffect | Add-Member -MemberType NoteProperty Mode "$(if ($Bounce) {"Bounce"})$(if ($loop) {"Loop"})" -Force
107+
if (-not $LoopCount) {
108+
$obsEffect | Add-Member -MemberType NoteProperty LoopCount -1 -Force
109+
}
75110
} else {
76111
$obsEffect | Add-Member -MemberType NoteProperty Mode "Once" -Force
77112
}
@@ -111,7 +146,11 @@ function Start-OBSEffect
111146
}
112147
}
113148
}
114-
149+
150+
if ($Duration -and $obsEffect.Parameters.Duration) {
151+
$EffectParameter.Duration = $Duration
152+
}
153+
115154
$obsEffectOutput = . $obsEffect @EffectParameter @EffectArgument
116155
if ($obsEffectOutput) {
117156
$obsEffect | Add-Member NoteProperty Messages $obsEffectOutput -Force
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
function Set-OBS3DFilter
2+
{
3+
<#
4+
.SYNOPSIS
5+
Sets an OBS 3D Filter.
6+
.DESCRIPTION
7+
Adds or Changes a 3D Filter on an OBS Input.
8+
9+
This requires the [3D Effect](https://github.com/exeldro/obs-3d-effect).
10+
#>
11+
[inherit(Command={
12+
Import-Module ..\..\obs-powershell.psd1 -Global
13+
"Add-OBSSourceFilter"
14+
}, Dynamic, Abstract, ExcludeParameter='FilterKind','FilterSettings')]
15+
[Alias('Add-OBS3DFilter')]
16+
param(
17+
# The Field of View
18+
[Parameter(ValueFromPipelineByPropertyName)]
19+
[ComponentModel.DefaultBindingProperty("fov")]
20+
[double]
21+
$FieldOfView,
22+
23+
# The Rotation along the X-axis
24+
[Parameter(ValueFromPipelineByPropertyName)]
25+
[ComponentModel.DefaultBindingProperty("rot_x")]
26+
[double]
27+
$RotationX,
28+
29+
# The Rotation along the Y-axis
30+
[Parameter(ValueFromPipelineByPropertyName)]
31+
[ComponentModel.DefaultBindingProperty("rot_y")]
32+
[double]
33+
$RotationY,
34+
35+
# The Rotation along the Z-axis
36+
[Parameter(ValueFromPipelineByPropertyName)]
37+
[ComponentModel.DefaultBindingProperty("rot_z")]
38+
[double]
39+
$RotationZ,
40+
41+
# The Position along the X-axis
42+
[Parameter(ValueFromPipelineByPropertyName)]
43+
[ComponentModel.DefaultBindingProperty("pos_x")]
44+
[double]
45+
$PositionX,
46+
47+
# The Position along the Y-axis
48+
[Parameter(ValueFromPipelineByPropertyName)]
49+
[ComponentModel.DefaultBindingProperty("pos_y")]
50+
[double]
51+
$PositionY,
52+
53+
# The Position along the Z-axis
54+
[Parameter(ValueFromPipelineByPropertyName)]
55+
[ComponentModel.DefaultBindingProperty("pos_z")]
56+
[double]
57+
$PositionZ,
58+
59+
# The scale of the source along the X-axis
60+
[Parameter(ValueFromPipelineByPropertyName)]
61+
[ComponentModel.DefaultBindingProperty("scale_x")]
62+
[double]
63+
$ScaleX,
64+
65+
# The scale of the source along the Y-axis
66+
[Parameter(ValueFromPipelineByPropertyName)]
67+
[ComponentModel.DefaultBindingProperty("scale_y")]
68+
[double]
69+
$ScaleY,
70+
71+
# If set, will remove a filter if one already exists.
72+
# If this is not provided and the filter already exists, the settings of the filter will be changed.
73+
[switch]
74+
$Force
75+
)
76+
77+
process {
78+
$myParameters = [Ordered]@{} + $PSBoundParameters
79+
80+
if (-not $myParameters["FilterName"]) {
81+
$filterName = $myParameters["FilterName"] = "3Band3D"
82+
}
83+
84+
$myParameterData = [Ordered]@{}
85+
foreach ($parameter in $MyInvocation.MyCommand.Parameters.Values) {
86+
87+
$bindToPropertyName = $null
88+
89+
foreach ($attribute in $parameter.Attributes) {
90+
if ($attribute -is [ComponentModel.DefaultBindingPropertyAttribute]) {
91+
$bindToPropertyName = $attribute.Name
92+
break
93+
}
94+
}
95+
96+
if (-not $bindToPropertyName) { continue }
97+
if ($myParameters.Contains($parameter.Name)) {
98+
$myParameterData[$bindToPropertyName] = $myParameters[$parameter.Name]
99+
if ($myParameters[$parameter.Name] -is [switch]) {
100+
$myParameterData[$bindToPropertyName] = $parameter.Name -as [bool]
101+
}
102+
}
103+
}
104+
105+
$addSplat = @{
106+
filterName = $myParameters["FilterName"]
107+
SourceName = $myParameters["SourceName"]
108+
filterKind = "3d_effect_filter"
109+
filterSettings = $myParameterData
110+
NoResponse = $myParameters["NoResponse"]
111+
}
112+
113+
if ($MyParameters["PassThru"]) {
114+
$addSplat.Passthru = $MyParameters["PassThru"]
115+
if ($MyInvocation.InvocationName -like 'Add-*') {
116+
Add-OBSSourceFilter @addSplat
117+
} else {
118+
$addSplat.Remove('FilterKind')
119+
Set-OBSSourceFilterSettings @addSplat
120+
}
121+
return
122+
}
123+
124+
# Add the input.
125+
$outputAddedResult = Add-OBSSourceFilter @addSplat *>&1
126+
127+
128+
# If we got back an error
129+
if ($outputAddedResult -is [Management.Automation.ErrorRecord]) {
130+
# and that error was saying the source already exists,
131+
if ($outputAddedResult.TargetObject.d.requestStatus.code -eq 601) {
132+
# then check if we use the -Force.
133+
if ($Force) { # If we do, remove the input
134+
Remove-OBSSourceFilter -FilterName $addSplat.FilterName -SourceName $addSplat.SourceName
135+
# and re-add our result.
136+
$outputAddedResult = Add-OBSInput @addSplat *>&1
137+
} else {
138+
# Otherwise, get the existing filter.
139+
$existingFilter = Get-OBSSourceFilter -SourceName $addSplat.SourceName -FilterName $addSplat.FilterName
140+
# then apply the settings
141+
$existingFilter.Set($addSplat.filterSettings)
142+
# and output them
143+
$existingFilter
144+
# (don't forget to null the result, so we don't show this error)
145+
$outputAddedResult = $null
146+
}
147+
}
148+
149+
# If the output was still an error
150+
if ($outputAddedResult -is [Management.Automation.ErrorRecord]) {
151+
# use $psCmdlet.WriteError so that it shows the error correctly.
152+
$psCmdlet.WriteError($outputAddedResult)
153+
}
154+
155+
}
156+
# Otherwise, if we had a result
157+
elseif ($outputAddedResult) {
158+
# Otherwise, get the input from the filters.
159+
Get-OBSSourceFilter -SourceName $addSplat.SourceName -FilterName $addSplat.FilterName
160+
161+
}
162+
}
163+
}

0 commit comments

Comments
 (0)