Resize tutorial dialog
This commit is contained in:
parent
4e25c3209d
commit
57800812f9
5 changed files with 49 additions and 18 deletions
|
@ -1,3 +1,6 @@
|
|||
1.4.7:
|
||||
- Fix user interface issues
|
||||
|
||||
1.4.6:
|
||||
- Improve quality of text rendering
|
||||
- Reduce memory usage when playing sounds
|
||||
|
|
14
game/game.go
14
game/game.go
|
@ -38,7 +38,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
AppVersion = "v1.4.6p1"
|
||||
AppVersion = "v1.4.7"
|
||||
baseButtonHeight = 54
|
||||
MaxDebug = 2
|
||||
DefaultServerAddress = "wss://ws.bgammon.org:1338"
|
||||
|
@ -3144,9 +3144,15 @@ func playSoundEffect(effect SoundEffect) {
|
|||
}
|
||||
|
||||
func randomizeSounds(s []*audio.Player) {
|
||||
for i := range s {
|
||||
j := rand.Intn(i + 1)
|
||||
s[i], s[j] = s[j], s[i]
|
||||
last := s[len(s)-1]
|
||||
for {
|
||||
for i := range s {
|
||||
j := rand.Intn(i + 1)
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
if s[0] != last {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,23 +10,48 @@ import (
|
|||
|
||||
type tutorialWidget struct {
|
||||
*etk.Frame
|
||||
grid *etk.Grid
|
||||
outerBox *tutorialBox
|
||||
content *etk.Frame
|
||||
page int
|
||||
lastClick time.Time
|
||||
}
|
||||
|
||||
func NewTutorialWidget() *tutorialWidget {
|
||||
w := &tutorialWidget{
|
||||
Frame: etk.NewFrame(),
|
||||
grid: etk.NewGrid(),
|
||||
Frame: etk.NewFrame(),
|
||||
content: etk.NewFrame(),
|
||||
}
|
||||
w.outerBox = w.newTutorialBox()
|
||||
|
||||
w.Frame.SetPositionChildren(true)
|
||||
w.Frame.AddChild(w.grid)
|
||||
w.Frame.AddChild(w.outerBox)
|
||||
w.Frame.AddChild(w.content)
|
||||
|
||||
w.content.SetPositionChildren(true)
|
||||
w.content.SetHorizontal(etk.AlignCenter)
|
||||
w.content.SetVertical(etk.AlignCenter)
|
||||
|
||||
w.setPage(0)
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *tutorialWidget) SetRect(r image.Rectangle) {
|
||||
maxWidth, maxHeight := etk.Scale(800), etk.Scale(400)
|
||||
if smallScreen {
|
||||
maxHeight = maxHeight / 3 * 2
|
||||
}
|
||||
if maxWidth > game.screenW/3*2 {
|
||||
maxWidth = game.screenW / 3 * 2
|
||||
}
|
||||
if maxHeight > game.screenH/3*2 {
|
||||
maxHeight = game.screenH / 3 * 2
|
||||
}
|
||||
w.content.SetMaxWidth(maxWidth)
|
||||
w.content.SetMaxHeight(maxHeight)
|
||||
|
||||
w.Frame.SetRect(r)
|
||||
}
|
||||
|
||||
func (w *tutorialWidget) nextPage() error {
|
||||
w.setPage(w.page + 1)
|
||||
return nil
|
||||
|
@ -39,7 +64,7 @@ func (w *tutorialWidget) hide() error {
|
|||
setViewBoard(false)
|
||||
game.board.gameState.PlayerNumber = 0
|
||||
game.savedUsername = "a"
|
||||
w.grid.Clear()
|
||||
w.Clear()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -56,6 +81,7 @@ func (w *tutorialWidget) newDialog(title string, message string) *Dialog {
|
|||
titleLabel.SetVertical(etk.AlignCenter)
|
||||
|
||||
messageLabel := etk.NewText(message)
|
||||
messageLabel.SetFont(etk.Style.TextFont, etk.Scale(mediumLargeFontSize))
|
||||
|
||||
grid := etk.NewGrid()
|
||||
grid.SetColumnSizes(20, -1, -1, 20)
|
||||
|
@ -122,12 +148,8 @@ func (w *tutorialWidget) setPage(page int) {
|
|||
return
|
||||
}
|
||||
|
||||
w.grid.Clear()
|
||||
w.grid.AddChildAt(w.newTutorialBox(), 0, 0, 6, 1)
|
||||
w.grid.AddChildAt(w.newTutorialBox(), 0, 1, 1, 2)
|
||||
w.grid.AddChildAt(w.newDialog(title, message), 1, 1, 4, 2)
|
||||
w.grid.AddChildAt(w.newTutorialBox(), 5, 1, 1, 2)
|
||||
w.grid.AddChildAt(w.newTutorialBox(), 0, 3, 6, 1)
|
||||
w.content.Clear()
|
||||
w.content.AddChild(w.newDialog(title, message))
|
||||
}
|
||||
|
||||
type tutorialBox struct {
|
||||
|
|
2
go.mod
2
go.mod
|
@ -7,7 +7,7 @@ toolchain go1.23.0
|
|||
require (
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20241119105320-bdceb0644748
|
||||
code.rocket9labs.com/tslocum/bgammon-bei-bot v0.0.0-20240917031657-2648772e515e
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20241119085405-e8f49c56416a
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20241120182706-e4e37cf67eb4
|
||||
code.rocket9labs.com/tslocum/gotext v0.0.0-20240728181248-46f419ff143b
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20241024013344-d112a9463c51
|
||||
github.com/coder/websocket v1.8.12
|
||||
|
|
4
go.sum
4
go.sum
|
@ -6,8 +6,8 @@ code.rocket9labs.com/tslocum/bgammon-bei-bot v0.0.0-20240917031657-2648772e515e
|
|||
code.rocket9labs.com/tslocum/bgammon-bei-bot v0.0.0-20240917031657-2648772e515e/go.mod h1:mZA8T+w1qkH5tzFfDQb87wCms+qlulyT9Q8deuK1ApQ=
|
||||
code.rocket9labs.com/tslocum/clipboard v0.0.0-20241012025701-2c0fb515daab h1:0sF/YYnb3/GaPMKALyNVXS0Ku5JoulpC4GWdTcP1v+Q=
|
||||
code.rocket9labs.com/tslocum/clipboard v0.0.0-20241012025701-2c0fb515daab/go.mod h1:v2cql+mNoahFvZ1U/KQmDDqPmD0H0l1jyistVAgg8YA=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20241119085405-e8f49c56416a h1:y4i0iAPzSe+/XIHYt6JV8rwd6lyS+QFPNb+cmzFN9Sc=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20241119085405-e8f49c56416a/go.mod h1:Vx+vyYrAVVbPrrHUg570gfdFSdDOqQIZzREf/FNVKt8=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20241120182706-e4e37cf67eb4 h1:gLOsytIndkjVjVCjgrvfwdiNLloI1pnuFdJiJFotyO0=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20241120182706-e4e37cf67eb4/go.mod h1:Vx+vyYrAVVbPrrHUg570gfdFSdDOqQIZzREf/FNVKt8=
|
||||
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-20241024013344-d112a9463c51 h1:JkjRKoSSmtHFSVIOAZV6e+Z+7r0mIxClsDpJxC/ZlOs=
|
||||
|
|
Loading…
Reference in a new issue