Esempio n. 1
0
    def initializeXvmServices(self):
        if self.xvmServicesInitialized:
            return

        accountDBID = utils.getAccountDBID()
        if accountDBID is None and not isReplay():
            return

        self.xvmServicesInitialized = True

        config.token = config.XvmServicesToken.restore()
        config.token.updateTokenFromApi()

        if config.networkServicesSettings.servicesActive and config.networkServicesSettings.statBattle:
            #data = xvmapi.getVersion()
            #topclans.clear()
            data = xvmapi.getVersionWithLimit(
                config.networkServicesSettings.topClansCount)
            topclans.update(data)
        else:
            data = xvmapi.getVersionWithLimit(
                config.networkServicesSettings.topClansCount)
            topclans.update(data)
        config.verinfo = config.XvmVersionInfo(data)

        if g_appLoader.getSpaceID() == GUI_GLOBAL_SPACE_ID.LOBBY:
            svcmsg.tokenUpdated()

        g_eventBus.handleEvent(
            events.HasCtxEvent(XVM_EVENT.XVM_SERVICES_INITIALIZED))
 def stop(self, isDisconnected=False):
     if self.app and self.app.loaderManager:
         self.app.loaderManager.onViewLoaded -= self.__onViewLoaded
     if isDisconnected:
         if g_appLoader.getSpaceID() == app_settings.GUI_GLOBAL_SPACE_ID.LOGIN:
             SOUND_DEBUG('Restart login space sound environment after banks reloading')
             self._restartSounds()
Esempio n. 3
0
 def stop(self, isDisconnected = False):
     if self.app and self.app.loaderManager:
         self.app.loaderManager.onViewLoaded -= self.__onViewLoaded
     if isDisconnected:
         if g_appLoader.getSpaceID() == _SPACE_ID.LOGIN:
             SOUND_DEBUG('Restart login space sound environment after banks reloading')
             self._restartSounds()
Esempio n. 4
0
    def initializeXvmServices(self):
        if self.xvmServicesInitialized:
            return

        accountDBID = utils.getAccountDBID()
        if accountDBID is None and not isReplay():
            return

        self.xvmServicesInitialized = True

        config.token = config.XvmServicesToken.restore()
        config.token.updateTokenFromApi()

        if config.networkServicesSettings.servicesActive and config.networkServicesSettings.statBattle:
            #data = xvmapi.getVersion()
            #topclans.clear()
            data = xvmapi.getVersionWithLimit(config.networkServicesSettings.topClansCount)
            topclans.update(data)
        else:
            data = xvmapi.getVersionWithLimit(config.networkServicesSettings.topClansCount)
            topclans.update(data)
        config.verinfo = config.XvmVersionInfo(data)

        if g_appLoader.getSpaceID() == GUI_GLOBAL_SPACE_ID.LOBBY:
            svcmsg.tokenUpdated()

        g_eventBus.handleEvent(events.HasCtxEvent(XVM_EVENT.XVM_SERVICES_INITIALIZED))
