Add settings dialog
This commit is contained in:
parent
0a672e9676
commit
c49e33332f
5 changed files with 61 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
1.0.8:
|
||||
- Add menu
|
||||
- Add in-game menu
|
||||
- Add settings dialog
|
||||
- Allow highlighting available moves when moving a checker
|
||||
- Display match duration and current time when viewing board
|
||||
|
||||
|
|
|
@ -80,6 +80,9 @@ type board struct {
|
|||
|
||||
menuGrid *etk.Grid
|
||||
|
||||
highlightCheckbox *etk.Checkbox
|
||||
settingsGrid *etk.Grid
|
||||
|
||||
matchStatusGrid *etk.Grid
|
||||
|
||||
inputGrid *etk.Grid
|
||||
|
@ -126,6 +129,7 @@ func NewBoard() *board {
|
|||
opponentLabel: NewLabel(color.RGBA{255, 255, 255, 255}),
|
||||
playerLabel: NewLabel(color.RGBA{0, 0, 0, 255}),
|
||||
menuGrid: etk.NewGrid(),
|
||||
settingsGrid: etk.NewGrid(),
|
||||
uiGrid: etk.NewGrid(),
|
||||
frame: etk.NewFrame(),
|
||||
confirmLeaveGameFrame: etk.NewFrame(),
|
||||
|
@ -147,6 +151,33 @@ func NewBoard() *board {
|
|||
b.menuGrid.SetVisible(false)
|
||||
}
|
||||
|
||||
{
|
||||
settingsLabel := etk.NewText(gotext.Get("Settings"))
|
||||
settingsLabel.SetHorizontal(messeji.AlignCenter)
|
||||
|
||||
b.highlightCheckbox = etk.NewCheckbox(b.toggleHighlightCheckbox)
|
||||
b.highlightCheckbox.SetBorderColor(triangleA)
|
||||
b.highlightCheckbox.SetCheckColor(triangleA)
|
||||
b.highlightCheckbox.SetSelected(b.highlightAvailable)
|
||||
|
||||
highlightLabel := etk.NewText(gotext.Get("Highlight legal moves"))
|
||||
highlightLabel.SetVertical(messeji.AlignCenter)
|
||||
|
||||
checkboxGrid := etk.NewGrid()
|
||||
checkboxGrid.SetColumnSizes(-1, -1, -1, -1, -1)
|
||||
checkboxGrid.AddChildAt(b.highlightCheckbox, 0, 0, 1, 1)
|
||||
checkboxGrid.AddChildAt(highlightLabel, 1, 0, 4, 1)
|
||||
|
||||
b.settingsGrid.SetBackground(color.RGBA{40, 24, 9, 255})
|
||||
b.settingsGrid.SetColumnSizes(20, -1, -1, 20)
|
||||
b.settingsGrid.SetRowSizes(72, 72, 20, -1)
|
||||
b.settingsGrid.AddChildAt(settingsLabel, 1, 0, 2, 1)
|
||||
b.settingsGrid.AddChildAt(checkboxGrid, 1, 1, 2, 1)
|
||||
b.settingsGrid.AddChildAt(etk.NewBox(), 1, 2, 1, 1)
|
||||
b.settingsGrid.AddChildAt(etk.NewButton(gotext.Get("Return"), b.hideMenu), 0, 3, 4, 1)
|
||||
b.settingsGrid.SetVisible(false)
|
||||
}
|
||||
|
||||
{
|
||||
leaveGameLabel := etk.NewText(gotext.Get("Leave match?"))
|
||||
leaveGameLabel.SetHorizontal(messeji.AlignCenter)
|
||||
|
@ -201,6 +232,7 @@ func NewBoard() *board {
|
|||
b.frame.AddChild(b.uiGrid)
|
||||
b.frame.AddChild(b.bearOffOverlay)
|
||||
b.frame.AddChild(b.menuGrid)
|
||||
b.frame.AddChild(b.settingsGrid)
|
||||
b.frame.AddChild(b.leaveGameGrid)
|
||||
|
||||
b.fontUpdated()
|
||||
|
@ -299,13 +331,13 @@ func (b *board) leaveGame() error {
|
|||
|
||||
func (b *board) showSettings() error {
|
||||
b.menuGrid.SetVisible(false)
|
||||
//b.settingsGrid.SetVisible(true)
|
||||
// TODO
|
||||
b.settingsGrid.SetVisible(true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *board) hideMenu() error {
|
||||
b.menuGrid.SetVisible(false)
|
||||
b.settingsGrid.SetVisible(false)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -346,6 +378,11 @@ func (b *board) selectResign() {
|
|||
b.Client.Out <- []byte("resign")
|
||||
}
|
||||
|
||||
func (b *board) toggleHighlightCheckbox() error {
|
||||
b.highlightAvailable = b.highlightCheckbox.Selected()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *board) newSprite(white bool) *Sprite {
|
||||
s := &Sprite{}
|
||||
s.colorWhite = white
|
||||
|
@ -927,6 +964,20 @@ func (b *board) setRect(x, y, w, h int) {
|
|||
b.menuGrid.SetRect(image.Rect(x, y, x+dialogWidth, y+dialogHeight))
|
||||
}
|
||||
|
||||
{
|
||||
dialogWidth := game.scale(620)
|
||||
if dialogWidth > game.screenW {
|
||||
dialogWidth = game.screenW
|
||||
}
|
||||
dialogHeight := 72 + 72 + 20 + game.scale(56)
|
||||
if dialogHeight > game.screenH {
|
||||
dialogHeight = game.screenH
|
||||
}
|
||||
|
||||
x, y := game.screenW/2-dialogWidth/2, game.screenH/2-dialogHeight+int(b.verticalBorderSize)
|
||||
b.settingsGrid.SetRect(image.Rect(x, y, x+dialogWidth, y+dialogHeight))
|
||||
}
|
||||
|
||||
{
|
||||
dialogWidth := game.scale(400)
|
||||
if dialogWidth > game.screenW {
|
||||
|
|
|
@ -472,6 +472,7 @@ func setViewBoard(view bool) {
|
|||
}
|
||||
|
||||
game.Board.menuGrid.SetVisible(false)
|
||||
game.Board.settingsGrid.SetVisible(false)
|
||||
game.Board.leaveGameGrid.SetVisible(false)
|
||||
|
||||
if !game.loggedIn {
|
||||
|
@ -1062,6 +1063,8 @@ func (g *Game) handleInput(keys []ebiten.Key) error {
|
|||
if viewBoard {
|
||||
if g.Board.menuGrid.Visible() {
|
||||
g.Board.menuGrid.SetVisible(false)
|
||||
} else if g.Board.settingsGrid.Visible() {
|
||||
g.Board.settingsGrid.SetVisible(false)
|
||||
} else if g.Board.leaveGameGrid.Visible() {
|
||||
g.Board.leaveGameGrid.SetVisible(false)
|
||||
} else {
|
||||
|
|
2
go.mod
2
go.mod
|
@ -4,7 +4,7 @@ go 1.17
|
|||
|
||||
require (
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231102214836-522663becc48
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20231102195906-c2c9a228d0aa
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20231103045149-354a405635ac
|
||||
code.rocketnine.space/tslocum/kibodo v1.0.2-0.20231102011532-8d3f420207ad
|
||||
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231102191237-a6fd28a6b52d
|
||||
github.com/hajimehoshi/ebiten/v2 v2.6.2
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,7 +1,7 @@
|
|||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231102214836-522663becc48 h1:kZSLjFfPd/ur0/VEaMx5NZQCl8bsnl8Dx/WdF6dcHeA=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231102214836-522663becc48/go.mod h1:U8qo60VHGzKFUHLZZJcvT0yDzwWybJBabsCw3Lyqx4s=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20231102195906-c2c9a228d0aa h1:twbOyuAP8EdcCz7mDJyj9adN557Qvwn4XdTwOMPtj8Q=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20231102195906-c2c9a228d0aa/go.mod h1:LkiMYCUwPC1JYD/K1G67XoJUDpgzcdvw8O9+vQiCXrU=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20231103045149-354a405635ac h1:2eCpRxkdjXwSjDSVDx7D/VA26dxMny4+f3+V5A3NF1A=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20231103045149-354a405635ac/go.mod h1:/NKTqYGNoES3oQNXbxn665TgcSPrVLc7qBZwz18HlYo=
|
||||
code.rocketnine.space/tslocum/kibodo v1.0.2-0.20231102011532-8d3f420207ad h1:Iyk7JYRCov59+XeIQQbZJMN6VWag007Ro1j5hziuSGw=
|
||||
code.rocketnine.space/tslocum/kibodo v1.0.2-0.20231102011532-8d3f420207ad/go.mod h1:C7M1NUuVi0Mv+/xraUurjl4XSLRIILmWDWCBBOY4UeM=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231102191237-a6fd28a6b52d h1:+/yDwjXqp7aKxDEYAKmWJfGNO7uOeo0nraj4aL8zUfQ=
|
||||
|
|
Loading…
Reference in a new issue