aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-04-29 15:22:13 -0500
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:16 +0200
commitec2741ae85303309253cb790d8d0554cd358d919 (patch)
tree5a6a98212abc10f4b49b7720711aeb9a7b020cda
parenta7aa3c974e10a1bb671eb7859dc2aeaad560da05 (diff)
downloadmuhqs-game-ec2741ae85303309253cb790d8d0554cd358d919.tar.gz
muhqs-game-ec2741ae85303309253cb790d8d0554cd358d919.zip
add touch friendly way to cancel the current prompt
-rw-r--r--go/client/game.go32
-rw-r--r--go/client/keybindings.go1
2 files changed, 24 insertions, 9 deletions
diff --git a/go/client/game.go b/go/client/game.go
index 92708f3c..62e1d79c 100644
--- a/go/client/game.go
+++ b/go/client/game.go
@@ -44,6 +44,7 @@ type Game struct {
mapView *ui.MapView
choice ui.Widget
passButton *ui.SimpleButton
+ resetButton *ui.SimpleButton
discardPileView *ui.PocList
discardPileButton *ui.SimpleButton
storeView *ui.PocList
@@ -92,6 +93,15 @@ func newGame(app *app, gameState game.State) *Game {
}
})
+ g.resetButton = ui.NewSimpleButton(g.Width-PASS_BUTTON_WIDTH,
+ g.Height-DEFAULT_BUTTON_HEIGHT,
+ PASS_BUTTON_WIDTH,
+ DEFAULT_BUTTON_HEIGHT,
+ "cancel",
+ func(*ui.SimpleButton) {
+ reset(g)
+ })
+
g.stackBuffer = ui.NewBuffer(g.Width-STACK_BUFFER_WIDTH, g.passButton.Y-400,
STACK_BUFFER_WIDTH, 400)
return g
@@ -295,6 +305,7 @@ func (g *Game) addPrompt(action game.Action, prompt string) {
}
g.prompt = ui.NewPrompt(g.Height/2, g.Width, action, prompt)
g.AddWidget(g.prompt)
+ g.AddWidget(g.resetButton)
g.updateHighlight()
}
@@ -312,6 +323,7 @@ func (g *Game) progressPrompt() {
func (g *Game) removePrompt() {
g.RemoveWidget(g.prompt)
+ g.RemoveWidget(g.resetButton)
g.prompt = nil
}
@@ -361,19 +373,20 @@ func (g *Game) declareAction(a game.Action) {
g.stateBar.ForceRedraw()
}
-func (g *Game) showPassButton() {
- if g.FindWidget(g.passButton) == -1 {
- g.AddWidget(g.passButton)
+// show a widget by adding it to the collection
+func (g *Game) show(w ui.Widget) {
+ if g.FindWidget(w) == -1 {
+ g.AddWidget(w)
}
}
-func (g *Game) hidePassButton() {
+func (g *Game) hide(w ui.Widget) {
g.RemoveWidget(g.passButton)
}
-func (g *Game) updatePassButton() {
+func (g *Game) updateButtons() {
if g.prompt == nil && !g.hasPriority {
- g.hidePassButton()
+ g.hide(g.passButton)
}
passButtonLabel := "pass"
@@ -381,7 +394,8 @@ func (g *Game) updatePassButton() {
targets := g.prompt.Action().Targets()
if targets.RequireSelection() {
if !targets.Cur().HasSelection() {
- g.hidePassButton()
+ g.hide(g.passButton)
+ g.show(g.resetButton)
return
}
passButtonLabel = "next"
@@ -395,7 +409,7 @@ func (g *Game) updatePassButton() {
}
}
- g.showPassButton()
+ g.show(g.passButton)
g.passButton.UpdateLabel(passButtonLabel)
}
@@ -572,7 +586,7 @@ func (g *Game) Update() error {
g.handlePlayerNotifications()
g.handleKeyBindings(g.keyBindings)
- g.updatePassButton()
+ g.updateButtons()
return nil
}
diff --git a/go/client/keybindings.go b/go/client/keybindings.go
index 7f52b9df..b39a0da4 100644
--- a/go/client/keybindings.go
+++ b/go/client/keybindings.go
@@ -89,6 +89,7 @@ func reset(g *Game) bool {
g.clearHighlights()
g.hideStore()
g.RemoveWidget(g.discardPileView)
+ g.RemoveWidget(g.resetButton)
if g.prompt != nil {
if g.prompt.Action().Targets().NoSelections() {
g.removePrompt()