parent
6f2af709e7
commit
799e360a2d
6 changed files with 49 additions and 52 deletions
|
@ -1,6 +1,7 @@
|
|||
1.4.0:
|
||||
- Auto-scale font size to fit text
|
||||
- Support returning to the main menu
|
||||
- Support navigating replay via clickable moves list
|
||||
|
||||
1.3.9:
|
||||
- Add shadow behind player rating labels
|
||||
|
|
|
@ -146,6 +146,7 @@ type board struct {
|
|||
|
||||
replayAuto time.Time
|
||||
replayPauseButton *etk.Button
|
||||
replayList *etk.List
|
||||
replayGrid *etk.Grid
|
||||
|
||||
inputGrid *etk.Grid
|
||||
|
@ -309,6 +310,7 @@ func NewBoard() *board {
|
|||
b.inputGrid.AddChildAt(inputBuffer, 0, 0, 1, 1)
|
||||
|
||||
b.createReplayControls()
|
||||
b.createReplayList()
|
||||
|
||||
b.uiGrid.SetBackground(frameColor)
|
||||
b.recreateUIGrid()
|
||||
|
|
|
@ -462,45 +462,41 @@ func (b *board) createReplayControls() {
|
|||
b.replayGrid.AddChildAt(etk.NewButton(">>|", b.selectReplayEnd), 6, 0, 1, 1)
|
||||
}
|
||||
|
||||
func (b *board) createReplayList() {
|
||||
scrollBarWidth := etk.Scale(32)
|
||||
b.replayList = etk.NewList(etk.Scale(baseButtonHeight), nil)
|
||||
b.replayList.SetScrollBarColors(etk.Style.ScrollAreaColor, etk.Style.ScrollHandleColor)
|
||||
b.replayList.SetScrollBarWidth(scrollBarWidth)
|
||||
}
|
||||
|
||||
func (b *board) recreateUIGrid() {
|
||||
b.uiGrid.Clear()
|
||||
b.uiGrid.AddChildAt(etk.NewBox(), 0, 0, 1, 1)
|
||||
b.uiGrid.AddChildAt(b.matchStatusGrid, 0, 1, 1, 1)
|
||||
b.uiGrid.AddChildAt(etk.NewBox(), 0, 2, 1, 1)
|
||||
gridY := 3
|
||||
if AutoEnableTouchInput {
|
||||
b.uiGrid.AddChildAt(b.inputGrid, 0, gridY, 1, 1)
|
||||
b.uiGrid.AddChildAt(etk.NewBox(), 0, gridY+1, 1, 1)
|
||||
gridY += 2
|
||||
}
|
||||
if game.replay {
|
||||
summary1 := etk.NewText("")
|
||||
summary1.SetFont(etk.Style.TextFont, etk.Scale(smallFontSize))
|
||||
summary1.Write(game.replaySummary1)
|
||||
summary2 := etk.NewText("")
|
||||
summary2.SetFont(etk.Style.TextFont, etk.Scale(smallFontSize))
|
||||
summary2.Write(game.replaySummary2)
|
||||
subGrid := etk.NewGrid()
|
||||
subGrid.SetBackground(bufferBackgroundColor)
|
||||
subGrid.AddChildAt(summary2, 0, 0, 1, 1)
|
||||
subGrid.AddChildAt(summary1, 1, 0, 1, 1)
|
||||
|
||||
g := etk.NewGrid()
|
||||
g.SetRowSizes(etk.Scale(baseButtonHeight), int(b.verticalBorderSize/2), -1, int(b.verticalBorderSize/2), lobbyStatusBufferHeight*2)
|
||||
g.SetRowSizes(etk.Scale(baseButtonHeight), int(b.verticalBorderSize/2), -1, int(b.verticalBorderSize/2), etk.Scale(baseButtonHeight*2))
|
||||
g.AddChildAt(b.replayGrid, 0, 0, 1, 1)
|
||||
g.AddChildAt(subGrid, 0, 2, 1, 1)
|
||||
g.AddChildAt(b.replayList, 0, 2, 1, 1)
|
||||
g.AddChildAt(statusBuffer, 0, 4, 1, 1)
|
||||
b.uiGrid.AddChildAt(g, 0, gridY, 1, 3)
|
||||
gridY++
|
||||
} else {
|
||||
if AutoEnableTouchInput {
|
||||
b.uiGrid.AddChildAt(b.inputGrid, 0, gridY, 1, 1)
|
||||
b.uiGrid.AddChildAt(etk.NewBox(), 0, gridY+1, 1, 1)
|
||||
gridY += 2
|
||||
}
|
||||
b.uiGrid.AddChildAt(statusBuffer, 0, gridY, 1, 1)
|
||||
b.uiGrid.AddChildAt(etk.NewBox(), 0, gridY+1, 1, 1)
|
||||
b.uiGrid.AddChildAt(gameBuffer, 0, gridY+2, 1, 1)
|
||||
gridY += 3
|
||||
}
|
||||
if !AutoEnableTouchInput {
|
||||
b.uiGrid.AddChildAt(etk.NewBox(), 0, gridY, 1, 1)
|
||||
b.uiGrid.AddChildAt(b.inputGrid, 0, gridY+1, 1, 1)
|
||||
if !AutoEnableTouchInput {
|
||||
b.uiGrid.AddChildAt(etk.NewBox(), 0, gridY, 1, 1)
|
||||
b.uiGrid.AddChildAt(b.inputGrid, 0, gridY+1, 1, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
52
game/game.go
52
game/game.go
|
@ -621,12 +621,10 @@ type Game struct {
|
|||
|
||||
downloadReplay int
|
||||
|
||||
replay bool
|
||||
replayData []byte
|
||||
replayFrame int
|
||||
replayFrames []*replayFrame
|
||||
replaySummary1 []byte
|
||||
replaySummary2 []byte
|
||||
replay bool
|
||||
replayData []byte
|
||||
replayFrame int
|
||||
replayFrames []*replayFrame
|
||||
|
||||
localServer chan net.Conn
|
||||
|
||||
|
@ -2215,11 +2213,8 @@ func (g *Game) HandleReplay(replay []byte) {
|
|||
Spectating: true,
|
||||
}
|
||||
|
||||
g.replaySummary1 = g.replaySummary1[:0]
|
||||
g.replaySummary2 = g.replaySummary2[:0]
|
||||
var haveRoll bool
|
||||
var wrote1 bool
|
||||
var wrote2 bool
|
||||
g.board.replayList.Clear()
|
||||
var listY int
|
||||
|
||||
var lineNumber int
|
||||
scanner := bufio.NewScanner(bytes.NewReader(replay))
|
||||
|
@ -2241,23 +2236,26 @@ func (g *Game) HandleReplay(replay []byte) {
|
|||
player = 2
|
||||
}
|
||||
|
||||
if player == 1 {
|
||||
if wrote1 {
|
||||
g.replaySummary1 = append(g.replaySummary1, '\n')
|
||||
}
|
||||
g.replaySummary1 = append(g.replaySummary1, scanner.Bytes()[4:]...)
|
||||
haveRoll = true
|
||||
wrote1 = true
|
||||
} else {
|
||||
if wrote2 {
|
||||
g.replaySummary2 = append(g.replaySummary2, '\n')
|
||||
}
|
||||
g.replaySummary2 = append(g.replaySummary2, scanner.Bytes()[4:]...)
|
||||
wrote2 = true
|
||||
if !haveRoll {
|
||||
g.replaySummary1 = append(g.replaySummary1, '\n')
|
||||
haveRoll = true
|
||||
label := string(scanner.Bytes()[4:])
|
||||
|
||||
var x int
|
||||
if player == 2 {
|
||||
x = 1
|
||||
}
|
||||
frame := len(g.replayFrames)
|
||||
btn := etk.NewButton(label, func() error {
|
||||
if !game.board.replayAuto.IsZero() {
|
||||
game.board.replayAuto = time.Time{}
|
||||
game.board.replayPauseButton.SetText("|>")
|
||||
}
|
||||
g.showReplayFrame(frame, true)
|
||||
return nil
|
||||
})
|
||||
btn.SetHorizontal(etk.AlignStart)
|
||||
g.board.replayList.AddChildAt(btn, x, listY)
|
||||
|
||||
if player == 2 {
|
||||
listY++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -5,7 +5,7 @@ go 1.19
|
|||
require (
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240830210522-ef40f1443a36
|
||||
code.rocket9labs.com/tslocum/bgammon-bei-bot v0.0.0-20240830071659-92734e0c2a83
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240902043209-4d44a01b2904
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240902055205-10177aa6dcb9
|
||||
code.rocket9labs.com/tslocum/gotext v0.0.0-20240728181248-46f419ff143b
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20240820025521-91065b63f1be
|
||||
github.com/coder/websocket v1.8.12
|
||||
|
|
4
go.sum
4
go.sum
|
@ -4,8 +4,8 @@ code.rocket9labs.com/tslocum/bgammon v0.0.0-20240830210522-ef40f1443a36 h1:fpIrq
|
|||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240830210522-ef40f1443a36/go.mod h1:1wuDH6u2P1SDyyiIDukWOOn0rMcPmsX25a4InIEJYKE=
|
||||
code.rocket9labs.com/tslocum/bgammon-bei-bot v0.0.0-20240830071659-92734e0c2a83 h1:M8BkpBdZfADl9csIQuWkeaUnSziv8D6IjJb0spMQp24=
|
||||
code.rocket9labs.com/tslocum/bgammon-bei-bot v0.0.0-20240830071659-92734e0c2a83/go.mod h1:2Z6p21stqKPaASnORhe5vNGvOi6FLKX14SP3cvUF0Kg=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240902043209-4d44a01b2904 h1:AFbtRWz7VFlUG8DqYHfhZmJ2oRPh9ZUrx9GYp68nhnU=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240902043209-4d44a01b2904/go.mod h1:uRulVK4IG8uhho3k5KRQYg1XrSiztaL5Cfjr5ac1u8E=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240902055205-10177aa6dcb9 h1:S62dvsp+nQ54whKnL0MWgT+mmKJqw/0LXCrhuY6j57E=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240902055205-10177aa6dcb9/go.mod h1:uRulVK4IG8uhho3k5KRQYg1XrSiztaL5Cfjr5ac1u8E=
|
||||
code.rocket9labs.com/tslocum/gotext v0.0.0-20240728181248-46f419ff143b h1:KSdR7VPoftY5Bt+osGRBbtHlCWxhe1QbOuf58CG7ieI=
|
||||
code.rocket9labs.com/tslocum/gotext v0.0.0-20240728181248-46f419ff143b/go.mod h1:ZkYZ/IF/ebzhUL2bNp4ALROsuH9iCztUWvUJBWsHXRU=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20240820025521-91065b63f1be h1:awgpl3vS+d7vciw7X5z+joGSPZHB1OOTpkPKW3mPGDs=
|
||||
|
|
Loading…
Reference in a new issue