def load(self, src, pList, settings, forceLoad): if not SoundSettingsLoader.IS_VOICE_CHAT_DEVICES_REFRESHED: SoundSettingsLoader.IS_VOICE_CHAT_DEVICES_REFRESHED = True VOIP.api().requestCaptureDevices() for flashKey, SettingsKey in SOUND_SETTINGS_DICT.iteritems(): setattr(src, flashKey, settings.getSoundSettings()['volume'][SettingsKey]) for flashKey, SettingsKey in Settings.SOUND_PARAMETERS.iteritems(): setattr(src, flashKey, settings.getSoundSettings()['volumeEnabled'][SettingsKey]) voipPrefs = settings.getVoipSettings() for flashKey, SettingsKey in Settings.VOIP_PARAMETERS_DICT.iteritems(): if SettingsKey == 'isVoipEnabled': src.enableVoiceChat = voipPrefs[SettingsKey] and VOIP.api().voipSupported elif SettingsKey == 'captureDevice': src.voiceChatMicDevice.index = -1 src.voiceChatMicDevice.data = [voipPrefs[SettingsKey]] else: setattr(src, flashKey, voipPrefs[SettingsKey]) src.voiceChatMicActivationButtonId = InputMapping.CMD_PUSH_TO_TALK src.voiceChatMicActivationButtonId2 = InputMapping.CMD_PUSH_TO_TALK_SQUAD src.voiceChatMicActivationButtonId3 = InputMapping.CMD_TOGGLE_ARENA_VOICE_CHANNEL src.isVoiceChatVisible = VOIP.api().voipSupported src.isArenaVoiceChatVisible = VOIP.api().arenaChannelSupported src.qualitySound.data = [ localizeOptions(quality) for quality in QUALITY_SOUND_LOC ] src.qualitySound.index = SOUND_QUALITY_IDX_DICT[settings.getSoundSettings()['quality']] src.soundType.data = [ localizeOptions(id) for id in SOUND_TYPE_LOC ] src.soundType.index = settings.getSoundSettings()['speakerPreset'] self._isLoaded = True
def fini(): global g_scenario LOG_DEBUG('fini') if OfflineMode.enabled(): return else: BigWorld.wg_setScreenshotNotifyCallback(None) if g_postProcessing is None: return g_critMemHandler.restore() g_critMemHandler.destroy() if constants.IS_CAT_LOADED: import Cat Cat.fini() MusicControllerWWISE.destroy() if RSSDownloader.g_downloader is not None: RSSDownloader.g_downloader.destroy() connectionManager.onConnected -= onConnected connectionManager.onDisconnected -= onDisconnected MessengerEntry.g_instance.fini() g_postProcessing.fini() from helpers import EdgeDetectColorController if EdgeDetectColorController.g_instance is not None: EdgeDetectColorController.g_instance.destroy() EdgeDetectColorController.g_instance = None BigWorld.resetEntityManager(False, False) BigWorld.clearAllSpaces() if TriggersManager.g_manager is not None: TriggersManager.g_manager.destroy() TriggersManager.g_manager = None gui_personality.fini() tutorialLoaderFini() import LcdKeyboard LcdKeyboard.finalize() import Vibroeffects if Vibroeffects.VibroManager.g_instance is not None: Vibroeffects.VibroManager.g_instance.destroy() Vibroeffects.VibroManager.g_instance = None if g_replayCtrl is not None: g_replayCtrl.destroy() from LightFx import LightManager if LightManager.g_instance is not None: LightManager.g_instance.destroy() LightManager.g_instance = None import AuxiliaryFx if AuxiliaryFx.g_instance is not None: AuxiliaryFx.g_instance.destroy() AuxiliaryFx.g_instance = None from predefined_hosts import g_preDefinedHosts if g_preDefinedHosts is not None: g_preDefinedHosts.fini() voipRespHandler = VOIP.getVOIPManager() if voipRespHandler is not None: VOIP.getVOIPManager().destroy() import SoundGroups SoundGroups.g_instance.destroy() Settings.g_instance.save() if g_scenario is not None: g_scenario.fini() return
def __onJoinedChannel(self, channel, isTestChannel, isRejoin): if self.isVOIPEnabled(): keyCode = CommandMapping.g_instance.get('CMD_VOICECHAT_MUTE') if BigWorld.isKeyDown(keyCode): VOIP.getVOIPManager().setMicMute(False) g_messengerEvents.voip.onChannelEntered(channel, isTestChannel, isRejoin)
def dispossessUI(self): LOG_DEBUG('dispossessUI') self.__clearVoiceChatMicDeviceCallback() VOIP.api().localTestMode = False VOIP.api().clearEventCaptureDevicesUpdated() player = BigWorld.player() from Account import PlayerAccount if player is not None and player.__class__ == PlayerAccount: player.onInitPremium -= self.__onPremiumChanged Settings.g_instance.eChangedGraphicsDetails -= self.__onChangeGraphicsDetails GlobalEvents.onRefreshResolutions -= self.__handleRefreshResolutions InputMapping.g_instance.onProfileLoaded -= self.__inputProfileChanged for command in self.__externalCallbacks.iterkeys(): self.uiHolder.removeExternalCallback(command) self.__externalCallbacks = None self.__eUpdateSettings() self.__gameOptionsManager.destroy() self.__gameOptionsManager = None Settings.g_instance.cmdFilter = list() self.__virtualJoystick.dispose() self.__virtualJoystick = None self.__virtualGamePad.dispose() self.__virtualGamePad = None self.__virtualJoystickProfile.dispose() self.__virtualJoystickProfile = None Settings.g_instance.save() UIInterface.dispossessUI(self) return
def save(self, value): voipCaptureDevices = Settings.g_instance.voipCaptureDevices deviceIndex = int(value) if 0 <= deviceIndex < len(voipCaptureDevices): device = voipCaptureDevices[deviceIndex] Settings.g_instance.setVoipValue('captureDevice', device) VOIP.api().updateSettings(captureDevice=device)
def dispossessUI(self, proxy): if self.uiHolder != proxy: return import VOIP VOIP.getVOIPManager().channelsMgr.onInitialized -= self.__initResponse VOIP.getVOIPManager().OnCaptureDevicesUpdated -= self.__captureDevicesResponse chatManager.unsubscribeChatAction(self.processFailedMessage, CHAT_ACTIONS.VOIPSettings) UIInterface.dispossessUI(self)
def populateUI(self, proxy): UIInterface.populateUI(self, proxy) chatManager.subscribeChatAction(self.processFailedMessage, CHAT_ACTIONS.VOIPSettings) import VOIP VOIP.getVOIPManager().channelsMgr.onInitialized += self.__initResponse VOIP.getVOIPManager( ).OnCaptureDevicesUpdated += self.__captureDevicesResponse
def updateCaptureDevices(self): Waiting.show('__updateCaptureDevices') devices = yield self.app.voiceChatManager.requestCaptureDevices() currentCaptureDeviceIdx = -1 if VOIP.getVOIPManager().currentCaptureDevice in devices: currentCaptureDeviceIdx = devices.index(VOIP.getVOIPManager().currentCaptureDevice) value = [ d.decode(sys.getfilesystemencoding()).encode('utf-8') for d in devices ] Waiting.hide('__updateCaptureDevices') self.as_setCaptureDevicesS(currentCaptureDeviceIdx, value)
def save(self, value): Settings.g_instance.setVoipValue(self.__SettingsKey, value) if self.__SettingsKey == 'isVoipEnabled': VOIP.api().enabled = value else: key = self.__voipKey if self.__voipKey is not None else self.__SettingsKey kwargs = {key: value} VOIP.api().updateSettings(**kwargs) return
def setUserMuted(self, userId, mute): try: dbid = int(userId) except: LOG_DEBUG( "Xmpp chat: setUserMuted can not request non int value '%s'" % userId) return VOIP.api().setClientMuted(dbid, mute)
def dispossessUI(self, proxy): if self.uiHolder != proxy: return import VOIP VOIP.getVOIPManager().channelsMgr.onInitialized -= self.__initResponse VOIP.getVOIPManager( ).OnCaptureDevicesUpdated -= self.__captureDevicesResponse chatManager.unsubscribeChatAction(self.processFailedMessage, CHAT_ACTIONS.VOIPSettings) UIInterface.dispossessUI(self)
def editMuteList(self, userId, operationType): self._logger.debug( "editMuteList fromFlash : userId = '{0}', operationType = '{1}'". format(userId, operationType)) operation = int(operationType) operation = bool(operation) self._logger.debug( "editMuteList: userId = '{0}', operationType = '{1}'".format( userId, operation)) VOIP.api().setAvatarMuted(userId, operationType)
def __voiceChatEnable(self, isEnable): if BattleReplay.isPlaying(): return if isEnable is None: return preveVoIP = Settings.g_instance.userPrefs.readBool(Settings.KEY_ENABLE_VOIP) import VOIP if preveVoIP != isEnable: VOIP.getVOIPManager().enable(isEnable) Settings.g_instance.userPrefs.writeBool(Settings.KEY_ENABLE_VOIP, bool(isEnable)) LOG_NOTE('Change state of voip: %s' % str(isEnable))
def __onJoinedChannel(self, data): """ This is callback for VOIPManager's 'onJoinedChannel' event. After joining at channel, check if user presses PTY button to enable a MIC. For example, after echo-test, user can still pressing a button, enable mic in this case @param data: channel data """ if self.isVOIPEnabled(): keyCode = CommandMapping.g_instance.get('CMD_VOICECHAT_MUTE') if BigWorld.isKeyDown(keyCode): VOIP.getVOIPManager().setMicMute(False)
def _set(self, isEnable): if isEnable is None: return else: prevVoIP = self._get() if prevVoIP != isEnable: VOIP.getVOIPManager().enable(isEnable) from gui.WindowsManager import g_windowsManager if g_windowsManager.battleWindow is not None and not isEnable: g_windowsManager.battleWindow.speakingPlayersReset() LOG_NOTE('Change state of voip:', isEnable) return
def requestCaptureDevices(self, callback): import VOIP if VOIP.getVOIPManager().vivoxDomain == '': LOG_ERROR('RequestCaptureDevices. Vivox is not supported') callback([]) return if not self.ready: LOG_ERROR('RequestCaptureDevices. Vivox has not been initialized') callback([]) return self.__callback = callback VOIP.getVOIPManager().requestCaptureDevices()
def updateCaptureDevices(self): Waiting.show('__updateCaptureDevices') devices = yield self.app.voiceChatManager.requestCaptureDevices() currentCaptureDeviceIdx = -1 if VOIP.getVOIPManager().currentCaptureDevice in devices: currentCaptureDeviceIdx = devices.index( VOIP.getVOIPManager().currentCaptureDevice) value = [ d.decode(sys.getfilesystemencoding()).encode('utf-8') for d in devices ] Waiting.hide('__updateCaptureDevices') self.as_setCaptureDevicesS(currentCaptureDeviceIdx, value)
def __voiceChatEnable(self, isEnable): if isEnable is None: return else: preveVoIP = Settings.g_instance.userPrefs.readBool(Settings.KEY_ENABLE_VOIP) import VOIP if preveVoIP != isEnable: VOIP.getVOIPManager().enable(isEnable) Settings.g_instance.userPrefs.writeBool(Settings.KEY_ENABLE_VOIP, bool(isEnable)) from gui.WindowsManager import g_windowsManager if g_windowsManager.battleWindow is not None and not isEnable: g_windowsManager.battleWindow.speakingPlayersReset() LOG_NOTE('Change state of voip: %s' % str(isEnable)) return
def doLeaveWorld(self): self.__isBattleUILoaded = False self.__eventManager.clear() for avatarInfo in self.avatarInfos.values(): self.__destroyObjectControllers(avatarInfo) for objData in self.__allObjectsData.itervalues(): self.__destroyObjectControllers(objData) VOIP.api().unsubscribeMemberStateObserversByType( consts.VOIP.MEMBER_STATUS_OBSERVER_TYPES.ARENA_HUD) self.gameMode.destroy() self._gameActionsManager.cleanup() self._gameActionsManager = None return
def requestCaptureDevices(self, firstTime = False, callback = None): """ Request sound devices which can capture sound. This method is used by SettingsWindow to show devices in a drop-down list. :param firstTime: is it the first time? (the controller itself passes True during initialization another external classes should pass False or nothing) :param callback: the list of devices will come in the callback """ voipMgr = VOIP.getVOIPManager() if voipMgr.getVOIPDomain() == '': LOG_WARNING('RequestCaptureDevices. Vivox is not supported') callback([]) return if not self.isReady(): LOG_WARNING('RequestCaptureDevices. Vivox has not been initialized') callback([]) return options = self.settingsCore.options def resetCapturedDevice(devices, firstTime = firstTime): if firstTime: option = options.getSetting(SOUND.CAPTURE_DEVICES) option.apply(option.get(), firstTime) callback(devices) self.__captureDevicesCallbacks.append(resetCapturedDevice) voipMgr.requestCaptureDevices()
def requestCaptureDevices(self, firstTime = False, callback = None): """ Request sound devices which can capture sound. This method is used by SettingsWindow to show devices in a drop-down list. :param firstTime: is it the first time? (the controller itself passes True during initialization another external classes should pass False or nothing) :param callback: the list of devices will come in the callback """ voipMgr = VOIP.getVOIPManager() if voipMgr.getVOIPDomain() == '': LOG_WARNING('RequestCaptureDevices. Vivox is not supported') callback([]) return if not self.isReady(): LOG_WARNING('RequestCaptureDevices. Vivox has not been initialized') callback([]) return def resetCapturedDevice(devices, firstTime = firstTime): if firstTime: option = g_settingsCore.options.getSetting(SOUND.CAPTURE_DEVICES) option.apply(option.get(), firstTime) callback(devices) self.__captureDevicesCallbacks.append(resetCapturedDevice) voipMgr.requestCaptureDevices()
def _set(self, value): vm = VOIP.getVOIPManager() if len(vm.captureDevices): device = vm.captureDevices[0] if len(vm.captureDevices) > value: device = vm.captureDevices[int(value)] vm.setCaptureDevice(device)
def __onChangeFocus(self, _, focused): self.__updateHistoryControls() if focused: responseHandler = VOIP.getVOIPManager() if responseHandler is not None and responseHandler.getCurrentChannel(): responseHandler.setMicMute(muted=True) self.__focused = focused
def _getVIOPState(key): voipMgr = VOIP.getVOIPManager() if IS_CHINA or not voipMgr.isVoiceSupported(): return 'withoutVOIP' if key == Keys.KEY_NONE: return 'specifyVOIP' return 'disableVOIP' if voipMgr.isEnabled() and voipMgr.isCurrentChannelEnabled() else 'enableVOIP'
def onProcessVivoxTest(self, callbackId, isStart): LOG_DEBUG("Vivox test: %s" % str(isStart)) import VOIP rh = VOIP.getVOIPManager() rh.enterTestChannel() if isStart else rh.leaveTestChannel() self.respond([callbackId, False])
def setMicrophoneMute(self, isMuted, force=False): voipMgr = VOIP.getVOIPManager() if voipMgr is not None: if force or voipMgr.getCurrentChannel( ) and not voipMgr.isInTesting(): voipMgr.setMicMute(muted=isMuted) return
def _populate(self): View._populate(self) self.__currIgrType = gui.game_control.g_instance.igr.getRoomType() g_prbLoader.setEnabled(True) self.addListener(events.LobbySimpleEvent.SHOW_HELPLAYOUT, self.__showHelpLayout, EVENT_BUS_SCOPE.LOBBY) self.addListener(events.LobbySimpleEvent.CLOSE_HELPLAYOUT, self.__closeHelpLayout, EVENT_BUS_SCOPE.LOBBY) g_playerEvents.onVehicleBecomeElite += self.__onVehicleBecomeElite self.app.loaderManager.onViewLoadInit += self.__onViewLoadInit self.app.loaderManager.onViewLoaded += self.__onViewLoaded self.app.loaderManager.onViewLoadError += self.__onViewLoadError game_control.g_instance.igr.onIgrTypeChanged += self.__onIgrTypeChanged self.__showBattleResults() self.fireEvent(events.GUICommonEvent(events.GUICommonEvent.LOBBY_VIEW_LOADED)) keyCode = CommandMapping.g_instance.get('CMD_VOICECHAT_MUTE') if not BigWorld.isKeyDown(keyCode): VOIP.getVOIPManager().setMicMute(True)
def __voiceChatEnable(self, isEnable): if isEnable is None: return else: preveVoIP = Settings.g_instance.userPrefs.readBool( Settings.KEY_ENABLE_VOIP) import VOIP if preveVoIP != isEnable: VOIP.getVOIPManager().enable(isEnable) Settings.g_instance.userPrefs.writeBool( Settings.KEY_ENABLE_VOIP, bool(isEnable)) from gui.WindowsManager import g_windowsManager if g_windowsManager.battleWindow is not None and not isEnable: g_windowsManager.battleWindow.speakingPlayersReset() LOG_NOTE('Change state of voip: %s' % str(isEnable)) return
def getPlayerStatus(self, vo, isTeamKiller=False): status = super(PlayerTeamOverrides, self).getPlayerStatus(vo) voipMgr = VOIP.getVOIPManager() if self.personal.vehicleID == vo.vehicleID and vo.isSquadMan( ) and self.__isVoipSupported and not (voipMgr.isEnabled( ) and voipMgr.isCurrentChannelEnabled()) and not self.isReplayPlaying: status |= _P_STATUS.IS_VOIP_DISABLED return status
def __onChangeFocus(self, _, focused): LOG_DEBUG('[BattleMessanger]', '__onChangeFocus = %s' % focused) if focused: responseHandler = VOIP.getVOIPManager() if responseHandler is not None and responseHandler.channelsMgr.currentChannel: responseHandler.setMicMute(muted=True) self.__focused = focused return
def __captureDevicesResponse(self): """ This is callback for VOIPManager's 'onCaptureDevicesUpdated' event. We will notify subscribers with device list. """ devices = VOIP.getVOIPManager().getCaptureDevices() while self.__captureDevicesCallbacks: self.__captureDevicesCallbacks.pop(0)(devices)
def __onChangeFocus(self, _, focused): self.__updateHistoryControls() if focused: responseHandler = VOIP.getVOIPManager() if responseHandler is not None and responseHandler.getCurrentChannel(): responseHandler.setMicMute(muted=True) self.__focused = focused return
def startVOIPTest(self, isStart): LOG_DEBUG('Vivox test: %s' % str(isStart)) rh = VOIP.getVOIPManager() if isStart: rh.enterTestChannel() else: rh.leaveTestChannel() return False
def __canShowHint(self): if self.__isObserver or self.sessionProvider.isReplayPlaying or self.__wasDisplayed or self.__areOtherIndicatorsShown(): return False voipMgr = VOIP.getVOIPManager() if voipMgr: if not voipMgr.isVoiceSupported(): return False keyName = getReadableKey(CommandMapping.CMD_VOICECHAT_ENABLE) return False if not keyName else self._haveHintsLeft(self.__settings)
def start(self): voipMgr = VOIP.getVOIPManager() voipMgr.onInitialized += self.__initResponse voipMgr.onFailedToConnect += self.__failedResponse voipMgr.onCaptureDevicesUpdated += self.__captureDevicesResponse voipMgr.onPlayerSpeaking += self.__onPlayerSpeaking voipMgr.onStateToggled += self.__onStateToggled voipMgr.onJoinedChannel += self.__onJoinedChannel self.__initialize()
def isPlayerSpeaking(self, accountDBID): """ Implement IVOIPChatController interface, see its description. :param accountDBID: player dbID :return: bool """ if self.isVOIPEnabled(): return bool(VOIP.getVOIPManager().isParticipantTalking(accountDBID)) return False
def stop(self): voipMgr = VOIP.getVOIPManager() voipMgr.onInitialized -= self.__initResponse voipMgr.onFailedToConnect -= self.__failedResponse voipMgr.onCaptureDevicesUpdated -= self.__captureDevicesResponse voipMgr.onPlayerSpeaking -= self.__onPlayerSpeaking voipMgr.onStateToggled -= self.__onStateToggled voipMgr.onJoinedChannel -= self.__onJoinedChannel self.__callbacks = [] self.__captureDevicesCallbacks = []
def _populate(self): View._populate(self) self.__currIgrType = gui.game_control.g_instance.igr.getRoomType() g_prbLoader.setEnabled(True) self.addListener(events.LobbySimpleEvent.SHOW_HELPLAYOUT, self.__showHelpLayout, EVENT_BUS_SCOPE.LOBBY) self.addListener(events.LobbySimpleEvent.CLOSE_HELPLAYOUT, self.__closeHelpLayout, EVENT_BUS_SCOPE.LOBBY) self.addListener(events.GameEvent.SCREEN_SHOT_MADE, self.__handleScreenShotMade, EVENT_BUS_SCOPE.GLOBAL) g_playerEvents.onVehicleBecomeElite += self.__onVehicleBecomeElite self.app.loaderManager.onViewLoadInit += self.__onViewLoadInit self.app.loaderManager.onViewLoaded += self.__onViewLoaded self.app.loaderManager.onViewLoadError += self.__onViewLoadError game_control.g_instance.igr.onIgrTypeChanged += self.__onIgrTypeChanged self.__showBattleResults() battlesCount = g_itemsCache.items.getAccountDossier().getTotalStats().getBattlesCount() g_lobbyContext.updateBattlesCount(battlesCount) self.fireEvent(events.GUICommonEvent(events.GUICommonEvent.LOBBY_VIEW_LOADED)) keyCode = CommandMapping.g_instance.get('CMD_VOICECHAT_MUTE') if not BigWorld.isKeyDown(keyCode): VOIP.getVOIPManager().setMicMute(True)
def setMicrophoneMute(self, isMuted, force = False): """ Sets local microphone mute. :param isMuted: is muted. :param force: is necessary to check whether EchoTest in progress and currentChannel exists """ voipMgr = VOIP.getVOIPManager() if voipMgr is not None: if force or voipMgr.getCurrentChannel() and not voipMgr.isInTesting(): voipMgr.setMicMute(muted=isMuted) return
def start(self): """ Subscribe on VOIP manager events and initialize VOIP manager, internal variables. """ voipMgr = VOIP.getVOIPManager() voipMgr.onInitialized += self.__initResponse voipMgr.onFailedToConnect += self.__failedResponse voipMgr.onCaptureDevicesUpdated += self.__captureDevicesResponse voipMgr.onPlayerSpeaking += self.__onPlayerSpeaking voipMgr.onStateToggled += self.__onStateToggled self.__initialize()
def stop(self): """ Tell the controller to stop working. It will unsubscribe from VOIP manager events and reset flags, internal variables """ voipMgr = VOIP.getVOIPManager() voipMgr.onInitialized -= self.__initResponse voipMgr.onFailedToConnect -= self.__failedResponse voipMgr.onCaptureDevicesUpdated -= self.__captureDevicesResponse voipMgr.onPlayerSpeaking -= self.__onPlayerSpeaking voipMgr.onStateToggled -= self.__onStateToggled self.__callbacks = [] self.__captureDevicesCallbacks = []
def dispossessUI(self, proxy): if self.uiHolder != proxy: return import VOIP VOIP.getVOIPManager().channelsMgr.onInitialized -= self.__initResponse VOIP.getVOIPManager().OnCaptureDevicesUpdated -= self.__captureDevicesResponse VOIP.getVOIPManager().channelsMgr.onFailedToConnect -= self.processFailedMessage UIInterface.dispossessUI(self)
def initialize(self, domain, callback): import VOIP rh = VOIP.getVOIPManager() if domain == '': LOG_ERROR('Initialize. Vivox is not supported') self.__state = VC_STATES.Failed callback(False) return if self.__state == VC_STATES.Initialized: callback(True) return self.__callback = callback rh.enable(Settings.g_instance.userPrefs.readBool(Settings.KEY_ENABLE_VOIP)) rh.initialize(domain)
def __changeCaptureDevice(self, captureDeviceIdx): if captureDeviceIdx is None or captureDeviceIdx == -1: return else: import VOIP rh = VOIP.getVOIPManager() devices = [ device.decode(sys.getfilesystemencoding()).encode('utf-8') for device in rh.captureDevices ] if captureDeviceIdx < len(devices): newCaptureDevice = devices[captureDeviceIdx] previousDevice = Settings.g_instance.userPrefs.readString(Settings.KEY_VOIP_DEVICE) if previousDevice != newCaptureDevice: Settings.g_instance.userPrefs.writeString(Settings.KEY_VOIP_DEVICE, newCaptureDevice) LOG_NOTE('Change device of voip: %s' % str(newCaptureDevice)) return
def __getCaptureDeviceSettings(self): import VOIP rh = VOIP.getVOIPManager() devices = [ device.decode(sys.getfilesystemencoding()).encode('utf-8') for device in rh.captureDevices ] currentDeviceName = Settings.g_instance.userPrefs.readString(Settings.KEY_VOIP_DEVICE) currentCaptureDeviceIdx = -1 try: currentCaptureDeviceIdx = devices.index(currentDeviceName) except: try: currentCaptureDeviceIdx = rh.captureDevices.index(rh.currentCaptureDevice) except: pass settings = {'current': currentCaptureDeviceIdx, 'options': devices} return settings
def __updateCaptureDevices(self): Waiting.show('__updateCaptureDevices') devices = yield VoiceChatInterface.g_instance.requestCaptureDevices() currentDeviceName = Settings.g_instance.userPrefs.readString(Settings.KEY_VOIP_DEVICE) currentCaptureDeviceIdx = -1 try: currentCaptureDeviceIdx = devices.index(currentDeviceName) except Exception: try: import VOIP currentCaptureDeviceIdx = devices.index(VOIP.getVOIPManager().currentCaptureDevice) except Exception: pass value = [currentCaptureDeviceIdx] value.extend([ d.decode(sys.getfilesystemencoding()).encode('utf-8') for d in devices ]) Waiting.hide('__updateCaptureDevices') self.call('SettingsDialog.updateCaptureDevices', value)
def __initializeSettings(self, domain, callback): """ Check if VOIP is enabled in client and initialize manager if necessary. :param domain: voip server URL :param callback: pass callback to get results """ if self.isReady(): vOIPSetting = g_settingsCore.options.getSetting('enableVoIP') vOIPSetting.initFromPref() callback(True) return if domain == '': LOG_WARNING('Initialize. Vivox is not supported') return self.__callbacks.append(callback) voipMgr = VOIP.getVOIPManager() if voipMgr.isNotInitialized(): voipMgr.initialize(domain) vOIPSetting = g_settingsCore.options.getSetting('enableVoIP') vOIPSetting.initFromPref()
def initialize(self, domain, callback): import VOIP rh = VOIP.getVOIPManager() if domain == '': LOG_ERROR('Initialize. Vivox is not supported') self.__state = VC_STATES.Failed callback(False) return if self.__state == VC_STATES.Initialized: callback(True) return self.__callback = callback def __initTimoutCallback(): if self.__initializationTimoutCallback is not None: BigWorld.cancelCallback(self.__initializationTimoutCallback) self.__initializationTimoutCallback = None return rh.enable(Settings.g_instance.userPrefs.readBool(Settings.KEY_ENABLE_VOIP)) self.__initializationTimoutCallback = BigWorld.callback(constants.VOICE_CHAT_INIT_TIMEOUT, __initTimoutCallback) rh.initialize(domain)
def startVOIPTest(self, isStart): LOG_DEBUG('Vivox test: %s' % str(isStart)) rh = VOIP.getVOIPManager() rh.enterTestChannel() if isStart else rh.leaveTestChannel() return False
def handleGlobalKeyEvent(self, keyCode, eventType): LOG_DEBUG('GameInputMgr.handleGlobalKeyEvent', keyCode, eventType) if keyCode == self.__voiceChatKey and VOIP.getVOIPManager().getCurrentChannel(): VOIP.getVOIPManager().setMicMute(True if eventType == 'keyUp' else False)
def afterCreate(self): event = events.AppLifeCycleEvent g_eventBus.handleEvent(event(self.__ns, event.INITIALIZING)) player = BigWorld.player() voice = VoiceChatInterface.g_instance LOG_DEBUG('[Battle] afterCreate') setattr(self.movie, '_global.wg_isShowLanguageBar', GUI_SETTINGS.isShowLanguageBar) setattr(self.movie, '_global.wg_isShowServerStats', constants.IS_SHOW_SERVER_STATS) setattr(self.movie, '_global.wg_isShowVoiceChat', GUI_SETTINGS.voiceChat) setattr(self.movie, '_global.wg_voiceChatProvider', voice.voiceChatProvider) setattr(self.movie, '_global.wg_isChina', constants.IS_CHINA) setattr(self.movie, '_global.wg_isKorea', constants.IS_KOREA) setattr(self.movie, '_global.wg_isReplayPlaying', BattleReplay.g_replayCtrl.isPlaying) BattleWindow.afterCreate(self) addListener = g_eventBus.addListener addListener(events.GameEvent.HELP, self.toggleHelpWindow, scope=_SCOPE) addListener(events.GameEvent.GUI_VISIBILITY, self.showAll, scope=_SCOPE) player.inputHandler.onPostmortemVehicleChanged += self.onPostmortemVehicleChanged player.inputHandler.onCameraChanged += self.onCameraChanged g_settingsCore.onSettingsChanged += self.__accs_onSettingsChanged g_settingsCore.interfaceScale.onScaleChanged += self.__onRecreateDevice isMutlipleTeams = g_sessionProvider.getArenaDP().isMultipleTeams() isEvent = isEventBattle() self.proxy = weakref.proxy(self) self.__battle_flashObject = self.proxy.getMember('_level0') if self.__battle_flashObject: self.__battle_flashObject.resync() voice.populateUI(self.proxy) voice.onPlayerSpeaking += self.setPlayerSpeaking voice.onVoiceChatInitFailed += self.onVoiceChatInitFailed self.colorManager = ColorSchemeManager._ColorSchemeManager() self.colorManager.populateUI(self.proxy) self.movingText = MovingText() self.movingText.populateUI(self.proxy) self.__settingsInterface = SettingsInterface() self.__settingsInterface.populateUI(self.proxy) self.__soundManager = SoundManager() self.__soundManager.populateUI(self.proxy) self.__timersBar = TimersBar(self.proxy, isEvent) self.__teamBasesPanel = TeamBasesPanel(self.proxy) self.__debugPanel = DebugPanel(self.proxy) self.__consumablesPanel = ConsumablesPanel(self.proxy) self.__damagePanel = DamagePanel(self.proxy) self.__markersManager = MarkersManager(self.proxy) self.__ingameHelp = IngameHelp(self.proxy) self.__minimap = Minimap(self.proxy) self.__radialMenu = RadialMenu(self.proxy) self.__ribbonsPanel = BattleRibbonsPanel(self.proxy) self.__indicators = IndicatorsCollection() self.__ppSwitcher = PlayersPanelsSwitcher(self.proxy) isColorBlind = g_settingsCore.getSetting('isColorBlind') self.__leftPlayersPanel = playersPanelFactory(self.proxy, True, isColorBlind, isEvent, isMutlipleTeams) self.__rightPlayersPanel = playersPanelFactory(self.proxy, False, isColorBlind, isEvent, isMutlipleTeams) self.__damageInfoPanel = VehicleDamageInfoPanel(self.proxy) self.__fragCorrelation = scorePanelFactory(self.proxy, isEvent, isMutlipleTeams) self.__statsForm = statsFormFactory(self.proxy, isEvent, isMutlipleTeams) self.__plugins.init() self.isVehicleCountersVisible = g_settingsCore.getSetting('showVehiclesCounter') self.__fragCorrelation.showVehiclesCounter(self.isVehicleCountersVisible) self.__vErrorsPanel = VehicleErrorMessages(self.proxy) self.__vMsgsPanel = VehicleMessages(self.proxy) self.__pMsgsPanel = PlayerMessages(self.proxy) self.__plugins.start() self.__debugPanel.start() self.__consumablesPanel.start() self.__damagePanel.start() self.__ingameHelp.start() self.__vErrorsPanel.start() self.__vMsgsPanel.start() self.__pMsgsPanel.start() self.__markersManager.start() self.__markersManager.setMarkerDuration(GUI_SETTINGS.markerHitSplashDuration) markers = {'enemy': g_settingsCore.getSetting('enemy'), 'dead': g_settingsCore.getSetting('dead'), 'ally': g_settingsCore.getSetting('ally')} self.__markersManager.setMarkerSettings(markers) MessengerEntry.g_instance.gui.invoke('populateUI', self.proxy) g_guiResetters.add(self.__onRecreateDevice) g_repeatKeyHandlers.add(self.component.handleKeyEvent) self.__onRecreateDevice() self.__statsForm.populate() self.__leftPlayersPanel.populateUI(self.proxy) self.__rightPlayersPanel.populateUI(self.proxy) if BattleReplay.g_replayCtrl.isPlaying: BattleReplay.g_replayCtrl.onBattleSwfLoaded() self.__populateData(isMutlipleTeams) self.__minimap.start() self.__radialMenu.setSettings(self.__settingsInterface) self.__radialMenu.populateUI(self.proxy) self.__ribbonsPanel.start() g_sessionProvider.setBattleUI(self) self.__arenaCtrl = battleArenaControllerFactory(self, isEvent, isMutlipleTeams) g_sessionProvider.addArenaCtrl(self.__arenaCtrl) self.updateFlagsColor() self.movie.setFocussed(SCALEFORM_SWF_PATH) self.call('battle.initDynamicSquad', self.__getDynamicSquadsInitParams(disableAlly=BattleReplay.g_replayCtrl.isPlaying)) self.call('sixthSenseIndicator.setDuration', [GUI_SETTINGS.sixthSenseDuration]) g_tankActiveCamouflage[player.vehicleTypeDescriptor.type.compactDescr] = self.__arena.arenaType.vehicleCamouflageKind keyCode = CommandMapping.g_instance.get('CMD_VOICECHAT_MUTE') if not BigWorld.isKeyDown(keyCode): VOIP.getVOIPManager().setMicMute(True) ctrl = g_sessionProvider.getVehicleStateCtrl() ctrl.onVehicleStateUpdated += self.__onVehicleStateUpdated ctrl.onPostMortemSwitched += self.__onPostMortemSwitched self.__dynSquadListener = DynSquadViewListener(self.proxy) g_eventBus.handleEvent(event(self.__ns, event.INITIALIZED))