Skip to content

Commit

Permalink
v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pidgy committed Sep 15, 2023
1 parent 13ce071 commit cc9c9b1
Show file tree
Hide file tree
Showing 21 changed files with 1,937 additions and 1,759 deletions.
2 changes: 1 addition & 1 deletion desktop/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Factory struct {
}

func Notification(format string, args ...interface{}) *Factory {
a := toast.IM
a := toast.Mail
if config.Current.Advanced.Notifications.Muted {
a = toast.Silent
}
Expand Down
106 changes: 61 additions & 45 deletions discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,42 @@ var (
var Activity = status()

func Connect() {
for ; reconnect(rpc.error()); time.Sleep(time.Second * 15) {
if config.Current.Advanced.Discord.Disabled {
for ; ; time.Sleep(time.Second * 15) {
if !reconnect() {
continue
}

Activity = status()

notify.Debug("Discord: %s: \"%s\"", Activity.Details, Activity.State)

rpc.send(frame{
Cmd: commandSetActivity,
Args: args{
Pid: os.Getpid(),
Activity: Activity,
Activity: status(),
},
Nonce: uuid.New().String(),
})
}
}

func reconnect(err error) bool {
func reconnect() bool {
if config.Current.Advanced.Discord.Disabled {
return true
}

err := rpc.error()
if err != nil {
notify.Feed(nrgba.Discord, "Discord disconnected (%v)", err)
notify.Feed(nrgba.Discord, "Reconnecting to Discord (%v)", err)
}

for ; !rpc.connected; time.Sleep(time.Second * 10) {
for ; !rpc.connected; time.Sleep(time.Second * 15) {
if config.Current.Advanced.Discord.Disabled {
continue
}

notify.Feed(nrgba.Discord, "Discord connecting...")
notify.Feed(nrgba.Discord, "Connecting to Discord")

rpc, err = connect()
if err != nil {
Expand All @@ -77,7 +84,7 @@ func reconnect(err error) bool {
continue
}

notify.Feed(nrgba.Discord, "Discord connected")
notify.Feed(nrgba.Discord, "Connected to Discord")
}

return rpc.connected
Expand Down Expand Up @@ -121,46 +128,55 @@ func status() activity {
if !server.Started() {
a.State = "Ready to capture scores"
}
if server.Match() {
last.score.orange, last.score.purple, last.score.self = server.Scores()
a.Details = "UniteHUD - In a Match"
a.State = fmt.Sprintf("[%s] %d - %d", server.Clock(), last.score.purple, last.score.orange)

ten := int64((time.Minute * 10).Milliseconds())
ms := int64(server.Seconds() * 1000)

started := ten - ms
ends := ten - started
if ms > 0 {
a.Timestamps.Start = time.Now().UnixMilli() - started
a.Timestamps.End = time.Now().UnixMilli() + ends
}

event := state.Last()
switch event.EventType {
case state.Nothing:
case state.MatchStarting:
a.Timestamps = timestamps{}
case state.Killed, state.KilledWithPoints, state.KilledWithoutPoints:
a.State = fmt.Sprintf("Died %s ago", time.Since(event.Time))
case state.MatchEnding:
a.Details = "UniteHUD - Match Ended"

won := "Purple"
if last.score.orange > last.score.purple {
won = "Orange"
}
a.State = fmt.Sprintf("%s team won %d - %d", won, last.score.purple, last.score.orange)
default:
if time.Since(event.Time) > time.Second*30 {
break
}
a.Details = fmt.Sprintf("UniteHUD - %s", event.EventType.String())
}
if !server.Match() {
return a
}

last.event.EventType = event.EventType
last.event.count++
last.score.orange, last.score.purple, last.score.self = server.Scores()
a.Details = "UniteHUD - In a Match"
a.State = fmt.Sprintf("[%s] %d - %d", server.Clock(), last.score.purple, last.score.orange)

ten := int64((time.Minute * 10).Milliseconds())
ms := int64(server.Seconds() * 1000)

started := ten - ms
ends := ten - started
if ms > 0 {
a.Timestamps.Start = time.Now().UnixMilli() - started
a.Timestamps.End = time.Now().UnixMilli() + ends
}

event := state.Last()
switch event.EventType {
case state.HoldingEnergy,
state.OrangeScoreMissed, state.PurpleScoreMissed,
state.PressButtonToScore, state.PreScore, state.PostScore,
state.Nothing:

case state.MatchStarting:
a.Timestamps = timestamps{}
case state.Killed, state.KilledWithPoints, state.KilledWithoutPoints:
a.State = fmt.Sprintf("Died %ds ago", int(time.Since(event.Time).Seconds()))
case state.MatchEnding:
a.Details = "UniteHUD - Match Ended"

won := "Purple"
if last.score.orange > last.score.purple {
won = "Orange"
}
a.State = fmt.Sprintf("%s team won %d - %d", won, last.score.purple, last.score.orange)
case state.PurpleScore, state.OrangeScore, state.FirstScored:
fallthrough
default:
if time.Since(event.Time) > time.Second*30 {
break
}
a.State = fmt.Sprintf("%s %s", event.EventType, a.State)
}

last.event.EventType = event.EventType
last.event.count++
}

return a
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ require (
gioui.org v0.3.0
gioui.org/x v0.3.0
git.sr.ht/~jackmordaunt/go-toast v1.0.0
github.com/Microsoft/go-winio v0.6.1
github.com/asticode/go-astikit v0.38.0
github.com/asticode/go-astilectron v0.29.0
github.com/gen2brain/malgo v0.11.10
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.1
github.com/guptarohit/asciigraph v0.5.5
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
Expand All @@ -21,18 +23,17 @@ require (
gocv.io/x/gocv v0.28.0
golang.org/x/sys v0.12.0
nhooyr.io/websocket v1.8.7
github.com/golang/protobuf v1.5.2
)

require (
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 // indirect
gioui.org/shader v1.0.6 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/gen2brain/shm v0.0.0-20221026125803-c33c9e32b1c8 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372 // indirect
github.com/gobwas/ws v1.1.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/jezek/xgb v1.1.0 // indirect
github.com/klauspost/compress v1.15.6 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
2 changes: 1 addition & 1 deletion gui/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func (g *GUI) videos(text float32) *videos {
go func() {
err := video.Open()
if err != nil {
g.ToastErrorForce(err)
g.ToastError(err)

config.Current.Window = config.MainDisplay
config.Current.VideoCaptureDevice = config.NoVideoCaptureDevice
Expand Down
6 changes: 3 additions & 3 deletions gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ type GUI struct {
}
}

resizeToMax bool
firstOpen bool
resizeToMax,
firstOpen bool

fps *fps.FPS
}
Expand Down Expand Up @@ -280,7 +280,7 @@ func (g *GUI) maximize() {
g.previous.size = g.dimensions.size

left := image.Pt(0, 0).Add(image.Pt(g.inset.left, 0))
right := g.dimensions.max.Sub(image.Pt(g.inset.right+1, 0))
right := g.dimensions.max.Sub(image.Pt(g.inset.left+g.inset.right+1, 0))
wapi.SetWindowPosShow(g.HWND, left, right)

//g.window.Perform(system.ActionCenter)
Expand Down
Loading

0 comments on commit cc9c9b1

Please sign in to comment.