Skip to content

Commit

Permalink
Merge pull request #138 from StartAutomating/obs-powershell-updates
Browse files Browse the repository at this point in the history
obs-powershell 0.1.9
  • Loading branch information
StartAutomating authored Jul 7, 2023
2 parents 7d3fead + 9836d53 commit 7cfc8a8
Show file tree
Hide file tree
Showing 63 changed files with 1,869 additions and 90 deletions.
3 changes: 2 additions & 1 deletion Assets/obs-powershell-animated-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Assets/obs-powershell-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Assets/obs-powershell-text-and-animated-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Assets/obs-powershell-text-and-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Assets/obs-powershell.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## obs-powershell 0.1.9:

* New Filters!
* @exeldro makes some excellent obs plugins
* obs-powershell now supports a couple of them:
* Set-OBS3DFilter (#137) - Transform an object in 3D!
* Set-OBSShaderFilter (#134) - Apply _any_ PixelShader!
* New Effects!
* LeftToRight (#125) / RightToLeft (#126)
* TopToBottom (#127) / BottomToTop (#128)
* ZoomIn (#129) / ZoomOut (#130)
* Effect Fixes
* Start-OBSEffect - Adding -LoopCount (#133)
* FadeIn/FadeOut no longer conflict (#119) (thanks @I-Am-Jakoby)!

---

## obs-powershell 0.1.8:

* Added Sponsorship, Please support obs-powershell (#78)
Expand Down
45 changes: 42 additions & 3 deletions Commands/Effects/Start-OBSEffect.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,31 @@ function Start-OBSEffect
[CmdletBinding(PositionalBinding=$false)]
param(
# The name of the effect.
[ArgumentCompleter({
param ( $commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters )
$effectNames = @(Get-OBSEffect|
Select-Object -Unique -ExpandProperty EffectName)
if ($wordToComplete) {
$toComplete = $wordToComplete -replace "^'" -replace "'$"
return @($effectNames -like "$toComplete*" -replace '^', "'" -replace '$',"'")
} else {
return @($effectNames -replace '^', "'" -replace '$',"'")
}
})]
[Parameter(Mandatory)]
[string[]]
$EffectName,

# The duration of the effect.
# If provided, all effects should use this duration.
# If not provided, each effect should use it's own duration.
[Timespan]
$Duration,

# The parameters passed to the effect.
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('EffectParameters')]
Expand Down Expand Up @@ -59,7 +80,11 @@ function Start-OBSEffect
[switch]
$Loop,

# If set, will bounce the effect
# If provided, will loop the effect a number of times.
[int]
$LoopCount,

# If set, will bounce the effect (flip it / reverse it)
[switch]
$Bounce
)
Expand All @@ -68,10 +93,20 @@ function Start-OBSEffect
foreach ($NameOfEffect in $EffectName) {
$obsEffect = Get-OBSEffect -EffectName $NameOfEffect

if (-not $obsEffect) { continue }
if (-not $obsEffect) {
Write-Warning "No Effect named '$NameOfEffect'"
continue
}

if ($LoopCount) {
$obsEffect | Add-Member -MemberType NoteProperty LoopCount $LoopCount -Force
}

if ($loop -or $Bounce) {
$obsEffect | Add-Member -MemberType NoteProperty Mode "$(if ($Bounce) {"Bounce"})$(if ($loop) {"Loop"})" -Force
if (-not $LoopCount) {
$obsEffect | Add-Member -MemberType NoteProperty LoopCount -1 -Force
}
} else {
$obsEffect | Add-Member -MemberType NoteProperty Mode "Once" -Force
}
Expand Down Expand Up @@ -111,7 +146,11 @@ function Start-OBSEffect
}
}
}


if ($Duration -and $obsEffect.Parameters.Duration) {
$EffectParameter.Duration = $Duration
}

$obsEffectOutput = . $obsEffect @EffectParameter @EffectArgument
if ($obsEffectOutput) {
$obsEffect | Add-Member NoteProperty Messages $obsEffectOutput -Force
Expand Down
163 changes: 163 additions & 0 deletions Commands/Filters/Set-OBS3DFilter.ps.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
function Set-OBS3DFilter
{
<#
.SYNOPSIS
Sets an OBS 3D Filter.
.DESCRIPTION
Adds or Changes a 3D Filter on an OBS Input.
This requires the [3D Effect](https://github.com/exeldro/obs-3d-effect).
#>
[inherit(Command={
Import-Module ..\..\obs-powershell.psd1 -Global
"Add-OBSSourceFilter"
}, Dynamic, Abstract, ExcludeParameter='FilterKind','FilterSettings')]
[Alias('Add-OBS3DFilter')]
param(
# The Field of View
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty("fov")]
[double]
$FieldOfView,

# The Rotation along the X-axis
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty("rot_x")]
[double]
$RotationX,

# The Rotation along the Y-axis
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty("rot_y")]
[double]
$RotationY,

# The Rotation along the Z-axis
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty("rot_z")]
[double]
$RotationZ,

# The Position along the X-axis
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty("pos_x")]
[double]
$PositionX,

# The Position along the Y-axis
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty("pos_y")]
[double]
$PositionY,

# The Position along the Z-axis
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty("pos_z")]
[double]
$PositionZ,

# The scale of the source along the X-axis
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty("scale_x")]
[double]
$ScaleX,

# The scale of the source along the Y-axis
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty("scale_y")]
[double]
$ScaleY,

