Skip to content

Commit f656f51

Browse files
committed
Add reset button, fetch live circuit data from IGL
1 parent ca2201f commit f656f51

File tree

8 files changed

+89
-44
lines changed

8 files changed

+89
-44
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ compile:
77
packr2 clean
88
fyne-win:
99
packr2
10-
fyne-cross windows
10+
fyne-cross windows -icon Icon.png
1111
packr2 clean
1212

1313
fyne-mac:

README.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,13 @@ Better KQB Scoreboard helps casters keep track of scores and display them beauti
55
KQB Scoreboard was written in Go and provides a browser widget interface for use with OBS.
66

77
## Instructions
8-
1. Download the entire release zip file from github
9-
2. Unzip the directory and run the kqb-scoreboard executable (Mac and Windows compatible)
10-
3. Create a browser source in OBS pointed at http://localhost:8080
11-
* Within the browser source set the dimensions to 1440 x 90 (Large) or 1920 x 90 (Smaller)
8+
1. Download the new GUI release from Github for your platform (Windows or Mac)
9+
2. Unzip the file and run the App
10+
3. Follow the on screen instructions for IGL or Custom Match Type
11+
4. Create a browser source in OBS pointed at http://localhost:8080
12+
* Recommended dimensions are 1760x90 to get the look in the screen shot below
1213
* Then add a green chroma filter to make it transparent
13-
4. Profit
14-
15-
### IMPORTANT NOTE FOR WINDOWS USERS
16-
Unless you have the developer terminal on windows some parts of the app will not display 100% correctly, this is purely cosmetic and will have no affect on what the viewers see. On windows instead of using the arrow keys you must use the J K H L keys to navigate the menus.
17-
18-
#### Windows Key Bindings (Will hopefully be improved)
19-
- *J = Down*
20-
- *K = Up*
21-
- *H = Page Down*
22-
- *L = Page Up*
23-
- *Enter = Select*
24-
25-
### ALPHA LIMITATIONS
26-
Note during this alpha phase there may be bugs and minor issues you run into, here is a list of current known issues:
27-
1. No way to subtract from scores - so please make sure you record map results correctly
28-
2. ~~Dark mode not working - currently the score boxes have a white background, looking to correctly implement a dark mode~~
29-
* Dark mode support added 05/10
30-
3. Windows keybinding and display issues as per above
14+
5. Profit
3115

3216

3317
## Screen Shots and Demo

igl.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"io/ioutil"
7+
"net/http"
8+
)
9+
10+
const CircuitAPIURL = "https://indy-gaming-league-api.herokuapp.com/api/circuits?data={%22motherCircuitId%22:%225e4b290a420594ace7e97726%22,%22live%22:false,%22active%22:true,%22hidden%22:false,%20%22game%22:%22KILLER%20QUEEN%20BLACK%22}"
11+
12+
type IGLCircuit struct {
13+
ID string `json:"id"`
14+
Name string `json:"name"`
15+
Region string `json:"region"`
16+
Game string `json:"game"`
17+
}
18+
19+
func (c IGLCircuit) String() string {
20+
return fmt.Sprintf("Circuit ID: %s, Name: %s, Region: %s\n", c.ID, c.Name, c.Region)
21+
}
22+
23+
type IGLCircuitData struct {
24+
Circuits []IGLCircuit `json:"circuits"`
25+
}
26+
27+
func GetIGLCircuits(c chan []IGLCircuit) {
28+
fmt.Println("Fetching Circuit Information from IGL...")
29+
resp, err := http.Get(CircuitAPIURL)
30+
if err != nil {
31+
// handle error
32+
}
33+
defer resp.Body.Close()
34+
body, err := ioutil.ReadAll(resp.Body)
35+
var result IGLCircuitData
36+
json.Unmarshal([]byte(body), &result)
37+
38+
// fmt.Println(result.Circuits)
39+
40+
c <- result.Circuits
41+
}

kqb-scoreboard

-20.7 MB
Binary file not shown.

kqb-scoreboard.exe

-10.3 MB
Binary file not shown.

