Skip to content

Commit

Permalink
Add reset button, fetch live circuit data from IGL
Browse files Browse the repository at this point in the history
  • Loading branch information
achhabra2 committed May 19, 2020
1 parent ca2201f commit f656f51
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 44 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ compile:
packr2 clean
fyne-win:
packr2
fyne-cross windows
fyne-cross windows -icon Icon.png
packr2 clean

fyne-mac:
Expand Down
28 changes: 6 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,13 @@ Better KQB Scoreboard helps casters keep track of scores and display them beauti
KQB Scoreboard was written in Go and provides a browser widget interface for use with OBS.

## Instructions
1. Download the entire release zip file from github
2. Unzip the directory and run the kqb-scoreboard executable (Mac and Windows compatible)
3. Create a browser source in OBS pointed at http://localhost:8080
* Within the browser source set the dimensions to 1440 x 90 (Large) or 1920 x 90 (Smaller)
1. Download the new GUI release from Github for your platform (Windows or Mac)
2. Unzip the file and run the App
3. Follow the on screen instructions for IGL or Custom Match Type
4. Create a browser source in OBS pointed at http://localhost:8080
* Recommended dimensions are 1760x90 to get the look in the screen shot below
* Then add a green chroma filter to make it transparent
4. Profit

### IMPORTANT NOTE FOR WINDOWS USERS
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.

#### Windows Key Bindings (Will hopefully be improved)
- *J = Down*
- *K = Up*
- *H = Page Down*
- *L = Page Up*
- *Enter = Select*

### ALPHA LIMITATIONS
Note during this alpha phase there may be bugs and minor issues you run into, here is a list of current known issues:
1. No way to subtract from scores - so please make sure you record map results correctly
2. ~~Dark mode not working - currently the score boxes have a white background, looking to correctly implement a dark mode~~
* Dark mode support added 05/10
3. Windows keybinding and display issues as per above
5. Profit


## Screen Shots and Demo
Expand Down
41 changes: 41 additions & 0 deletions igl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)

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}"

type IGLCircuit struct {
ID string `json:"id"`
Name string `json:"name"`
Region string `json:"region"`
Game string `json:"game"`
}

func (c IGLCircuit) String() string {
return fmt.Sprintf("Circuit ID: %s, Name: %s, Region: %s\n", c.ID, c.Name, c.Region)
}

type IGLCircuitData struct {
Circuits []IGLCircuit `json:"circuits"`
}

func GetIGLCircuits(c chan []IGLCircuit) {
fmt.Println("Fetching Circuit Information from IGL...")
resp, err := http.Get(CircuitAPIURL)
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var result IGLCircuitData
json.Unmarshal([]byte(body), &result)

// fmt.Println(result.Circuits)

c <- result.Circuits
}
Binary file removed kqb-scoreboard
Binary file not shown.
Binary file removed kqb-scoreboard.exe
Binary file not shown.
17 changes: 2 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import (
"log"
"net/http"
"os"
"os/signal"
"strconv"
"sync"
"syscall"

"fyne.io/fyne/app"
)
Expand Down Expand Up @@ -57,8 +54,8 @@ func setupLogs() {

func main() {
setupLogs()
var wg sync.WaitGroup
wg.Add(1)
// var wg sync.WaitGroup
// wg.Add(1)
StartHTTPServer()
// SetupCloseHandler()
myApp := app.New()
Expand Down Expand Up @@ -112,13 +109,3 @@ func GetTeamInfo(url string, c chan []Team) {
}
c <- teams
}

func SetupCloseHandler() {
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
fmt.Println("\r- Ctrl+C pressed in Terminal")
os.Exit(0)
}()
}
45 changes: 39 additions & 6 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,26 @@ func IGLCircuitSelect(w fyne.Window) *fyne.Container {
label.Alignment = fyne.TextAlignCenter
label.TextStyle.Bold = true

options := []string{"East Circuit", "West Circuit"}
ch := make(chan []IGLCircuit)

w.SetContent(ProgressIndicator())
go GetIGLCircuits(ch)
circuits := <-ch

kqbCircuits := []IGLCircuit{}

for _, circuit := range circuits {
if circuit.Game == "KILLER QUEEN BLACK" {
kqbCircuits = append(kqbCircuits, circuit)
}
}

options := make([]string, len(kqbCircuits))

for i, circuit := range kqbCircuits {
options[i] = circuit.Region + " " + circuit.Game
}

var url string

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

circuitSelect := widget.NewSelect(options, func(value string) {
if value == "East Circuit" {
url = fmt.Sprintf("%s%s/results?bucket=igl-teamlogopics", IglAPIURL, IglEastID)
} else {
url = fmt.Sprintf("%s%s/results?bucket=igl-teamlogopics", IglAPIURL, IglWestID)
for i, option := range options {
if option == value {
url = fmt.Sprintf("%s%s/results?bucket=igl-teamlogopics", IglAPIURL, kqbCircuits[i].ID)
}
}

nextButton.Enable()
Expand Down Expand Up @@ -241,7 +260,21 @@ func ScoreboardContent(w fyne.Window) *fyne.Container {
scoreboardURL, _ := url.Parse("http://localhost:8080")
link := widget.NewHyperlink("Scoreboard", scoreboardURL)
link.Alignment = fyne.TextAlignCenter
container := fyne.NewContainerWithLayout(layout.NewVBoxLayout(), scoreboardLabel, blueContainer, goldContainer, scoreboardContainer, link)

resetButton := widget.NewButtonWithIcon("Reset", theme.DeleteIcon(), func() {
s.HomeMaps = 0
s.HomeGames = 0
s.AwayGames = 0
s.HomeGames = 0
blueMaps.Text = strconv.Itoa(s.HomeMaps)
blueSets.Text = strconv.Itoa(s.HomeGames)
goldMaps.Text = strconv.Itoa(s.AwayMaps)
goldSets.Text = strconv.Itoa(s.AwayGames)
scoreboardContainer.Refresh()
UpdateScoreBoard(&s)
})
resetButtonContainer := fyne.NewContainerWithLayout(layout.NewHBoxLayout(), layout.NewSpacer(), resetButton, layout.NewSpacer())
container := fyne.NewContainerWithLayout(layout.NewVBoxLayout(), scoreboardLabel, blueContainer, goldContainer, scoreboardContainer, resetButtonContainer, link)
return container
}

Expand Down

0 comments on commit f656f51

Please sign in to comment.