mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 21:56:50 -04:00
Add sound when match result is shown (closes #120).
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -69,5 +69,11 @@ func UpdateMatchSounds() {
|
||||
-1,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"match_result",
|
||||
"wav",
|
||||
-1,
|
||||
false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
BIN
static/audio/match_result.wav
Normal file
BIN
static/audio/match_result.wav
Normal file
Binary file not shown.
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user