Skip to content

Commit

Permalink
feature request for menu
Browse files Browse the repository at this point in the history
  • Loading branch information
peakle committed Aug 13, 2023
1 parent 732da69 commit 1f6c144
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ github.com/quasilyte/ebitengine-resource v0.5.1-0.20230412072401-66c02806357e h1
github.com/quasilyte/ebitengine-resource v0.5.1-0.20230412072401-66c02806357e/go.mod h1:PEj32KsbbcgeSzAYQY5KspbImb/ucvJXoBgRMUrtBAQ=
github.com/quasilyte/ge v0.0.0-20230614081121-ca050b0c82ca h1:wfeq2kd9rEzz0m2quuS2QlLl0j17/TnTJ5216IlYlts=
github.com/quasilyte/ge v0.0.0-20230614081121-ca050b0c82ca/go.mod h1:GSOXFTKMmLyRleAqa7d3syNCsOfKG7dSultrYb0UhBc=
github.com/quasilyte/gmath v0.0.0-20230428180022-2163470ca0a9 h1:a7LbchKx0dyxohIASRHDr16ylkxlfZ3XGeqzwd09J+Q=
github.com/quasilyte/gmath v0.0.0-20230428180022-2163470ca0a9/go.mod h1:EbI+KMbALSVE2s0YFOQpR4uj66zBh9ter5P4CBMSuvA=
github.com/quasilyte/gmath v0.0.0-20230626195558-43d7cdc669ef h1:ylROAnCA+a6Ry6M9pkRXzL+bhPIT5ctHND5kcdxbwe4=
github.com/quasilyte/gmath v0.0.0-20230626195558-43d7cdc669ef/go.mod h1:EbI+KMbALSVE2s0YFOQpR4uj66zBh9ter5P4CBMSuvA=
github.com/quasilyte/gsignal v0.0.0-20230130114532-ff67b4bb9e15 h1:7JgEJ6KA+VQtt+Bbx2MpV4LttBOJTLH4ehB/R3DfijM=
Expand Down
8 changes: 7 additions & 1 deletion src/scenes/menus/lobbymenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/quasilyte/ge"
"github.com/quasilyte/ge/xslices"

"github.com/quasilyte/roboden-game/assets"
"github.com/quasilyte/roboden-game/controls"
"github.com/quasilyte/roboden-game/descriptions"
Expand Down Expand Up @@ -257,7 +258,12 @@ func (c *LobbyMenuController) createButtonsPanel(uiResources *eui.Resources) *wi
}

c.config.Finalize()
c.scene.Context().ChangeScene(staging.NewController(c.state, c.config.Clone(), NewLobbyMenuController(c.state, c.mode)))

optController := NewOptionsController(c.state)
stagingController := staging.NewController(c.state, c.config.Clone(), optController)
optController.WithBackController(stagingController)

c.scene.Context().ChangeScene(stagingController)
}))

panel.AddChild(eui.NewButton(uiResources, c.scene, d.Get("menu.back"), func() {
Expand Down
13 changes: 13 additions & 0 deletions src/scenes/menus/optionsmenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ type OptionsMenuController struct {
state *session.State

scene *ge.Scene

backController ge.SceneController
}

func NewOptionsController(state *session.State) *OptionsMenuController {
return &OptionsMenuController{state: state}
}

func (c *OptionsMenuController) WithBackController(controller ge.SceneController) *OptionsMenuController {
c.backController = controller
return c
}

func (c *OptionsMenuController) Init(scene *ge.Scene) {
c.scene = scene
c.initUI()
Expand All @@ -47,6 +54,12 @@ func (c *OptionsMenuController) initUI() {

options := &c.state.Persistent.Settings

if c.backController != nil {
rowContainer.AddChild(eui.NewButton(uiResources, c.scene, d.Get("menu.options.continue"), func() {
c.scene.Context().ChangeScene(c.backController)
}))
}

rowContainer.AddChild(eui.NewButton(uiResources, c.scene, d.Get("menu.options.sound"), func() {
c.scene.Context().ChangeScene(NewOptionsSoundMenuController(c.state))
}))
Expand Down

0 comments on commit 1f6c144

Please sign in to comment.