diff --git a/CHANGELOG.md b/CHANGELOG.md index d1dec14..d51879c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,18 @@ Before any minor/major patch is released all test units will be run to verify th ## [Unreleased] - [x] + + +## [1.8] - 2021-08-23 +### Added +- Added special commands + +### Changed +- Add special section to README + +### Fixed +- Removed unneeded console output + ## [1.6] - 2021-06-06 ### Added - Add vban commands diff --git a/README.md b/README.md index d3ef743..f7c3091 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,15 @@ $vmr.vban_in[2].port = 6990 $vmr.vban_out[3].bit = 16 ``` +### Special +Certain 'special' commands are defined by the API as performing actions rather than setting values. You may invoke them with the following commands: +```powershell +$vmr.command.show +$vmr.command.restart +$vmr.command.showvbanchat +$vmr.command.shutdown +``` + ### Run tests Run tests using .\runall.ps1 which accepts two parameters: - tag Run tests of this type diff --git a/examples/special.ps1 b/examples/special.ps1 new file mode 100644 index 0000000..3a49708 --- /dev/null +++ b/examples/special.ps1 @@ -0,0 +1,10 @@ +Import-Module Voicemeeter + +try { + $vmr = Get-RemoteBanana + + $vmr.command.show + $vmr.command.restart + $vmr.command.showvbanchat +} +finally { $vmr.Logout() } diff --git a/lib/Voicemeeter.psm1 b/lib/Voicemeeter.psm1 index 0fb91bf..2601e8e 100644 --- a/lib/Voicemeeter.psm1 +++ b/lib/Voicemeeter.psm1 @@ -7,6 +7,7 @@ class Remote { [System.Collections.ArrayList]$bus [System.Collections.ArrayList]$vban_in [System.Collections.ArrayList]$vban_out + $command # Constructor Remote ([String]$type) @@ -24,6 +25,7 @@ class Remote { $this.bus = Buses $this.vban_in = Vban_In $this.vban_out = Vban_Out + $this.command = Special } else { Exit } } diff --git a/lib/base.ps1 b/lib/base.ps1 index 97d11ec..148b8dc 100644 --- a/lib/base.ps1 +++ b/lib/base.ps1 @@ -4,6 +4,7 @@ . $PSScriptRoot\bus.ps1 . $PSScriptRoot\macrobuttons.ps1 . $PSScriptRoot\vban.ps1 +. $PSScriptRoot\special.ps1 $global:layout = $null diff --git a/lib/special.ps1 b/lib/special.ps1 new file mode 100644 index 0000000..b1ae2d8 --- /dev/null +++ b/lib/special.ps1 @@ -0,0 +1,49 @@ +class Special { + hidden AddPublicMembers($commands) { + $commands | ForEach-Object { + # Define getter + # $GetterSignature = "`$this.Getter(`$this.cmd('{0}'))" -f $_ + # Define setter + $SetterSignature = "`$this.Setter(`$this.cmd('{0}'))" -f $_ + + $AddMemberParams = @{ + Name = $_ + MemberType = 'ScriptProperty' + Value = [ScriptBlock]::Create($SetterSignature) + SecondValue = [ScriptBlock]::Create($SetterSignature) + } + $this | Add-Member @AddMemberParams + } + } + + # Constructor + Special() + { + $this.AddPublicMembers(@('restart', 'shutdown', 'show')) + } + + [String] Getter($param) { + return Write-Warning("ERROR: " + $param + " is a write only parameter") + } + + [void] Setter($param) { + Param_Set -PARAM $param -VALUE 1 + } + + [String] cmd ($arg) { + return "Command.$arg" + } + + hidden $_showvbanchat = $($this | Add-Member ScriptProperty 'showvbanchat' ` + { + $this._showvbanchat = $this.Setter($this.cmd('DialogShow.VBANCHAT')) + }` + { + $this._showvbanchat = $this.Setter($this.cmd('DialogShow.VBANCHAT')) + } + ) +} + +Function Special { + return [Special]::new() +}