From 42c80f3ea8b624ff84c6bf9b382f9dcdf375d82f Mon Sep 17 00:00:00 2001 From: aynakeya Date: Wed, 5 Mar 2025 20:07:17 +0800 Subject: [PATCH] add enabled button --- assets/translation.json | 4 ++++ plugin/yinliang/yinliang.go | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/assets/translation.json b/assets/translation.json index 8593ff5..4dc12b5 100644 --- a/assets/translation.json +++ b/assets/translation.json @@ -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": "音量增加命令" diff --git a/plugin/yinliang/yinliang.go b/plugin/yinliang/yinliang.go index 2a05f1e..3b71dcc 100644 --- a/plugin/yinliang/yinliang.go +++ b/plugin/yinliang/yinliang.go @@ -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,