]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
醒目排序方法更新
authorqydysky <qydysky@foxmail.com>
Sun, 25 Oct 2020 06:16:18 +0000 (14:16 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 25 Oct 2020 06:16:18 +0000 (14:16 +0800)
Reply/Msg.go
Reply/gtk.go
_msg_sample/SUPER_CHAT_MESSAGE_DELETE.json [new file with mode: 0644]
_msg_sample/SUPER_CHAT_MESSAGE_JPN.json [new file with mode: 0644]
_msg_sample/TRADING_SCORE.json [new file with mode: 0644]

index a8ff07e9b59e4702ec181d08fd2dfe5e1d16380e..0e92fafac44a876cc42bc642d1fc65e471afa51e 100644 (file)
@@ -12,6 +12,7 @@ var msglog = p.Logf().New().Base(-1, "Msg.go").Open("danmu.log").Level(1)
 
 //Msg类型数据处理方法map
 var Msg_map = map[string]func(replyF, string) {
+       "TRADING_SCORE":nil,//每日任务
        "MATCH_ROOM_CONF":nil,//赛事房间配置
        "HOT_ROOM_NOTIFY":nil,//热点房间
        "MATCH_TEAM_GIFT_RANK":nil,//赛事人气比拼
@@ -55,6 +56,7 @@ var Msg_map = map[string]func(replyF, string) {
        "PREPARING":replyF.preparing,//下播
        "LIVE":replyF.live,//开播
        "SUPER_CHAT_ENTRANCE":nil,//SC入口
+       "SUPER_CHAT_MESSAGE_DELETE":nil,//SC删除
        "SUPER_CHAT_MESSAGE":nil,//replyF.super_chat_message,//SC
        "SUPER_CHAT_MESSAGE_JPN":replyF.super_chat_message,//SC
        "PANEL":replyF.panel,//排行榜
index ffb165b10258b93fe2d4f1ed621633994ab241de..8a6e87756848869ed63270d3c6057b33559b6b34 100644 (file)
@@ -24,17 +24,17 @@ var pro_style *gtk.CssProvider
 var gtkGetList = list.New()
 
 var imgbuf = make(map[string](*gdk.Pixbuf))
-var keep int
-var keep_s int
+var keep_list = list.New()
+
 var keep_key = map[string]int{
        "face/0default":0,
        "face/0room":0,
-       "face/0buyguide":8,
+       "face/0buyguide":9,
        "face/0gift":8,
        "face/0jiezou":8,
        "face/0level1":5,
-       "face/0level2":5,
-       "face/0level3":5,
+       "face/0level2":3,
+       "face/0level3":2,
        "face/0superchat":13,
 }
 var (
@@ -159,30 +159,37 @@ func Gtk_danmu() {
                        }
                        {
                                loc := int(grid0.Container.GetChildren().Length())/2;
-
-                               if sec,ok := keep_key[img_src];ok && sec != 0 {
+                               sec := 0
+                               if tsec,ok := keep_key[img_src];ok && tsec != 0 {
+                                       sec = tsec
                                        if sty,e := tmp_list.text.GetStyleContext();e == nil{
                                                sty.AddClass("view")
                                                sty.AddProvider(pro_style,gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
                                        }else{{log.Println(e)}}
-                                       
-                                       grid0.InsertRow(loc);
-                                       grid0.Attach(tmp_list.img, 0, loc, 1, 1)
-                                       grid0.Attach(tmp_list.text, 1, loc, 1, 1)
-                                       keep += 1
-                                       keep_s += sec
-                                       if keep_s > 20 {keep_s = 20}
-                                       
-                                       glib.TimeoutAdd(uint(keep_s * 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)
+
+                               }
+                               /*
+                                       front
+                                       |
+                                       back index:0
+                               */
+                               var InsertIndex int = keep_list.Len()
+                               if sec != 0 {
+                                       var cu_To = time.Now().Add(time.Second * time.Duration(sec))
+                                       var hasInsert bool
+                                       for el := keep_list.Front(); el != nil; el = el.Next(){
+                                               if cu_To.After(el.Value.(time.Time)) {InsertIndex -= 1;continue}
+                                               keep_list.InsertBefore(cu_To,el)
+                                               hasInsert = true
+                                               break
+                                       }
+                                       if !hasInsert {
+                                               keep_list.PushBack(cu_To)
+                                       }
                                }
+                               grid0.InsertRow(loc - InsertIndex);
+                               grid0.Attach(tmp_list.img, 0, loc - InsertIndex, 1, 1)
+                               grid0.Attach(tmp_list.text, 1, loc - InsertIndex, 1, 1)
 
                                loc = int(grid0.Container.GetChildren().Length())/2;
                                for loc > max {
@@ -192,13 +199,6 @@ func Gtk_danmu() {
                                        loc -= 1
                                }
                        }
-                       
-                       go func(){
-                               for{
-                                       time.Sleep(time.Second)
-                                       if keep_s > 0 {keep_s -= 1}
-                               }
-                       }()
 
                        glib.TimeoutAdd(uint(3000), func()(o bool){
                                o = true
@@ -235,17 +235,20 @@ func Gtk_danmu() {
 
        application.Connect("activate", func() {
                log.Println("application activate")
-               glib.TimeoutAdd(uint(300),func()(o bool){
-                       o = true
-                       var tmax int = max
-                       for len(Gtk_danmuChan) != 0 {
-                               tmax -= 1
-                               if tmax <= 0 {return}
-                               y(<-Gtk_danmuChan,load_face(<-Gtk_danmuChan_uid))
+               go func(){
+                       for{
+                               time.Sleep(time.Second)
+                               for el := keep_list.Front(); el != nil && time.Now().After(el.Value.(time.Time));el = el.Next() {
+                                       keep_list.Remove(el)
+                               }
+                               if len(Gtk_danmuChan) == 0 {continue}
+                               glib.TimeoutAdd(uint(1000 / (len(Gtk_danmuChan) + 1)),func()(bool){
+                                       if len(Gtk_danmuChan) == 0 {return false}
+                                       y(<-Gtk_danmuChan,load_face(<-Gtk_danmuChan_uid))
+                                       return true
+                               })
                        }
-                       return
-               })
-
+               }()
        })
 
        application.Connect("shutdown", func() {
@@ -270,7 +273,7 @@ func onMainWindowDestroy() {
 func load_face(uid string) (loc string) {
        loc = Gtk_img_path + `/` + "0default"
        if uid == "" {return}
-       if _,ok := keep_key[uid];ok{
+       if _,ok := keep_key[Gtk_img_path + `/` + uid];ok{
                loc = Gtk_img_path + `/` + uid
                return
        }
diff --git a/_msg_sample/SUPER_CHAT_MESSAGE_DELETE.json b/_msg_sample/SUPER_CHAT_MESSAGE_DELETE.json
new file mode 100644 (file)
index 0000000..0827a86
--- /dev/null
@@ -0,0 +1,9 @@
+{
+    "cmd": "SUPER_CHAT_MESSAGE_DELETE",
+    "data": {
+        "ids": [
+            771517
+        ]
+    },
+    "roomid": 21448649
+}
\ No newline at end of file
diff --git a/_msg_sample/SUPER_CHAT_MESSAGE_JPN.json b/_msg_sample/SUPER_CHAT_MESSAGE_JPN.json
new file mode 100644 (file)
index 0000000..3da15a9
--- /dev/null
@@ -0,0 +1,51 @@
+{
+    "cmd": "SUPER_CHAT_MESSAGE_JPN",
+    "data": {
+        "id": "771519",
+        "uid": "17572451",
+        "price": 30,
+        "rate": 1000,
+        "message": "\u7406\u89e3\u7406\u89e3\uff0c\u5927\u5c0f\u59d0\u662f\u77e5\u9053\u6211\u559c\u6b22\u7684\u662f\u4eba\u59bb\u624d\u8fd9\u6837\u505a\u7684",
+        "message_jpn": "\u7406\u89e3\u3067\u304d\u307e\u3059\u3002\u304a\u5b22\u3055\u3093\u306f\u79c1\u304c\u597d\u304d\u306a\u306e\u306f\u4eba\u59bb\u3060\u3068\u77e5\u3063\u3066\u3044\u307e\u3059\u3002",
+        "is_ranked": 1,
+        "background_image": "https:\/\/i0.hdslb.com\/bfs\/live\/a712efa5c6ebc67bafbe8352d3e74b820a00c13e.png",
+        "background_color": "#EDF5FF",
+        "background_icon": "",
+        "background_price_color": "#7497CD",
+        "background_bottom_color": "#2A60B2",
+        "ts": 1603590464,
+        "token": "47BF2F57",
+        "medal_info": {
+            "icon_id": 0,
+            "target_id": 434662713,
+            "special": "",
+            "anchor_uname": "NoWorld_Official",
+            "anchor_roomid": 21448649,
+            "medal_level": 27,
+            "medal_name": "NO\u6c11",
+            "medal_color": "#6154c"
+        },
+        "user_info": {
+            "uname": "\u5c4a\u304b\u306a\u3044\u9ebb\u7f8e\u306e\u5f8c\u8f29",
+            "face": "http:\/\/i1.hdslb.com\/bfs\/face\/152b7547d6a00f4417d710bb0fbf8c86db51c321.jpg",
+            "face_frame": "http:\/\/i0.hdslb.com\/bfs\/live\/9b3cfee134611c61b71e38776c58ad67b253c40a.png",
+            "guard_level": 2,
+            "user_level": 21,
+            "level_color": "#5896de",
+            "is_vip": 0,
+            "is_svip": 0,
+            "is_main_vip": 1,
+            "title": "0",
+            "manager": 0
+        },
+        "time": 59,
+        "start_time": 1603590463,
+        "end_time": 1603590523,
+        "gift": {
+            "num": 1,
+            "gift_id": 12000,
+            "gift_name": "\u9192\u76ee\u7559\u8a00"
+        }
+    },
+    "roomid": "21448649"
+}
\ No newline at end of file
diff --git a/_msg_sample/TRADING_SCORE.json b/_msg_sample/TRADING_SCORE.json
new file mode 100644 (file)
index 0000000..4996f66
--- /dev/null
@@ -0,0 +1,11 @@
+{
+    "cmd": "TRADING_SCORE",
+    "data": {
+        "bubble_show_time": 3,
+        "num": 4,
+        "score_id": 3,
+        "uid": 623441612,
+        "update_time": 1603555393,
+        "update_type": 1
+    }
+}
\ No newline at end of file