]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
特殊用户/事件弹幕停留
authorqydysky <qydysky@foxmail.com>
Fri, 23 Oct 2020 12:36:02 +0000 (20:36 +0800)
committerqydysky <qydysky@foxmail.com>
Fri, 23 Oct 2020 12:43:20 +0000 (20:43 +0800)
README.md
Reply/gtk.go

index c680a7b1f2cf9f2781214c9ca65401ea3da3f0d8..148e536560ab47960d6b6efd4fb2e9ad493fb43a 100644 (file)
--- 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
index a504a12774a3bb0a422821b89fe86aa33716988f..26d844d13193afaccf2f0205c1046e5b1d375894 100644 (file)
@@ -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)