Skip to content

Commit

Permalink
save the values while the score and rate windows are not visible
Browse files Browse the repository at this point in the history
  • Loading branch information
ftl committed Jul 26, 2023
1 parent 32e3442 commit a713ff0
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
1 change: 1 addition & 0 deletions core/rate/rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (c *Counter) SetView(view View) {

func (c *Counter) Show() {
c.view.Show()
c.view.SetGoals(c.qsosGoal, c.pointsGoal, c.multisGoal)
c.view.ShowRate(c.QSORate)
}

Expand Down
3 changes: 2 additions & 1 deletion core/score/score.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func (c *Counter) SetView(view View) {
return
}
c.view = view
c.view.ShowScore(c.Score)
c.view.SetGoals(c.contestPointsGoal, c.contestMultisGoal)
c.view.ShowScore(c.Score)
}

func (c *Counter) StationChanged(station core.Station) {
Expand Down Expand Up @@ -152,6 +152,7 @@ func (c *Counter) Valid() bool {

func (c *Counter) Show() {
c.view.Show()
c.view.SetGoals(c.contestPointsGoal, c.contestMultisGoal)
c.view.ShowScore(c.Score)
}

Expand Down
6 changes: 0 additions & 6 deletions ui/rateView.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@ func setupNewRateView(builder *gtk.Builder, colors colorProvider) *rateView {
}

func (v *rateView) ShowRate(rate core.QSORate) {
if v == nil {
return
}
v.indicator.SetRate(rate)
if v.indicatorArea != nil {
v.indicatorArea.QueueDraw()
}
}

func (v *rateView) SetGoals(qsos int, points int, multis int) {
if v == nil {
return
}
v.indicator.SetGoals(qsos, points, multis)
}
24 changes: 24 additions & 0 deletions ui/rateWindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/ftl/gmtry"
"github.com/gotk3/gotk3/gtk"

"github.com/ftl/hellocontest/core"
"github.com/ftl/hellocontest/ui/style"
)

Expand All @@ -14,6 +15,11 @@ type rateWindow struct {
geometry *gmtry.Geometry
style *style.Style

rate core.QSORate
qsosGoal int
pointsGoal int
multisGoal int

*rateView
}

Expand Down Expand Up @@ -43,6 +49,8 @@ func (w *rateWindow) Show() {
w.window.SetTitle("QSO Rate")
w.window.Connect("destroy", w.onDestroy)
w.rateView = setupNewRateView(builder, w.style.ForWidget(w.window.ToWidget()))
w.rateView.SetGoals(w.qsosGoal, w.pointsGoal, w.multisGoal)
w.rateView.ShowRate(w.rate)
connectToGeometry(w.geometry, RateWindowID, w.window)
}
w.window.ShowAll()
Expand Down Expand Up @@ -75,3 +83,19 @@ func (w *rateWindow) onDestroy() {
w.window = nil
w.rateView = nil
}

func (w *rateWindow) ShowRate(rate core.QSORate) {
w.rate = rate
if w.rateView != nil {
w.rateView.ShowRate(rate)
}
}

func (w *rateWindow) SetGoals(qsos int, points int, multis int) {
w.qsosGoal = qsos
w.pointsGoal = points
w.multisGoal = multis
if w.rateView != nil {
w.rateView.SetGoals(qsos, points, multis)
}
}
6 changes: 0 additions & 6 deletions ui/scoreView.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ func setupNewScoreView(builder *gtk.Builder, colors colorProvider) *scoreView {
}

func (v *scoreView) ShowScore(score core.Score) {
if v == nil {
return
}
v.graph.SetGraphs(score.StackedGraphPerBand())

if v.tableLabel != nil {
Expand All @@ -45,9 +42,6 @@ func (v *scoreView) ShowScore(score core.Score) {
}

func (v *scoreView) SetGoals(points int, multis int) {
if v == nil {
return
}
v.graph.SetGoals(points, multis)
}

Expand Down
22 changes: 22 additions & 0 deletions ui/scoreWindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/ftl/gmtry"
"github.com/gotk3/gotk3/gtk"

"github.com/ftl/hellocontest/core"
"github.com/ftl/hellocontest/ui/style"
)

Expand All @@ -14,6 +15,10 @@ type scoreWindow struct {
geometry *gmtry.Geometry
style *style.Style

score core.Score
pointsGoal int
multisGoal int

*scoreView
}

Expand Down Expand Up @@ -43,6 +48,8 @@ func (w *scoreWindow) Show() {
w.window.SetTitle("Score")
w.window.Connect("destroy", w.onDestroy)
w.scoreView = setupNewScoreView(builder, w.style.ForWidget(w.window.ToWidget()))
w.scoreView.SetGoals(w.pointsGoal, w.multisGoal)
w.scoreView.ShowScore(w.score)
connectToGeometry(w.geometry, ScoreWindowID, w.window)
}
w.window.ShowAll()
Expand Down Expand Up @@ -75,3 +82,18 @@ func (w *scoreWindow) onDestroy() {
w.window = nil
w.scoreView = nil
}

func (w *scoreWindow) ShowScore(score core.Score) {
w.score = score
if w.scoreView != nil {
w.scoreView.ShowScore(score)
}
}

func (w *scoreWindow) SetGoals(points int, multis int) {
w.pointsGoal = points
w.multisGoal = multis
if w.scoreView != nil {
w.scoreView.SetGoals(points, multis)
}
}

0 comments on commit a713ff0

Please sign in to comment.