Esempio n. 5
0
 def _dispose(self):
     if g_appLoader.getSpaceID() != _SPACE_ID.LOGIN:
         self.__releaseItemSound()
         self.soundManager.playInstantSound(SOUNDS.EXIT)
     self.settingsCore.onSettingsChanged -= self.__onSettingsChanged
     self.settingsCore.interfaceScale.onScaleExactlyChanged -= self.__onInterfaceScaleChanged
     self._vehicleCustomizationAnchorsUpdater.stopUpdater()
     self._vehicleCustomizationAnchorsUpdater = None
     if self.__locatedOnEmbelem and g_hangarSpace.spaceInited:
         space = g_hangarSpace.space
         space.clearSelectedEmblemInfo()
         space.locateCameraToPreview()
     self.__viewLifecycleWatcher.stop()
     self.service.stopHighlighter()
     g_clientUpdateManager.removeObjectCallbacks(self)
     self.lobbyContext.deleteHeaderNavigationConfirmator(self.__confirmHeaderNavigation)
     self.lobbyContext.getServerSettings().onServerSettingsChange -= self.__onServerSettingChanged
     self.service.onCarouselFilter -= self.__onCarouselFilter
     self.service.onRemoveItems -= self.removeItems
     self.service.onOutfitChanged -= self.__onOutfitChanged
     g_eventBus.removeListener(CameraRelatedEvents.IDLE_CAMERA, self.__onNotifyHangarCameraIdleStateChanged)
     g_hangarSpace.onSpaceCreate -= self.__onSpaceCreateHandler
     g_hangarSpace.onSpaceDestroy -= self.__onSpaceDestroyHandler
     g_hangarSpace.onSpaceRefresh -= self.__onSpaceRefreshHandler
     self.service.onRegionHighlighted -= self.__onRegionHighlighted
     self.itemsCache.onSyncCompleted -= self.__onCacheResync
     if g_currentVehicle.item:
         g_tankActiveCamouflage[g_currentVehicle.item.intCD] = self._currentSeason
         g_currentVehicle.refreshModel()
     super(CamoSelectorMainView, self)._dispose()
Esempio n. 6
0
def showI18nConfirmDialog(i18nKey, callback, meta = None, focusedID = None):
    if g_appLoader.getSpaceID() == GUI_GLOBAL_SPACE_ID.BATTLE and not GUI_SETTINGS.useAS3Battle:
        customMsg = None
        if meta is not None:
            customMsg.getMessage()
        showConfirmDialog(i18nKey, callback, customMessage=customMsg, ns='battle')
    else:
        showDialog(I18nConfirmDialogMeta(i18nKey, meta=meta, focusedID=focusedID), callback)
    return
Esempio n. 7
0
def _DestroyTimersPanel__hideDeathZoneTimer(self, value):
    if xmqp.is_active() and g_appLoader.getSpaceID() == GUI_GLOBAL_SPACE_ID.BATTLE:
        code = value
        if code is None:
            code = 'ALL'
        xmqp.call({
            'event':EVENTS.XMQP_DEATH_ZONE_TIMER,
            'enable':False,
            'code':code})