# If set, will remove a filter if one already exists.
# If this is not provided and the filter already exists, the settings of the filter will be changed.
[switch]
$Force
)

process {
$myParameters = [Ordered]@{} + $PSBoundParameters

if (-not $myParameters["FilterName"]) {
$filterName = $myParameters["FilterName"] = "3Band3D"
}

$myParameterData = [Ordered]@{}
foreach ($parameter in $MyInvocation.MyCommand.Parameters.Values) {

$bindToPropertyName = $null

foreach ($attribute in $parameter.Attributes) {
if ($attribute -is [ComponentModel.DefaultBindingPropertyAttribute]) {
$bindToPropertyName = $attribute.Name
break
}
}

if (-not $bindToPropertyName) { continue }
if ($myParameters.Contains($parameter.Name)) {
$myParameterData[$bindToPropertyName] = $myParameters[$parameter.Name]
if ($myParameters[$parameter.Name] -is [switch]) {
$myParameterData[$bindToPropertyName] = $parameter.Name -as [bool]
}
}
}

$addSplat = @{
filterName = $myParameters["FilterName"]
SourceName = $myParameters["SourceName"]
filterKind = "3d_effect_filter"
filterSettings = $myParameterData
NoResponse = $myParameters["NoResponse"]
}

if ($MyParameters["PassThru"]) {
$addSplat.Passthru = $MyParameters["PassThru"]
if ($MyInvocation.InvocationName -like 'Add-*') {
Add-OBSSourceFilter @addSplat
} else {
$addSplat.Remove('FilterKind')
Set-OBSSourceFilterSettings @addSplat
}
return
}

# Add the input.
$outputAddedResult = Add-OBSSourceFilter @addSplat *>&1


# If we got back an error
if ($outputAddedResult -is [Management.Automation.ErrorRecord]) {
# and that error was saying the source already exists,
if ($outputAddedResult.TargetObject.d.requestStatus.code -eq 601) {
# then check if we use the -Force.
if ($Force) { # If we do, remove the input
Remove-OBSSourceFilter -FilterName $addSplat.FilterName -SourceName $addSplat.SourceName
# and re-add our result.
$outputAddedResult = Add-OBSInput @addSplat *>&1
} else {
# Otherwise, get the existing filter.
$existingFilter = Get-OBSSourceFilter -SourceName $addSplat.SourceName -FilterName $addSplat.FilterName
# then apply the settings
$existingFilter.Set($addSplat.filterSettings)
# and output them
$existingFilter
# (don't forget to null the result, so we don't show this error)
$outputAddedResult = $null
}
}

# If the output was still an error
if ($outputAddedResult -is [Management.Automation.ErrorRecord]) {
# use $psCmdlet.WriteError so that it shows the error correctly.
$psCmdlet.WriteError($outputAddedResult)
}

}
# Otherwise, if we had a result
elseif ($outputAddedResult) {
# Otherwise, get the input from the filters.
Get-OBSSourceFilter -SourceName $addSplat.SourceName -FilterName $addSplat.FilterName

}
}
}
Loading

0 comments on commit 7cfc8a8

Please sign in to comment.