--[[ 通用语聊界面 ]] local UICommonVoiceChat = UIViewClass() function UICommonVoiceChat:OnOpened(context) self:RegistSystemEvent(EventID.SDK_OnVoiceRoomStateChange, self.RefreshVoiceUI) self.voiceRoomType = context.voiceRoomType self.isNeedServer = context.isNeedServer if self.isNeedServer then MDL.VoiceRoom.VoiceCallStateReq(self.voiceRoomType) end end function UICommonVoiceChat:RefreshVoiceUI() self.state_Listen:SetState(CTL.VoiceRoom.IsEnabledListener() and 0 or 1) self.state_Speak:SetState(CTL.VoiceRoom.IsEnabledMicrophone() and 0 or 1) end function UICommonVoiceChat:OnButtonClicked(comp) if comp == self.button_Listen then --收听 local listen, call = CTL.VoiceRoom.IsEnabledListener(), CTL.VoiceRoom.IsEnabledMicrophone() listen = not listen MDL.VoiceRoom.VoiceCallSetStateReq(self.voiceRoomType, call, listen) if listen then CTL.Tips.AddTipsMsg(Const_IDS["IDS_WarChannel_Listening"]) CTL.Sound.PlayGameSound("UI_voice_system") else CTL.Tips.AddTipsMsg(Const_IDS["IDS_WarChannel_NotListening"]) CTL.Sound.PlayGameSound("UI_invalid") end elseif comp == self.button_Speak then --麦克风 local listen, call = CTL.VoiceRoom.IsEnabledListener(), CTL.VoiceRoom.IsEnabledMicrophone() call = not call MDL.VoiceRoom.VoiceCallSetStateReq(self.voiceRoomType, call, listen) if call then CTL.Tips.AddTipsMsg(Const_IDS["IDS_WarChannel_NotSpeakingBtn"]) CTL.Sound.PlayGameSound("UI_voice_system") else CTL.Tips.AddTipsMsg(Const_IDS["IDS_WarChannel_SpeakingBtn"]) CTL.Sound.PlayGameSound("UI_invalid") end end end return UICommonVoiceChat