Esempio n. 8
0
def _DestroyTimersPanel__showDeathZoneTimer(self, value):
    if xmqp.is_active() and g_appLoader.getSpaceID() == GUI_GLOBAL_SPACE_ID.BATTLE:
        code, totalTime, level = value
        xmqp.call({
            'event':EVENTS.XMQP_DEATH_ZONE_TIMER,
            'enable':True,
            'code':code,
            'totalTime':totalTime,
            'level':level})
 def _dispose(self):
     self.fireEvent(events.HangarCustomizationEvent(
         events.HangarCustomizationEvent.RESET_VEHICLE_MODEL_TRANSFORM),
                    scope=EVENT_BUS_SCOPE.LOBBY)
     self.fireEvent(
         CameraRelatedEvents(
             CameraRelatedEvents.FORCE_DISABLE_IDLE_PARALAX_MOVEMENT,
             ctx={'isDisable': False}), EVENT_BUS_SCOPE.LOBBY)
     if g_appLoader.getSpaceID() != _SPACE_ID.LOGIN:
         self.__releaseItemSound()
         self.soundManager.playInstantSound(SOUNDS.EXIT)
     self.settingsCore.interfaceScale.onScaleExactlyChanged -= self.__onInterfaceScaleChanged
     self._vehicleCustomizationAnchorsUpdater.stopUpdater()
     self._vehicleCustomizationAnchorsUpdater = None
     if self.hangarSpace.spaceInited:
         space = self.hangarSpace.space
         if self.__locatedOnEmbelem:
             space.clearSelectedEmblemInfo()
         space.locateCameraToStartState()
     self._seasonSoundAnimantion = None
     self.__renderEnv.enable(False)
     self.__renderEnv = None
     self.__viewLifecycleWatcher.stop()
     self.service.stopHighlighter()
     self.lobbyContext.deleteHeaderNavigationConfirmator(
         self.__confirmHeaderNavigation)
     self.lobbyContext.getServerSettings(
     ).onServerSettingsChange -= self.__onServerSettingChanged
     g_eventBus.removeListener(CameraRelatedEvents.IDLE_CAMERA,
                               self.__onNotifyHangarCameraIdleStateChanged)
     self.hangarSpace.onSpaceCreate -= self.__onSpaceCreateHandler
     self.hangarSpace.onSpaceDestroy -= self.__onSpaceDestroyHandler
     self.hangarSpace.onSpaceRefresh -= self.__onSpaceRefreshHandler
     self.service.onRegionHighlighted -= self.__onRegionHighlighted
     if g_currentVehicle.item:
         g_tankActiveCamouflage[
             g_currentVehicle.item.intCD] = self.__ctx.currentSeason
         g_currentVehicle.refreshModel()
     self.__hidePropertiesSheet()
     self.__propertiesSheet = None
     self.__ctx.onPropertySheetShown -= self.__onPropertySheetShown
     self.__ctx.onPropertySheetHidden -= self.__onPropertySheetHidden
     self.__ctx.onCaruselItemSelected -= self.__onCaruselItemSelected
     self.__ctx.onChangesCanceled -= self.__onChangesCanceled
     self.__ctx.onCacheResync -= self.__onCacheResync
     self.__ctx.onCustomizationItemsBought -= self.__onItemsBought
     self.__ctx.onCustomizationItemsRemoved -= self.__onItemsRemoved
     self.__ctx.onCustomizationItemInstalled -= self.__onItemsInstalled
     self.__ctx.onCustomizationTabChanged -= self.__onTabChanged
     self.__ctx.onCustomizationModeChanged -= self.__onModeChanged
     self.__ctx.onCustomizationSeasonChanged -= self.__onSeasonChanged
     self.__ctx = None
     self.service.destroyCtx()
     super(MainView, self)._dispose()
     return
Esempio n. 10
0
def _DestroyTimersPanel_hideDeathZoneTimer(self, value):
    if xmqp.is_active() and g_appLoader.getSpaceID(
    ) == GUI_GLOBAL_SPACE_ID.BATTLE:
        code = value
        if code is None:
            code = 'ALL'
        xmqp.call({
            'event': EVENTS.XMQP_DEATH_ZONE_TIMER,
            'enable': False,
            'code': code
        })
Esempio n. 11
0
def _DestroyTimersPanel_showDeathZoneTimer(self, value):
    if xmqp.is_active() and g_appLoader.getSpaceID(
    ) == GUI_GLOBAL_SPACE_ID.BATTLE:
        code, totalTime, level = value
        xmqp.call({
            'event': EVENTS.XMQP_DEATH_ZONE_TIMER,
            'enable': True,
            'code': code,
            'totalTime': totalTime,
            'level': level
        })
Esempio n. 12
0
 def _getUserName(userDBID):
     name, abbrev = ('', None)
     if userDBID:
         if g_appLoader.getSpaceID() == GUI_GLOBAL_SPACE_ID.BATTLE:
             name, abbrev = g_battleCtrl.getCtx().getPlayerFullNameParts(accID=userDBID, showVehShortName=False)[1:3]
         if not name:
             userName = self.getUserName(userDBID)
             userClanAbbrev = self.getUserClanAbbrev(userDBID)
             user = rosterGetter(userDBID)
             if user and user.hasValidName():
                 name, abbrev = userName, userClanAbbrev
     return (name, abbrev)
