voicemeeter-api-python/voicemeeterlib/command.py

50 lines
1.1 KiB
Python
Raw Normal View History

2022-06-16 14:07:12 +01:00
from .iremote import IRemote
2023-06-23 03:39:07 +01:00
from .meta import action_fn
2022-06-16 14:07:12 +01:00
class Command(IRemote):
"""
Implements the common interface
Defines concrete implementation for command
"""
@classmethod
def make(cls, remote):
"""
Factory function for command class.
Returns a Command class of a kind.
"""
CMD_cls = type(
2025-01-15 12:40:31 +00:00
f'Command{remote.kind}',
2022-06-16 14:07:12 +01:00
(cls,),
{
**{
2025-01-15 12:40:31 +00:00
param: action_fn(param) for param in ['show', 'shutdown', 'restart']
2022-06-16 14:07:12 +01:00
},
2025-01-15 12:40:31 +00:00
'hide': action_fn('show', val=0),
2022-06-16 14:07:12 +01:00
},
)
return CMD_cls(remote)
def __str__(self):
2025-01-15 12:40:31 +00:00
return f'{type(self).__name__}'
2022-06-16 14:07:12 +01:00
@property
def identifier(self) -> str:
2025-01-15 12:40:31 +00:00
return 'Command'
2022-06-16 14:07:12 +01:00
def set_showvbanchat(self, val: bool):
2025-01-15 12:40:31 +00:00
self.setter('DialogShow.VBANCHAT', 1 if val else 0)
2022-06-16 14:07:12 +01:00
showvbanchat = property(fset=set_showvbanchat)
def set_lock(self, val: bool):
2025-01-15 12:40:31 +00:00
self.setter('lock', 1 if val else 0)
2022-06-16 14:07:12 +01:00
lock = property(fset=set_lock)
def reset(self):
2025-01-15 12:40:31 +00:00
self._remote.apply_config('reset')