From: qydysky Date: Fri, 23 Oct 2020 12:36:02 +0000 (+0800) Subject: 特殊用户/事件弹幕停留 X-Git-Tag: v0.5.0^2~20 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=f0e3736de34fb4cfd147dab5a72d6e16ef6ed38d;p=bili_danmu%2F.git 特殊用户/事件弹幕停留 --- diff --git a/README.md b/README.md index c680a7b..148e536 100644 --- a/README.md +++ b/README.md @@ -86,12 +86,14 @@ var AllF = map[string]bool{ 弹幕重连 直播流开播自动下载 直播流下载重连 +gtk弹幕窗自定义人/事件消息停留 ... ``` ### demo - 已配置了[go环境](https://golang.google.cn/dl/) +- 配置了[gtk](https://www.gtk.org/) > 清晰度可取[数值](https://github.com/qydysky/bili_danmu/blob/028d6d8ed47df4631aca7df93871a4795bedda76/CV/Var.go#L19) ``` git clone https://github.com/qydysky/bili_danmu.git diff --git a/Reply/gtk.go b/Reply/gtk.go index a504a12..26d844d 100644 --- a/Reply/gtk.go +++ b/Reply/gtk.go @@ -22,6 +22,16 @@ type gtk_list struct { var gtkGetList = list.New() var imgbuf = make(map[string](*gdk.Pixbuf)) +var keep int +var keep_key = map[string]int{ + "face/0buyguide":8, + "face/0gift":8, + "face/0jiezou":8, + "face/0level1":8, + "face/0level2":8, + "face/0level3":8, + "face/0superchat":13, +} var ( Gtk_on bool Gtk_Tra bool @@ -124,7 +134,7 @@ func Gtk_danmu() { var ( pixbuf *gdk.Pixbuf e error - } + ) if v,ok := imgbuf[img_src];ok{ pixbuf,e = gdk.PixbufCopy(v) } else { @@ -135,12 +145,24 @@ func Gtk_danmu() { } { loc := int(grid0.Container.GetChildren().Length())/2; - grid0.InsertRow(loc); - grid0.Attach(tmp_list.img, 0, loc, 1, 1) - grid0.Attach(tmp_list.text, 1, loc, 1, 1) - for loc > max { + if sec,ok := keep_key[img_src];ok { + grid0.InsertRow(loc); + grid0.Attach(tmp_list.img, 0, loc, 1, 1) + grid0.Attach(tmp_list.text, 1, loc, 1, 1) + keep += 1 + glib.TimeoutAdd(uint(sec * 1000),func()(o bool){ + o = false + keep -= 1 + return + }) + }else{ + grid0.InsertRow(loc - keep); + grid0.Attach(tmp_list.img, 0, loc - keep, 1, 1) + grid0.Attach(tmp_list.text, 1, loc - keep, 1, 1) + } + for loc > max { if i,e := grid0.GetChildAt(0,0); e != nil{i.(*gtk.Widget).Destroy()} if i,e := grid0.GetChildAt(1,0); e != nil{i.(*gtk.Widget).Destroy()} grid0.RemoveRow(0)