示例#1
1
    def apply(self, restartApproved, callbackId, settings):
        restartClient = False
        interfaceScaled = False
        g_settingsCore.isDeviseRecreated = False
        import VOIP

        if (not self.resolutions.isVideoWindowed or settings["fullScreen"]) and (
            settings["monitor"] != self.resolutions.realMonitorIndex or self.resolutions.monitorChanged
        ):
            restartClient = True
        if g_settingsCore.getSetting("interfaceScale") != settings["interfaceScale"]:
            interfaceScaled = True
        g_settingsCore.applySetting("ppShowTypes", settings["ppShowTypes"])
        g_settingsCore.applySetting("ppShowLevels", settings["ppShowLevels"])
        g_settingsCore.applySetting("replayEnabled", settings["replayEnabled"])
        g_settingsCore.applySetting("fpsPerfomancer", settings["fpsPerfomancer"])
        g_settingsCore.applySetting("colorFilterIntensity", settings["colorFilterIntensity"])
        g_settingsCore.applySetting("fov", settings["fov"])
        g_settingsCore.applySetting("dynamicFov", settings["dynamicFov"])
        g_settingsCore.applySetting("enableOpticalSnpEffect", settings["enableOpticalSnpEffect"])
        g_settingsCore.applySetting("nationalVoices", settings["nationalVoices"])
        g_settingsCore.applySetting("isColorBlind", settings["isColorBlind"])
        g_settingsCore.applySetting("useServerAim", settings["useServerAim"])
        g_settingsCore.applySetting("showVehiclesCounter", settings["showVehiclesCounter"])
        g_settingsCore.applySetting("showMarksOnGun", settings["showMarksOnGun"])
        g_settingsCore.applySetting("minimapAlpha", settings["minimapAlpha"])
        g_settingsCore.applySetting("showVectorOnMap", settings["showVectorOnMap"])
        g_settingsCore.applySetting("showSectorOnMap", settings["showSectorOnMap"])
        g_settingsCore.applySetting("showVehModelsOnMap", settings["showVehModelsOnMap"])
        arcade = g_settingsCore.options.getSetting("arcade").fromAccountSettings(settings["arcade"])
        sniper = g_settingsCore.options.getSetting("sniper").fromAccountSettings(settings["sniper"])
        g_settingsCore.applySetting("arcade", arcade)
        g_settingsCore.applySetting("sniper", sniper)
        g_settingsCore.applySetting("enemy", settings["markers"]["enemy"])
        g_settingsCore.applySetting("dead", settings["markers"]["dead"])
        g_settingsCore.applySetting("ally", settings["markers"]["ally"])
        g_settingsCore.applySetting("interfaceScale", settings["interfaceScale"])
        if "showBattleEfficiencyRibbons" in settings:
            g_settingsCore.applySetting("showBattleEfficiencyRibbons", settings["showBattleEfficiencyRibbons"])
        g_settingsCore.applySetting("dynamicCamera", settings["dynamicCamera"])
        g_settingsCore.applySetting("horStabilizationSnp", settings["horStabilizationSnp"])
        if self.__altVoiceSetting.isOptionEnabled():
            altVoices = settings.get("alternativeVoices")
            if altVoices is not None:
                self.__altVoiceSetting.apply(altVoices)
        vManager = VibroManager.g_instance
        vManager.setGain(settings["vibroGain"] / 100.0)
        vEffGroups = vManager.getGroupsSettings()
        for groupName, newValue in [
            ("engine", settings["vibroEngine"]),
            ("acceleration", settings["vibroAcceleration"]),
            ("shots", settings["vibroShots"]),
            ("hits", settings["vibroHits"]),
            ("collisions", settings["vibroCollisions"]),
            ("damage", settings["vibroDamage"]),
            ("gui", settings["vibroGUI"]),
        ]:
            if groupName in vEffGroups:
                vEffGroups[groupName].gain = newValue / 100.0
                vEffGroups[groupName].enabled = newValue > 0

        vManager.setGroupsSettings(vEffGroups)
        self.__voiceChatEnable(settings["enableVoIP"])
        g_settingsCore.applySetting(SOUND.CAPTURE_DEVICES, settings[Settings.KEY_VOIP_DEVICE])
        g_settingsCore.applySetting("enablePostMortemEffect", settings["enablePostMortemEffect"])
        g_settingsCore.applySetting("enablePostMortemDelay", settings["enablePostMortemDelay"])
        self.uiHolder.clearCommands()
        keyboard = settings["controls"]["keyboard"]
        keyboardMapping = {}
        keysLayout = dict(g_settingsCore.options.getSetting("keyboard").KEYS_LAYOUT)
        layout = list(itertools.chain(*keysLayout.values()))
        for i in xrange(len(self.KEYBOARD_MAPPING_BLOCKS)):
            group_name = keyboard[i]["id"]
            for j in xrange(len(self.KEYBOARD_MAPPING_BLOCKS[group_name])):
                key_name = keyboard[i]["commands"][j]["id"]
                value = keyboard[i]["commands"][j]["key"]
                cmd = self.KEYBOARD_MAPPING_COMMANDS[group_name][key_name]
                for item in layout:
                    key, command = item[0], item[1]
                    if command == cmd:
                        keyboardMapping[key] = value
                        break

        g_settingsCore.applySetting("keyboard", keyboardMapping)
        self.uiHolder.bindCommands()
        player = BigWorld.player()
        mouse = settings["controls"]["mouse"]
        if hasattr(player.inputHandler, "ctrls"):
            player.inputHandler.ctrls["arcade"].camera.setUserConfigValue("sensitivity", mouse["arcadeSens"]["value"])
            player.inputHandler.ctrls["sniper"].camera.setUserConfigValue("sensitivity", mouse["sniperSens"]["value"])
            player.inputHandler.ctrls["strategic"].camera.setUserConfigValue("sensitivity", mouse["artSens"]["value"])
        else:
            ds = Settings.g_instance.userPrefs[Settings.KEY_CONTROL_MODE]
            if ds:
                ds["arcadeMode/camera"].writeFloat("sensitivity", mouse["arcadeSens"]["value"])
                ds["sniperMode/camera"].writeFloat("sensitivity", mouse["sniperSens"]["value"])
                ds["strategicMode/camera"].writeFloat("sensitivity", mouse["artSens"]["value"])
        g_settingsCore.applySetting("mouseHorzInvert", bool(mouse["horInvert"]["value"]))
        g_settingsCore.applySetting("mouseVertInvert", bool(mouse["vertInvert"]["value"]))
        g_settingsCore.applySetting("backDraftInvert", bool(mouse["backDraftInvert"]["value"]))
        g_settingsCore.applySetting("monitor", settings["monitor"])
        isFullScreen = bool(settings["fullScreen"])
        if isFullScreen:
            g_settingsCore.applySetting("refreshRate", settings["refreshRate"])
            g_settingsCore.applySetting("resolution", settings["resolution"])
            g_settingsCore.applySetting("aspectRatio", settings["aspectRatio"])
            g_settingsCore.applySetting("gamma", settings["gamma"])
        else:
            g_settingsCore.applySetting("windowSize", settings["windowSize"])
        g_settingsCore.applySetting("fullScreen", isFullScreen)
        g_settingsCore.applySetting("multisampling", settings["multisampling"])
        g_settingsCore.applySetting("customAA", settings["customAA"])
        g_settingsCore.applySetting("vertSync", settings["vertSync"])
        g_settingsCore.applySetting("tripleBuffered", settings["tripleBuffered"])
        if round(SoundGroups.g_instance.getVolume("masterVivox") * 100) != settings["masterVivoxVolume"]:
            VOIP.getVOIPManager().setMasterVolume(settings["masterVivoxVolume"])
        if round(SoundGroups.g_instance.getVolume("micVivox") * 100) != settings["micVivoxVolume"]:
            VOIP.getVOIPManager().setMicrophoneVolume(settings["micVivoxVolume"])
        SoundGroups.g_instance.setMasterVolume(float(settings["masterVolume"]) / 100)
        SoundGroups.g_instance.setVolume("music", float(settings["musicVolume"]) / 100)
        SoundGroups.g_instance.setVolume("voice", float(settings["voiceVolume"]) / 100)
        SoundGroups.g_instance.setVolume("vehicles", float(settings["vehiclesVolume"]) / 100)
        SoundGroups.g_instance.setVolume("effects", float(settings["effectsVolume"]) / 100)
        SoundGroups.g_instance.setVolume("gui", float(settings["guiVolume"]) / 100)
        SoundGroups.g_instance.setVolume("ambient", float(settings["ambientVolume"]) / 100)
        SoundGroups.g_instance.setVolume("masterVivox", float(settings["masterVivoxVolume"]) / 100)
        SoundGroups.g_instance.setVolume("micVivox", float(settings["micVivoxVolume"]) / 100)
        SoundGroups.g_instance.setVolume("masterFadeVivox", float(settings["masterFadeVivoxVolume"]) / 100)
        g_settingsCore.applySetting("showDateMessage", settings["datetimeIdx"] & 1)
        g_settingsCore.applySetting("showTimeMessage", settings["datetimeIdx"] & 2)
        g_settingsCore.applySetting("enableOlFilter", settings["enableOlFilter"])
        g_settingsCore.applySetting("enableSpamFilter", settings["enableSpamFilter"])
        g_windowsStoredData.start()
        g_settingsCore.applySetting("receiveFriendshipRequest", settings["receiveFriendshipRequest"])
        g_settingsCore.applySetting("receiveInvitesInBattle", settings.get("receiveInvitesInBattle"))
        g_windowsStoredData.stop()
        g_settingsCore.applySetting("invitesFromFriendsOnly", settings["invitesFromFriendsOnly"])
        g_settingsCore.applySetting("storeReceiverInBattle", settings["storeReceiverInBattle"])
        g_settingsCore.applySetting("disableBattleChat", settings["disableBattleChat"])
        g_settingsCore.applySetting("chatContactsListOnly", settings["chatContactsListOnly"])
        gameplayKeys = filter(lambda item: item.startswith(self.GAMEPLAY_PREFIX), settings.keys())
        for key in gameplayKeys:
            g_settingsCore.applySetting(key, settings[key])

        qualitySettings = settings["quality"]
        applyMethod = g_settingsCore.options.getApplyMethod(qualitySettings)
        for key in GraphicsPresets.GRAPHICS_QUALITY_SETTINGS:
            value = qualitySettings.get(key)
            if value is not None:
                g_settingsCore.applySetting(key, value)

        g_settingsCore.applySetting("dynamicRenderer", settings["dynamicRenderer"])
        if applyMethod == APPLY_METHOD.RESTART:
            BigWorld.commitPendingGraphicsSettings()
            restartClient = True
        elif applyMethod == APPLY_METHOD.DELAYED:
            BigWorld.commitPendingGraphicsSettings()
        confirmators = g_settingsCore.applyStorages(restartClient)
        for confirmation, revert in confirmators:
            if confirmation is not None:
                if confirmation == "graphicsChangeConfirmation":

                    def callback(isConfirmed):
                        if not isConfirmed:
                            g_settingsCore.isChangesConfirmed = False
                            revert()

                    self.graphicsChangeConfirmationRevert = revert
                    self.call("SettingsDialog.ApplySettings", [confirmation])

        g_postProcessing.refresh()
        if restartClient:
            BigWorld.savePreferences()
            if restartApproved:
                from BattleReplay import g_replayCtrl

                if g_replayCtrl.isPlaying and g_replayCtrl.playbackSpeed == 0:
                    g_replayCtrl.setPlaybackSpeedIdx(5)
                BigWorld.callback(0.3, self.__restartGame)
            elif g_settingsCore.isDeviseRecreated:
                g_settingsCore.isDeviseRecreated = False
            else:
                BigWorld.callback(0.0, partial(BigWorld.changeVideoMode, -1, BigWorld.isVideoWindowed()))
        if interfaceScaled:
            self.__settingsUI.buildGraphicsData(self.__getVideoSettings())
        return
    def applySettings(self):
        yield self._updateToVersion()
        enableBattleReplay = self._core.options.getSetting(self.GAME.REPLAY_ENABLED)
        enableBattleReplayValue = enableBattleReplay.get()
        from BattleReplay import g_replayCtrl
        g_replayCtrl.enableAutoRecordingBattles(enableBattleReplayValue)
        enablePostMortem = self._core.options.getSetting(self.GAME.ENABLE_POSTMORTEM)
        enablePostMortemValue = enablePostMortem.get()
        from post_processing import g_postProcessing
        g_postProcessing.setSetting('mortem_post_effect', enablePostMortemValue)
        g_postProcessing.refresh()
        enableDynamicCamera = self._core.options.getSetting(self.GAME.DYNAMIC_CAMERA)
        enableDynamicCameraValue = enableDynamicCamera.get()
        enableSniperStabilization = self._core.options.getSetting(self.GAME.SNIPER_MODE_STABILIZATION)
        enableSniperStabilizationValue = enableSniperStabilization.get()
        from AvatarInputHandler import AvatarInputHandler
        AvatarInputHandler.enableDynamicCamera(enableDynamicCameraValue, enableSniperStabilizationValue)
        from messenger.doc_loaders import user_prefs
        from messenger import g_settings as messenger_settings
        user_prefs.loadFromServer(messenger_settings)
        masks = self.SECTIONS[SETTINGS_SECTIONS.GRAPHICS].masks
        offsets = self.SECTIONS[SETTINGS_SECTIONS.GRAPHICS].offsets
        graphicSettingNames = masks.keys() + offsets.keys()
        for setting in graphicSettingNames:
            settingOption = self._core.options.getSetting(setting)
            settingValue = settingOption.get()
            settingOption.setSystemValue(settingValue)

        alternativeVoices = self._core.options.getSetting(self.SOUND.ALT_VOICES)
        alternativeVoicesValue = alternativeVoices.get()
        alternativeVoices.setSystemValue(alternativeVoicesValue)
        self._core.options.getSetting('keyboard').setSystemValue()
        if isPlayerAvatar():
            BigWorld.player().invRotationOnBackMovement = self._core.getSetting('backDraftInvert')
    def applySettings(self):
        yield self._updateToVersion()
        enableBattleReplay = self._core.options.getSetting(
            self.GAME.REPLAY_ENABLED)
        enableBattleReplayValue = enableBattleReplay.get()
        from BattleReplay import g_replayCtrl
        g_replayCtrl.enableAutoRecordingBattles(enableBattleReplayValue)
        enablePostMortem = self._core.options.getSetting(
            self.GAME.ENABLE_POSTMORTEM)
        enablePostMortemValue = enablePostMortem.get()
        from post_processing import g_postProcessing
        g_postProcessing.setSetting('mortem_post_effect',
                                    enablePostMortemValue)
        g_postProcessing.refresh()
        enableDynamicCamera = self._core.options.getSetting(
            self.GAME.DYNAMIC_CAMERA)
        enableDynamicCameraValue = enableDynamicCamera.get()
        enableSniperStabilization = self._core.options.getSetting(
            self.GAME.SNIPER_MODE_STABILIZATION)
        enableSniperStabilizationValue = enableSniperStabilization.get()
        from AvatarInputHandler import AvatarInputHandler
        AvatarInputHandler.enableDynamicCamera(enableDynamicCameraValue,
                                               enableSniperStabilizationValue)
        from messenger.doc_loaders import user_prefs
        from messenger import g_settings as messenger_settings
        user_prefs.loadFromServer(messenger_settings)
        masks = self.SECTIONS[SETTINGS_SECTIONS.GRAPHICS].masks
        offsets = self.SECTIONS[SETTINGS_SECTIONS.GRAPHICS].offsets
        graphicSettingNames = masks.keys() + offsets.keys()
        for setting in graphicSettingNames:
            settingOption = self._core.options.getSetting(setting)
            settingValue = settingOption.get()
            settingOption.setSystemValue(settingValue)

        alternativeVoices = self._core.options.getSetting(
            self.SOUND.ALT_VOICES)
        alternativeVoicesValue = alternativeVoices.get()
        alternativeVoices.setSystemValue(alternativeVoicesValue)
        self._core.options.getSetting('keyboard').setSystemValue()
        if isPlayerAvatar():
            BigWorld.player(
            ).invRotationOnBackMovement = self._core.getSetting(
                'backDraftInvert')
