tShow popup with user token on registration - scoreboard - Interactive scoreboard for CTF-like games
(HTM) git clone git://git.z3bra.org/scoreboard.git
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 6af2a93891a9cce705a9cbfc68a4c6eea4a11e39
(DIR) parent f5a66d0061f0b62d09dc9fc96a863e510e048782
(HTM) Author: Willy Goiffon <contact@z3bra.org>
Date: Tue, 22 Aug 2023 15:52:37 +0200
Show popup with user token on registration
Diffstat:
M playerbox.go | 19 +++++++++++++++++++
M ui.go | 3 +--
2 files changed, 20 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/playerbox.go b/playerbox.go
t@@ -16,6 +16,24 @@ type PlayerBox struct {
score *tview.TextView
}
+const (
+ SAVE_TOKEN string = `Token for flag #%d:
+
+%s
+
+Save it.
+Do not share.
+
+
+~~~
+
+Tokens are single-use.
+
+A new one will be provided
+when submitting next flag.
+`
+)
+
var charlist = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-!"
var playerbox = PlayerBox {name: []byte("AAA"), char: []int{0,0,0}, cur: 0}
t@@ -77,6 +95,7 @@ func PlayerBoxName(p *Player) *tview.TextView {
}
cyboard.HighlightBoard(p.ScoreRank())
cyboard.GenerateHTML()
+ cyboard.Popup("CONGRATULATIONS", fmt.Sprintf(SAVE_TOKEN, p.flag+1, p.token));
} else {
cyboard.Popup("NOPE", "Player name unavailable\nPlease pick another one")
}
(DIR) diff --git a/ui.go b/ui.go
t@@ -132,7 +132,6 @@ func popup(title, text string, w, h int, callback func(key tcell.Key)) tview.Pri
}
func (a *Application) Message(title, text string) {
- //p := popup(title, text, 52, 19, func(key tcell.Key) {
p := popup(title, text, 64, 19, func(key tcell.Key) {
a.pages.RemovePage("popup")
})
t@@ -141,7 +140,7 @@ func (a *Application) Message(title, text string) {
}
func (a *Application) Popup(title, text string) {
- p := popup(title, text, 28, 19, func(key tcell.Key) {
+ p := popup(title, text, BOARD_WIDTH+2, BOARD_HEIGHT+4, func(key tcell.Key) {
a.pages.RemovePage("popup")
})