From d2f1fbbecc36f24e131cf050071a8f073dc058d8 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 23 Aug 2025 19:03:46 +0200 Subject: improve draft activity ui and introduce wasm specific ui constants --- go/activities/draft.go | 8 ++++---- go/ui/constants.go | 6 ++++++ go/ui/constants_wasm.go | 8 ++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 go/ui/constants.go create mode 100644 go/ui/constants_wasm.go (limited to 'go') diff --git a/go/activities/draft.go b/go/activities/draft.go index 53e762a6..7e7eb2c6 100644 --- a/go/activities/draft.go +++ b/go/activities/draft.go @@ -52,9 +52,9 @@ func NewLocalDraft(width, height int, playerName string) *Draft { ).Centering(true)) d.setInput = ui.NewTextInput( - (d.Width-DRAFT_BUTTON_WIDTH)/2, + (d.Width-3*DRAFT_BUTTON_WIDTH)/2, (d.Height-DRAFT_BUTTON_HEIGHT)/2-3*DRAFT_BUTTON_HEIGHT, - DRAFT_BUTTON_WIDTH, + DRAFT_BUTTON_WIDTH*3, DRAFT_BUTTON_HEIGHT, "base,magic,equipments", ) @@ -97,7 +97,7 @@ func NewLocalDraft(width, height int, playerName string) *Draft { ).Centering(true)) aiNInput := ui.NewNumberChoice( - (d.Width-DRAFT_BUTTON_WIDTH)/2, + (d.Width-ui.NUMBER_CHOICE_WIDTH_MIN)/2, (d.Height-DRAFT_BUTTON_HEIGHT)/2-DRAFT_BUTTON_HEIGHT, 1, nil, @@ -163,7 +163,7 @@ func (d *Draft) Update() error { 0, d.Width-SEALED_DECK_STRIP_WIDTH, d.Height, - 0.5, + ui.DRAFT_DECK_VIEW_SCALE, d.player.Deck).Columns(3) d.AddWidget(d.deckView) default: diff --git a/go/ui/constants.go b/go/ui/constants.go new file mode 100644 index 00000000..052ae527 --- /dev/null +++ b/go/ui/constants.go @@ -0,0 +1,6 @@ +//go:build !wasm +package ui + +const ( + DRAFT_DECK_VIEW_SCALE = 0.5 +) diff --git a/go/ui/constants_wasm.go b/go/ui/constants_wasm.go new file mode 100644 index 00000000..e6e2bbce --- /dev/null +++ b/go/ui/constants_wasm.go @@ -0,0 +1,8 @@ +package ui + +const ( + // The atlas of the ebiten wasm port does not allow as big imaes as the linux version. + // Therefore, we scale the deck view to reduce its size. + // FIXME: This is only needed because the cardView rendering is very naiv. + DRAFT_DECK_VIEW_SCALE = 0.35 +) -- cgit v1.2.3