示例#4
0
    def apply(self, restartApproved, callbackId, settings):
        restartClient = False
        g_settingsCore.isDeviseRecreated = False
        import VOIP
        if (not self.resolutions.isVideoWindowed or settings['fullScreen']) and (settings['monitor'] != self.resolutions.realMonitorIndex or self.resolutions.monitorChanged):
            restartClient = True
        g_settingsCore.applySetting('ppShowTypes', settings['ppShowTypes'])
        g_settingsCore.applySetting('ppShowLevels', settings['ppShowLevels'])
        g_settingsCore.applySetting('replayEnabled', settings['replayEnabled'])
        g_settingsCore.applySetting('fpsPerfomancer', settings['fpsPerfomancer'])
        g_settingsCore.applySetting('dynamicRenderer', settings['dynamicRenderer'])
        g_settingsCore.applySetting('colorFilterIntensity', settings['colorFilterIntensity'])
        g_settingsCore.applySetting('fov', settings['fov'])
        g_settingsCore.applySetting('dynamicFov', settings['dynamicFov'])
        g_settingsCore.applySetting('enableOpticalSnpEffect', settings['enableOpticalSnpEffect'])
        g_settingsCore.applySetting('nationalVoices', settings['nationalVoices'])
        g_settingsCore.applySetting('isColorBlind', settings['isColorBlind'])
        g_settingsCore.applySetting('useServerAim', settings['useServerAim'])
        g_settingsCore.applySetting('showVehiclesCounter', settings['showVehiclesCounter'])
        g_settingsCore.applySetting('showMarksOnGun', settings['showMarksOnGun'])
        g_settingsCore.applySetting('minimapAlpha', settings['minimapAlpha'])
        g_settingsCore.applySetting('showVectorOnMap', settings['showVectorOnMap'])
        g_settingsCore.applySetting('showSectorOnMap', settings['showSectorOnMap'])
        g_settingsCore.applySetting('showVehModelsOnMap', settings['showVehModelsOnMap'])
        arcade = g_settingsCore.options.getSetting('arcade').fromAccountSettings(settings['arcade'])
        sniper = g_settingsCore.options.getSetting('sniper').fromAccountSettings(settings['sniper'])
        g_settingsCore.applySetting('arcade', arcade)
        g_settingsCore.applySetting('sniper', sniper)
        g_settingsCore.applySetting('enemy', settings['markers']['enemy'])
        g_settingsCore.applySetting('dead', settings['markers']['dead'])
        g_settingsCore.applySetting('ally', settings['markers']['ally'])
        g_settingsCore.applySetting('dynamicCamera', settings['dynamicCamera'])
        g_settingsCore.applySetting('horStabilizationSnp', settings['horStabilizationSnp'])
        if self.__altVoiceSetting.isOptionEnabled():
            altVoices = settings.get('alternativeVoices')
            if altVoices is not None:
                self.__altVoiceSetting.apply(altVoices)
        vManager = VibroManager.g_instance
        vManager.setGain(settings['vibroGain'] / 100.0)
        vEffGroups = vManager.getGroupsSettings()
        for groupName, newValue in [('engine', settings['vibroEngine']),
         ('acceleration', settings['vibroAcceleration']),
         ('shots', settings['vibroShots']),
         ('hits', settings['vibroHits']),
         ('collisions', settings['vibroCollisions']),
         ('damage', settings['vibroDamage']),
         ('gui', settings['vibroGUI'])]:
            if groupName in vEffGroups:
                vEffGroups[groupName].gain = newValue / 100.0
                vEffGroups[groupName].enabled = newValue > 0

        vManager.setGroupsSettings(vEffGroups)
        self.__voiceChatEnable(settings['enableVoIP'])
        g_settingsCore.applySetting(SOUND.CAPTURE_DEVICES, settings[Settings.KEY_VOIP_DEVICE])
        g_settingsCore.applySetting('enablePostMortemEffect', settings['enablePostMortemEffect'])
        g_settingsCore.applySetting('enablePostMortemDelay', settings['enablePostMortemDelay'])
        self.uiHolder.clearCommands()
        keyboard = settings['controls']['keyboard']
        keyboardMapping = {}
        keysLayout = dict(g_settingsCore.options.getSetting('keyboard').KEYS_LAYOUT)
        layout = list(itertools.chain(*keysLayout.values()))
        for i in xrange(len(self.KEYBOARD_MAPPING_BLOCKS)):
            group_name = keyboard[i]['id']
            for j in xrange(len(self.KEYBOARD_MAPPING_BLOCKS[group_name])):
                key_name = keyboard[i]['commands'][j]['id']
                value = keyboard[i]['commands'][j]['key']
                cmd = self.KEYBOARD_MAPPING_COMMANDS[group_name][key_name]
                for item in layout:
                    key, command = item[0], item[1]
                    if command == cmd:
                        keyboardMapping[key] = value
                        break

        g_settingsCore.applySetting('keyboard', keyboardMapping)
        self.uiHolder.bindCommands()
        player = BigWorld.player()
        mouse = settings['controls']['mouse']
        if hasattr(player.inputHandler, 'ctrls'):
            player.inputHandler.ctrls['arcade'].camera.setUserConfigValue('sensitivity', mouse['arcadeSens']['value'])
            player.inputHandler.ctrls['sniper'].camera.setUserConfigValue('sensitivity', mouse['sniperSens']['value'])
            player.inputHandler.ctrls['strategic'].camera.setUserConfigValue('sensitivity', mouse['artSens']['value'])
        else:
            ds = Settings.g_instance.userPrefs[Settings.KEY_CONTROL_MODE]
            if ds:
                ds['arcadeMode/camera'].writeFloat('sensitivity', mouse['arcadeSens']['value'])
                ds['sniperMode/camera'].writeFloat('sensitivity', mouse['sniperSens']['value'])
                ds['strategicMode/camera'].writeFloat('sensitivity', mouse['artSens']['value'])
        g_settingsCore.applySetting('mouseHorzInvert', bool(mouse['horInvert']['value']))
        g_settingsCore.applySetting('mouseVertInvert', bool(mouse['vertInvert']['value']))
        g_settingsCore.applySetting('backDraftInvert', bool(mouse['backDraftInvert']['value']))
        isFullScreen = bool(settings['fullScreen'])
        if isFullScreen:
            g_settingsCore.applySetting('refreshRate', settings['refreshRate'])
            g_settingsCore.applySetting('resolution', settings['resolution'])
            g_settingsCore.applySetting('aspectRatio', settings['aspectRatio'])
            g_settingsCore.applySetting('gamma', settings['gamma'])
        else:
            g_settingsCore.applySetting('windowSize', settings['windowSize'])
        g_settingsCore.applySetting('fullScreen', isFullScreen)
        g_settingsCore.applySetting('multisampling', settings['multisampling'])
        g_settingsCore.applySetting('customAA', settings['customAA'])
        g_settingsCore.applySetting('monitor', settings['monitor'])
        g_settingsCore.applySetting('vertSync', settings['vertSync'])
        g_settingsCore.applySetting('tripleBuffered', settings['tripleBuffered'])
        if round(SoundGroups.g_instance.getVolume('masterVivox') * 100) != settings['masterVivoxVolume']:
            VOIP.getVOIPManager().setMasterVolume(settings['masterVivoxVolume'])
        if round(SoundGroups.g_instance.getVolume('micVivox') * 100) != settings['micVivoxVolume']:
            VOIP.getVOIPManager().setMicrophoneVolume(settings['micVivoxVolume'])
        SoundGroups.g_instance.setMasterVolume(float(settings['masterVolume']) / 100)
        SoundGroups.g_instance.setVolume('music', float(settings['musicVolume']) / 100)
        SoundGroups.g_instance.setVolume('voice', float(settings['voiceVolume']) / 100)
        SoundGroups.g_instance.setVolume('vehicles', float(settings['vehiclesVolume']) / 100)
        SoundGroups.g_instance.setVolume('effects', float(settings['effectsVolume']) / 100)
        SoundGroups.g_instance.setVolume('gui', float(settings['guiVolume']) / 100)
        SoundGroups.g_instance.setVolume('ambient', float(settings['ambientVolume']) / 100)
        SoundGroups.g_instance.setVolume('masterVivox', float(settings['masterVivoxVolume']) / 100)
        SoundGroups.g_instance.setVolume('micVivox', float(settings['micVivoxVolume']) / 100)
        SoundGroups.g_instance.setVolume('masterFadeVivox', float(settings['masterFadeVivoxVolume']) / 100)
        from BattleReplay import g_replayCtrl
        if g_replayCtrl is not None and g_replayCtrl.isPlaying:
            if g_replayCtrl.playbackSpeed == 0 or g_replayCtrl.playbackSpeed > 4.0:
                SoundGroups.g_instance.enableReplaySounds(False)
        g_settingsCore.applySetting('showDateMessage', settings['datetimeIdx'] & 1)
        g_settingsCore.applySetting('showTimeMessage', settings['datetimeIdx'] & 2)
        g_settingsCore.applySetting('enableOlFilter', settings['enableOlFilter'])
        g_settingsCore.applySetting('enableSpamFilter', settings['enableSpamFilter'])
        g_windowsStoredData.start()
        g_settingsCore.applySetting('enableStoreMws', settings['enableStoreChatMws'])
        g_settingsCore.applySetting('enableStoreCws', settings['enableStoreChatCws'])
        g_windowsStoredData.stop()
        g_settingsCore.applySetting('invitesFromFriendsOnly', settings['invitesFromFriendsOnly'])
        g_settingsCore.applySetting('storeReceiverInBattle', settings['storeReceiverInBattle'])
        g_settingsCore.applySetting('disableBattleChat', settings['disableBattleChat'])
        gameplayKeys = filter(lambda item: item.startswith(self.GAMEPLAY_PREFIX), settings.keys())
        for key in gameplayKeys:
            g_settingsCore.applySetting(key, settings[key])

        qualitySettings = settings['quality']
        applyMethod = g_settingsCore.options.getApplyMethod(qualitySettings)
        for key in GraphicsPresets.GRAPHICS_QUALITY_SETTINGS:
            value = qualitySettings.get(key)
            if value is not None:
                g_settingsCore.applySetting(key, value)

        if applyMethod == APPLY_METHOD.RESTART:
            BigWorld.commitPendingGraphicsSettings()
            restartClient = True
        elif applyMethod == APPLY_METHOD.DELAYED:
            BigWorld.commitPendingGraphicsSettings()
        confirmators = g_settingsCore.applyStorages(restartClient)
        for confirmation, revert in confirmators:
            if confirmation is not None:
                if confirmation == 'graphicsChangeConfirmation':

                    def callback(isConfirmed):
                        if not isConfirmed:
                            g_settingsCore.isChangesConfirmed = False
                            revert()

                    self.graphicsChangeConfirmationRevert = revert
                    self.call('SettingsDialog.ApplySettings', [confirmation])

        g_postProcessing.refresh()
        if restartClient:
            BigWorld.savePreferences()
            if restartApproved:
                if g_replayCtrl.isPlaying and g_replayCtrl.playbackSpeed == 0:
                    g_replayCtrl.setPlaybackSpeedIdx(5)
                BigWorld.callback(0.3, self.__restartGame)
            elif g_settingsCore.isDeviseRecreated:
                g_settingsCore.isDeviseRecreated = False
            else:
                BigWorld.callback(0.0, partial(BigWorld.changeVideoMode, -1, BigWorld.isVideoWindowed()))
        return
    def apply(self, restartApproved, callbackId, settings):
        restartClient = False
        import VOIP
        ppSettings = dict(AccountSettings.getSettings('players_panel'))
        ppSettings['showTypes'] = settings['ppShowTypes']
        if (not self.resolutions.isVideoWindowed or settings['fullScreen']) and (settings['monitor'] != self.resolutions.realMonitorIndex or self.resolutions.monitorChanged):
            restartClient = True
        AccountSettings.setSettings('players_panel', ppSettings)
        g_settingsCore.applySetting('ppShowLevels', settings['ppShowLevels'])
        g_settingsCore.applySetting('replayEnabled', settings['replayEnabled'])
        g_settingsCore.applySetting('fpsPerfomancer', settings['fpsPerfomancer'])
        AccountSettings.setSettings('nationalVoices', settings['nationalVoices'])
        AccountSettings.setSettings('isColorBlind', settings['isColorBlind'])
        g_settingsCore.applySetting('useServerAim', settings['useServerAim'])
        g_settingsCore.applySetting('showVehiclesCounter', settings['showVehiclesCounter'])
        g_settingsCore.applySetting('minimapAlpha', settings['minimapAlpha'])
        arcade = g_settingsCore.options.getSetting('arcade').fromAccountSettings(settings['arcade'])
        sniper = g_settingsCore.options.getSetting('sniper').fromAccountSettings(settings['sniper'])
        g_settingsCore.applySetting('arcade', arcade)
        g_settingsCore.applySetting('sniper', sniper)
        g_settingsCore.applySetting('enemy', settings['markers']['enemy'])
        g_settingsCore.applySetting('dead', settings['markers']['dead'])
        g_settingsCore.applySetting('ally', settings['markers']['ally'])
        g_settingsCore.applySetting('dynamicCamera', settings['dynamicCamera'])
        g_settingsCore.applySetting('horStabilizationSnp', settings['horStabilizationSnp'])
        if self.__altVoiceSetting.isOptionEnabled():
            altVoices = settings.get('alternativeVoices')
            if altVoices is not None:
                self.__altVoiceSetting.apply(altVoices)
        vManager = VibroManager.g_instance
        vManager.setGain(settings['vibroGain'] / 100.0)
        vEffGroups = vManager.getGroupsSettings()
        for groupName, newValue in [('engine', settings['vibroEngine']),
         ('acceleration', settings['vibroAcceleration']),
         ('shots', settings['vibroShots']),
         ('hits', settings['vibroHits']),
         ('collisions', settings['vibroCollisions']),
         ('damage', settings['vibroDamage']),
         ('gui', settings['vibroGUI'])]:
            if groupName in vEffGroups:
                vEffGroups[groupName].gain = newValue / 100.0
                vEffGroups[groupName].enabled = newValue > 0

        vManager.setGroupsSettings(vEffGroups)
        self.__voiceChatEnable(settings['enableVoIP'])
        self.__changeCaptureDevice(settings[Settings.KEY_VOIP_DEVICE])
        g_settingsCore.applySetting('enablePostMortemEffect', settings['enablePostMortemEffect'])
        self.uiHolder.clearCommands()
        keyboard = settings['controls']['keyboard']
        keyboardMapping = {}
        keysLayout = dict(g_settingsCore.options.getSetting('keyboard').KEYS_LAYOUT)
        layout = list(itertools.chain(*keysLayout.values()))
        for i in xrange(len(self.KEYBOARD_MAPPING_BLOCKS)):
            group_name = keyboard[i]['id']
            for j in xrange(len(self.KEYBOARD_MAPPING_BLOCKS[group_name])):
                key_name = keyboard[i]['commands'][j]['id']
                value = keyboard[i]['commands'][j]['key']
                cmd = self.KEYBOARD_MAPPING_COMMANDS[group_name][key_name]
                for item in layout:
                    key, command = item[0], item[1]
                    if command == cmd:
                        keyboardMapping[key] = value
                        break

        g_settingsCore.applySetting('keyboard', keyboardMapping)
        self.uiHolder.bindCommands()
        player = BigWorld.player()
        mouse = settings['controls']['mouse']
        if hasattr(player.inputHandler, 'ctrls'):
            player.inputHandler.ctrls['arcade'].camera.setUserConfigValue('sensitivity', mouse['arcadeSens']['value'])
            player.inputHandler.ctrls['sniper'].camera.setUserConfigValue('sensitivity', mouse['sniperSens']['value'])
            player.inputHandler.ctrls['strategic'].camera.setUserConfigValue('sensitivity', mouse['artSens']['value'])
        else:
            ds = Settings.g_instance.userPrefs[Settings.KEY_CONTROL_MODE]
            if ds:
                ds['arcadeMode/camera'].writeFloat('sensitivity', mouse['arcadeSens']['value'])
                ds['sniperMode/camera'].writeFloat('sensitivity', mouse['sniperSens']['value'])
                ds['strategicMode/camera'].writeFloat('sensitivity', mouse['artSens']['value'])
        g_settingsCore.applySetting('mouseHorzInvert', bool(mouse['horInvert']['value']))
        g_settingsCore.applySetting('mouseVertInvert', bool(mouse['vertInvert']['value']))
        g_settingsCore.applySetting('backDraftInvert', bool(mouse['backDraftInvert']['value']))
        self.resolutions.applyChanges(settings['fullScreen'], settings['vertSync'], settings['tripleBuffered'], settings['windowSize'] if not settings['fullScreen'] else settings['resolution'], settings['aspectRatio'], settings['multisampling'], settings['customAA'], settings['gamma'], settings['monitor'])
        if round(SoundGroups.g_instance.getVolume('masterVivox') * 100) != settings['masterVivoxVolume']:
            VOIP.getVOIPManager().setMasterVolume(settings['masterVivoxVolume'])
        if round(SoundGroups.g_instance.getVolume('micVivox') * 100) != settings['micVivoxVolume']:
            VOIP.getVOIPManager().setMicrophoneVolume(settings['micVivoxVolume'])
        SoundGroups.g_instance.setMasterVolume(float(settings['masterVolume']) / 100)
        SoundGroups.g_instance.setVolume('music', float(settings['musicVolume']) / 100)
        SoundGroups.g_instance.setVolume('voice', float(settings['voiceVolume']) / 100)
        SoundGroups.g_instance.setVolume('vehicles', float(settings['vehiclesVolume']) / 100)
        SoundGroups.g_instance.setVolume('effects', float(settings['effectsVolume']) / 100)
        SoundGroups.g_instance.setVolume('gui', float(settings['guiVolume']) / 100)
        SoundGroups.g_instance.setVolume('ambient', float(settings['ambientVolume']) / 100)
        SoundGroups.g_instance.setVolume('masterVivox', float(settings['masterVivoxVolume']) / 100)
        SoundGroups.g_instance.setVolume('micVivox', float(settings['micVivoxVolume']) / 100)
        SoundGroups.g_instance.setVolume('masterFadeVivox', float(settings['masterFadeVivoxVolume']) / 100)
        if len(VOIP.getVOIPManager().captureDevices):
            device = VOIP.getVOIPManager().captureDevices[0]
            if len(VOIP.getVOIPManager().captureDevices) > settings['captureDevice']:
                device = VOIP.getVOIPManager().captureDevices[settings['captureDevice']]
            VOIP.getVOIPManager().setCaptureDevice(device)
        g_settingsCore.applySetting('showDateMessage', settings['datetimeIdx'] & 1)
        g_settingsCore.applySetting('showTimeMessage', settings['datetimeIdx'] & 2)
        g_settingsCore.applySetting('enableOlFilter', settings['enableOlFilter'])
        g_settingsCore.applySetting('enableSpamFilter', settings['enableSpamFilter'])
        g_windowsStoredData.start()
        g_settingsCore.applySetting('enableStoreMws', settings['enableStoreChatMws'])
        g_settingsCore.applySetting('enableStoreCws', settings['enableStoreChatCws'])
        g_windowsStoredData.stop()
        g_settingsCore.applySetting('invitesFromFriendsOnly', settings['invitesFromFriendsOnly'])
        g_settingsCore.applySetting('storeReceiverInBattle', settings['storeReceiverInBattle'])
        gameplayKeys = filter(lambda item: item.startswith(self.GAMEPLAY_PREFIX) and bool(settings[item]), settings.keys())
        prefixLen = len(self.GAMEPLAY_PREFIX)
        gameplay_ctx.setMaskByNames(map(lambda key: str(key[prefixLen:]), gameplayKeys))
        qualitySettings = settings['quality']
        applyPresets = self.graphicsPresets.checkApplyGraphicsPreset(int(settings['graphicsQuality']), qualitySettings)
        if applyPresets:
            self.graphicsPresets.applyGraphicsPresets(int(settings['graphicsQuality']), qualitySettings)
            if applyPresets == 'restartNeeded':
                BigWorld.commitPendingGraphicsSettings()
                restartClient = True
            elif applyPresets == 'hasPendingSettings':
                BigWorld.commitPendingGraphicsSettings()
        g_settingsCore.applyStorages()
        g_postProcessing.refresh()
        if restartClient:
            BigWorld.savePreferences()
            if restartApproved:
                from BattleReplay import g_replayCtrl
                if g_replayCtrl.isPlaying and g_replayCtrl.playbackSpeed == 0:
                    g_replayCtrl.setPlaybackSpeedIdx(5)
                BigWorld.callback(0.3, BigWorld.restartGame)
            else:
                BigWorld.callback(0.0, partial(BigWorld.changeVideoMode, -1, BigWorld.isVideoWindowed()))
        return
    def apply(self, restartApproved, callbackId, settings):
        restartClient = False
        interfaceScaled = False
        g_settingsCore.isDeviseRecreated = False
        isSoundChanged = settings[
            SOUND.MASTER_TOGGLE] is not g_settingsCore.getSetting(
                SOUND.MASTER_TOGGLE) or settings[
                    SOUND.SOUND_QUALITY] is not g_settingsCore.getSetting(
                        SOUND.SOUND_QUALITY)
        import VOIP
        if (not self.resolutions.isVideoWindowed or settings['fullScreen']
            ) and (settings['monitor'] != self.resolutions.realMonitorIndex
                   or self.resolutions.monitorChanged):
            restartClient = True
        if g_settingsCore.getSetting(
                'interfaceScale') != settings['interfaceScale']:
            interfaceScaled = True
        g_settingsCore.applySetting('ppShowTypes', settings['ppShowTypes'])
        g_settingsCore.applySetting('ppShowLevels', settings['ppShowLevels'])
        g_settingsCore.applySetting('replayEnabled', settings['replayEnabled'])
        g_settingsCore.applySetting('fpsPerfomancer',
                                    settings['fpsPerfomancer'])
        g_settingsCore.applySetting('colorFilterIntensity',
                                    settings['colorFilterIntensity'])
        g_settingsCore.applySetting('fov', settings['fov'])
        g_settingsCore.applySetting('dynamicFov', settings['dynamicFov'])
        g_settingsCore.applySetting('enableOpticalSnpEffect',
                                    settings['enableOpticalSnpEffect'])
        g_settingsCore.applySetting('isColorBlind', settings['isColorBlind'])
        g_settingsCore.applySetting('useServerAim', settings['useServerAim'])
        g_settingsCore.applySetting('showVehiclesCounter',
                                    settings['showVehiclesCounter'])
        g_settingsCore.applySetting('showMarksOnGun',
                                    settings['showMarksOnGun'])
        g_settingsCore.applySetting('simplifiedTTC', settings['simplifiedTTC'])
        g_settingsCore.applySetting('minimapAlpha', settings['minimapAlpha'])
        g_settingsCore.applySetting('showVectorOnMap',
                                    settings['showVectorOnMap'])
        g_settingsCore.applySetting('showSectorOnMap',
                                    settings['showSectorOnMap'])
        g_settingsCore.applySetting('showVehModelsOnMap',
                                    settings['showVehModelsOnMap'])
        g_settingsCore.applySetting('minimapViewRange',
                                    settings['minimapViewRange'])
        g_settingsCore.applySetting('minimapMaxViewRange',
                                    settings['minimapMaxViewRange'])
        g_settingsCore.applySetting('minimapDrawRange',
                                    settings['minimapDrawRange'])
        g_settingsCore.applySetting('battleLoadingInfo',
                                    settings['battleLoadingInfo'])
        arcade = g_settingsCore.options.getSetting(
            'arcade').fromAccountSettings(settings['arcade'])
        sniper = g_settingsCore.options.getSetting(
            'sniper').fromAccountSettings(settings['sniper'])
        g_settingsCore.applySetting('arcade', arcade)
        g_settingsCore.applySetting('sniper', sniper)
        g_settingsCore.applySetting('enemy', settings['markers']['enemy'])
        g_settingsCore.applySetting('dead', settings['markers']['dead'])
        g_settingsCore.applySetting('ally', settings['markers']['ally'])
        g_settingsCore.applySetting('interfaceScale',
                                    settings['interfaceScale'])
        if 'showBattleEfficiencyRibbons' in settings:
            g_settingsCore.applySetting(
                'showBattleEfficiencyRibbons',
                settings['showBattleEfficiencyRibbons'])
        g_settingsCore.applySetting('dynamicCamera', settings['dynamicCamera'])
        g_settingsCore.applySetting('horStabilizationSnp',
                                    settings['horStabilizationSnp'])
        g_settingsCore.applySetting('increasedZoom', settings['increasedZoom'])
        g_settingsCore.applySetting('sniperModeByShift',
                                    settings['sniperModeByShift'])
        if self.__altVoiceSetting.isOptionEnabled():
            altVoices = settings.get('alternativeVoices')
            if altVoices is not None:
                self.__altVoiceSetting.apply(altVoices)
        vManager = VibroManager.g_instance
        vManager.setGain(settings['vibroGain'] / 100.0)
        vEffGroups = vManager.getGroupsSettings()
        for groupName, newValue in [
            ('engine', settings['vibroEngine']),
            ('acceleration', settings['vibroAcceleration']),
            ('shots', settings['vibroShots']), ('hits', settings['vibroHits']),
            ('collisions', settings['vibroCollisions']),
            ('damage', settings['vibroDamage']), ('gui', settings['vibroGUI'])
        ]:
            if groupName in vEffGroups:
                vEffGroups[groupName].gain = newValue / 100.0
                vEffGroups[groupName].enabled = newValue > 0

        vManager.setGroupsSettings(vEffGroups)
        self.__voiceChatEnable(settings['enableVoIP'])
        g_settingsCore.applySetting(SOUND.CAPTURE_DEVICES,
                                    settings[Settings.KEY_VOIP_DEVICE])
        g_settingsCore.applySetting('enablePostMortemEffect',
                                    settings['enablePostMortemEffect'])
        g_settingsCore.applySetting('enablePostMortemDelay',
                                    settings['enablePostMortemDelay'])
        self.uiHolder.clearCommands()
        keyboard = settings['controls']['keyboard']
        keyboardMapping = {}
        keysLayout = dict(
            g_settingsCore.options.getSetting('keyboard').KEYS_LAYOUT)
        layout = list(itertools.chain(*keysLayout.values()))
        for i in xrange(len(self.KEYBOARD_MAPPING_BLOCKS)):
            group_name = keyboard[i]['id']
            for j in xrange(len(self.KEYBOARD_MAPPING_BLOCKS[group_name])):
                key_name = keyboard[i]['commands'][j]['id']
                value = keyboard[i]['commands'][j]['key']
                cmd = self.KEYBOARD_MAPPING_COMMANDS[group_name][key_name]
                for item in layout:
                    key, command = item[0], item[1]
                    if command == cmd:
                        keyboardMapping[key] = value
                        break

        g_settingsCore.applySetting('keyboard', keyboardMapping)
        self.uiHolder.bindCommands()
        player = BigWorld.player()
        mouse = settings['controls']['mouse']
        if hasattr(player.inputHandler, 'ctrls'):
            player.inputHandler.ctrls['arcade'].camera.setUserConfigValue(
                'sensitivity', mouse['arcadeSens']['value'])
            player.inputHandler.ctrls['sniper'].camera.setUserConfigValue(
                'sensitivity', mouse['sniperSens']['value'])
            player.inputHandler.ctrls['strategic'].camera.setUserConfigValue(
                'sensitivity', mouse['artSens']['value'])
        else:
            ds = Settings.g_instance.userPrefs[Settings.KEY_CONTROL_MODE]
            if ds:
                ds['arcadeMode/camera'].writeFloat(
                    'sensitivity', mouse['arcadeSens']['value'])
                ds['sniperMode/camera'].writeFloat(
                    'sensitivity', mouse['sniperSens']['value'])
                ds['strategicMode/camera'].writeFloat(
                    'sensitivity', mouse['artSens']['value'])
        g_settingsCore.applySetting('mouseHorzInvert',
                                    bool(mouse['horInvert']['value']))
        g_settingsCore.applySetting('mouseVertInvert',
                                    bool(mouse['vertInvert']['value']))
        g_settingsCore.applySetting('backDraftInvert',
                                    bool(mouse['backDraftInvert']['value']))
        g_settingsCore.applySetting('monitor', settings['monitor'])
        isFullScreen = bool(settings['fullScreen'])
        if isFullScreen:
            g_settingsCore.applySetting('refreshRate', settings['refreshRate'])
            g_settingsCore.applySetting('resolution', settings['resolution'])
            g_settingsCore.applySetting('aspectRatio', settings['aspectRatio'])
            g_settingsCore.applySetting('gamma', settings['gamma'])
        else:
            g_settingsCore.applySetting('windowSize', settings['windowSize'])
        g_settingsCore.applySetting('fullScreen', isFullScreen)
        g_settingsCore.applySetting('multisampling', settings['multisampling'])
        g_settingsCore.applySetting('customAA', settings['customAA'])
        g_settingsCore.applySetting('vertSync', settings['vertSync'])
        g_settingsCore.applySetting('tripleBuffered',
                                    settings['tripleBuffered'])
        if round(SoundGroups.g_instance.getVolume('masterVivox') *
                 100) != settings['masterVivoxVolume']:
            VOIP.getVOIPManager().setMasterVolume(
                settings['masterVivoxVolume'])
        if round(SoundGroups.g_instance.getVolume('micVivox') *
                 100) != settings['micVivoxVolume']:
            VOIP.getVOIPManager().setMicrophoneVolume(
                settings['micVivoxVolume'])
        for s in (SOUND.MASTER_TOGGLE, SOUND.SOUND_QUALITY):
            g_settingsCore.applySetting(s, settings[s])

        SoundGroups.g_instance.setMasterVolume(
            float(settings['masterVolume']) / 100)
        SoundGroups.g_instance.setVolume('music',
                                         float(settings['musicVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'vehicles',
            float(settings['vehiclesVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'effects',
            float(settings['effectsVolume']) / 100)
        SoundGroups.g_instance.setVolume('gui',
                                         float(settings['guiVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'ambient',
            float(settings['ambientVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'masterVivox',
            float(settings['masterVivoxVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'micVivox',
            float(settings['micVivoxVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'masterFadeVivox',
            float(settings['masterFadeVivoxVolume']) / 100)
        g_settingsCore.applySetting('dynamicRange', settings['dynamicRange'])
        g_settingsCore.applySetting('soundDevice', settings['soundDevice'])
        g_settingsCore.applySetting('showDateMessage',
                                    settings['datetimeIdx'] & 1)
        g_settingsCore.applySetting('showTimeMessage',
                                    settings['datetimeIdx'] & 2)
        g_settingsCore.applySetting('enableOlFilter',
                                    settings['enableOlFilter'])
        g_settingsCore.applySetting('enableSpamFilter',
                                    settings['enableSpamFilter'])
        g_windowsStoredData.start()
        g_settingsCore.applySetting('receiveFriendshipRequest',
                                    settings['receiveFriendshipRequest'])
        g_settingsCore.applySetting('receiveInvitesInBattle',
                                    settings.get('receiveInvitesInBattle'))
        g_settingsCore.applySetting(
            'receiveClanInvitesNotifications',
            settings.get('receiveClanInvitesNotifications'))
        g_windowsStoredData.stop()
        g_settingsCore.applySetting('invitesFromFriendsOnly',
                                    settings['invitesFromFriendsOnly'])
        g_settingsCore.applySetting('disableBattleChat',
                                    settings['disableBattleChat'])
        g_settingsCore.applySetting('chatContactsListOnly',
                                    settings['chatContactsListOnly'])
        gameplayKeys = filter(
            lambda item: item.startswith(self.GAMEPLAY_PREFIX),
            settings.keys())
        for key in gameplayKeys:
            g_settingsCore.applySetting(key, settings[key])

        qualitySettings = settings['quality']
        applyMethod = g_settingsCore.options.getApplyMethod(qualitySettings)
        for key in GraphicsPresets.GRAPHICS_QUALITY_SETTINGS:
            value = qualitySettings.get(key)
            if value is not None:
                g_settingsCore.applySetting(key, value)

        g_settingsCore.applySetting('dynamicRenderer',
                                    settings['dynamicRenderer'])
        if applyMethod == APPLY_METHOD.RESTART or isSoundChanged:
            BigWorld.commitPendingGraphicsSettings()
            restartClient = True
        elif applyMethod == APPLY_METHOD.DELAYED:
            BigWorld.commitPendingGraphicsSettings()
        confirmators = g_settingsCore.applyStorages(restartClient)
        for confirmation, revert in confirmators:
            if confirmation is not None:
                if confirmation == 'graphicsChangeConfirmation':

                    def callback(isConfirmed):
                        if not isConfirmed:
                            g_settingsCore.isChangesConfirmed = False
                            revert()

                    self.graphicsChangeConfirmationRevert = revert
                    self.call('SettingsDialog.ApplySettings', [confirmation])

        g_postProcessing.refresh()
        if restartClient:
            BigWorld.savePreferences()
            if restartApproved:
                from BattleReplay import g_replayCtrl
                if g_replayCtrl.isPlaying and g_replayCtrl.playbackSpeed == 0:
                    g_replayCtrl.setPlaybackSpeedIdx(5)
                BigWorld.callback(0.3, self.__restartGame)
            elif g_settingsCore.isDeviseRecreated:
                g_settingsCore.isDeviseRecreated = False
            else:
                BigWorld.callback(
                    0.0,
                    partial(BigWorld.changeVideoMode, -1,
                            BigWorld.isVideoWindowed()))
        if interfaceScaled:
            self.__settingsUI.buildGraphicsData(self.__getVideoSettings())
        return
示例#7
0
    def apply(self, restartApproved, callbackId, settings):
        restartClient = False
        import VOIP
        ppSettings = dict(AccountSettings.getSettings('players_panel'))
        ppSettings['showTypes'] = settings['ppShowTypes']
        if (not self.resolutions.isVideoWindowed or settings['fullScreen']
            ) and (settings['monitor'] != self.resolutions.realMonitorIndex
                   or self.resolutions.monitorChanged):
            restartClient = True
        AccountSettings.setSettings('players_panel', ppSettings)
        g_settingsCore.applySetting('ppShowLevels', settings['ppShowLevels'])
        g_settingsCore.applySetting('replayEnabled', settings['replayEnabled'])
        g_settingsCore.applySetting('fpsPerfomancer',
                                    settings['fpsPerfomancer'])
        AccountSettings.setSettings('nationalVoices',
                                    settings['nationalVoices'])
        AccountSettings.setSettings('isColorBlind', settings['isColorBlind'])
        g_settingsCore.applySetting('useServerAim', settings['useServerAim'])
        g_settingsCore.applySetting('showVehiclesCounter',
                                    settings['showVehiclesCounter'])
        g_settingsCore.applySetting('minimapAlpha', settings['minimapAlpha'])
        arcade = g_settingsCore.options.getSetting(
            'arcade').fromAccountSettings(settings['arcade'])
        sniper = g_settingsCore.options.getSetting(
            'sniper').fromAccountSettings(settings['sniper'])
        g_settingsCore.applySetting('arcade', arcade)
        g_settingsCore.applySetting('sniper', sniper)
        g_settingsCore.applySetting('enemy', settings['markers']['enemy'])
        g_settingsCore.applySetting('dead', settings['markers']['dead'])
        g_settingsCore.applySetting('ally', settings['markers']['ally'])
        g_settingsCore.applySetting('dynamicCamera', settings['dynamicCamera'])
        g_settingsCore.applySetting('horStabilizationSnp',
                                    settings['horStabilizationSnp'])
        if self.__altVoiceSetting.isOptionEnabled():
            altVoices = settings.get('alternativeVoices')
            if altVoices is not None:
                self.__altVoiceSetting.apply(altVoices)
        vManager = VibroManager.g_instance
        vManager.setGain(settings['vibroGain'] / 100.0)
        vEffGroups = vManager.getGroupsSettings()
        for groupName, newValue in [
            ('engine', settings['vibroEngine']),
            ('acceleration', settings['vibroAcceleration']),
            ('shots', settings['vibroShots']), ('hits', settings['vibroHits']),
            ('collisions', settings['vibroCollisions']),
            ('damage', settings['vibroDamage']), ('gui', settings['vibroGUI'])
        ]:
            if groupName in vEffGroups:
                vEffGroups[groupName].gain = newValue / 100.0
                vEffGroups[groupName].enabled = newValue > 0

        vManager.setGroupsSettings(vEffGroups)
        self.__voiceChatEnable(settings['enableVoIP'])
        self.__changeCaptureDevice(settings[Settings.KEY_VOIP_DEVICE])
        g_settingsCore.applySetting('enablePostMortemEffect',
                                    settings['enablePostMortemEffect'])
        self.uiHolder.clearCommands()
        keyboard = settings['controls']['keyboard']
        keyboardMapping = {}
        keysLayout = dict(
            g_settingsCore.options.getSetting('keyboard').KEYS_LAYOUT)
        layout = list(itertools.chain(*keysLayout.values()))
        for i in xrange(len(self.KEYBOARD_MAPPING_BLOCKS)):
            group_name = keyboard[i]['id']
            for j in xrange(len(self.KEYBOARD_MAPPING_BLOCKS[group_name])):
                key_name = keyboard[i]['commands'][j]['id']
                value = keyboard[i]['commands'][j]['key']
                cmd = self.KEYBOARD_MAPPING_COMMANDS[group_name][key_name]
                for item in layout:
                    key, command = item[0], item[1]
                    if command == cmd:
                        keyboardMapping[key] = value
                        break

        g_settingsCore.applySetting('keyboard', keyboardMapping)
        self.uiHolder.bindCommands()
        player = BigWorld.player()
        mouse = settings['controls']['mouse']
        if hasattr(player.inputHandler, 'ctrls'):
            player.inputHandler.ctrls['arcade'].camera.setUserConfigValue(
                'sensitivity', mouse['arcadeSens']['value'])
            player.inputHandler.ctrls['sniper'].camera.setUserConfigValue(
                'sensitivity', mouse['sniperSens']['value'])
            player.inputHandler.ctrls['strategic'].camera.setUserConfigValue(
                'sensitivity', mouse['artSens']['value'])
        else:
            ds = Settings.g_instance.userPrefs[Settings.KEY_CONTROL_MODE]
            if ds:
                ds['arcadeMode/camera'].writeFloat(
                    'sensitivity', mouse['arcadeSens']['value'])
                ds['sniperMode/camera'].writeFloat(
                    'sensitivity', mouse['sniperSens']['value'])
                ds['strategicMode/camera'].writeFloat(
                    'sensitivity', mouse['artSens']['value'])
        g_settingsCore.applySetting('mouseHorzInvert',
                                    bool(mouse['horInvert']['value']))
        g_settingsCore.applySetting('mouseVertInvert',
                                    bool(mouse['vertInvert']['value']))
        g_settingsCore.applySetting('backDraftInvert',
                                    bool(mouse['backDraftInvert']['value']))
        self.resolutions.applyChanges(
            settings['fullScreen'], settings['vertSync'],
            settings['tripleBuffered'], settings['windowSize']
            if not settings['fullScreen'] else settings['resolution'],
            settings['aspectRatio'], settings['multisampling'],
            settings['customAA'], settings['gamma'], settings['monitor'])
        if round(SoundGroups.g_instance.getVolume('masterVivox') *
                 100) != settings['masterVivoxVolume']:
            VOIP.getVOIPManager().setMasterVolume(
                settings['masterVivoxVolume'])
        if round(SoundGroups.g_instance.getVolume('micVivox') *
                 100) != settings['micVivoxVolume']:
            VOIP.getVOIPManager().setMicrophoneVolume(
                settings['micVivoxVolume'])
        SoundGroups.g_instance.setMasterVolume(
            float(settings['masterVolume']) / 100)
        SoundGroups.g_instance.setVolume('music',
                                         float(settings['musicVolume']) / 100)
        SoundGroups.g_instance.setVolume('voice',
                                         float(settings['voiceVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'vehicles',
            float(settings['vehiclesVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'effects',
            float(settings['effectsVolume']) / 100)
        SoundGroups.g_instance.setVolume('gui',
                                         float(settings['guiVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'ambient',
            float(settings['ambientVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'masterVivox',
            float(settings['masterVivoxVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'micVivox',
            float(settings['micVivoxVolume']) / 100)
        SoundGroups.g_instance.setVolume(
            'masterFadeVivox',
            float(settings['masterFadeVivoxVolume']) / 100)
        if len(VOIP.getVOIPManager().captureDevices):
            device = VOIP.getVOIPManager().captureDevices[0]
            if len(VOIP.getVOIPManager().captureDevices
                   ) > settings['captureDevice']:
                device = VOIP.getVOIPManager().captureDevices[
                    settings['captureDevice']]
            VOIP.getVOIPManager().setCaptureDevice(device)
        g_settingsCore.applySetting('showDateMessage',
                                    settings['datetimeIdx'] & 1)
        g_settingsCore.applySetting('showTimeMessage',
                                    settings['datetimeIdx'] & 2)
        g_settingsCore.applySetting('enableOlFilter',
                                    settings['enableOlFilter'])
        g_settingsCore.applySetting('enableSpamFilter',
                                    settings['enableSpamFilter'])
        g_windowsStoredData.start()
        g_settingsCore.applySetting('enableStoreMws',
                                    settings['enableStoreChatMws'])
        g_settingsCore.applySetting('enableStoreCws',
                                    settings['enableStoreChatCws'])
        g_windowsStoredData.stop()
        g_settingsCore.applySetting('invitesFromFriendsOnly',
                                    settings['invitesFromFriendsOnly'])
        g_settingsCore.applySetting('storeReceiverInBattle',
                                    settings['storeReceiverInBattle'])
        gameplayKeys = filter(
            lambda item: item.startswith(self.GAMEPLAY_PREFIX) and bool(
                settings[item]), settings.keys())
        prefixLen = len(self.GAMEPLAY_PREFIX)
        gameplay_ctx.setMaskByNames(
            map(lambda key: str(key[prefixLen:]), gameplayKeys))
        qualitySettings = settings['quality']
        applyPresets = self.graphicsPresets.checkApplyGraphicsPreset(
            int(settings['graphicsQuality']), qualitySettings)
        if applyPresets:
            self.graphicsPresets.applyGraphicsPresets(
                int(settings['graphicsQuality']), qualitySettings)
            if applyPresets == 'restartNeeded':
                BigWorld.commitPendingGraphicsSettings()
                restartClient = True
            elif applyPresets == 'hasPendingSettings':
                BigWorld.commitPendingGraphicsSettings()
        g_settingsCore.applyStorages()
        g_postProcessing.refresh()
        if restartClient:
            BigWorld.savePreferences()
            if restartApproved:
                from BattleReplay import g_replayCtrl
                if g_replayCtrl.isPlaying and g_replayCtrl.playbackSpeed == 0:
                    g_replayCtrl.setPlaybackSpeedIdx(5)
                BigWorld.callback(0.3, BigWorld.restartGame)
            else:
                BigWorld.callback(
                    0.0,
                    partial(BigWorld.changeVideoMode, -1,
                            BigWorld.isVideoWindowed()))
        return