initial options bug fixed

See
424f62327b

Thanks a lot for the fast support, amazing!
This commit is contained in:
2024-06-08 20:06:02 +02:00
parent 3c992a00c6
commit 4f7cf4c419
4 changed files with 16 additions and 5 deletions

2
go.mod
View File

@@ -13,7 +13,7 @@ require (
github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895 // indirect
github.com/ebitengine/hideconsole v1.0.0 // indirect
github.com/ebitengine/purego v0.7.0 // indirect
github.com/ebitenui/ebitenui v0.5.6 // indirect
github.com/ebitenui/ebitenui v0.5.8-0.20240608175527-424f62327b21 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/jezek/xgb v1.1.1 // indirect
github.com/tinne26/etxt v0.0.8 // indirect

2
go.sum
View File

@@ -8,6 +8,8 @@ github.com/ebitengine/purego v0.7.0 h1:HPZpl61edMGCEW6XK2nsR6+7AnJ3unUxpTZBkkIXn
github.com/ebitengine/purego v0.7.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/ebitenui/ebitenui v0.5.6 h1:qyJRU5j+lQo1lamxB48IBwMxMfz1xNb5iWUayCtA0Wk=
github.com/ebitenui/ebitenui v0.5.6/go.mod h1:I0rVbTOUi7gWKTPet2gzbvhOdkHp5pJXMM6c6b3dRoE=
github.com/ebitenui/ebitenui v0.5.8-0.20240608175527-424f62327b21 h1:dElhYGyf+FYY+makAndUQNOSDwFSFYyFWziPwQrPObY=
github.com/ebitenui/ebitenui v0.5.8-0.20240608175527-424f62327b21/go.mod h1:I0rVbTOUi7gWKTPet2gzbvhOdkHp5pJXMM6c6b3dRoE=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/hajimehoshi/ebiten/v2 v2.7.4 h1:X+heODRQ3Ie9F9QFjm24gEZqQd5FSfR9XuT2XfHwgf8=

View File

@@ -82,35 +82,36 @@ func (scene *SceneOptions) Init() {
rowContainer := NewRowContainer("Options")
pause := NewCheckbox("Pause",
scene.Config.Paused,
func(args *widget.CheckboxChangedEventArgs) {
scene.Config.TogglePaused()
})
debugging := NewCheckbox("Debugging",
scene.Config.Debug,
func(args *widget.CheckboxChangedEventArgs) {
scene.Config.ToggleDebugging()
})
scene.SetInitialValue(debugging, scene.Config.Debug)
gridlines := NewCheckbox("Show grid lines",
scene.Config.ShowGrid,
func(args *widget.CheckboxChangedEventArgs) {
fmt.Println("CHECKBOX CALLED")
repr.Println(args.State)
scene.Config.ToggleGridlines()
})
scene.SetInitialValue(gridlines, scene.Config.ShowGrid)
evolution := NewCheckbox("Show evolution traces",
scene.Config.ShowEvolution,
func(args *widget.CheckboxChangedEventArgs) {
scene.Config.ToggleEvolution()
})
scene.SetInitialValue(evolution, scene.Config.ShowEvolution)
wrap := NewCheckbox("Wrap around edges",
scene.Config.Wrap,
func(args *widget.CheckboxChangedEventArgs) {
scene.Config.ToggleWrap()
})
scene.SetInitialValue(wrap, scene.Config.Wrap)
themes := NewCombobox(
[]string{"dark", "light"},
@@ -118,6 +119,7 @@ func (scene *SceneOptions) Init() {
func(args *widget.ListComboButtonEntrySelectedEventArgs) {
scene.Config.SwitchTheme(args.Entry.(ListEntry).Name)
})
themelabel := NewLabel("Themes")
combocontainer := NewColumnContainer()
combocontainer.AddChild(themes)

View File

@@ -42,11 +42,17 @@ func NewMenuButton(
func NewCheckbox(
text string,
initialvalue bool,
action func(args *widget.CheckboxChangedEventArgs)) *widget.LabeledCheckbox {
checkboxImage, _ := LoadCheckboxImage()
buttonImage, _ := LoadButtonImage()
var state widget.WidgetState
if initialvalue {
state = widget.WidgetChecked
}
return widget.NewLabeledCheckbox(
widget.LabeledCheckboxOpts.CheckboxOpts(
widget.CheckboxOpts.ButtonOpts(
@@ -54,6 +60,7 @@ func NewCheckbox(
),
widget.CheckboxOpts.Image(checkboxImage),
widget.CheckboxOpts.StateChangedHandler(action),
widget.CheckboxOpts.InitialState(state),
),
widget.LabeledCheckboxOpts.LabelOpts(
widget.LabelOpts.Text(text, *FontRenderer.FontSmall,