Esempio n. 13
0
def showI18nInfoDialog(i18nKey, callback, meta=None):
    if g_appLoader.getSpaceID(
    ) == GUI_GLOBAL_SPACE_ID.BATTLE and not GUI_SETTINGS.useAS3Battle:
        customMsg = None
        if meta is not None:
            customMsg.getMessage()
        showInformationDialog(i18nKey,
                              callback,
                              customMessage=customMsg,
                              ns='battle')
    else:
        showDialog(I18nInfoDialogMeta(i18nKey, meta=meta), callback)
    return
Esempio n. 14
0
    def _buildReceivedInvitesList(self, invitesLists):
        if self.__inited & PRB_INVITES_INIT_STEP.DATA_BUILD == 0:
            self.__inited |= PRB_INVITES_INIT_STEP.DATA_BUILD
        self.__clearInvites()
        userGetter = self.users.getUser
        for invitesData, maker in invitesLists:
            for item in invitesData:
                _, invite = maker(item)
                if invite:
                    self._addInvite(invite, userGetter)

        if g_appLoader.getSpaceID() != GUI_GLOBAL_SPACE_ID.BATTLE:
            self.syncUsersInfo()
Esempio n. 15
0
    def _buildReceivedInvitesList(self, invitesLists):
        if self.__inited & PRB_INVITES_INIT_STEP.DATA_BUILD == 0:
            self.__inited |= PRB_INVITES_INIT_STEP.DATA_BUILD
        self.__clearInvites()
        userGetter = self.users.getUser
        for invitesData, maker in invitesLists:
            for item in invitesData:
                _, invite = maker(item)
                if invite:
                    self._addInvite(invite, userGetter)

        if g_appLoader.getSpaceID() != GUI_GLOBAL_SPACE_ID.BATTLE:
            self.syncUsersInfo()
Esempio n. 16
0
def _DestroyTimersPanel__showDestroyTimer(self, value):
    if xmqp.is_active() and g_appLoader.getSpaceID(
    ) == GUI_GLOBAL_SPACE_ID.BATTLE:
        if len(value) == 4:
            code, totalTime, level, startTime = value
        else:
            (code, totalTime, level), startTime = value, None
        xmqp.call({
            'event': EVENTS.XMQP_VEHICLE_TIMER,
            'enable': True,
            'code': code,
            'totalTime': totalTime,
            'level': level
        })
Esempio n. 17
0
 def onKeyEvent(self, event):
     try:
         if not event.isRepeatedEvent():
             # debug("key=" + str(event.key) + ' ' + ('down' if event.isKeyDown() else 'up'))
             spaceID = g_appLoader.getSpaceID()
             if spaceID == GUI_GLOBAL_SPACE_ID.BATTLE:
                 app = getBattleApp()
                 if app and not MessengerEntry.g_instance.gui.isFocused():
                     as_xfw_cmd(XVM_COMMAND.AS_ON_KEY_EVENT, event.key, event.isKeyDown())
             elif spaceID == GUI_GLOBAL_SPACE_ID.LOBBY:
                 app = getLobbyApp()
                 if app:
                     as_xfw_cmd(XVM_COMMAND.AS_ON_KEY_EVENT, event.key, event.isKeyDown())
     except Exception, ex:
         err('onKeyEvent(): ' + traceback.format_exc())
Esempio n. 18
0
 def onKeyEvent(self, event):
     try:
         if not event.isRepeatedEvent():
             # debug("key=" + str(event.key) + ' ' + ('down' if event.isKeyDown() else 'up'))
             spaceID = g_appLoader.getSpaceID()
             if spaceID == GUI_GLOBAL_SPACE_ID.BATTLE:
                 app = getBattleApp()
                 if app and not MessengerEntry.g_instance.gui.isFocused():
                     as_xfw_cmd(XVM_COMMAND.AS_ON_KEY_EVENT, event.key, event.isKeyDown())
             elif spaceID == GUI_GLOBAL_SPACE_ID.LOBBY:
                 app = getLobbyApp()
                 if app:
                     as_xfw_cmd(XVM_COMMAND.AS_ON_KEY_EVENT, event.key, event.isKeyDown())
     except Exception, ex:
         err('onKeyEvent(): ' + traceback.format_exc())
