diff --git a/buttonbar.go b/buttonbar.go index f42aec3..610c0ef 100644 --- a/buttonbar.go +++ b/buttonbar.go @@ -9,11 +9,10 @@ import ( // import "github.com/veandco/go-sdl2/sdl" type ButtonBar struct { - ui.ContainerBase + ui.StackPanel Background color.Color ButtonLength float32 - Orientation ui.Orientation } const buttonBarWidth = 96 diff --git a/cmd/tins2020/tins2020.go b/cmd/tins2020/tins2020.go index 18f596e..6f195fa 100644 --- a/cmd/tins2020/tins2020.go +++ b/cmd/tins2020/tins2020.go @@ -84,11 +84,13 @@ func (a *app) Init(ctx ui.Context) error { content := tins2020.NewContent(a.dialogs) content.AddChild(tins2020.NewTerrainRenderer(a.game)) - content.AddChild(tins2020.NewGameControls(a.game, a.dialogs)) + controls := tins2020.NewGameControls(a.game, a.dialogs) + content.AddChild(controls) a.Content = content a.dialogs.Init(ctx) a.game.Reset(ctx) + controls.Init(ctx) a.dialogs.ShowIntro(ctx) return nil diff --git a/gamecontrols.go b/gamecontrols.go index e2e826a..69e6b6f 100644 --- a/gamecontrols.go +++ b/gamecontrols.go @@ -26,8 +26,10 @@ type GameControls struct { } func NewGameControls(game *Game, dialogs *Dialogs) *GameControls { - c := &GameControls{game: game, dialogs: dialogs} + return &GameControls{game: game, dialogs: dialogs} +} +func (c *GameControls) Init(ctx ui.Context) { c.game.SpeedChanged().AddHandler(c.speedChanged) c.game.ToolChanged().AddHandler(c.toolChanged) c.dialogs.DialogOpened().AddHandlerEmpty(func(ctx ui.Context) { c.game.Pause(ctx) }) @@ -105,8 +107,6 @@ func NewGameControls(game *Game, dialogs *Dialogs) *GameControls { c.AddChild(&c.top) c.AddChild(&c.flowers) c.AddChild(&c.otherTools) - - return c } func (c *GameControls) createBuyFlowerButton(id string) *BuyFlowerButton {