diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-06-06 16:42:46 -0500 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:18 +0200 |
| commit | bcffeac4c5086eba59448d4fe5d79bb786b05de2 (patch) | |
| tree | cc0b3648f2b070c731225e88b42fb3f4adcb65da /go/client/startMenu.go | |
| parent | c15142c3bcae4316c8580adb7a9f0b223e586ae9 (diff) | |
| download | muhqs-game-bcffeac4c5086eba59448d4fe5d79bb786b05de2.tar.gz muhqs-game-bcffeac4c5086eba59448d4fe5d79bb786b05de2.zip | |
refactor client activities
Make the activity stack explicit and move reusable activities to the
activity package.
Diffstat (limited to 'go/client/startMenu.go')
| -rw-r--r-- | go/client/startMenu.go | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/go/client/startMenu.go b/go/client/startMenu.go index 10fa8e1f..10b9e23d 100644 --- a/go/client/startMenu.go +++ b/go/client/startMenu.go @@ -3,6 +3,7 @@ package main import ( "log" + "muhq.space/muhqs-game/go/activities" "muhq.space/muhqs-game/go/game" "muhq.space/muhqs-game/go/ui" ) @@ -15,25 +16,28 @@ const ( DECK_LIST_HEIGHT = 500 ) -type StartMenu struct { +type startMenu struct { ui.Collection app *app deckInput *ui.TextInput + draft *activities.Draft + sealed *activities.Sealed + playerName string startDeck string remote string mapPath string } -func NewStartMenu(app *app) *StartMenu { - m := &StartMenu{app: app} +func NewStartMenu(app *app) *startMenu { + m := &startMenu{app: app} return m } -func (m *StartMenu) build() { +func (m *startMenu) build() { deckInput := ui.NewTextInput( (m.Width-DECK_LIST_WIDTH)/2, (m.Height-DECK_LIST_HEIGHT)/2, @@ -101,8 +105,8 @@ func (m *StartMenu) build() { START_BUTTON_HEIGHT, "Sealed", func(*ui.SimpleButton) { - sealed := NewSealed(m.Width, m.Height, m.app) - m.app.pushActivity(sealed) + sealed := activities.NewSealed(m.Width, m.Height) + activities.PushActivity(sealed) })) m.AddWidget(ui.NewSimpleButton( @@ -112,8 +116,8 @@ func (m *StartMenu) build() { START_BUTTON_HEIGHT, "Draft", func(*ui.SimpleButton) { - draft := NewDraft(m.Width, m.Height, m.app) - m.app.pushActivity(draft) + m.draft = activities.NewDraft(m.Width, m.Height, playerInput.Text()) + activities.PushActivity(m.draft) })) m.AddWidget(ui.NewSimpleButton( @@ -130,11 +134,23 @@ func (m *StartMenu) build() { })) } -func (m *StartMenu) Update() error { +func (m *startMenu) Update() error { if m.Widgets() == nil { m.build() } + // Get the drafted deck + if m.draft != nil { + m.deckInput.SetInput(m.draft.GetDeckList()) + m.draft = nil + } + + // Get the sealed deck + if m.sealed != nil { + m.deckInput.SetInput(m.sealed.Deck.ToList()) + m.sealed = nil + } + if err := ui.TouchManager.Update(); err != nil { return err } @@ -142,11 +158,11 @@ func (m *StartMenu) Update() error { return m.Collection.Update() } -func (m *StartMenu) Layout(width, height int) (int, int) { +func (m *startMenu) Layout(width, height int) (int, int) { return m.Width, m.Height } -func (m *StartMenu) startGame() { +func (m *startMenu) startGame() { var state game.State if m.remote != "" { log.Fatal("Remote games are currently not implemented") @@ -162,5 +178,5 @@ func (m *StartMenu) startGame() { g.gameState.AddNewAiPlayer("kraken", color) } - m.app.pushActivity(g.Start()) + activities.PushActivity(g.Start()) } |