Esempio n. 19
0
 def _getUserName(userDBID):
     name, abbrev = ('', None)
     if userDBID:
         if g_appLoader.getSpaceID() == GUI_GLOBAL_SPACE_ID.BATTLE:
             ctx = self.sessionProvider.getCtx()
             isUserInBattle = ctx.getVehIDByAccDBID(userDBID) != 0
             if isUserInBattle:
                 name, abbrev = ctx.getPlayerFullNameParts(accID=userDBID, showVehShortName=False)[1:3]
         if not name:
             userName = self.getUserName(userDBID)
             userClanAbbrev = self.getUserClanAbbrev(userDBID)
             user = rosterGetter(userDBID)
             if user and user.hasValidName():
                 name, abbrev = userName, userClanAbbrev
     return (name, abbrev)
Esempio n. 20
0
def _DestroyTimersPanel_showDeathZoneTimer(self, value):
    if xmqp.is_active() and g_appLoader.getSpaceID(
    ) == GUI_GLOBAL_SPACE_ID.BATTLE:
        if value.needToCloseAll():
            xmqp.call({
                'event': EVENTS.XMQP_DEATH_ZONE_TIMER,
                'enable': False,
                'code': 'ALL'
            })
        elif value.needToCloseTimer():
            xmqp.call({
                'event': EVENTS.XMQP_DEATH_ZONE_TIMER,
                'enable': False,
                'code': value.code
            })
        else:
            xmqp.call({
                'event': EVENTS.XMQP_DEATH_ZONE_TIMER,
                'enable': True,
                'code': value.code,
                'totalTime': value.totalTime,
                'level': value.level
            })
    def __stopAllSounds(self, stopPersistent):
        if stopPersistent or self.__soundSpaceSettings is None:
            persistentSounds = []
        else:
            persistentSounds = self.__soundSpaceSettings.persistentSounds
        privateSounds = self.__privateSounds.values()
        soundsToDelete = []
        for eventName, sound in self.__sounds.iteritems():
            if eventName in privateSounds:
                continue
            if eventName not in persistentSounds or not sound.isPlaying:
                soundsToDelete.append(eventName)
                if eventName not in persistentSounds:
                    self.stopSound(eventName)

        for eventName in soundsToDelete:
            del self.__sounds[eventName]

        if self.__soundSpaceSettings is not None:
            if g_appLoader.getSpaceID(
            ) != _SPACE_ID.LOGIN and self.__soundSpaceSettings.exitEvent:
                self.playInstantSound(self.__soundSpaceSettings.exitEvent)
        return
