add enabled button

This commit is contained in:
aynakeya
2025-03-05 20:07:17 +08:00
parent e311c40f5e
commit 42c80f3ea8
2 changed files with 15 additions and 1 deletions

View File

@@ -568,6 +568,10 @@
"en": "Admin only",
"zh-CN": "仅房管可操作"
},
"plugin.yinliang.enabled": {
"en": "Enabled volume control",
"zh-CN": "启用弹幕音量控制"
},
"plugin.yinliang.volume_up_cmd": {
"en": "Volume increase command",
"zh-CN": "音量增加命令"

View File

@@ -21,6 +21,7 @@ import (
type Yinliang struct {
config.BaseConfig
Enabled bool
AdminPermission bool
VolumeUpCMD string
VolumeDownCMD string
@@ -32,11 +33,12 @@ type Yinliang struct {
func NewYinliang() *Yinliang {
return &Yinliang{
Enabled: false,
AdminPermission: true,
VolumeUpCMD: "音量调大",
VolumeDownCMD: "音量调小",
VolumeStep: 5.0,
MaxVolume: 50.0,
MaxVolume: 75.0,
currentVolume: 50.0,
}
}
@@ -82,6 +84,9 @@ func (y *Yinliang) Disable() error {
}
func (y *Yinliang) handleMessage(event *event.Event) {
if !y.Enabled {
return
}
message := event.Data.(events.LiveRoomMessageReceiveEvent).Message
cmd := strings.TrimSpace(message.Message)
@@ -126,6 +131,10 @@ func (y *Yinliang) CreatePanel() fyne.CanvasObject {
return y.panel
}
enabledCheck := component.NewCheckOneWayBinding(i18n.T("plugin.yinliang.enabled"),
&y.AdminPermission,
y.AdminPermission)
permCheck := component.NewCheckOneWayBinding(
i18n.T("plugin.yinliang.admin_permission"),
&y.AdminPermission,
@@ -174,6 +183,7 @@ func (y *Yinliang) CreatePanel() fyne.CanvasObject {
)
y.panel = container.NewVBox(
enabledCheck,
permCheck,
cmdConfig,
volumeControlConfig,