Add mnemonic mute controls
This commit is contained in:
@@ -205,6 +205,46 @@ func (b *Barnard) OnVoiceToggle(ui *uiterm.Ui, key uiterm.Key) {
|
||||
b.setTransmit(ui, 2)
|
||||
}
|
||||
|
||||
func (b *Barnard) OnSelfMuteToggle(ui *uiterm.Ui, key uiterm.Key) {
|
||||
b.toggleSelfMute()
|
||||
}
|
||||
|
||||
func (b *Barnard) selfMuted() bool {
|
||||
if b.Client == nil || b.Client.Self == nil {
|
||||
return false
|
||||
}
|
||||
muted := false
|
||||
b.Client.Do(func() { muted = b.Client.Self.SelfMuted })
|
||||
return muted
|
||||
}
|
||||
|
||||
func (b *Barnard) setSelfMute(muted bool) {
|
||||
if !b.isConnected() || b.Client == nil || b.Client.Self == nil {
|
||||
b.Notify("error", "me", "cannot change self mute while disconnected")
|
||||
b.UpdateGeneralStatus("cannot change self mute while disconnected", true)
|
||||
return
|
||||
}
|
||||
if b.selfMuted() == muted {
|
||||
return
|
||||
}
|
||||
if muted && b.isTransmitting() {
|
||||
b.StopTransmission()
|
||||
}
|
||||
b.Client.Self.SetSelfMuted(muted)
|
||||
event := "unmute"
|
||||
line := "You unmuted yourself"
|
||||
if muted {
|
||||
event = "mute"
|
||||
line = "You muted yourself"
|
||||
}
|
||||
b.Notify(event, "me", "")
|
||||
b.AddOutputLine(line)
|
||||
}
|
||||
|
||||
func (b *Barnard) toggleSelfMute() {
|
||||
b.setSelfMute(!b.selfMuted())
|
||||
}
|
||||
|
||||
func (b *Barnard) CommandLog(ui *uiterm.Ui, cmd string) {
|
||||
b.AddOutputLine("command " + cmd)
|
||||
}
|
||||
@@ -381,6 +421,10 @@ func (b *Barnard) setTransmit(ui *uiterm.Ui, val int) {
|
||||
b.Notify("error", "me", "cannot transmit in muted channel")
|
||||
b.setTransmitting(false)
|
||||
b.UpdateGeneralStatus("cannot transmit in muted channel", true)
|
||||
} else if b.selfMuted() {
|
||||
b.Notify("error", "me", "cannot transmit while self-muted")
|
||||
b.setTransmitting(false)
|
||||
b.UpdateGeneralStatus("cannot transmit while self-muted", true)
|
||||
} else {
|
||||
b.setTransmitting(true)
|
||||
if b.ToneTest {
|
||||
@@ -640,6 +684,7 @@ func (b *Barnard) OnUiInitialize(ui *uiterm.Ui) {
|
||||
b.Ui.AddKeyListener(b.OnFocusPress, b.Hotkeys.SwitchViews)
|
||||
b.Ui.AddKeyListener(b.OnAdminMenuPress, b.Hotkeys.AdminMenu)
|
||||
b.Ui.AddKeyListener(b.OnVoiceToggle, b.Hotkeys.Talk)
|
||||
b.Ui.AddKeyListener(b.OnSelfMuteToggle, b.Hotkeys.SelfMuteToggle)
|
||||
b.Ui.AddKeyListener(b.OnTimestampToggle, b.Hotkeys.ToggleTimestamps)
|
||||
b.Ui.AddKeyListener(b.OnNoiseSuppressionToggle, b.Hotkeys.NoiseSuppressionToggle)
|
||||
b.Ui.AddKeyListener(b.OnAGCToggle, b.Hotkeys.AGCToggle)
|
||||
|
||||
Reference in New Issue
Block a user