Esempio n. 22
0
    def __init__(self):
        self.__enableStatus = SOUND_ENABLE_STATUS_DEFAULT
        self.__volumeByCategory = {}
        self.__masterVolume = 1.0
        self.__lqRenderState = LQ_RENDER_STATE_DEFAULT
        self.__isWindowVisible = BigWorld.isWindowVisible()
        self.__handleInside = None
        self.__handleOutside = None
        self.__activeStinger = None
        self.__activeTrack = None
        self.__activeStingerPriority = None
        self.__muffled = False
        self.__muffledByReplay = False
        self.__states = []
        from gui.app_loader import g_appLoader
        self.__spaceID = g_appLoader.getSpaceID()
        PlayerEvents.g_playerEvents.onAvatarReady += self.onAvatarReady
        self.__categories = {
            'vehicles': ('outside/vehicles', 'vehicles'),
            'effects':
            ('hits', 'outside/hits', 'inside/weapons', 'outside/weapons',
             'outside/environment', 'battle_gui'),
            'gui': ('gui', 'ingame_voice'),
            'music': ('music', ),
            'ambient': ('outside/ambient', 'hangar_v2', 'ambientUR'),
            'masterVivox': (),
            'micVivox': (),
            'masterFadeVivox': ()
        }
        defMasterVolume = 0.5
        defCategoryVolumes = {
            'music': 0.5,
            'masterVivox': 0.7,
            'micVivox': 0.4
        }
        userPrefs = Settings.g_instance.userPrefs
        soundModeName = SoundModes.DEFAULT_MODE_NAME
        nationalMapping = None
        self.__soundModes = None
        if not userPrefs.has_key(Settings.KEY_SOUND_PREFERENCES):
            userPrefs.write(Settings.KEY_SOUND_PREFERENCES, '')
            self.__masterVolume = defMasterVolume
            for categoryName in self.__categories.keys():
                self.__volumeByCategory[categoryName] = defCategoryVolumes.get(
                    categoryName, 1.0)

            self.savePreferences()
        else:
            ds = userPrefs[Settings.KEY_SOUND_PREFERENCES]
            self.__enableStatus = ds.readInt('enable',
                                             SOUND_ENABLE_STATUS_DEFAULT)
            self.__lqRenderState = ds.readInt('LQ_render',
                                              LQ_RENDER_STATE_DEFAULT)
            self.__masterVolume = ds.readFloat('masterVolume', defMasterVolume)
            for categoryName in self.__categories.keys():
                volume = ds.readFloat(
                    'volume_' + categoryName,
                    defCategoryVolumes.get(categoryName, 1.0))
                self.__volumeByCategory[categoryName] = volume

            soundModeSec = ds['soundMode']
            if soundModeSec is not None:
                soundModeName = soundModeSec.asString
                if soundModeName == '':
                    soundModeName = SoundModes.DEFAULT_MODE_NAME
                    if ds['soundMode'].has_key('nationalPreset'):
                        nationalMapping = ds.readString(
                            'soundMode/nationalPreset', '')
                    else:
                        nationsSec = soundModeSec['nations']
                        if nationsSec is not None:
                            nationalMapping = {}
                            for nation, sec in nationsSec.items():
                                nationalMapping[nation] = sec.asString

        self.__soundModes = SoundModes(SoundModes.DEFAULT_MODE_NAME)
        if isinstance(nationalMapping, str):
            self.__soundModes.setNationalMappingByPreset(nationalMapping)
        elif isinstance(nationalMapping, dict):
            self.__soundModes.setNationalMapping(nationalMapping)
        else:
            self.__soundModes.setNationalMappingByMode(soundModeName)
        self.applyPreferences()
        self.__muteCallbackID = BigWorld.callback(
            0.25, self.__muteByWindowVisibility)
        self.defaultGroupList = ''
        settings = ResMgr.openSection(
            'scripts/arena_defs/_default_.xml/preloadSoundBanks')
        if settings is not None:
            self.defaultGroupList = settings.asString
        g_replayEvents.onMuteSound += self.__onReplayMute
        from gui.app_loader import g_appLoader
        g_appLoader.onGUISpaceEntered += self.__onGUISpaceEntered
        return
