Skip to content

Commit

Permalink
Add support for box score
Browse files Browse the repository at this point in the history
  • Loading branch information
achhabra2 committed Jan 20, 2021
1 parent bcea692 commit cc82cd8
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ _testmain.go

/fyne-cross
/kqb-scoreboard.app
/kqb-scoreboard.exe
# This file includes artifacts of Go build that should not be checked in.
# For files created by specific development environment (e.g. editor),
# use alternative ways to exclude files from git.
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Stats struct {

var h Team = Team{"Blue Team", PlaceholderImage, 1, 1, Stats{1, 1, 1, 1}}
var a Team = Team{"Gold Team", PlaceholderImage, 1, 1, Stats{1, 1, 1, 1}}
var s Scoreboard = Scoreboard{&h, &a, 0, 0, 0, 0}
var s Scoreboard = Scoreboard{&h, &a, 0, 0, 0, 0, []ScoreboardSet{}}
var logoPath string
var FyneApp fyne.App

Expand Down
12 changes: 12 additions & 0 deletions scoreboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,23 @@ type Scoreboard struct {
AwayMaps int
HomeGames int
AwayGames int
// BlueBerries int
// GoldBerries int
// BlueEggs int
// GoldEggs int
Sets []ScoreboardSet
}

type ScoreboardSet struct {
Away int
Home int
}

// IncrementHome accounts for when the home team wins a map
func (s *Scoreboard) IncrementHome() {
s.HomeMaps++
if s.HomeMaps == 3 {
s.Sets = append(s.Sets, ScoreboardSet{Away: s.AwayMaps, Home: s.HomeMaps})
s.HomeMaps = 0
s.AwayMaps = 0
s.HomeGames++
Expand All @@ -35,6 +46,7 @@ func (s *Scoreboard) DecrementHome() {
func (s *Scoreboard) IncrementAway() {
s.AwayMaps++
if s.AwayMaps == 3 {
s.Sets = append(s.Sets, ScoreboardSet{Away: s.AwayMaps, Home: s.HomeMaps})
s.HomeMaps = 0
s.AwayMaps = 0
s.AwayGames++
Expand Down
50 changes: 38 additions & 12 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,35 @@
document.getElementById("away-img").src = data.Away.Img
}
updateMapCSS(data)
if (data.HomeGames >= 3) {
document.getElementById("home-winner").classList.add("winner-background")
} else {
if(document.getElementById("home-winner").classList.contains("winner-background")) {
document.getElementById("home-winner").classList.remove("winner-background")
}
// if (data.HomeGames >= 3) {
// document.getElementById("home-winner").classList.add("winner-background")
// } else {
// if(document.getElementById("home-winner").classList.contains("winner-background")) {
// document.getElementById("home-winner").classList.remove("winner-background")
// }
// }
// if (data.AwayGames >= 3) {
// document.getElementById("away-winner").classList.add("winner-background")
// } else {
// if(document.getElementById("away-winner").classList.contains("winner-background")) {
// document.getElementById("away-winner").classList.remove("winner-background")
// }
// }
let homeRow = document.getElementById("home-row")
let awayRow = document.getElementById("away-row")
let x = homeRow.cells.length
let y = awayRow.cells.length
for(let i = x-1; i>0 ; i--) {
homeRow.deleteCell(i)
}
if (data.AwayGames >= 3) {
document.getElementById("away-winner").classList.add("winner-background")
} else {
if(document.getElementById("away-winner").classList.contains("winner-background")) {
document.getElementById("away-winner").classList.remove("winner-background")
}
for(let j = y-1; j>0 ; j--) {
awayRow.deleteCell(j)
}
for(let [idx,set] of data.Sets.entries()) {
let homeCell = homeRow.insertCell(-1)
let awayCell = awayRow.insertCell(-1)
homeCell.innerText = set.Home
awayCell.innerText = set.Away
}
}
function DarkModeToggle() {
Expand Down Expand Up @@ -252,6 +268,16 @@
<div id="timer-box" class="timer-box">
<span id="timer-text">00:00</span>
</div>
<div id="set-box" class="set-box">
<table id="set-table">
<tr id="away-row" class="blue-text">
<td>A</td>
</tr>
<tr id="home-row" class="gold-text">
<td>H</td>
</tr>
</table>
</div>
<div id="away-winner" class="right away-box">
<article class="wrapper-right">
<div class="one">
Expand Down
53 changes: 42 additions & 11 deletions static/scoreboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ body {

.blue-text {
color: #0192ff;
text-shadow: 2px 2px 8px #0192ff;
}

.gold-text {
color: #f2ae12;
text-shadow: 2px 2px 8px #f2ae12;
}

.home-box {
Expand Down Expand Up @@ -97,7 +99,7 @@ body {
height: 4rem;
background: #0192ff;
border-radius: 50px / 25px;
border: 3px #0061ac solid;
border: 4px #0061ac solid;
transform: rotate(-10deg);
display:inline-block;
}
Expand All @@ -107,7 +109,7 @@ body {
height: 4rem;
background: #888888;
border-radius: 50px / 25px;
border: 3px #0061ac solid;
border: 4px #0061ac solid;
transform: rotate(-10deg);
display:inline-block;
}
Expand All @@ -117,7 +119,7 @@ body {
height: 4rem;
background: #888888;
border-radius: 50px / 25px;
border: 3px #af7e0d solid;
border: 4px #af7e0d solid;
transform: rotate(10deg);
display:inline-block;
}
Expand All @@ -128,7 +130,7 @@ body {
width: 1.5rem;
height: 4rem;
border-radius: 50px / 25px;
border: 3px #af7e0d solid;
border: 4px #af7e0d solid;
transform: rotate(10deg);
display:inline-block;
}
Expand Down Expand Up @@ -181,11 +183,13 @@ body {
}

.home-outline {
border: 3px #0061ac solid;
border: 4px #0192ff solid;
box-shadow: 2px 2px 6px #0192ff;
}

.away-outline {
border: 3px #af7e0d solid;
border: 4px #f2ae12 solid;
box-shadow: 2px 2px 6px #f2ae12;
}

.timer-box {
Expand All @@ -211,18 +215,45 @@ body {

@keyframes textColorPalette {
0% {
color: #f2ae12;
border: 5px solid #f2ae12;
}
25% {
color: #af7e0d;
border: 5px solid #af7e0d;
}
50% {
color: #0192ff;
border: 5px solid #0192ff;
}
75% {
color: #0061ac;
border: 5px solid #0061ac;
}
100% {
color: #a055fb;
border: 5px solid #a055fb;
}
}

.set-box {
height: 90px;
width: 200px;
position: fixed;
/* line-height: 90px; */
text-align: left;
vertical-align: middle;
font-size: 2em;
/* top: 50%; */
left: 50%;
padding: 8px;
transform: translate(-50%, 0%);
background-color: black !important;
border-radius: 6px;
animation-name: textColorPalette;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: linear;
}


table, td {
width: 100%;
padding: 5px;
}
5 changes: 3 additions & 2 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func CustomTeamSelection(w fyne.Window) *fyne.Container {
log.Println("Scoreboard Starting")
blueTeam := Team{blueInput.Text, "avatar.png", 1, 1, Stats{0, 0, blueWinsInt, blueLossInt}}
goldTeam := Team{goldInput.Text, "avatar.png", 1, 1, Stats{0, 0, goldWinsInt, goldLossInt}}
s = Scoreboard{&blueTeam, &goldTeam, 0, 0, 0, 0}
s = Scoreboard{&blueTeam, &goldTeam, 0, 0, 0, 0, []ScoreboardSet{}}
StartScoreboard(w)
})
saveButton.Style = widget.PrimaryButton
Expand Down Expand Up @@ -111,7 +111,7 @@ func IGLTeamSelection(w fyne.Window, apiUrl string) *fyne.Container {

saveButton := widget.NewButton("Start Scoreboard", func() {
log.Println("Saved.")
s = Scoreboard{&blueTeam, &goldTeam, 0, 0, 0, 0}
s = Scoreboard{&blueTeam, &goldTeam, 0, 0, 0, 0, []ScoreboardSet{}}
UpdateTeamLogo(&blueTeam)
UpdateTeamLogo(&goldTeam)
StartScoreboard(w)
Expand Down Expand Up @@ -260,6 +260,7 @@ func ScoreboardContent(w fyne.Window, SetupEventHooks func(func())) *fyne.Contai
s.HomeGames = 0
s.AwayGames = 0
s.AwayMaps = 0
s.Sets = []ScoreboardSet{}
RefreshScoreboardUI()
UpdateScoreBoard(&s)
})
Expand Down

0 comments on commit cc82cd8

Please sign in to comment.