Add match sound muting.

This commit is contained in:
Patrick Fairbank
2015-03-28 19:45:49 -07:00
parent 8d8068641b
commit e8b307bf24
5 changed files with 45 additions and 14 deletions

View File

@@ -87,6 +87,7 @@ type Arena struct {
savedMatchResult *MatchResult
leftGoalHotFirst bool
lights Lights
muteMatchSounds bool
}
var mainArena Arena // Named thusly to avoid polluting the global namespace with something more generic.
@@ -99,10 +100,10 @@ func NewRealtimeScore() *RealtimeScore {
// Sets the arena to its initial state.
func (arena *Arena) Setup() {
arena.matchTiming.AutoDurationSec = 10
arena.matchTiming.AutoDurationSec = 15
arena.matchTiming.PauseDurationSec = 2
arena.matchTiming.TeleopDurationSec = 140
arena.matchTiming.EndgameTimeLeftSec = 30
arena.matchTiming.TeleopDurationSec = 135
arena.matchTiming.EndgameTimeLeftSec = 20
arena.AllianceStations = make(map[string]*AllianceStation)
arena.AllianceStations["R1"] = new(AllianceStation)
@@ -360,7 +361,9 @@ func (arena *Arena) AbortMatch() error {
arena.MatchState = POST_MATCH
arena.audienceDisplayScreen = "blank"
arena.audienceDisplayNotifier.Notify(nil)
arena.playSoundNotifier.Notify("match-abort")
if !arena.muteMatchSounds {
arena.playSoundNotifier.Notify("match-abort")
}
return nil
}
@@ -376,6 +379,7 @@ func (arena *Arena) ResetMatch() error {
arena.AllianceStations["B1"].Bypass = false
arena.AllianceStations["B2"].Bypass = false
arena.AllianceStations["B3"].Bypass = false
arena.muteMatchSounds = false
return nil
}
@@ -412,7 +416,9 @@ func (arena *Arena) Update() {
sendDsPacket = true
arena.audienceDisplayScreen = "match"
arena.audienceDisplayNotifier.Notify(nil)
arena.playSoundNotifier.Notify("match-start")
if !arena.muteMatchSounds {
arena.playSoundNotifier.Notify("match-start")
}
case AUTO_PERIOD:
auto = true
enabled = true
@@ -421,7 +427,9 @@ func (arena *Arena) Update() {
auto = false
enabled = false
sendDsPacket = true
arena.playSoundNotifier.Notify("match-end")
if !arena.muteMatchSounds {
arena.playSoundNotifier.Notify("match-end")
}
}
case PAUSE_PERIOD:
auto = false
@@ -431,7 +439,9 @@ func (arena *Arena) Update() {
auto = false
enabled = true
sendDsPacket = true
arena.playSoundNotifier.Notify("match-resume")
if !arena.muteMatchSounds {
arena.playSoundNotifier.Notify("match-resume")
}
}
case TELEOP_PERIOD:
auto = false
@@ -440,7 +450,9 @@ func (arena *Arena) Update() {
arena.matchTiming.TeleopDurationSec-arena.matchTiming.EndgameTimeLeftSec) {
arena.MatchState = ENDGAME_PERIOD
sendDsPacket = false
arena.playSoundNotifier.Notify("match-endgame")
if !arena.muteMatchSounds {
arena.playSoundNotifier.Notify("match-endgame")
}
}
case ENDGAME_PERIOD:
auto = false
@@ -459,7 +471,9 @@ func (arena *Arena) Update() {
arena.allianceStationDisplayScreen = "logo"
arena.allianceStationDisplayNotifier.Notify(nil)
}()
arena.playSoundNotifier.Notify("match-end")
if !arena.muteMatchSounds {
arena.playSoundNotifier.Notify("match-end")
}
}
}

View File

@@ -295,6 +295,15 @@ func MatchPlayWebsocketHandler(w http.ResponseWriter, r *http.Request) {
}
mainArena.AllianceStations[station].Bypass = !mainArena.AllianceStations[station].Bypass
case "startMatch":
args := struct {
MuteMatchSounds bool
}{}
err = mapstructure.Decode(data, &args)
if err != nil {
websocket.WriteError(err.Error())
continue
}
mainArena.muteMatchSounds = args.MuteMatchSounds
err = mainArena.StartMatch()
if err != nil {
websocket.WriteError(err.Error())

View File

@@ -16,7 +16,7 @@ import (
)
var rules = []string{"G4", "G5", "G6", "G6-1", "G16", "G17", "G18", "G19", "G20", "G21", "G22", "G23", "G24",
"G26", "G30", "G31", "G33", "G34", }
"G26", "G30", "G31", "G33", "G34"}
// Renders the referee interface for assigning fouls.
func RefereeDisplayHandler(w http.ResponseWriter, r *http.Request) {
@@ -136,9 +136,9 @@ func RefereeDisplayWebsocketHandler(w http.ResponseWriter, r *http.Request) {
switch messageType {
case "addFoul":
args := struct {
Alliance string
TeamId int
Rule string
Alliance string
TeamId int
Rule string
}{}
err = mapstructure.Decode(data, &args)
if err != nil {

View File

@@ -18,7 +18,7 @@ var toggleBypass = function(station) {
// Sends a websocket message to start the match.
var startMatch = function() {
websocket.send("startMatch");
websocket.send("startMatch", { muteMatchSounds: $("#muteMatchSounds").prop("checked") });
};
// Sends a websocket message to abort the match.

View File

@@ -150,6 +150,14 @@
<p><span class="label label-scoring" id="refereeScoreStatus">Referee</span><br />
<span class="label label-scoring" id="redScoreStatus">Red Scoring</span><br />
<span class="label label-scoring" id="blueScoreStatus">Blue Scoring</span></p>
<br />
<p>Match Sounds</p>
<div class="checkbox">
<label>
<input type="checkbox" id="muteMatchSounds">
Mute
</label>
</div>
</div>
<div class="col-lg-4">
Alliance Station Display