From 831b1176e37de0339d7148f938c069b5652370b6 Mon Sep 17 00:00:00 2001 From: qydysky Date: Wed, 18 Nov 2020 08:39:00 +0800 Subject: [PATCH] =?utf8?q?gtk=E5=8F=AA=E8=BF=90=E8=A1=8C=E4=BA=8Elinux?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .github/workflows/go.yml | 16 ++-------------- .github/workflows/test.yml | 16 ++-------------- README.md | 5 +---- Reply/0Init.go | 14 ++++++++++++++ Reply/F.go | 18 +----------------- Reply/Reply.go | 20 ++++++++++++++------ Reply/gtk.go | 14 ++++++++++++++ bili_danmu.go | 3 +-- demo/go.mod | 2 +- demo/go.sum | 6 ++++++ 10 files changed, 56 insertions(+), 58 deletions(-) create mode 100644 Reply/0Init.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a8115c7..12aa399 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -51,7 +51,7 @@ jobs: run: | sudo apt-get install libgtk-3-dev libcairo2-dev libglib2.0-dev cd demo - go build -v -buildmode=exe -tags gtk_3_24 -o demo.run -i main.go + go build -v -buildmode=exe -tags 'gtk gtk_3_24' -o demo.run -i main.go - name: zip run: zip -q -r ubuntu_go${{ matrix.go }}.zip * @@ -91,25 +91,13 @@ jobs: with: go-version: ${{ matrix.go }} - - name: Set up Gtk - uses: msys2/setup-msys2@v2 - with: - msystem: MINGW64 - path-type: inherit - update: true - install: 'mingw-w64-x86_64-gtk2 mingw-w64-x86_64-gtk3 mingw-w64-x86_64-pkg-config base-devel' - - name: Check out code uses: actions/checkout@v2 - name: Build - shell: msys2 {0} run: | - export CGO_LDFLAGS_ALLOW="-Wl.*" - export CGO_CFLAGS_ALLOW="-Wl.*" - export CGO_CXXFLAGS_ALLOW="-Wl.*" cd demo - go build -v -buildmode=exe -tags gtk_3_24 -o demo.exe -i main.go + go build -v -buildmode=exe -o demo.exe -i main.go - name: zip run: .\7za.exe a -r .\windows_go${{ matrix.go }}.zip ./ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 23d5d9a..f6e9b30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: run: | sudo apt-get install libgtk-3-dev libcairo2-dev libglib2.0-dev cd demo - go build -v -buildmode=exe -tags gtk_3_24 -o demo.run -i main.go + go build -v -buildmode=exe -tags 'gtk gtk_3_24' -o demo.run -i main.go - name: zip run: zip -q -r ubuntu_go${{ matrix.go }}.zip * @@ -48,25 +48,13 @@ jobs: with: go-version: ${{ matrix.go }} - - name: Set up Gtk - uses: msys2/setup-msys2@v2 - with: - msystem: MINGW64 - path-type: inherit - update: true - install: 'mingw-w64-x86_64-gtk2 mingw-w64-x86_64-gtk3 mingw-w64-x86_64-pkg-config base-devel' - - name: Check out code uses: actions/checkout@v2 - name: Build - shell: msys2 {0} run: | - export CGO_LDFLAGS_ALLOW="-Wl.*" - export CGO_CFLAGS_ALLOW="-Wl.*" - export CGO_CXXFLAGS_ALLOW="-Wl.*" cd demo - go build -v -buildmode=exe -tags gtk_3_24 -o demo.exe -i *.go + go build -v -buildmode=exe -o demo.exe -i main.go - name: zip run: .\7za.exe a -r .\windows_go${{ matrix.go }}.zip ./ diff --git a/README.md b/README.md index e1c62d1..aad2367 100644 --- a/README.md +++ b/README.md @@ -162,14 +162,11 @@ ctrl+c退出,会同时追加记录到文件danmu.log中(文件记录完整 ![](_Screenshot/Screenshot_20200926_173834.png) [截图地址](//zdir.ntsdtt.bid/ALL/Admin/Remote/%E5%9B%BE%E7%89%87/Screenshot_20200926_173834.png) -Gtk弹幕窗 +Gtk弹幕窗(Linux Only) ![](_Screenshot/Screenshot_20201023_232029.png) [截图地址](//zdir.ntsdtt.bid/ALL/Admin/Remote/%E5%9B%BE%E7%89%87/Screenshot_20201023_232029.png) -Qt弹幕窗 -![](_Screenshot/Screenshot_20201002_045627.png) -[截图地址](//zdir.ntsdtt.bid/ALL/Admin/Remote/%E5%9B%BE%E7%89%87/Screenshot_20201002_045627.png) 更多内容详见注释,如有疑问请发issues,欢迎pr diff --git a/Reply/0Init.go b/Reply/0Init.go new file mode 100644 index 0000000..972f53a --- /dev/null +++ b/Reply/0Init.go @@ -0,0 +1,14 @@ +package reply + +import ( + s "github.com/qydysky/part/buf" +) + +//从config.json初始化 +func init(){ + buf := s.New() + buf.Load("config_F.json") + for k,v := range buf.B { + AllF[k] = v.(bool) + } +} diff --git a/Reply/F.go b/Reply/F.go index 1ef436d..29fc58b 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -14,7 +14,6 @@ import ( F "github.com/qydysky/bili_danmu/F" "github.com/christopher-dG/go-obs-websocket" p "github.com/qydysky/part" - s "github.com/qydysky/part/buf" ) /* @@ -24,7 +23,7 @@ import ( //功能开关 var AllF = map[string]bool{ `ShowRev`:true,//显示本次营收 - "Gtk":false,//Gtk弹幕窗口 + "Gtk":false,//Gtk弹幕窗口(使用go build -tags 'gtk gtk_3_24'编译,linux only) "Saveflv":true,//保存直播流(默认高清,有cookie默认蓝光) "Ass":true,//Ass弹幕生成,由于时间对应关系,仅开启流保存时生效 "Obs":false,//obs组件(仅录播) @@ -43,15 +42,6 @@ var AllF = map[string]bool{ "Shortdanmu":true,//上下文相同文字缩减 } -//从config.json初始化 -func init(){ - buf := s.New() - buf.Load("config_F.json") - for k,v := range buf.B { - AllF[k] = v.(bool) - } -} - //功能开关选取函数 func IsOn(s string) bool { if v, ok := AllF[s]; ok && v { @@ -136,12 +126,6 @@ func ShowRevf(){ } } -//Gtk 弹幕Gtk窗口 -func Gtkf(){ - if!IsOn("Gtk") {return} - Gtk_danmu() -} - //Ass 弹幕转字幕 type Ass struct { diff --git a/Reply/Reply.go b/Reply/Reply.go index 5b31fbd..1dacbf4 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -8,6 +8,7 @@ import ( "compress/zlib" p "github.com/qydysky/part" + mq "github.com/qydysky/part/msgq" F "github.com/qydysky/bili_danmu/F" S "github.com/qydysky/bili_danmu/Send" c "github.com/qydysky/bili_danmu/CV" @@ -572,14 +573,21 @@ func Msg_showdanmu(auth interface{}, m ...string) { if auth != nil {msglog.I(auth, ":", msg)} } +type Danmu_mq_t struct { + uid string + msg string +} +var Danmu_mq = mq.New() + func Gui_show(m ...string){ //m[0]:msg m[1]:uid - if Gtk_on { - if len(m) > 1 { - Gtk_danmuChan_uid <- m[1] - } else {Gtk_danmuChan_uid <- ""} - Gtk_danmuChan <- m[0] - } + uid := "" + if len(m) > 1 {uid = m[1]} + + Danmu_mq.Push(Danmu_mq_t{ + uid:uid, + msg:m[0], + }) } func Itos(i []interface{}) string { diff --git a/Reply/gtk.go b/Reply/gtk.go index 0552d16..dca144c 100644 --- a/Reply/gtk.go +++ b/Reply/gtk.go @@ -1,3 +1,5 @@ +//+build gtk + package reply import ( @@ -52,6 +54,18 @@ var ( Gtk_danmuChan_uid chan string = make(chan string, 1000) ) +func init(){ + if!IsOn("Gtk") {return} + go func(){ + go Gtk_danmu() + for { + o := Danmu_mq.Pull().(Danmu_mq_t) + Gtk_danmuChan_uid <- o.uid + Gtk_danmuChan <- o.msg + } + }() +} + func Gtk_danmu() { if Gtk_on {return} gtk.Init(nil) diff --git a/bili_danmu.go b/bili_danmu.go index d1ab449..8810836 100644 --- a/bili_danmu.go +++ b/bili_danmu.go @@ -93,9 +93,8 @@ func Demo(roomid ...int) { if p.Checkfile().IsExist("cookie.txt") {//附加功能 弹幕机 reply.Danmuji_auto(1) } - {//附加功能 直播流保存 Gtk窗口 营收 + {//附加功能 直播流保存 营收 go reply.Saveflvf() - go reply.Gtkf() go reply.ShowRevf() } }() diff --git a/demo/go.mod b/demo/go.mod index 3f38863..4ba5de0 100644 --- a/demo/go.mod +++ b/demo/go.mod @@ -8,7 +8,7 @@ require ( github.com/miekg/dns v1.1.35 // indirect github.com/mitchellh/mapstructure v1.3.3 // indirect github.com/qydysky/bili_danmu v0.4.0 - github.com/qydysky/part v0.2.1 // indirect + github.com/qydysky/part v0.2.2-0.20201117225521-b27dd91d56af // indirect github.com/shirou/gopsutil v3.20.10+incompatible // indirect golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect diff --git a/demo/go.sum b/demo/go.sum index 0e14ac2..1b6c67d 100644 --- a/demo/go.sum +++ b/demo/go.sum @@ -40,6 +40,12 @@ github.com/qydysky/part v0.0.6 h1:DEIziO8d9PT+E1OIij3Ua0H8vO9Z5yqCJGb3m8BOGL0= github.com/qydysky/part v0.0.6/go.mod h1:+8N3UgJBVyJj8ar31eZtucwrKpLpay854Y5qq0xk3x0= github.com/qydysky/part v0.2.1 h1:D/ZZzKPYA9yFbudzu0HtR7RffEzdacvGr/D4hGNggRI= github.com/qydysky/part v0.2.1/go.mod h1:93s9ohLtzULet5ZPEUUWrT9BELC30oDZgRpgGSiDye4= +github.com/qydysky/part v0.2.2-0.20201117213340-ef56d5480392 h1:8QRCTgpR+g0R6PY97eTYRcHqgnnT4q8KZdLrertM4so= +github.com/qydysky/part v0.2.2-0.20201117213340-ef56d5480392/go.mod h1:93s9ohLtzULet5ZPEUUWrT9BELC30oDZgRpgGSiDye4= +github.com/qydysky/part v0.2.2-0.20201117223624-77dfebe855ee h1:esBBaTeqkbxMKv4ixjVEUeResctj+/nbh7y/UytpIbw= +github.com/qydysky/part v0.2.2-0.20201117223624-77dfebe855ee/go.mod h1:93s9ohLtzULet5ZPEUUWrT9BELC30oDZgRpgGSiDye4= +github.com/qydysky/part v0.2.2-0.20201117225521-b27dd91d56af h1:wzpjAMxFBduOz9TWZreDYElmREXq7o752X1s4pc2NiE= +github.com/qydysky/part v0.2.2-0.20201117225521-b27dd91d56af/go.mod h1:93s9ohLtzULet5ZPEUUWrT9BELC30oDZgRpgGSiDye4= github.com/shirou/gopsutil v2.20.7+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.20.8+incompatible h1:8c7Atn0FAUZJo+f4wYbN0iVpdWniCQk7IYwGtgdh1mY= github.com/shirou/gopsutil v2.20.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -- 2.39.2