Add sound when match result is shown (closes #120).

This commit is contained in:
Patrick Fairbank
2022-04-30 14:40:39 -07:00
parent d4d4292b6f
commit 8962b48f3e
4 changed files with 29 additions and 6 deletions

View File

@@ -361,6 +361,25 @@ func (arena *Arena) StartTimeout(durationSec int) error {
return nil
}
// Updates the audience display screen.
func (arena *Arena) SetAudienceDisplayMode(mode string) {
if arena.AudienceDisplayMode != mode {
arena.AudienceDisplayMode = mode
arena.AudienceDisplayModeNotifier.Notify()
if mode == "score" {
arena.playSound("match_result")
}
}
}
// Updates the alliance station display screen.
func (arena *Arena) SetAllianceStationDisplayMode(mode string) {
if arena.AllianceStationDisplayMode != mode {
arena.AllianceStationDisplayMode = mode
arena.AllianceStationDisplayModeNotifier.Notify()
}
}
// Returns the fractional number of seconds since the start of the match.
func (arena *Arena) MatchTimeSec() float64 {
if arena.MatchState == PreMatch || arena.MatchState == StartMatch || arena.MatchState == PostMatch {

View File

@@ -69,5 +69,11 @@ func UpdateMatchSounds() {
-1,
false,
},
{
"match_result",
"wav",
-1,
false,
},
}
}

Binary file not shown.

View File

@@ -283,22 +283,20 @@ func (web *Web) matchPlayWebsocketHandler(w http.ResponseWriter, r *http.Request
}
continue // Skip sending the status update, as the client is about to terminate and reload.
case "setAudienceDisplay":
screen, ok := data.(string)
mode, ok := data.(string)
if !ok {
ws.WriteError(fmt.Sprintf("Failed to parse '%s' message.", messageType))
continue
}
web.arena.AudienceDisplayMode = screen
web.arena.AudienceDisplayModeNotifier.Notify()
web.arena.SetAudienceDisplayMode(mode)
continue
case "setAllianceStationDisplay":
screen, ok := data.(string)
mode, ok := data.(string)
if !ok {
ws.WriteError(fmt.Sprintf("Failed to parse '%s' message.", messageType))
continue
}
web.arena.AllianceStationDisplayMode = screen
web.arena.AllianceStationDisplayModeNotifier.Notify()
web.arena.SetAllianceStationDisplayMode(mode)
continue
case "startTimeout":
durationSec, ok := data.(float64)