def apply(self, diff): diff = self.__settingsDiffPreprocessing(diff) applyMethod = self.getApplyMethod(diff) self.SETTINGS.apply(diff) g_settingsCore.applyStorages() if len(set(graphics.GRAPHICS_SETTINGS.ALL()) & set(diff.keys())): BigWorld.commitPendingGraphicsSettings() return applyMethod == options.APPLY_METHOD.RESTART
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 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