Repos / gorts / 8162523910
commit 816252391065cc29c8d40252aa43708261cd6196
Author: Nhân <hi@imnhan.com>
Date:   Mon Jun 19 21:03:21 2023 +0700

    add subtitle field

diff --git a/main.go b/main.go
index 4bbec2a..c7909bf 100644
--- a/main.go
+++ b/main.go
@@ -107,6 +107,7 @@ func startGUI() {
 		case "readstate":
 			// TODO: there must be a more... civilized way.
 			respond(state.Description)
+			respond(state.Subtitle)
 			respond(state.P1name)
 			respond(state.P1country)
 			respond(strconv.Itoa(state.P1score))
@@ -117,6 +118,7 @@ func startGUI() {
 			respond(state.P2team)
 		case "applystate":
 			state.Description = next()
+			state.Subtitle = next()
 			state.P1name = next()
 			state.P1country = next()
 			state.P1score, _ = strconv.Atoi(next())
@@ -138,6 +140,7 @@ func startGUI() {
 
 type State struct {
 	Description string `json:"description"`
+	Subtitle    string `json:"subtitle"`
 	P1name      string `json:"p1name"`
 	P1country   string `json:"p1country"`
 	P1score     int    `json:"p1score"`
diff --git a/tcl/main.tcl b/tcl/main.tcl
index 917eb9b..b126e66 100644
--- a/tcl/main.tcl
+++ b/tcl/main.tcl
@@ -29,6 +29,7 @@ wm protocol . WM_DELETE_WINDOW {
 # Data that we send to the actual web-based overlay:
 array set scoreboard {
     description ""
+    subtitle ""
     p1name ""
     p1country ""
     p1score 0
@@ -48,6 +49,7 @@ foreach key [array names scoreboard] {
 
 array set var_to_widget {
     description .c.description.entry
+    subtitle .c.subtitle.entry
     p1name .c.players.p1name
     p1country .c.players.p1country
     p1score .c.players.p1score
@@ -62,8 +64,11 @@ array set var_to_widget {
 
 ttk::frame .c -padding 5
 ttk::frame .c.description
-ttk::label .c.description.lbl -text "Match description"
+ttk::label .c.description.lbl -text "Title"
 ttk::entry .c.description.entry -textvariable scoreboard(description)
+ttk::frame .c.subtitle
+ttk::label .c.subtitle.lbl -text "Subtitle"
+ttk::entry .c.subtitle.entry -textvariable scoreboard(subtitle)
 ttk::frame .c.players
 ttk::label .c.players.p1lbl -text "Player 1"
 ttk::combobox .c.players.p1name -textvariable scoreboard(p1name) -width 35
@@ -101,7 +106,11 @@ grid .c.description -row 0 -column 0 -sticky NESW -pady {0 5}
 grid .c.description.lbl -row 0 -column 0 -padx {0 5}
 grid .c.description.entry -row 0 -column 1 -sticky EW
 grid columnconfigure .c.description 1 -weight 1
-grid .c.players -row 1 -column 0
+grid .c.subtitle -row 1 -column 0 -sticky NESW -pady {0 5}
+grid .c.subtitle.lbl -row 0 -column 0 -padx {0 5}
+grid .c.subtitle.entry -row 0 -column 1 -sticky EW
+grid columnconfigure .c.subtitle 1 -weight 1
+grid .c.players -row 2 -column 0
 grid .c.players.p1lbl -row 0 -column 0
 grid .c.players.p1name -row 0 -column 1
 grid .c.players.p1country -row 0 -column 2
@@ -117,12 +126,12 @@ grid .c.players.p2score -row 3 -column 3
 grid .c.players.p2win -row 3 -column 4 -padx {5 0} -rowspan 2 -sticky NS
 grid .c.players.p2teamlbl -row 4 -column 0
 grid .c.players.p2team -row 4 -column 1 -columnspan 3 -sticky EW
-grid .c.buttons -row 2 -column 0 -sticky W -pady {10 0}
+grid .c.buttons -row 3 -column 0 -sticky W -pady {10 0}
 grid .c.buttons.apply -row 0 -column 0
 grid .c.buttons.discard -row 0 -column 1
 grid .c.buttons.reset -row 0 -column 2
 grid .c.buttons.swap -row 0 -column 3
-grid .c.status -row 3 -column 0 -columnspan 5 -pady {10 0} -sticky EW
+grid .c.status -row 4 -column 0 -columnspan 5 -pady {10 0} -sticky EW
 
 grid columnconfigure .c.players 2 -pad 5
 grid columnconfigure .c.buttons 1 -pad 15
@@ -148,6 +157,7 @@ proc seticon {b64data} {
 proc readstate {} {
     puts "readstate"
     set ::scoreboard(description) [gets stdin]
+    set ::scoreboard(subtitle) [gets stdin]
     set ::scoreboard(p1name) [gets stdin]
     set ::scoreboard(p1country) [gets stdin]
     set ::scoreboard(p1score) [gets stdin]
@@ -162,6 +172,7 @@ proc readstate {} {
 proc applystate {} {
     puts "applystate"
     puts $::scoreboard(description)
+    puts $::scoreboard(subtitle)
     puts $::scoreboard(p1name)
     puts $::scoreboard(p1country)
     puts $::scoreboard(p1score)
diff --git a/web/state.sample.json b/web/state.sample.json
index 1223710..3b81452 100644
--- a/web/state.sample.json
+++ b/web/state.sample.json
@@ -1,5 +1,6 @@
 {
     "description": "Saigon Cup 2023",
+    "subtitle": "FT3",
     "p1name": "BST CYG Diego Umejuarez",
     "p1country": "jp",
     "p1score": 10,
@@ -8,4 +9,4 @@
     "p2country": "us",
     "p2score": 1,
     "p2team": "Team Japan2"
-}
\ No newline at end of file
+}