Esempio n. 23
0
    def __init__(self):
        self.__enableStatus = SOUND_ENABLE_STATUS_DEFAULT
        self.__volumeByCategory = {}
        self.__masterVolume = 1.0
        self.__lqRenderState = LQ_RENDER_STATE_DEFAULT
        self.__isWindowVisible = BigWorld.isWindowVisible()
        self.__handleInside = None
        self.__handleOutside = None
        self.__activeStinger = None
        self.__activeTrack = None
        self.__activeStingerPriority = None
        self.__muffled = False
        self.__muffledByReplay = False
        self.__states = []
        from gui.app_loader import g_appLoader
        self.__spaceID = g_appLoader.getSpaceID()
        PlayerEvents.g_playerEvents.onAvatarReady += self.onAvatarReady
        self.__categories = {'vehicles': ('outside/vehicles', 'vehicles'),
         'effects': ('hits', 'outside/hits', 'inside/weapons', 'outside/weapons', 'outside/environment', 'battle_gui'),
         'gui': ('gui', 'ingame_voice'),
         'music': ('music',),
         'ambient': ('outside/ambient', 'hangar_v2', 'ambientUR'),
         'masterVivox': (),
         'micVivox': (),
         'masterFadeVivox': ()}
        defMasterVolume = 0.5
        defCategoryVolumes = {'music': 0.5,
         'masterVivox': 0.7,
         'micVivox': 0.4}
        userPrefs = Settings.g_instance.userPrefs
        soundModeName = SoundModes.DEFAULT_MODE_NAME
        nationalMapping = None
        self.__soundModes = None
        if not userPrefs.has_key(Settings.KEY_SOUND_PREFERENCES):
            userPrefs.write(Settings.KEY_SOUND_PREFERENCES, '')
            self.__masterVolume = defMasterVolume
            for categoryName in self.__categories.keys():
                self.__volumeByCategory[categoryName] = defCategoryVolumes.get(categoryName, 1.0)

            self.savePreferences()
        else:
            ds = userPrefs[Settings.KEY_SOUND_PREFERENCES]
            self.__enableStatus = ds.readInt('enable', SOUND_ENABLE_STATUS_DEFAULT)
            self.__lqRenderState = ds.readInt('LQ_render', LQ_RENDER_STATE_DEFAULT)
            self.__masterVolume = ds.readFloat('masterVolume', defMasterVolume)
            for categoryName in self.__categories.keys():
                volume = ds.readFloat('volume_' + categoryName, defCategoryVolumes.get(categoryName, 1.0))
                self.__volumeByCategory[categoryName] = volume

            soundModeSec = ds['soundMode']
            if soundModeSec is not None:
                soundModeName = soundModeSec.asString
                if soundModeName == '':
                    soundModeName = SoundModes.DEFAULT_MODE_NAME
                    if ds['soundMode'].has_key('nationalPreset'):
                        nationalMapping = ds.readString('soundMode/nationalPreset', '')
                    else:
                        nationsSec = soundModeSec['nations']
                        if nationsSec is not None:
                            nationalMapping = {}
                            for nation, sec in nationsSec.items():
                                nationalMapping[nation] = sec.asString

        self.__soundModes = SoundModes(SoundModes.DEFAULT_MODE_NAME)
        if isinstance(nationalMapping, str):
            self.__soundModes.setNationalMappingByPreset(nationalMapping)
        elif isinstance(nationalMapping, dict):
            self.__soundModes.setNationalMapping(nationalMapping)
        else:
            self.__soundModes.setNationalMappingByMode(soundModeName)
        self.applyPreferences()
        self.__muteCallbackID = BigWorld.callback(0.25, self.__muteByWindowVisibility)
        self.defaultGroupList = ''
        settings = ResMgr.openSection('scripts/arena_defs/_default_.xml/preloadSoundBanks')
        if settings is not None:
            self.defaultGroupList = settings.asString
        g_replayEvents.onMuteSound += self.__onReplayMute
        from gui.app_loader import g_appLoader
        g_appLoader.onGUISpaceEntered += self.__onGUISpaceEntered
        return
