From: qydysky Date: Fri, 23 Oct 2020 15:22:48 +0000 (+0800) Subject: 突出显示 X-Git-Tag: v0.5.0^2~19 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=1520e48804744caa09d73e7cf60a212b3a90f6b6;p=bili_danmu%2F.git 突出显示 --- diff --git a/README.md b/README.md index 148e536..eeaf381 100644 --- 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) diff --git a/Reply/Reply.go b/Reply/Reply.go index 56ba772..00f8b7f 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -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) != ""{ diff --git a/Reply/gtk.go b/Reply/gtk.go index 26d844d..66cd335 100644 --- a/Reply/gtk.go +++ b/Reply/gtk.go @@ -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 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 index 0000000..703e63c Binary files /dev/null and b/_Screenshot/Screenshot_20201023_232029.png differ diff --git a/demo/config_F.json b/demo/config_F.json index 4395690..944a7bc 100644 --- a/demo/config_F.json +++ b/demo/config_F.json @@ -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 index 0000000..1239647 --- /dev/null +++ b/demo/ui/1.css @@ -0,0 +1,4 @@ +text { + background-color: rgba(255, 255, 255, 0.2); + color: rgb(255, 255, 255); +} \ No newline at end of file