]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
突出显示
authorqydysky <qydysky@foxmail.com>
Fri, 23 Oct 2020 15:22:48 +0000 (23:22 +0800)
committerqydysky <qydysky@foxmail.com>
Fri, 23 Oct 2020 15:22:48 +0000 (23:22 +0800)
README.md
Reply/Reply.go
Reply/gtk.go
_Screenshot/Screenshot_20201021_082757.png [deleted file]
_Screenshot/Screenshot_20201023_232029.png [new file with mode: 0644]
demo/config_F.json
demo/ui/1.css [new file with mode: 0644]

index 148e536560ab47960d6b6efd4fb2e9ad493fb43a..eeaf38144943955dd110eed08c9f05c1322956c7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -166,9 +166,9 @@ ctrl+c退出,会同时追加记录到文件danmu.log中(文件记录完整
 
 Gtk弹幕窗
 
-![](_Screenshot/Screenshot_20201021_082757.png)
+![](_Screenshot/Screenshot_20201023_232029.png)
 
-[截图地址](//zdir.ntsdtt.bid/ALL/Admin/Remote/%E5%9B%BE%E7%89%87/Screenshot_20201021_082757.png)
+[截图地址](//zdir.ntsdtt.bid/ALL/Admin/Remote/%E5%9B%BE%E7%89%87/Screenshot_20201023_232029.png)
 
 Qt弹幕窗
 ![](_Screenshot/Screenshot_20201002_045627.png)
index 56ba77240c2ac7111c81a7ccdcdf934b9a41475e..00f8b7f6c07ef0b1dd833bc58c0b7f3b32e1dfe1 100644 (file)
@@ -403,9 +403,9 @@ func (replyF) super_chat_message(s string){
                sh = append(sh, uname)
        }
        if price != nil {
-               sh = append(sh, "¥", price)
+               sh = append(sh, "¥", price, "\n")
        }
-       fmt.Println("\n====")
+       fmt.Println("====")
        fmt.Println(sh...)
        // Gui_show("\n====")
        if message != nil && message.(string) != ""{
index 26d844d13193afaccf2f0205c1046e5b1d375894..66cd335f9624f6fe5f1e897701df5481d71ee1d6 100644 (file)
@@ -3,6 +3,7 @@ package reply
 import (
        "container/list"
        "errors"
+       "time"
        "log"
 
        "github.com/gotk3/gotk3/glib"
@@ -11,25 +12,27 @@ import (
        p "github.com/qydysky/part"
        F "github.com/qydysky/bili_danmu/F"
 )
-const max = 100
+const max = 50
 const appId = "com.github.qydysky.bili_danmu.reply"
+
 type gtk_list struct {
        text *gtk.TextView
        img *gtk.Image
        handle glib.SignalHandle
 }
-
+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_key = map[string]int{
        "face/0buyguide":8,
        "face/0gift":8,
        "face/0jiezou":8,
-       "face/0level1":8,
-       "face/0level2":8,
-       "face/0level3":8,
+       "face/0level1":5,
+       "face/0level2":5,
+       "face/0level3":5,
        "face/0superchat":13,
 }
 var (
@@ -98,6 +101,15 @@ func Gtk_danmu() {
 
                imgbuf["face/0default"],_ = gdk.PixbufNewFromFileAtSize("face/0default", 40, 40);
 
+               {
+                       var e error
+                       if pro_style,e = gtk.CssProviderNew();e == nil{
+                               if e = pro_style.LoadFromPath(`ui/1.css`);e != nil{
+                                       log.Println(e)
+                               }
+                       }else{log.Println(e)}
+               }
+
                y = func(s,img_src string){
                        var tmp_list gtk_list
 
@@ -118,11 +130,11 @@ func Gtk_danmu() {
 
                                        {
                                                var e error
-                                                       tmp := scrolledwindow0.GetVAdjustment()
-                                                       h := viewport0.GetViewWindow().WindowGetHeight()
-                                                       if tmp.GetUpper() - tmp.GetValue() < float64(h) * 1.5 {
-                                                               tmp.SetValue(tmp.GetUpper() - float64(h))
-                                                       }
+                                               tmp := scrolledwindow0.GetVAdjustment()
+                                               h := viewport0.GetViewWindow().WindowGetHeight()
+                                               if tmp.GetUpper() - tmp.GetValue() < float64(h) * 1.7 {
+                                                       tmp.SetValue(tmp.GetUpper() - float64(h))
+                                               }
                                                if e != nil {log.Println(e)}
                                        }
                                })
@@ -147,11 +159,19 @@ func Gtk_danmu() {
                                loc := int(grid0.Container.GetChildren().Length())/2;
 
                                if sec,ok := keep_key[img_src];ok {
+                                       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
-                                       glib.TimeoutAdd(uint(sec * 1000),func()(o bool){
+                                       keep_s += sec
+                                       if keep_s > 20 {keep_s = 20}
+                                       
+                                       glib.TimeoutAdd(uint(keep_s * 1000),func()(o bool){
                                                o = false
                                                keep -= 1
                                                return
@@ -162,14 +182,22 @@ func Gtk_danmu() {
                                        grid0.Attach(tmp_list.text, 1, loc - keep, 1, 1)
                                }
 
+                               loc = int(grid0.Container.GetChildren().Length())/2;
                                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)
-                                       loc = int(grid0.Container.GetChildren().Length())/2;
+                                       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
 
@@ -239,7 +267,8 @@ func onMainWindowDestroy() {
 
 func load_face(uid string) (loc string) {
        loc = Gtk_img_path + `/` + "0default"
-       if uid != "" && p.Checkfile().IsExist(Gtk_img_path + `/` + uid) && p.Rand().MixRandom(1,100) > 1 {
+       if uid == "" {return}
+       if p.Checkfile().IsExist(Gtk_img_path + `/` + uid) && p.Rand().MixRandom(1,100) > 1 {
                loc = Gtk_img_path + `/` + uid
                return
        }
diff --git a/_Screenshot/Screenshot_20201021_082757.png b/_Screenshot/Screenshot_20201021_082757.png
deleted file mode 100644 (file)
index 4fffb8d..0000000
Binary files a/_Screenshot/Screenshot_20201021_082757.png and /dev/null differ
diff --git a/_Screenshot/Screenshot_20201023_232029.png b/_Screenshot/Screenshot_20201023_232029.png
new file mode 100644 (file)
index 0000000..703e63c
Binary files /dev/null and b/_Screenshot/Screenshot_20201023_232029.png differ
index 43956903696f13b6f50ac96d981366318d30db4b..944a7bceed1de00f90942d69c277f9d617991021 100644 (file)
@@ -1,7 +1,7 @@
 {
     "Gtk": true,
     "Qtd": false,
-    "Saveflv": true,
+    "Saveflv": false,
     "Ass": true,
     "Obs": false,
     "Autoban": false,
diff --git a/demo/ui/1.css b/demo/ui/1.css
new file mode 100644 (file)
index 0000000..1239647
--- /dev/null
@@ -0,0 +1,4 @@
+text {
+    background-color: rgba(255, 255, 255, 0.2);
+    color: rgb(255, 255, 255);
+}
\ No newline at end of file