tDisplay token after user flag submission - scoreboard - Interactive scoreboard for CTF-like games
HTML git clone git://git.z3bra.org/scoreboard.git
DIR Log
DIR Files
DIR Refs
---
DIR commit 3f2e8d5a04c80bf53ecdfc6c4d855e2816be1624
DIR parent 5c9d5d6fc331ae6b72ce6ceed2c24444efc45135
HTML Author: Willy Goiffon <contact@z3bra.org>
Date: Tue, 22 Aug 2023 16:24:56 +0200
Display token after user flag submission
Diffstat:
M main.go | 7 +++----
M ui.go | 11 ++++++++---
2 files changed, 11 insertions(+), 7 deletions(-)
---
DIR diff --git a/main.go b/main.go
t@@ -47,7 +47,7 @@ type Application struct {
app *tview.Application
html string
pages *tview.Pages
- frame *tview.Grid
+ frame *tview.Frame
board *tview.Flex
player *Player
}
t@@ -120,8 +120,8 @@ func pageBoard() tview.Primitive {
cyboard.SetupFrame()
cyboard.DrawBoard()
- // center frame on screen, counting borders + header
- return center(BOARD_WIDTH + 2, BOARD_HEIGHT + 4, cyboard.frame)
+ // center frame on screen, counting borders + header + footer
+ return center(BOARD_WIDTH + 2, BOARD_HEIGHT + 7, cyboard.frame)
}
func main() {
t@@ -159,7 +159,6 @@ func main() {
cyboard.html = *html
cyboard.app = tview.NewApplication()
cyboard.pages = tview.NewPages()
- cyboard.frame = tview.NewGrid()
cyboard.board = tview.NewFlex()
cyboard.player = &Player{ db: cyboard.db }
DIR diff --git a/ui.go b/ui.go
t@@ -73,13 +73,16 @@ func RankTable(offset, limit, rank int, fill bool) *tview.Table {
func (a *Application) SetupFrame() {
- a.frame.
+
+ var grid = tview.NewGrid().
SetColumns(BOARD_WIDTH).
SetRows(1, BOARD_HEIGHT).
SetBorders(true)
- a.frame.AddItem(BoardHeader(), 0, 0, 1, 1, 1, BOARD_WIDTH, false)
- a.frame.AddItem(a.board, 1, 0, 1, 1, BOARD_HEIGHT, BOARD_WIDTH, true)
+ grid.AddItem(BoardHeader(), 0, 0, 1, 1, 1, BOARD_WIDTH, false)
+ grid.AddItem(a.board, 1, 0, 1, 1, BOARD_HEIGHT, BOARD_WIDTH, true)
+
+ a.frame = tview.NewFrame(grid)
}
func (a *Application) DrawBoard() {
t@@ -93,6 +96,8 @@ func (a *Application) HighlightBoard(line int) {
SetDirection(tview.FlexRow).
AddItem(RankTable(0, -1, 0, true).Select(line - 1, 0), BOARD_HEIGHT, 1, true)
a.app.SetFocus(a.board)
+
+ a.frame.AddText(fmt.Sprintf("🔑 %s", a.player.token), false, tview.AlignCenter, 0)
}
func (a *Application) NewPlayer(rank int) {