Muting a channel now stops you from transmitting, it acts sort of like deafen.
This commit is contained in:
parent
2e337db3c5
commit
356ff5a3a8
100
barnard.go
100
barnard.go
@ -9,6 +9,11 @@ import (
|
|||||||
"git.stormux.org/storm/barnard/uiterm"
|
"git.stormux.org/storm/barnard/uiterm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type TreeItem struct {
|
||||||
|
User *gumble.User
|
||||||
|
Channel *gumble.Channel
|
||||||
|
}
|
||||||
|
|
||||||
type Barnard struct {
|
type Barnard struct {
|
||||||
Config *gumble.Config
|
Config *gumble.Config
|
||||||
UserConfig *config.Config
|
UserConfig *config.Config
|
||||||
@ -35,4 +40,99 @@ type Barnard struct {
|
|||||||
|
|
||||||
exitStatus int
|
exitStatus int
|
||||||
exitMessage string
|
exitMessage string
|
||||||
|
|
||||||
|
// Added for channel muting
|
||||||
|
MutedChannels map[uint32]bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Barnard) StopTransmission() {
|
||||||
|
if b.Tx {
|
||||||
|
b.Notify("micdown", "me", "")
|
||||||
|
b.Tx = false
|
||||||
|
b.UpdateGeneralStatus(" Idle ", false)
|
||||||
|
b.Stream.StopSource()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Barnard) TreeItemCharacter(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm.TreeItem, ch rune) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Barnard) TreeItemKeyPress(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm.TreeItem, key uiterm.Key) {
|
||||||
|
treeItem := item.(TreeItem)
|
||||||
|
if key == uiterm.KeyEnter {
|
||||||
|
if treeItem.Channel != nil {
|
||||||
|
b.Client.Self.Move(treeItem.Channel)
|
||||||
|
b.SetSelectedUser(nil)
|
||||||
|
b.GotoChat()
|
||||||
|
}
|
||||||
|
if treeItem.User != nil {
|
||||||
|
if b.selectedUser == treeItem.User {
|
||||||
|
b.SetSelectedUser(nil)
|
||||||
|
b.GotoChat()
|
||||||
|
} else {
|
||||||
|
b.SetSelectedUser(treeItem.User)
|
||||||
|
b.GotoChat()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle mute toggle
|
||||||
|
if treeItem.Channel != nil {
|
||||||
|
if key == *b.Hotkeys.MuteToggle {
|
||||||
|
// Toggle mute for all users in channel
|
||||||
|
users := makeUsersArray(treeItem.Channel.Users)
|
||||||
|
for _, u := range users {
|
||||||
|
b.UserConfig.ToggleMute(u)
|
||||||
|
if u.AudioSource != nil {
|
||||||
|
if u.LocallyMuted {
|
||||||
|
u.AudioSource.SetGain(0)
|
||||||
|
} else {
|
||||||
|
u.AudioSource.SetGain(u.Volume)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle channel mute state
|
||||||
|
if b.MutedChannels[treeItem.Channel.ID] {
|
||||||
|
delete(b.MutedChannels, treeItem.Channel.ID)
|
||||||
|
} else {
|
||||||
|
b.MutedChannels[treeItem.Channel.ID] = true
|
||||||
|
// If this is the current channel, stop transmission
|
||||||
|
if b.Client.Self.Channel.ID == treeItem.Channel.ID && b.Tx {
|
||||||
|
b.StopTransmission()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b.UiTree.Rebuild()
|
||||||
|
b.Ui.Refresh()
|
||||||
|
}
|
||||||
|
if key == *b.Hotkeys.VolumeDown {
|
||||||
|
b.changeVolume(makeUsersArray(treeItem.Channel.Users), -0.1)
|
||||||
|
}
|
||||||
|
if key == *b.Hotkeys.VolumeUp {
|
||||||
|
b.changeVolume(makeUsersArray(treeItem.Channel.Users), 0.1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if treeItem.User != nil {
|
||||||
|
if key == *b.Hotkeys.MuteToggle {
|
||||||
|
// Toggle mute for single user
|
||||||
|
b.UserConfig.ToggleMute(treeItem.User)
|
||||||
|
if treeItem.User.AudioSource != nil {
|
||||||
|
if treeItem.User.LocallyMuted {
|
||||||
|
treeItem.User.AudioSource.SetGain(0)
|
||||||
|
} else {
|
||||||
|
treeItem.User.AudioSource.SetGain(treeItem.User.Volume)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
b.UiTree.Rebuild()
|
||||||
|
b.Ui.Refresh()
|
||||||
|
}
|
||||||
|
if key == *b.Hotkeys.VolumeDown {
|
||||||
|
b.changeVolume([]*gumble.User{treeItem.User}, -0.1)
|
||||||
|
}
|
||||||
|
if key == *b.Hotkeys.VolumeUp {
|
||||||
|
b.changeVolume([]*gumble.User{treeItem.User}, 0.1)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
1
main.go
1
main.go
@ -158,6 +158,7 @@ func main() {
|
|||||||
Config: gumble.NewConfig(),
|
Config: gumble.NewConfig(),
|
||||||
UserConfig: userConfig,
|
UserConfig: userConfig,
|
||||||
Address: *server,
|
Address: *server,
|
||||||
|
MutedChannels: make(map[uint32]bool),
|
||||||
}
|
}
|
||||||
b.Config.Buffers = *buffers
|
b.Config.Buffers = *buffers
|
||||||
|
|
||||||
|
24
ui.go
24
ui.go
@ -96,9 +96,6 @@ func (b *Barnard) OnTimestampToggle(ui *uiterm.Ui, key uiterm.Key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Barnard) UpdateGeneralStatus(text string, notice bool) {
|
func (b *Barnard) UpdateGeneralStatus(text string, notice bool) {
|
||||||
// if (b.UiStatus.Text == text) {
|
|
||||||
//return
|
|
||||||
//}
|
|
||||||
if notice {
|
if notice {
|
||||||
b.UiStatus.Fg = uiterm.ColorWhite | uiterm.AttrBold
|
b.UiStatus.Fg = uiterm.ColorWhite | uiterm.AttrBold
|
||||||
b.UiStatus.Bg = uiterm.ColorRed
|
b.UiStatus.Bg = uiterm.ColorRed
|
||||||
@ -146,6 +143,11 @@ func (b *Barnard) setTransmit(ui *uiterm.Ui, val int) {
|
|||||||
b.Notify("error", "me", "no tx while disconnected")
|
b.Notify("error", "me", "no tx while disconnected")
|
||||||
b.Tx = false
|
b.Tx = false
|
||||||
b.UpdateGeneralStatus("no tx while disconnected", true)
|
b.UpdateGeneralStatus("no tx while disconnected", true)
|
||||||
|
} else if b.MutedChannels[b.Client.Self.Channel.ID] {
|
||||||
|
// Check if current channel is muted
|
||||||
|
b.Notify("error", "me", "cannot transmit in muted channel")
|
||||||
|
b.Tx = false
|
||||||
|
b.UpdateGeneralStatus("cannot transmit in muted channel", true)
|
||||||
} else {
|
} else {
|
||||||
b.Tx = true
|
b.Tx = true
|
||||||
err := b.Stream.StartSource(b.UserConfig.GetInputDevice())
|
err := b.Stream.StartSource(b.UserConfig.GetInputDevice())
|
||||||
@ -155,9 +157,9 @@ func (b *Barnard) setTransmit(ui *uiterm.Ui, val int) {
|
|||||||
} else {
|
} else {
|
||||||
b.Notify("micup", "me", "")
|
b.Notify("micup", "me", "")
|
||||||
b.UpdateGeneralStatus(" Tx ", true)
|
b.UpdateGeneralStatus(" Tx ", true)
|
||||||
} //if error transmit
|
}
|
||||||
} //not transmitting
|
}
|
||||||
} //func
|
}
|
||||||
|
|
||||||
func (b *Barnard) OnMicVolumeDown(ui *uiterm.Ui, key uiterm.Key) {
|
func (b *Barnard) OnMicVolumeDown(ui *uiterm.Ui, key uiterm.Key) {
|
||||||
b.Stream.SetMicVolume(-0.1, true)
|
b.Stream.SetMicVolume(-0.1, true)
|
||||||
@ -241,11 +243,6 @@ func (b *Barnard) OnUiInitialize(ui *uiterm.Ui) {
|
|||||||
Bg: uiterm.ColorMagenta,
|
Bg: uiterm.ColorMagenta,
|
||||||
})
|
})
|
||||||
|
|
||||||
// ui.Add(uiViewTop, &uiterm.Label{
|
|
||||||
// Fg: uiterm.ColorWhite,
|
|
||||||
// Bg: uiterm.ColorBlue,
|
|
||||||
// })
|
|
||||||
|
|
||||||
b.UiStatus = uiterm.Label{
|
b.UiStatus = uiterm.Label{
|
||||||
Text: " Idle ",
|
Text: " Idle ",
|
||||||
Fg: uiterm.ColorBlack,
|
Fg: uiterm.ColorBlack,
|
||||||
@ -281,8 +278,6 @@ func (b *Barnard) OnUiInitialize(ui *uiterm.Ui) {
|
|||||||
}
|
}
|
||||||
ui.Add(uiViewTree, &b.UiTree)
|
ui.Add(uiViewTree, &b.UiTree)
|
||||||
|
|
||||||
//add this to see what your commands are coming in as raw strings
|
|
||||||
// b.Ui.AddCommandListener(b.CommandLog, "*")
|
|
||||||
b.Ui.AddCommandListener(b.CommandMicUp, "micup")
|
b.Ui.AddCommandListener(b.CommandMicUp, "micup")
|
||||||
b.Ui.AddCommandListener(b.CommandMicDown, "micdown")
|
b.Ui.AddCommandListener(b.CommandMicDown, "micdown")
|
||||||
b.Ui.AddCommandListener(b.CommandTalk, "toggle")
|
b.Ui.AddCommandListener(b.CommandTalk, "toggle")
|
||||||
@ -312,12 +307,9 @@ func (b *Barnard) OnUiResize(ui *uiterm.Ui, width, height int) {
|
|||||||
treeHeight = 0
|
treeHeight = 0
|
||||||
outputHeight = height - 4
|
outputHeight = height - 4
|
||||||
}
|
}
|
||||||
// ui.SetBounds(uiViewLogo, 0, 0, 9, 1)
|
|
||||||
ui.SetBounds(uiViewOutput, 0, 1, width, outputHeight+1)
|
ui.SetBounds(uiViewOutput, 0, 1, width, outputHeight+1)
|
||||||
ui.SetBounds(uiViewTree, 0, 1, width, treeHeight+1)
|
ui.SetBounds(uiViewTree, 0, 1, width, treeHeight+1)
|
||||||
ui.SetBounds(uiViewStatus, 0, height-2, width, height-1)
|
ui.SetBounds(uiViewStatus, 0, height-2, width, height-1)
|
||||||
ui.SetBounds(uiViewInputStatus, 0, height-1, len(b.GetInputStatus()), height)
|
ui.SetBounds(uiViewInputStatus, 0, height-1, len(b.GetInputStatus()), height)
|
||||||
//setting this to inputStatus+1 will leave one space between inputStatus and input box
|
|
||||||
//x starts at 0, so 10 chars of text will go from 0 to 9, there'll be a space at char 10, and we'll start at (10+1)=11
|
|
||||||
ui.SetBounds(uiViewInput, len(b.GetInputStatus())+1, height-1, width, height)
|
ui.SetBounds(uiViewInput, len(b.GetInputStatus())+1, height-1, width, height)
|
||||||
}
|
}
|
||||||
|
82
ui_tree.go
82
ui_tree.go
@ -6,11 +6,6 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TreeItem struct {
|
|
||||||
User *gumble.User
|
|
||||||
Channel *gumble.Channel
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ti TreeItem) String() string {
|
func (ti TreeItem) String() string {
|
||||||
if ti.User != nil {
|
if ti.User != nil {
|
||||||
if ti.User.LocallyMuted {
|
if ti.User.LocallyMuted {
|
||||||
@ -34,9 +29,6 @@ func (ti TreeItem) TreeItemStyle(fg, bg uiterm.Attribute, active bool) (uiterm.A
|
|||||||
return fg, bg
|
return fg, bg
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Barnard) TreeItemCharacter(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm.TreeItem, ch rune) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *Barnard) changeVolume(users []*gumble.User, change float32) {
|
func (b *Barnard) changeVolume(users []*gumble.User, change float32) {
|
||||||
for _, u := range users {
|
for _, u := range users {
|
||||||
au := u.AudioSource
|
au := u.AudioSource
|
||||||
@ -78,74 +70,6 @@ func makeUsersArray(users gumble.Users) []*gumble.User {
|
|||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Barnard) TreeItemKeyPress(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm.TreeItem, key uiterm.Key) {
|
|
||||||
treeItem := item.(TreeItem)
|
|
||||||
if key == uiterm.KeyEnter {
|
|
||||||
if treeItem.Channel != nil {
|
|
||||||
b.Client.Self.Move(treeItem.Channel)
|
|
||||||
b.SetSelectedUser(nil)
|
|
||||||
b.GotoChat()
|
|
||||||
}
|
|
||||||
if treeItem.User != nil {
|
|
||||||
if b.selectedUser == treeItem.User {
|
|
||||||
b.SetSelectedUser(nil)
|
|
||||||
b.GotoChat()
|
|
||||||
} else {
|
|
||||||
b.SetSelectedUser(treeItem.User)
|
|
||||||
b.GotoChat()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle mute toggle
|
|
||||||
if treeItem.Channel != nil {
|
|
||||||
if key == *b.Hotkeys.MuteToggle {
|
|
||||||
// Toggle mute for all users in channel
|
|
||||||
users := makeUsersArray(treeItem.Channel.Users)
|
|
||||||
for _, u := range users {
|
|
||||||
b.UserConfig.ToggleMute(u)
|
|
||||||
if u.AudioSource != nil {
|
|
||||||
if u.LocallyMuted {
|
|
||||||
u.AudioSource.SetGain(0)
|
|
||||||
} else {
|
|
||||||
u.AudioSource.SetGain(u.Volume)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.UiTree.Rebuild()
|
|
||||||
b.Ui.Refresh()
|
|
||||||
}
|
|
||||||
if key == *b.Hotkeys.VolumeDown {
|
|
||||||
b.changeVolume(makeUsersArray(treeItem.Channel.Users), -0.1)
|
|
||||||
}
|
|
||||||
if key == *b.Hotkeys.VolumeUp {
|
|
||||||
b.changeVolume(makeUsersArray(treeItem.Channel.Users), 0.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if treeItem.User != nil {
|
|
||||||
if key == *b.Hotkeys.MuteToggle {
|
|
||||||
// Toggle mute for single user
|
|
||||||
b.UserConfig.ToggleMute(treeItem.User)
|
|
||||||
if treeItem.User.AudioSource != nil {
|
|
||||||
if treeItem.User.LocallyMuted {
|
|
||||||
treeItem.User.AudioSource.SetGain(0)
|
|
||||||
} else {
|
|
||||||
treeItem.User.AudioSource.SetGain(treeItem.User.Volume)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.UiTree.Rebuild()
|
|
||||||
b.Ui.Refresh()
|
|
||||||
}
|
|
||||||
if key == *b.Hotkeys.VolumeDown {
|
|
||||||
b.changeVolume([]*gumble.User{treeItem.User}, -0.1)
|
|
||||||
}
|
|
||||||
if key == *b.Hotkeys.VolumeUp {
|
|
||||||
b.changeVolume([]*gumble.User{treeItem.User}, 0.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *Barnard) TreeItemBuild(item uiterm.TreeItem) []uiterm.TreeItem {
|
func (b *Barnard) TreeItemBuild(item uiterm.TreeItem) []uiterm.TreeItem {
|
||||||
if b.Client == nil {
|
if b.Client == nil {
|
||||||
return nil
|
return nil
|
||||||
@ -195,6 +119,12 @@ func (b *Barnard) TreeItemBuild(item uiterm.TreeItem) []uiterm.TreeItem {
|
|||||||
return cl[i].Name < cl[j].Name
|
return cl[i].Name < cl[j].Name
|
||||||
})
|
})
|
||||||
for _, subchannel := range cl {
|
for _, subchannel := range cl {
|
||||||
|
displayName := subchannel.Name
|
||||||
|
if b.MutedChannels[subchannel.ID] {
|
||||||
|
displayName = "[MUTED] #" + displayName
|
||||||
|
} else {
|
||||||
|
displayName = "#" + displayName
|
||||||
|
}
|
||||||
channels = append(channels, TreeItem{
|
channels = append(channels, TreeItem{
|
||||||
Channel: subchannel,
|
Channel: subchannel,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user