This commit is contained in:
Sander Schobers 2020-05-17 21:15:44 +02:00
parent 498021456d
commit 4b57ace9d6
3 changed files with 7 additions and 6 deletions

View File

@ -9,11 +9,10 @@ import (
// import "github.com/veandco/go-sdl2/sdl" // import "github.com/veandco/go-sdl2/sdl"
type ButtonBar struct { type ButtonBar struct {
ui.ContainerBase ui.StackPanel
Background color.Color Background color.Color
ButtonLength float32 ButtonLength float32
Orientation ui.Orientation
} }
const buttonBarWidth = 96 const buttonBarWidth = 96

View File

@ -84,11 +84,13 @@ func (a *app) Init(ctx ui.Context) error {
content := tins2020.NewContent(a.dialogs) content := tins2020.NewContent(a.dialogs)
content.AddChild(tins2020.NewTerrainRenderer(a.game)) 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.Content = content
a.dialogs.Init(ctx) a.dialogs.Init(ctx)
a.game.Reset(ctx) a.game.Reset(ctx)
controls.Init(ctx)
a.dialogs.ShowIntro(ctx) a.dialogs.ShowIntro(ctx)
return nil return nil

View File

@ -26,8 +26,10 @@ type GameControls struct {
} }
func NewGameControls(game *Game, dialogs *Dialogs) *GameControls { 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.SpeedChanged().AddHandler(c.speedChanged)
c.game.ToolChanged().AddHandler(c.toolChanged) c.game.ToolChanged().AddHandler(c.toolChanged)
c.dialogs.DialogOpened().AddHandlerEmpty(func(ctx ui.Context) { c.game.Pause(ctx) }) 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.top)
c.AddChild(&c.flowers) c.AddChild(&c.flowers)
c.AddChild(&c.otherTools) c.AddChild(&c.otherTools)
return c
} }
func (c *GameControls) createBuyFlowerButton(id string) *BuyFlowerButton { func (c *GameControls) createBuyFlowerButton(id string) *BuyFlowerButton {