main.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import (
77
"log"
88
"net/http"
99
"os"
10-
"os/signal"
1110
"strconv"
12-
"sync"
13-
"syscall"
1411

1512
"fyne.io/fyne/app"
1613
)
@@ -57,8 +54,8 @@ func setupLogs() {
5754

5855
func main() {
5956
setupLogs()
60-
var wg sync.WaitGroup
61-
wg.Add(1)
57+
// var wg sync.WaitGroup
58+
// wg.Add(1)
6259
StartHTTPServer()
6360
// SetupCloseHandler()
6461
myApp := app.New()
@@ -112,13 +109,3 @@ func GetTeamInfo(url string, c chan []Team) {
112109
}
113110
c <- teams
114111
}
115-
116-
func SetupCloseHandler() {
117-
c := make(chan os.Signal)
118-
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
119-
go func() {
120-
<-c
121-
fmt.Println("\r- Ctrl+C pressed in Terminal")
122-
os.Exit(0)
123-
}()
124-
}

ui.go

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,26 @@ func IGLCircuitSelect(w fyne.Window) *fyne.Container {
157157
label.Alignment = fyne.TextAlignCenter
158158
label.TextStyle.Bold = true
159159

160-
options := []string{"East Circuit", "West Circuit"}
160+
ch := make(chan []IGLCircuit)
161+
162+
w.SetContent(ProgressIndicator())
163+
go GetIGLCircuits(ch)
164+
circuits := <-ch
165+
166+
kqbCircuits := []IGLCircuit{}
167+
168+
for _, circuit := range circuits {
169+
if circuit.Game == "KILLER QUEEN BLACK" {
170+
kqbCircuits = append(kqbCircuits, circuit)
171+
}
172+
}
173+
174+
options := make([]string, len(kqbCircuits))
175+
176+
for i, circuit := range kqbCircuits {
177+
options[i] = circuit.Region + " " + circuit.Game
178+
}
179+
161180
var url string
162181

163182
nextButton := widget.NewButton("Next", func() {
@@ -169,10 +188,10 @@ func IGLCircuitSelect(w fyne.Window) *fyne.Container {
169188
nextButton.Disable()
170189

171190
circuitSelect := widget.NewSelect(options, func(value string) {
172-
if value == "East Circuit" {
173-
url = fmt.Sprintf("%s%s/results?bucket=igl-teamlogopics", IglAPIURL, IglEastID)
174-
} else {
175-
url = fmt.Sprintf("%s%s/results?bucket=igl-teamlogopics", IglAPIURL, IglWestID)
191+
for i, option := range options {
192+
if option == value {
193+
url = fmt.Sprintf("%s%s/results?bucket=igl-teamlogopics", IglAPIURL, kqbCircuits[i].ID)
194+
}
176195
}
177196

178197
nextButton.Enable()
@@ -241,7 +260,21 @@ func ScoreboardContent(w fyne.Window) *fyne.Container {
241260
scoreboardURL, _ := url.Parse("http://localhost:8080")
242261
link := widget.NewHyperlink("Scoreboard", scoreboardURL)
243262
link.Alignment = fyne.TextAlignCenter
244-
container := fyne.NewContainerWithLayout(layout.NewVBoxLayout(), scoreboardLabel, blueContainer, goldContainer, scoreboardContainer, link)
263+
264+
resetButton := widget.NewButtonWithIcon("Reset", theme.DeleteIcon(), func() {
265+
s.HomeMaps = 0
266+
s.HomeGames = 0
267+
s.AwayGames = 0
268+
s.HomeGames = 0
269+
blueMaps.Text = strconv.Itoa(s.HomeMaps)
270+
blueSets.Text = strconv.Itoa(s.HomeGames)
271+
goldMaps.Text = strconv.Itoa(s.AwayMaps)
272+
goldSets.Text = strconv.Itoa(s.AwayGames)
273+
scoreboardContainer.Refresh()
274+
UpdateScoreBoard(&s)
275+
})
276+
resetButtonContainer := fyne.NewContainerWithLayout(layout.NewHBoxLayout(), layout.NewSpacer(), resetButton, layout.NewSpacer())
277+
container := fyne.NewContainerWithLayout(layout.NewVBoxLayout(), scoreboardLabel, blueContainer, goldContainer, scoreboardContainer, resetButtonContainer, link)
245278
return container
246279
}
247280

0 commit comments

Comments
 (0)