aboutsummaryrefslogtreecommitdiff
path: root/go/ui
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-06-25 17:10:24 -0500
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:21 +0200
commit0f78406cde7890f3f9b16cd0ba55afac4c9065cf (patch)
tree9d8cb7243f67660369fa2a80535c9172c3447726 /go/ui
parent9a4b12e6d388bb14a3c1b6343197f63a362709f4 (diff)
downloadmuhqs-game-0f78406cde7890f3f9b16cd0ba55afac4c9065cf.tar.gz
muhqs-game-0f78406cde7890f3f9b16cd0ba55afac4c9065cf.zip
improve prompt cancellation
The cancel button was overlaying the submit button preventing the submission of a prompt. Distinguish between cancelable and mandatory prompt. Only^ allow cancelable prompts to be removed. Fixes: 37acd982
Diffstat (limited to 'go/ui')
-rw-r--r--go/ui/prompt.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/go/ui/prompt.go b/go/ui/prompt.go
index a7f2ce07..a289ae13 100644
--- a/go/ui/prompt.go
+++ b/go/ui/prompt.go
@@ -17,6 +17,7 @@ type Prompt struct {
y, width int
action game.Action
components []Widget
+ cancelable bool
}
func NewPrompt(y, width int, action game.Action, promptText string) *Prompt {
@@ -30,10 +31,15 @@ func NewPrompt(y, width int, action game.Action, promptText string) *Prompt {
return p
}
-func (p *Prompt) Action() game.Action {
- return p.action
+func NewCancelablePrompt(y, width int, action game.Action, promptText string) *Prompt {
+ p := NewPrompt(y, width, action, promptText)
+ p.cancelable = true
+ return p
}
+func (p *Prompt) Cancelable() bool { return p.cancelable }
+func (p *Prompt) Action() game.Action { return p.action }
+
func (p *Prompt) Add(obj interface{}) error {
if handCard, ok := obj.(HandCard); ok {
obj = handCard.C