diff options
| -rw-r--r-- | go/client/game.go | 81 | ||||
| -rw-r--r-- | go/ui/constants.go | 1 |
2 files changed, 80 insertions, 2 deletions
diff --git a/go/client/game.go b/go/client/game.go index 5ab70df2..da1c59e2 100644 --- a/go/client/game.go +++ b/go/client/game.go @@ -168,11 +168,85 @@ func (g *Game) initMapUi() { }) } +func (g *Game) resize(w, h int) { + g.Width = w + g.Height = h + + g.handLayer = ui.NewHandView(0, + g.mapView.Height(), + HAND_VIEW_WIDTH, + g.Height-g.mapView.Height()-DEFAULT_BUTTON_HEIGHT, + player.Hand, + true) + g.AddWidget(g.handLayer) + + discardImg := ebiten.NewImageFromImage(assets.GetIcon("discard2.png")) + g.discardBtn = ui.NewImageButton( + g.handLayer.X+2, + g.handLayer.Y+g.handLayer.Height-discardImg.Bounds().Dy()-2, + discardImg, + func(*ui.ImageButton) { + g.addCancelablePrompt(game.NewFreeDiscardAction(player), "select two hand cards") + }, + ) + g.AddWidget(g.discardBtn) + + g.stateBar = ui.NewStateBar(0, + g.Height-DEFAULT_BUTTON_HEIGHT, + STATE_BAR_WIDTH, + DEFAULT_BUTTON_HEIGHT, + g.gameState, + player) + g.AddWidget(g.stateBar) + + g.discardPileButton = ui.NewSimpleButton(g.stateBar.Width, + g.Height-DEFAULT_BUTTON_HEIGHT, + POC_BUTTON_WIDTH, + DEFAULT_BUTTON_HEIGHT, + "Discard Pile [0]", + func(*ui.SimpleButton) { + if !g.visible(g.discardPileView) { + g.discardPileView.ForceRedraw() + g.AddWidget(g.discardPileView) + } else { + g.RemoveWidget(g.discardPileView) + } + }) + g.AddWidget(g.discardPileButton) + + x = g.discardPileButton.X + g.discardPileButton.Width/2 + y = g.Height - DEFAULT_BUTTON_HEIGHT + g.discardPileView = ui.NewPocList(x, y, g.activePlayer().DiscardPile, &g.Collection) + + // Init the store view and the store button if we know there is only the active player's one. + if len(g.gameState.Map().Stores) == 0 { + x = g.stateBar.Width + g.discardPileButton.Width + y = g.Height - DEFAULT_BUTTON_HEIGHT + g.storeButton = ui.NewSimpleButton(x, y, + POC_BUTTON_WIDTH, + DEFAULT_BUTTON_HEIGHT, + fmt.Sprintf("Store [%d]", g.activePlayer().Store.Size()), + func(*ui.SimpleButton) { + if !g.storesVisible { + g.showStores() + } else { + g.hideStores() + } + }) + g.AddWidget(g.storeButton) + + x = g.storeButton.X + g.storeButton.Width/2 + y = g.Height - DEFAULT_BUTTON_HEIGHT + g.storeViews = []*ui.PocList{ui.NewPocList(x, y, g.activePlayer().Store, &g.Collection)} + } + +} + func (g *Game) addActivePlayer(name string, deckList string) *Game { deck := game.NewDeckFromDeckList(deckList) - g.gameState.AddNewPlayer(name, deck) - p := g.gameState.PlayerByName(name) + p := g.gameState.AddNewPlayer(name, deck) g.activePlayerId = p.Id + return g.initPlayerUi(p) } @@ -794,6 +868,9 @@ func (g *Game) Draw(screen *ebiten.Image) { } func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) { + if outsideWidth != g.Width || outsideHeight != g.Height { + g.resize(outsideHeight, outsideWidth) + } return g.Width, g.Height } diff --git a/go/ui/constants.go b/go/ui/constants.go index 4bc12558..53592de4 100644 --- a/go/ui/constants.go +++ b/go/ui/constants.go @@ -4,4 +4,5 @@ package ui const ( DRAFT_DECK_VIEW_SCALE = 0.5 + MIN_HAND_HEIGHT = 400 ) |