Esempio n. 24
0
    def __init__(self):
        self.__enableStatus = SOUND_ENABLE_STATUS_DEFAULT
        self.__volumeByCategory = {}
        self.__masterVolume = 1.0
        self.__handleInside = None
        self.__handleOutside = None
        self.__activeStinger = None
        self.__activeTrack = None
        self.__activeStingerPriority = None
        self.__muffled = False
        self.__muffledByReplay = False
        self.__states = []
        from gui.app_loader import g_appLoader
        self.__spaceID = g_appLoader.getSpaceID()
        PlayerEvents.g_playerEvents.onAvatarReady += self.onAvatarReady
        self.__categories = {
            'vehicles': ('outside/vehicles', 'vehicles'),
            'effects':
            ('hits', 'outside/hits', 'inside/weapons', 'outside/weapons',
             'outside/environment', 'battle_gui'),
            'gui': ('gui', 'ingame_voice'),
            'music': ('music', ),
            'ambient': ('outside/ambient', 'hangar_v2', 'ambientUR'),
            'masterVivox': (),
            'micVivox': (),
            'masterFadeVivox': ()
        }
        defCategoryVolumes = {
            'music': 0.5,
            'masterVivox': 0.7,
            'micVivox': 0.4
        }
        userPrefs = Settings.g_instance.userPrefs
        soundModeName = SoundModes.DEFAULT_MODE_NAME
        nationalMapping = None
        self.__soundModes = None
        if not userPrefs.has_key(Settings.KEY_SOUND_PREFERENCES):
            userPrefs.write(Settings.KEY_SOUND_PREFERENCES, '')
            self.__masterVolume = MASTER_VOLUME_DEFAULT
            for categoryName in self.__categories.iterkeys():
                self.__volumeByCategory[categoryName] = defCategoryVolumes.get(
                    categoryName, 1.0)

            self.savePreferences()
        else:
            ds = userPrefs[Settings.KEY_SOUND_PREFERENCES]
            self.__enableStatus = ds.readInt('enable',
                                             SOUND_ENABLE_STATUS_DEFAULT)
            self.__masterVolume = ds.readFloat('masterVolume',
                                               MASTER_VOLUME_DEFAULT)
            self.__volumeByCategory['music_hangar'] = ds.readFloat(
                'volume_music_hangar', 1.0)
            self.__volumeByCategory['voice'] = ds.readFloat(
                'volume_voice', 1.0)
            self.__volumeByCategory['ev_ambient'] = ds.readFloat(
                'volume_ev_ambient', 0.8)
            self.__volumeByCategory['ev_effects'] = ds.readFloat(
                'volume_ev_effects', 0.8)
            self.__volumeByCategory['ev_gui'] = ds.readFloat(
                'volume_ev_gui', 0.8)
            self.__volumeByCategory['ev_music'] = ds.readFloat(
                'volume_ev_music', 0.8)
            self.__volumeByCategory['ev_vehicles'] = ds.readFloat(
                'volume_ev_vehicles', 0.8)
            self.__volumeByCategory['ev_voice'] = ds.readFloat(
                'volume_ev_voice', 0.8)
            for categoryName in self.__categories.iterkeys():
                volume = ds.readFloat(
                    'volume_' + categoryName,
                    defCategoryVolumes.get(categoryName, 1.0))
                self.__volumeByCategory[categoryName] = volume

            soundModeSec = ds['soundMode']
            if soundModeSec is not None:
                soundModeName = soundModeSec.asString
                if soundModeName == '':
                    soundModeName = SoundModes.DEFAULT_MODE_NAME
                    if ds['soundMode'].has_key('nationalPreset'):
                        nationalMapping = ds.readString(
                            'soundMode/nationalPreset', '')
                    else:
                        nationsSec = soundModeSec['nations']
                        if nationsSec is not None:
                            nationalMapping = {}
                            for nation, sec in nationsSec.items():
                                nationalMapping[nation] = sec.asString

        self.__soundModes = SoundModes(SoundModes.DEFAULT_MODE_NAME)
        if isinstance(nationalMapping, str):
            self.__soundModes.setNationalMappingByPreset(nationalMapping)
        elif isinstance(nationalMapping, dict):
            self.__soundModes.setNationalMapping(nationalMapping)
        else:
            self.__soundModes.setNationalMappingByMode(soundModeName)
        self.applyPreferences()
        g_replayEvents.onMuteSound += self.__onReplayMute
        g_appLoader.onGUISpaceEntered += self.__onGUISpaceEntered
        return