From 35057ec8a64b9b03f59e64464bddb17d7c97a204 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Sun, 17 Mar 2024 16:29:56 +0100 Subject: [PATCH] added back button --- game/select_scene.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/game/select_scene.go b/game/select_scene.go index c5e74d3..d671536 100644 --- a/game/select_scene.go +++ b/game/select_scene.go @@ -95,7 +95,7 @@ func (scene *SelectScene) SetupUI() { widget.WidgetOpts.LayoutData(widget.RowLayoutData{ Position: widget.RowLayoutPositionCenter, Stretch: true, - MaxHeight: 300, + MaxHeight: 200, }), )), // Set the entries in the list @@ -148,14 +148,31 @@ func (scene *SelectScene) SetupUI() { }), ) + buttonContainer := widget.NewContainer( + widget.ContainerOpts.Layout(widget.NewGridLayout( + widget.GridLayoutOpts.Columns(2), + widget.GridLayoutOpts.Padding(widget.NewInsetsSimple(30)), + widget.GridLayoutOpts.Spacing(20, 10), + widget.GridLayoutOpts.Stretch([]bool{true, false}, []bool{false, true}), + )), + ) + buttonPlay := gameui.NewMenuButton("Play selected level", *assets.FontRenderer.FontNormal, func(args *widget.ButtonClickedEventArgs) { scene.SetNext(Play) }) + buttonAbort := gameui.NewMenuButton("Back", *assets.FontRenderer.FontNormal, + func(args *widget.ButtonClickedEventArgs) { + scene.SetNext(Menu) + }) + + buttonContainer.AddChild(buttonPlay) + buttonContainer.AddChild(buttonAbort) + rowContainer.AddChild(label) rowContainer.AddChild(list) - rowContainer.AddChild(buttonPlay) + rowContainer.AddChild(buttonContainer) scene.Ui = &ebitenui.UI{ Container: rowContainer.Container(),