Add rating information to history screen
This commit is contained in:
parent
08fd3f1134
commit
b804759fec
6 changed files with 81 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
|||
1.2.6:
|
||||
- Add rating column to list of matches
|
||||
- Add rating information to history screen
|
||||
|
||||
1.2.5:
|
||||
- Add setting for auto-playing forced moves
|
||||
|
|
|
@ -15,6 +15,10 @@ import (
|
|||
"nhooyr.io/websocket"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Debug = 1
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
Address string
|
||||
Username string
|
||||
|
|
67
game/game.go
67
game/game.go
|
@ -1093,12 +1093,60 @@ func NewGame() *Game {
|
|||
headerGrid.AddChildAt(g.lobby.historyUsername, 3, 0, 1, 1)
|
||||
headerGrid.AddChildAt(searchButton, 4, 0, 1, 1)
|
||||
|
||||
newLabel := func(text string, horizontal messeji.Alignment) *etk.Text {
|
||||
t := etk.NewText(text)
|
||||
t.SetVertical(messeji.AlignCenter)
|
||||
t.SetHorizontal(horizontal)
|
||||
return t
|
||||
}
|
||||
|
||||
g.lobby.historyRatingCasualBackgammonSingle = newLabel("...", messeji.AlignStart)
|
||||
g.lobby.historyRatingCasualBackgammonMulti = newLabel("...", messeji.AlignStart)
|
||||
g.lobby.historyRatingCasualAceySingle = newLabel("...", messeji.AlignStart)
|
||||
g.lobby.historyRatingCasualAceyMulti = newLabel("...", messeji.AlignStart)
|
||||
g.lobby.historyRatingCasualTabulaSingle = newLabel("...", messeji.AlignStart)
|
||||
g.lobby.historyRatingCasualTabulaMulti = newLabel("...", messeji.AlignStart)
|
||||
|
||||
ratingGrid := func(singleLabel *etk.Text, multiLabel *etk.Text) *etk.Grid {
|
||||
dividerSize := 10
|
||||
if defaultFontSize == extraLargeFontSize {
|
||||
dividerSize = 20
|
||||
}
|
||||
g := etk.NewGrid()
|
||||
g.SetColumnSizes(-1, dividerSize, -1)
|
||||
g.AddChildAt(newLabel(gotext.Get("Single"), messeji.AlignEnd), 0, 0, 1, 1)
|
||||
g.AddChildAt(singleLabel, 2, 0, 1, 1)
|
||||
g.AddChildAt(newLabel(gotext.Get("Multi"), messeji.AlignEnd), 0, 1, 1, 1)
|
||||
g.AddChildAt(multiLabel, 2, 1, 1, 1)
|
||||
return g
|
||||
}
|
||||
|
||||
historyDividerLine := etk.NewBox()
|
||||
historyDividerLine.SetBackground(bufferTextColor)
|
||||
|
||||
headerLabel := func(text string) *etk.Text {
|
||||
t := newLabel(text, messeji.AlignCenter)
|
||||
t.SetFont(extraLargeFont, fontMutex)
|
||||
return t
|
||||
}
|
||||
|
||||
historyRatingGrid := etk.NewGrid()
|
||||
historyRatingGrid.SetRowSizes(2, -1, -1, -1)
|
||||
historyRatingGrid.AddChildAt(historyDividerLine, 0, 0, 3, 1)
|
||||
historyRatingGrid.AddChildAt(headerLabel(gotext.Get("Backgammon")), 0, 1, 1, 1)
|
||||
historyRatingGrid.AddChildAt(ratingGrid(g.lobby.historyRatingCasualBackgammonSingle, g.lobby.historyRatingCasualBackgammonMulti), 0, 2, 1, 2)
|
||||
historyRatingGrid.AddChildAt(headerLabel(gotext.Get("Acey-deucey")), 1, 1, 1, 1)
|
||||
historyRatingGrid.AddChildAt(ratingGrid(g.lobby.historyRatingCasualAceySingle, g.lobby.historyRatingCasualAceyMulti), 1, 2, 1, 2)
|
||||
historyRatingGrid.AddChildAt(headerLabel(gotext.Get("Tabula")), 2, 1, 1, 1)
|
||||
historyRatingGrid.AddChildAt(ratingGrid(g.lobby.historyRatingCasualTabulaSingle, g.lobby.historyRatingCasualTabulaMulti), 2, 2, 1, 2)
|
||||
|
||||
historyContainer = etk.NewGrid()
|
||||
historyContainer.AddChildAt(headerGrid, 0, 0, 1, 1)
|
||||
historyContainer.AddChildAt(dividerLine, 0, 1, 1, 1)
|
||||
historyContainer.AddChildAt(g.lobby.historyList, 0, 2, 1, 1)
|
||||
historyContainer.AddChildAt(statusBuffer, 0, 3, 1, 1)
|
||||
historyContainer.AddChildAt(g.lobby.buttonsGrid, 0, 4, 1, 1)
|
||||
historyContainer.AddChildAt(historyRatingGrid, 0, 3, 1, 1)
|
||||
historyContainer.AddChildAt(statusBuffer, 0, 4, 1, 1)
|
||||
historyContainer.AddChildAt(g.lobby.buttonsGrid, 0, 5, 1, 1)
|
||||
|
||||
historyFrame.SetPositionChildren(true)
|
||||
historyFrame.AddChild(historyContainer)
|
||||
|
@ -1139,7 +1187,7 @@ func NewGame() *Game {
|
|||
headerGrid.AddChildAt(ratingLabel, 1, 0, 1, 1)
|
||||
headerGrid.AddChildAt(pointsLabel, 2, 0, 1, 1)
|
||||
headerGrid.AddChildAt(nameLabel, 3, 0, 1, 1)
|
||||
headerGrid.AddChildAt(g.lobby.historyButton, 3, 0, 1, 1)
|
||||
headerGrid.AddChildAt(g.lobby.historyButton, 4, 0, 1, 1)
|
||||
|
||||
listGamesContainer = etk.NewGrid()
|
||||
listGamesContainer.AddChildAt(headerGrid, 0, 0, 1, 1)
|
||||
|
@ -1250,9 +1298,14 @@ func (g *Game) setRoot(w etk.Widget) {
|
|||
func (g *Game) setBufferRects() {
|
||||
statusBufferHeight := g.scale(75)
|
||||
|
||||
historyRatingHeight := 200
|
||||
if defaultFontSize == extraLargeFontSize {
|
||||
historyRatingHeight = 400
|
||||
}
|
||||
|
||||
createGameContainer.SetRowSizes(-1, statusBufferHeight, g.lobby.buttonBarHeight)
|
||||
joinGameContainer.SetRowSizes(-1, statusBufferHeight, g.lobby.buttonBarHeight)
|
||||
historyContainer.SetRowSizes(g.itemHeight(), 2, -1, statusBufferHeight, g.lobby.buttonBarHeight)
|
||||
historyContainer.SetRowSizes(g.itemHeight(), 2, -1, historyRatingHeight, statusBufferHeight, g.lobby.buttonBarHeight)
|
||||
listGamesContainer.SetRowSizes(g.itemHeight(), 2, -1, statusBufferHeight, g.lobby.buttonBarHeight)
|
||||
}
|
||||
|
||||
|
@ -1521,6 +1574,12 @@ func (g *Game) handleEvent(e interface{}) {
|
|||
go game.HandleReplay(ev.Content)
|
||||
case *bgammon.EventHistory:
|
||||
game.lobby.historyMatches = ev.Matches
|
||||
game.lobby.historyRatingCasualBackgammonSingle.SetText(fmt.Sprintf("%d", ev.CasualBackgammonSingle))
|
||||
game.lobby.historyRatingCasualBackgammonMulti.SetText(fmt.Sprintf("%d", ev.CasualBackgammonMulti))
|
||||
game.lobby.historyRatingCasualAceySingle.SetText(fmt.Sprintf("%d", ev.CasualAceyDeuceySingle))
|
||||
game.lobby.historyRatingCasualAceyMulti.SetText(fmt.Sprintf("%d", ev.CasualAceyDeuceyMulti))
|
||||
game.lobby.historyRatingCasualTabulaSingle.SetText(fmt.Sprintf("%d", ev.CasualTabulaSingle))
|
||||
game.lobby.historyRatingCasualTabulaMulti.SetText(fmt.Sprintf("%d", ev.CasualTabulaMulti))
|
||||
list := game.lobby.historyList
|
||||
list.Clear()
|
||||
if len(ev.Matches) == 0 {
|
||||
|
|
|
@ -78,6 +78,13 @@ type lobby struct {
|
|||
historyUsername *etk.Input
|
||||
historyList *etk.List
|
||||
|
||||
historyRatingCasualBackgammonSingle *etk.Text
|
||||
historyRatingCasualBackgammonMulti *etk.Text
|
||||
historyRatingCasualAceySingle *etk.Text
|
||||
historyRatingCasualAceyMulti *etk.Text
|
||||
historyRatingCasualTabulaSingle *etk.Text
|
||||
historyRatingCasualTabulaMulti *etk.Text
|
||||
|
||||
availableMatchesList *etk.List
|
||||
|
||||
historyButton *etk.Button
|
||||
|
|
4
go.mod
4
go.mod
|
@ -3,9 +3,9 @@ module code.rocket9labs.com/tslocum/boxcars
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240114000531-eb958e27e786
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240114011535-d3ac00eb34a8
|
||||
code.rocket9labs.com/tslocum/bgammon-tabula-bot v0.0.0-20240111193502-f01ac821f8ba
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240112010933-fb51eb32adda
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240114013211-e39a6384edbc
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20240108183445-695ea428ae21
|
||||
code.rocketnine.space/tslocum/kibodo v1.0.3-0.20240110043547-31f31eb07497
|
||||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20240109205105-4ffeffdd2441
|
||||
|
|
8
go.sum
8
go.sum
|
@ -1,11 +1,11 @@
|
|||
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b h1:Y0a14Kf/hSYepSmp4ZfDeE4CZZGBGBS97CNjCbKJm0c=
|
||||
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240114000531-eb958e27e786 h1:TeEoa8aH7zXQYoQNzGdWWGE4WhgEchr8fPiVOVBhoT0=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240114000531-eb958e27e786/go.mod h1:LAki3jpHOsr4fwaK0xC9tkg+wgu/9ZNEqqx1zE3/HP4=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240114011535-d3ac00eb34a8 h1:gL8AT49E3aYiS8ZklxKMxpqL2+af9Dcfh5PjE4hIA+k=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240114011535-d3ac00eb34a8/go.mod h1:LAki3jpHOsr4fwaK0xC9tkg+wgu/9ZNEqqx1zE3/HP4=
|
||||
code.rocket9labs.com/tslocum/bgammon-tabula-bot v0.0.0-20240111193502-f01ac821f8ba h1:9KpLZT8DAOV0Uk5rJZfNVdfn3MTGBM8gy3MEx3qM8aY=
|
||||
code.rocket9labs.com/tslocum/bgammon-tabula-bot v0.0.0-20240111193502-f01ac821f8ba/go.mod h1:ZzucsodM8kqL3y3GYzDYrEUNrDlLlzMux7WVmJ06ZBI=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240112010933-fb51eb32adda h1:Ho2Jb3mRmpz1zLVlqeo7tmTgZK0ruL/Sr8BEy4bMnEw=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240112010933-fb51eb32adda/go.mod h1:RrN0szXD27BMmCX63/t9SbD1CYDHXaf72y8IozXSzyg=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240114013211-e39a6384edbc h1:gjKuiM26PHw6FTkIJQaqBrY6bQHbcfC9DcD8TU84JEY=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240114013211-e39a6384edbc/go.mod h1:RrN0szXD27BMmCX63/t9SbD1CYDHXaf72y8IozXSzyg=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20240108183445-695ea428ae21 h1:1VG88tdhCSVv7wGoIKQe8A8KfBXJsdz5pDsyP4ymDwk=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20240108183445-695ea428ae21/go.mod h1:WEJXESKXqrMFLAArikQ79lpRibNeeE1C0VruxXYMF5M=
|
||||
code.rocketnine.space/tslocum/kibodo v1.0.3-0.20240110043547-31f31eb07497 h1:QpzLvcDV7DsaeFKrQZcHkDfq1PqsHcwUVnRXRKBAxe0=
|
||||
|
|
Loading…
Reference in a new issue