def __init__(self, _=None): super(BattleQueue, self).__init__() self.__createTime = 0 self.__timerCallback = None self.__provider = None self._blur = CachedBlur() return
def __init__(self, parent=None): super(BattlePassDailyQuestsIntroWindow, self).__init__(WindowFlags.WINDOW, content=BattlePassDailyQuestsIntroView(), parent=parent) self.__blur = CachedBlur(enabled=True, ownLayer=WindowLayer.TOP_SUB_VIEW)
class MultipleAwardsViewWindow(LobbyNotificationWindow): __slots__ = ('__blur', ) def __init__(self, rewards, tooltips, productCode): super(MultipleAwardsViewWindow, self).__init__( content=self._getContentView(rewards, tooltips, productCode)) self.__blur = None return def load(self): if self.__blur is None: self.__blur = CachedBlur(enabled=True, ownLayer=self.layer - 1) super(MultipleAwardsViewWindow, self).load() return @classmethod def _getContentView(cls, rewards, tooltips, productCode): return MultipleAwardsView(rewards=rewards, tooltips=tooltips, productCode=productCode) def _finalize(self): if self.__blur is not None: self.__blur.fini() self.__blur = None super(MultipleAwardsViewWindow, self)._finalize() return
def _onLoading(self): self.__gui.windowsManager.onWindowStatusChanged += self.__windowStatusChanged self.__lobbyContext.addHeaderNavigationConfirmator( self.__handleHeaderNavigation) self.viewModel.onItemClicked += self.__itemClickHandler self.viewModel.onShowMapSelectionClicked += self.__showMapSelectionClickHandler self.viewModel.onShowWidgetsClicked += self.__showWidgetsClickHandler self.viewModel.onInfoClicked += self.__infoClickHandler self.__dataProvider.onListChanged += self.__dataProviderListChangeHandler self.__updateViewModel(self.viewModel) self.__blur = CachedBlur(enabled=True, ownLayer=WindowLayer.MARKER) g_eventBus.handleEvent(events.GameEvent( events.GameEvent.HIDE_LOBBY_SUB_CONTAINER_ITEMS), scope=EVENT_BUS_SCOPE.GLOBAL) g_eventBus.handleEvent(events.LobbyHeaderMenuEvent( events.LobbyHeaderMenuEvent.TOGGLE_VISIBILITY, ctx={ 'state': HeaderMenuVisibilityState.NOTHING, 'alias': self.layoutID }), scope=EVENT_BUS_SCOPE.LOBBY) app = self.__appLoader.getApp() self.__prevAppBackgroundAlpha = app.getBackgroundAlpha() app.setBackgroundAlpha(_BACKGROUND_ALPHA) self.__prevOptimizationEnabled = app.graphicsOptimizationManager.getEnable( ) if self.__prevOptimizationEnabled: app.graphicsOptimizationManager.switchOptimizationEnabled(False)
class WebViewTransparent(WebView): def __init__(self, ctx=None): super(WebViewTransparent, self).__init__(ctx) self._browserParams = (ctx or {}).get('browserParams', makeBrowserParams(bgAlpha=0.67)) self.__blur = None return def onEscapePress(self): self.destroy() def _populate(self): super(WebViewTransparent, self)._populate() self.__blur = CachedBlur(enabled=True, ownLayer=APP_CONTAINERS_NAMES.TOP_SUB_VIEW, layers=(APP_CONTAINERS_NAMES.SUBVIEW, APP_CONTAINERS_NAMES.WINDOWS, APP_CONTAINERS_NAMES.DIALOGS, APP_CONTAINERS_NAMES.IME, APP_CONTAINERS_NAMES.SERVICE_LAYOUT, APP_CONTAINERS_NAMES.MARKER, APP_CONTAINERS_NAMES.VIEWS, APP_CONTAINERS_NAMES.SYSTEM_MESSAGES)) def _dispose(self): super(WebViewTransparent, self)._dispose() if self.__blur is not None: self.__blur.fini() return
def _populate(self): super(ColorSettingsView, self)._populate() if self.app is not None: self._savedBackgroundAlpha = self.app.getBackgroundAlpha() self.app.setBackgroundAlpha(0) self.addListener(GameEvent.ON_BACKGROUND_ALPHA_CHANGE, self.__onExternalBackgroundAlphaChange, EVENT_BUS_SCOPE.GLOBAL) self.as_initDataS({'header': text_styles.superPromoTitle(SETTINGS.COLORSETTINGS_VIEW_HEADER), 'typesHeader': text_styles.highTitle(SETTINGS.COLORSETTINGS_VIEW_SUBTITLE), 'typesDesc': text_styles.main(SETTINGS.COLORSETTINGS_VIEW_DESCRIPTION), 'applyLabel': i18n.makeString(SETTINGS.APPLY_BUTTON), 'cancelLabel': i18n.makeString(SETTINGS.CANCEL_BUTTON), 'settingsTypes': self.__getTypes(), 'closeLabel': i18n.makeString(SETTINGS.COLORSETTINGS_VIEW_CLOSEBTN), 'beforeStr': text_styles.promoSubTitle(SETTINGS.COLORSETTINGS_VIEW_BEFORE), 'afterStr': text_styles.promoSubTitle(SETTINGS.COLORSETTINGS_VIEW_AFTER), 'filtersHeader': text_styles.highTitle(SETTINGS.COLORSETTINGS_TAB_FILTERS), 'filterPowerLabel': i18n.makeString(SETTINGS.COLORSETTINGS_TAB_FILTERS_INTENSITY), 'filtersTypes': self.__getFiltersTypes(), 'manualHeader': text_styles.highTitle(SETTINGS.COLORSETTINGS_TAB_CUSTOMSETTINGS), 'brightnessLabel': i18n.makeString(SETTINGS.COLORSETTINGS_TAB_CUSTOMSETTINGS_BRIGHTNESS), 'contrastLabel': i18n.makeString(SETTINGS.COLORSETTINGS_TAB_CUSTOMSETTINGS_CONTRAST), 'saturationLabel': i18n.makeString(SETTINGS.COLORSETTINGS_TAB_CUSTOMSETTINGS_SATURATION), 'resetLabel': i18n.makeString(SETTINGS.COLORSETTINGS_VIEW_RESETBTN)}) self.as_updateDataS(self.__selectedTabIdx, self.__initSettings) self.__blur = CachedBlur(enabled=False) return
class WebViewTransparent(WebView): __sound_env__ = HangarOverlayEnv def __init__(self, ctx=None): super(WebViewTransparent, self).__init__(ctx) self._browserParams = makeBrowserParams(bgAlpha=0.67) self._browserParams.update((ctx or {}).get('browserParams', {})) self.__blur = None self.__hiddenLayers = (ctx or {}).get('hiddenLayers', ()) return def _populate(self): super(WebViewTransparent, self)._populate() if self.__hiddenLayers: containerManager = self.app.containerManager containerManager.hideContainers(self.__hiddenLayers, 0) def setParentWindow(self, window): super(WebViewTransparent, self).setParentWindow(window) self.__blur = CachedBlur(enabled=True, ownLayer=window.layer) def onEscapePress(self): self.destroy() def _dispose(self): if self.__blur is not None: self.__blur.fini() if self.__hiddenLayers: containerManager = self.app.containerManager containerManager.showContainers(self.__hiddenLayers, 0) super(WebViewTransparent, self)._dispose() return
def _populate(self): self.__ctx = self.service.getCtx() self.__blur = CachedBlur() g_clientUpdateManager.addMoneyCallback(self.updateButton) g_currentVehicle.onChangeStarted += self.__onVehicleChangeStarted self.__ctx.events.onUpdateStyleInfoDOF += self.__onUpdateStyleInfoDOF self.service.onCustomizationHelperRecreated += self.__onCustomizationHelperRecreated
def __init__(self, ctx=None): super(HangarVehicleInfo, self).__init__(ctx) self.__guiVehConfigurator = None self.__vehicle = self.__itemsCache.items.getItemByCD( g_currentVehicle.item.intCD) self.__introPage = None self.__blur = CachedBlur(enabled=True) return
def _initialize(self): super(BootcampExitView, self)._initialize() window = self.getParentWindow() if self.__isInBattle: app = self.__appLoader.getApp() app.enterGuiControlMode(self.uniqueID, True, False) else: self.__blur = CachedBlur(enabled=True, ownLayer=window.layer - 1)
class _CommonCongratsView(ViewImpl): def __init__(self, context): settings = ViewSettings(R.views.lobby.common.congrats. common_congrats_view.CommonCongratsView()) settings.model = CommonCongratsViewModel() super(_CommonCongratsView, self).__init__(settings) self.__ctx = context @property def viewModel(self): return super(_CommonCongratsView, self).getViewModel() def _initialize(self, *args, **kwargs): super(_CommonCongratsView, self)._initialize() self.__updateVM() self.__addListeners() self._blur = CachedBlur(enabled=True) def _finalize(self): self._blur.fini() self.__removeListeners() super(_CommonCongratsView, self)._finalize() def __updateVM(self): with self.viewModel.transaction() as vm: vm.setBackground(self.__ctx.background) vm.setTitle(self.__ctx.title) vm.setDescription(self.__ctx.description) vm.setImage(self.__ctx.image) vm.setImageAlt(self.__ctx.imageAlt) vm.setConfirmLbl(self.__ctx.confirmLabel) vm.setBackLbl(self.__ctx.backLabel) def __addListeners(self): self.viewModel.onConfirmClick += self.__onConfirm self.viewModel.onBackClick += self.__onBack self.viewModel.onCloseClick += self.__onClose def __removeListeners(self): self.viewModel.onCloseClick -= self.__onClose self.viewModel.onBackClick -= self.__onBack self.viewModel.onConfirmClick -= self.__onConfirm def __onConfirm(self): self.__destroyWindow() self.__ctx.onConfirm() def __onBack(self): self.__destroyWindow() self.__ctx.onBack() def __onClose(self): self.__destroyWindow() self.__ctx.onConfirm() def __destroyWindow(self): self.viewModel.setNeedReset(True) self.destroyWindow()
def __init__(self, *args, **kwargs): super(_HangarVehicleInfoIntroWindow, self).__init__( wndFlags=WindowFlags.WINDOW | WindowFlags.WINDOW_FULLSCREEN, decorator=None, content=_HangarVehicleInfoIntroView( R.views.lobby.battleRoyale.vehicle_info_intro_overlay. VehicleInfoIntroOverlay(), *args, **kwargs)) self.__blur = CachedBlur(enabled=True, ownLayer=self.layer) return
def _populate(self): super(WebViewTransparent, self)._populate() self.__blur = CachedBlur(enabled=True, ownLayer=APP_CONTAINERS_NAMES.TOP_SUB_VIEW, layers=(APP_CONTAINERS_NAMES.SUBVIEW, APP_CONTAINERS_NAMES.WINDOWS, APP_CONTAINERS_NAMES.DIALOGS, APP_CONTAINERS_NAMES.IME, APP_CONTAINERS_NAMES.SERVICE_LAYOUT, APP_CONTAINERS_NAMES.MARKER, APP_CONTAINERS_NAMES.VIEWS, APP_CONTAINERS_NAMES.SYSTEM_MESSAGES))
def __init__(self, _=None): super(BattleStrongholdsQueue, self).__init__() self.__timerCallback = None self.__startAnimationTime = None self.__animationDuration = self.ANIMATION_DEFAULT_DURATION self.__groups = [] self.__battleQueueVO = {} self.__imagesFetchCoordinator = ImagesFetchCoordinator() self._blur = CachedBlur() return
def __init__(self, ctx=None): super(EventProgressionBuyConfirmView, self).__init__(ctx) self.__vehicle = ctx.get('vehicle') self.__price = ctx.get('price') self.__blur = CachedBlur(enabled=True, ownLayer=APP_CONTAINERS_NAMES.DIALOGS, layers=(APP_CONTAINERS_NAMES.VIEWS, APP_CONTAINERS_NAMES.WINDOWS, APP_CONTAINERS_NAMES.SUBVIEW, APP_CONTAINERS_NAMES.BROWSER))
def _initialize(self, *args, **kwargs): super(BuyVehicleView, self)._initialize() self._blur = CachedBlur(enabled=True) self.__addListeners() isElite = self.__vehicle.isElite vehType = self.__vehicle.type.replace('-', '_') isRestore = self.__vehicle.isRestoreAvailable() if self.__showOnlyCongrats: self.viewModel.setIsContentHidden(True) with self.viewModel.transaction() as vm: vm.setIsRestore(isRestore) vm.setBgSource( R.images.gui.maps.icons.store.shop_2_background_arsenal()) vm.setTankType('{}_elite'.format(vehType) if isElite else vehType) vehicleTooltip = i18n.makeString( getTypeUserName(self.__vehicle.type, isElite)) noCrewLabelPath = R.strings.store.buyVehicleWindow.checkBox vm.setVehicleNameTooltip(vehicleTooltip) vm.setNation(nations.NAMES[self.__vehicle.nationID]) vm.setNoCrewCheckboxLabel(noCrewLabelPath.restore.withoutCrew( ) if isRestore else noCrewLabelPath.buy.withoutCrew()) vm.setTankLvl(int2roman(self.__vehicle.level)) vm.setTankName(self.__vehicle.shortUserName) vm.setCountCrew(len(self.__vehicle.crew)) vm.setBuyVehicleIntCD(self.__vehicle.intCD) vm.setIsElite(isElite) if self.__vehicle.hasCrew: vm.setWithoutCommanderAltText( R.strings.store.buyVehicleWindow.crewInVehicle()) equipmentBlock = vm.equipmentBlock equipmentBlock.setIsRentVisible(self.__isRentVisible) equipmentBlock.setTradeInIsEnabled(self.__isTradeIn()) emtySlotAvailable = self.__itemsCache.items.inventory.getFreeSlots( self.__stats.vehicleSlots) > 0 equipmentBlock.setEmtySlotAvailable(emtySlotAvailable) equipmentBlock.setIsRestore(isRestore) if self.__vehicle.hasRentPackages and ( not isRestore or self.__actionType == VehicleBuyActionTypes.RENT ) and self.__actionType != VehicleBuyActionTypes.BUY: self.__selectedRentIdx = 0 self.__selectedRentID = self.__vehicle.rentPackages[ self.__selectedRentIdx]['rentID'] self.__updateCommanderCards() self.__updateSlotPrice() self.__updateAmmoPrice() self.__updateTradeInInfo() self.__updateRentInfo() self.__updateBuyBtnLabel() totalPriceArray = equipmentBlock.totalPrice.getItems() self.__addVMsInActionPriceList( totalPriceArray, ItemPrice(price=Money(credits=0, gold=0), defPrice=Money(credits=0, gold=0))) self.__updateTotalPrice()
class BattlePassDailyQuestsIntroWindow(WindowImpl): __slots__ = ('__blur', ) def __init__(self, parent=None): super(BattlePassDailyQuestsIntroWindow, self).__init__(WindowFlags.WINDOW, content=BattlePassDailyQuestsIntroView(), parent=parent) self.__blur = CachedBlur(enabled=True, ownLayer=WindowLayer.TOP_SUB_VIEW) def _finalize(self): self.__blur.fini() super(BattlePassDailyQuestsIntroWindow, self)._finalize()
def _populate(self): super(BCMessageWindow, self)._populate() self.as_setMessageDataS(self._content['messages']) self.__blur = CachedBlur(enabled=True, ownLayer=APP_CONTAINERS_NAMES.VIEWS, layers=(APP_CONTAINERS_NAMES.TOP_SUB_VIEW, APP_CONTAINERS_NAMES.SUBVIEW, APP_CONTAINERS_NAMES.WINDOWS), blurAnimRepeatCount=1) self.as_blurOtherWindowsS(APP_CONTAINERS_NAMES.DIALOGS) g_bootcampEvents.onRequestBootcampMessageWindowClose += self.onMessageRemoved if self._hangarSpace.spaceInited: self.__setCameraDisabled(True) else: self._hangarSpace.onSpaceCreate += self.__onSpaceCreated
def __init__(self, layoutID, ctx=None, *args, **kwargs): super(_HangarVehicleInfoIntroView, self).__init__(layoutID, ViewFlags.OVERLAY_VIEW, VehicleInfoIntroOverlayModel, *args, **kwargs) self.__vehicle = ctx.get('vehicle') self.__firstView = ctx.get('firstView', False) self.__blur = CachedBlur(enabled=True, ownLayer=APP_CONTAINERS_NAMES.OVERLAY, layers=[ APP_CONTAINERS_NAMES.VIEWS, APP_CONTAINERS_NAMES.SUBVIEW, APP_CONTAINERS_NAMES.TOP_SUB_VIEW, APP_CONTAINERS_NAMES.WINDOWS, APP_CONTAINERS_NAMES.BROWSER, APP_CONTAINERS_NAMES.DIALOGS ])
class BootcampProgressView(ViewImpl): __slots__ = ('__blur', '__tooltipData') uiBootcampLogger = BootcampLogger( BCLogKeys.BC_CURRENT_PROGRESS_WIDGET.value) def __init__(self, layoutID, *args, **kwargs): settings = ViewSettings(layoutID) settings.model = BootcampProgressModel() settings.args = args settings.kwargs = kwargs self.__blur = None self.__tooltipData = {} super(BootcampProgressView, self).__init__(settings) return @property def viewModel(self): return super(BootcampProgressView, self).getViewModel() def createToolTip(self, event): if event.contentID == R.views.common.tooltip_window.backport_tooltip_content.BackportTooltipContent( ): tooltipId = event.getArgument('tooltipId') if tooltipId: tooltipData = self.__tooltipData[int(tooltipId)] window = BackportTooltipWindow(tooltipData, self.getParentWindow()) if window: window.load() return window def _initialize(self): super(BootcampProgressView, self)._initialize() window = self.getParentWindow() self.__blur = CachedBlur(enabled=True, ownLayer=window.layer - 1) def _onLoading(self, *args, **kwargs): super(BootcampProgressView, self)._onLoading(*args, **kwargs) with self.viewModel.transaction() as model: g_bootcamp.fillProgressBar(model, self.__tooltipData, ICON_SIZE.BIG) def _finalize(self): self.uiBootcampLogger.log(BCLogActions.CLOSE.value) self.__blur.fini() super(BootcampProgressView, self)._finalize()
def __init__(self, layoutID, c11nView, *args, **kwargs): settings = ViewSettings(layoutID) settings.args = args settings.kwargs = kwargs settings.flags = ViewFlags.LOBBY_TOP_SUB_VIEW settings.model = ProgressiveItemsViewModel() super(ProgressiveItemsView, self).__init__(settings) self._itemsProgressData = None self._possibleItems = None self._vehicle = None self.__blur = CachedBlur() self.__layoutID = layoutID self.__c11nView = c11nView self.__urlMacros = URLMacros() self.__guiSettings = GUI_SETTINGS.progressiveItems.get( 'tutorialVideo', {}) return
class _HangarVehicleInfoIntroView(ViewImpl): __slots__ = ('__vehicle', '__firstView', '__blur') def __init__(self, layoutID, ctx=None, *args, **kwargs): super(_HangarVehicleInfoIntroView, self).__init__(layoutID, ViewFlags.OVERLAY_VIEW, VehicleInfoIntroOverlayModel, *args, **kwargs) self.__vehicle = ctx.get('vehicle') self.__firstView = ctx.get('firstView', False) self.__blur = CachedBlur(enabled=True, ownLayer=APP_CONTAINERS_NAMES.OVERLAY, layers=[ APP_CONTAINERS_NAMES.VIEWS, APP_CONTAINERS_NAMES.SUBVIEW, APP_CONTAINERS_NAMES.TOP_SUB_VIEW, APP_CONTAINERS_NAMES.WINDOWS, APP_CONTAINERS_NAMES.BROWSER, APP_CONTAINERS_NAMES.DIALOGS ]) def _initialize(self): super(_HangarVehicleInfoIntroView, self)._initialize() with self.getViewModel().transaction() as viewModel: viewModel.setVehicleTag( Vehicle.getIconResourceName(self.__vehicle.name)) viewModel.setIsFirstView(self.__firstView) viewModel.onSubmitBtnClick += self.__onSubmitClicked def _finalize(self): if self.__firstView: AccountSettings.setSettings( BATTLE_ROYALE_HANGAR_BOTTOM_PANEL_VIEWED, True) self.getViewModel().onSubmitBtnClick -= self.__onSubmitClicked self.__vehicle = None self.__blur.fini() self.__blur = None super(_HangarVehicleInfoIntroView, self)._finalize() return def __onSubmitClicked(self): self.destroyWindow()
def __init__(self, *args, **kwargs): super(MapsTrainingView, self).__init__( viewResource=R.views.lobby.maps_training.MapsTrainingPage(), viewModel=MapsTrainingViewModel()) self.__selectedMap = None self.__selectedScenario = 0 self.__ctxVehicleType = '' self.__ctxSide = 0 self.__ctxShowAnimation = False self.__tooltipData = {} self.__account = BigWorld.player() self.__mapsConfig = TacticalMapsConfigReader.readXml( self._TACTICAL_MAPS_CONFIG_PATH) self.__isDataLoaded = False self.__blur = CachedBlur(blurAnimRepeatCount=1, blurRadius=0.1) self.__blurRectId = None self.__packer = getDefaultBonusPacker() self.__hangarCameraManager = None self.__tickCallback = None self.__preferences = self.mapsTrainingController.preferences self.__markerPosOffset = 0.0 self.__finalizationInProgress = False self.__initFromCtx(kwargs.get('ctx', {})) return
class ColorSettingsView(LayerVisibilityMixin, ColorSettingsViewMeta): settingsCore = dependency.descriptor(ISettingsCore) def __init__(self, ctx=None): super(ColorSettingsView, self).__init__(ColorSettingsView) self.fireEvent(GameEvent(GameEvent.HIDE_EXTERNAL_COMPONENTS), scope=EVENT_BUS_SCOPE.GLOBAL) self.__selectedTabIdx = AccountSettings.getSettings( COLOR_SETTINGS_TAB_IDX) self.__componentWidth = 0 self.__isColorPreviewFilterActive = False self.__initSettings = self.__getSettings() self.__tabsPreviewSettings = self.__getLastAppliedTabsSettings() self.__wasGraphicsOptimizationEnabled = False if self.__selectedTabIdx == TABS.CUSTOM: self.__showColorPreviewFilter() self.__blur = None return def setViewWidth(self, width): self.__componentWidth = width if self.__isColorPreviewFilterActive: self.__showColorPreviewFilter() def moveSpace(self, dx, dy, dz): self.fireEvent( CameraRelatedEvents(CameraRelatedEvents.LOBBY_VIEW_MOUSE_MOVE, ctx={ 'dx': dx, 'dy': dy, 'dz': dz })) self.fireEvent( events.LobbySimpleEvent(events.LobbySimpleEvent.NOTIFY_SPACE_MOVED, ctx={ 'dx': dx, 'dy': dy, 'dz': dz })) def onSettingsChange(self, settingName, settingValue): settingValue = flashObject2Dict(settingValue) LOG_DEBUG('onSettingsChange', settingName, settingValue) self.settingsCore.previewSetting(settingName, settingValue) self.__tabsPreviewSettings[ self.__selectedTabIdx][settingName] = settingValue def onApply(self, diff): diff = flashObject2Dict(diff) AccountSettings.setSettings(COLOR_SETTINGS_TAB_IDX, self.__selectedTabIdx) if self.__selectedTabIdx == TABS.CUSTOM: if self.__hasChangesInSettings( settings_constants.GRAPHICS.getCustomColorSettings(), diff): diff.update({ settings_constants.GRAPHICS.COLOR_GRADING_TECHNIQUE: COLOR_GRADING_TECHNIQUE_DEFAULT }) diff[COLOR_SETTINGS.COLOR_GRADING_TECHNIQUE] = 0 diff[COLOR_SETTINGS.COLOR_FILTER_INTENSITY] = 25 self.settingsCore.applySettings(diff) lastAppliedSettings = AccountSettings.getSettings( APPLIED_COLOR_SETTINGS) lastAppliedSettings[self.__selectedTabIdx] = diff AccountSettings.setSettings(APPLIED_COLOR_SETTINGS, lastAppliedSettings) BigWorld.commitPendingGraphicsSettings() self.destroy() def onTabSelected(self, selectedTab): savedTab = AccountSettings.getSettings(COLOR_SETTINGS_TAB_IDX) if savedTab == self.__selectedTabIdx and self.__selectedTabIdx == TABS.FILTERS and selectedTab == TABS.CUSTOM: prevSettings = self.__getLastAppliedTabsSettings()[TABS.FILTERS] self.__selectedTabIdx = selectedTab settings = self.__getCurrentTabSettings() prevFilter = prevSettings[ settings_constants.GRAPHICS.COLOR_GRADING_TECHNIQUE] settings[settings_constants.GRAPHICS. COLOR_GRADING_TECHNIQUE] = prevFilter settings[COLOR_SETTINGS.COLOR_FILTER_INTENSITY] = prevSettings[ COLOR_SETTINGS.COLOR_FILTER_INTENSITY] else: self.__selectedTabIdx = selectedTab settings = self.__getCurrentTabSettings() self.__previewSettings(settings) self.as_updateDataS(self.__selectedTabIdx, settings) if self.__selectedTabIdx == TABS.CUSTOM: self.__showColorPreviewFilter() else: self.__hideColorPreviewFilter() def onReset(self): settings = self.__getCurrentTabSettings() for settingName in settings_constants.GRAPHICS.getCustomColorSettings( ): setting = self.settingsCore.options.getSetting(settingName) defaultValue = setting.getDefaultValue() self.settingsCore.previewSetting(settingName, defaultValue) self.__tabsPreviewSettings[ self.__selectedTabIdx][settingName] = defaultValue settings[settingName] = defaultValue self.as_updateDataS(self.__selectedTabIdx, settings) def onClose(self): self.settingsCore.options.revert( settings_constants.GRAPHICS.getColorSettings()) self.destroy() def _populate(self): super(ColorSettingsView, self)._populate() if self.app is not None: self._savedBackgroundAlpha = self.app.getBackgroundAlpha() self.app.setBackgroundAlpha(0) self.addListener(GameEvent.ON_BACKGROUND_ALPHA_CHANGE, self.__onExternalBackgroundAlphaChange, EVENT_BUS_SCOPE.GLOBAL) self.__wasGraphicsOptimizationEnabled = self.app.graphicsOptimizationManager.getEnable( ) self.app.graphicsOptimizationManager.switchOptimizationEnabled( False) self.as_initDataS({ 'header': text_styles.superPromoTitle(SETTINGS.COLORSETTINGS_VIEW_HEADER), 'typesHeader': text_styles.highTitle(SETTINGS.COLORSETTINGS_VIEW_SUBTITLE), 'typesDesc': text_styles.main(SETTINGS.COLORSETTINGS_VIEW_DESCRIPTION), 'applyLabel': i18n.makeString(SETTINGS.APPLY_BUTTON), 'cancelLabel': i18n.makeString(SETTINGS.CANCEL_BUTTON), 'settingsTypes': self.__getTypes(), 'closeLabel': i18n.makeString(SETTINGS.COLORSETTINGS_VIEW_CLOSEBTN), 'beforeStr': text_styles.promoSubTitle(SETTINGS.COLORSETTINGS_VIEW_BEFORE), 'afterStr': text_styles.promoSubTitle(SETTINGS.COLORSETTINGS_VIEW_AFTER), 'filtersHeader': text_styles.highTitle(SETTINGS.COLORSETTINGS_TAB_FILTERS), 'filterPowerLabel': i18n.makeString(SETTINGS.COLORSETTINGS_TAB_FILTERS_INTENSITY), 'filtersTypes': self.__getFiltersTypes(), 'manualHeader': text_styles.highTitle(SETTINGS.COLORSETTINGS_TAB_CUSTOMSETTINGS), 'brightnessLabel': i18n.makeString( SETTINGS.COLORSETTINGS_TAB_CUSTOMSETTINGS_BRIGHTNESS), 'contrastLabel': i18n.makeString( SETTINGS.COLORSETTINGS_TAB_CUSTOMSETTINGS_CONTRAST), 'saturationLabel': i18n.makeString( SETTINGS.COLORSETTINGS_TAB_CUSTOMSETTINGS_SATURATION), 'resetLabel': i18n.makeString(SETTINGS.COLORSETTINGS_VIEW_RESETBTN) }) self.as_updateDataS(self.__selectedTabIdx, self.__initSettings) self.__blur = CachedBlur(enabled=False) return def _dispose(self): self.__hideColorPreviewFilter() self.settingsCore.clearStorages() self.removeListener(GameEvent.ON_BACKGROUND_ALPHA_CHANGE, self.__onExternalBackgroundAlphaChange, EVENT_BUS_SCOPE.GLOBAL) if self.app is not None: self.app.setBackgroundAlpha(self._savedBackgroundAlpha) if hasattr(self.app, 'leaveGuiControlMode'): self.app.leaveGuiControlMode(VIEW_ALIAS.COLOR_SETTING) self.app.graphicsOptimizationManager.switchOptimizationEnabled( self.__wasGraphicsOptimizationEnabled) self.fireEvent(GameEvent(GameEvent.SHOW_EXTERNAL_COMPONENTS), scope=EVENT_BUS_SCOPE.GLOBAL) if self.__initSettings is not None: self.__initSettings.clear() self.__initSettings = None if self.__blur is not None: self.__blur.fini() super(ColorSettingsView, self)._dispose() return def __getLastAppliedTabsSettings(self): lastAppliedSettings = AccountSettings.getSettings( APPLIED_COLOR_SETTINGS) filterTabsKeys = (GRAPHICS.COLOR_GRADING_TECHNIQUE, GRAPHICS.COLOR_FILTER_INTENSITY) return { TABS.DEFAULT: {}, TABS.FILTERS: self.__getTabSettings(lastAppliedSettings, TABS.FILTERS, filterTabsKeys), TABS.CUSTOM: self.__getTabSettings(lastAppliedSettings, TABS.CUSTOM, GRAPHICS.getCustomColorSettings()) } def __getTabSettings(self, lastAppliedSettings, tabIdx, settingKeys): tabSettings = lastAppliedSettings.get(tabIdx, {}) settings = {} for key in settingKeys: settings[key] = tabSettings.get(key, self.__initSettings[key]) return settings def __getTypes(self): return [{ 'id': TABS.DEFAULT, 'label': text_styles.highlightText(SETTINGS.COLORSETTINGS_TAB_DEFAULT), 'icon': RES_ICONS.MAPS_ICONS_SETTINGS_COLORSETTINGS_DEFAULT }, { 'id': TABS.FILTERS, 'label': text_styles.highlightText(SETTINGS.COLORSETTINGS_TAB_FILTERS), 'icon': RES_ICONS.MAPS_ICONS_SETTINGS_COLORSETTINGS_FILTERS }, { 'id': TABS.CUSTOM, 'label': text_styles.highlightText( SETTINGS.COLORSETTINGS_TAB_CUSTOMSETTINGS), 'icon': RES_ICONS.MAPS_ICONS_SETTINGS_COLORSETTINGS_MANUAL }] def __getFiltersTypes(self): result = [] setting = self.settingsCore.options.getSetting( GRAPHICS.COLOR_GRADING_TECHNIQUE) images = graphics.getGraphicSettingColorSettingsFiletersImages() if setting is not None: for option in setting.getOptions(): result.append({ 'id': option.get('data', COLOR_GRADING_TECHNIQUE_DEFAULT), 'label': text_styles.stats(option.get('label')), 'icon': images.get( option.get('data', COLOR_GRADING_TECHNIQUE_DEFAULT)) }) result = sorted(result, key=lambda k: k['id']) return result def __getSettings(self): settings = {} for setting in settings_constants.GRAPHICS.getColorSettings(): settings[setting] = self.settingsCore.getSetting(setting) return settings def __showColorPreviewFilter(self): width, _ = GUI.screenResolution()[:2] witdthPrc = self.__componentWidth / width delimiterPrc = witdthPrc + (1 - witdthPrc) / 2 BigWorld.setColorBCSSetup(1, delimiterPrc) self.__isColorPreviewFilterActive = True def __hideColorPreviewFilter(self): BigWorld.setColorBCSSetup(0, 0) self.__isColorPreviewFilterActive = False def __hasChangesInSettings(self, settingsNames, diff): for name in settingsNames: if self.__initSettings[name] != diff[name]: return True return False def __getCurrentTabSettings(self): settings = {} for settingName in settings_constants.GRAPHICS.getColorSettings(): setting = self.settingsCore.options.getSetting(settingName) if settingName != settings_constants.GRAPHICS.COLOR_GRADING_TECHNIQUE: defaultValue = setting.getDefaultValue() else: defaultValue = COLOR_GRADING_TECHNIQUE_DEFAULT settings[settingName] = defaultValue settings.update(self.__tabsPreviewSettings[self.__selectedTabIdx]) return settings def __previewSettings(self, settings): for settingName, value in settings.iteritems(): self.settingsCore.applySetting(settingName, value) def __onExternalBackgroundAlphaChange(self, event): self._savedBackgroundAlpha = event.ctx['alpha'] self.app.setBackgroundAlpha(0, notSilentChange=False)
def setParentWindow(self, window): super(WebViewTransparent, self).setParentWindow(window) self.__blur = CachedBlur(enabled=True, ownLayer=window.layer)
def __init__(self, rewards, tooltips, productCode): super(MultipleAwardsViewWindow, self).__init__( content=self._getContentView(rewards, tooltips, productCode)) self.__blur = CachedBlur(enabled=True, ownLayer=self.layer - 1)
def _initialize(self): super(BootcampProgressView, self)._initialize() window = self.getParentWindow() self.__blur = CachedBlur(enabled=True, ownLayer=window.layer - 1)
class ProgressiveItemsView(ViewImpl): __slots__ = ('__c11nView', '_itemsProgressData', '_possibleItems', '_vehicle', '__blur', '__layoutID', '__urlMacros', '__guiSettings') __lobbyContext = dependency.descriptor(ILobbyContext) __itemsCache = dependency.descriptor(IItemsCache) __customizationService = dependency.descriptor(ICustomizationService) __appLoader = dependency.descriptor(IAppLoader) __settingsCore = dependency.descriptor(ISettingsCore) def __init__(self, layoutID, c11nView, *args, **kwargs): settings = ViewSettings(layoutID) settings.args = args settings.kwargs = kwargs settings.flags = ViewFlags.LOBBY_TOP_SUB_VIEW settings.model = ProgressiveItemsViewModel() super(ProgressiveItemsView, self).__init__(settings) self._itemsProgressData = None self._possibleItems = None self._vehicle = None self.__blur = CachedBlur() self.__layoutID = layoutID self.__c11nView = c11nView self.__urlMacros = URLMacros() self.__guiSettings = GUI_SETTINGS.progressiveItems.get( 'tutorialVideo', {}) return def createToolTip(self, event): if event.contentID == R.views.common.tooltip_window.backport_tooltip_content.BackportTooltipContent( ): intCD = int(event.getArgument('id')) level = int(event.getArgument('level')) window = BackportTooltipWindow( self.__getTooltipData(intCD, event.getArgument('tooltip'), level), self.getParentWindow()) window.load() return window return super(ProgressiveItemsView, self).createToolTip(event) @property def viewModel(self): return super(ProgressiveItemsView, self).getViewModel() def _initialize(self, *args, **kwargs): super(ProgressiveItemsView, self)._initialize(*args, **kwargs) if self.__c11nView is not None: self.__c11nView.changeVisible(False) self.viewModel.onSelectItem += self._onSelectItem self.viewModel.tutorial.showVideo += self._showVideoPage return def _finalize(self): super(ProgressiveItemsView, self)._finalize() if self.__c11nView is not None: self.__c11nView.changeVisible(True) self.__c11nView = None self.__blur.fini() self.viewModel.onSelectItem -= self._onSelectItem self.viewModel.tutorial.showVideo -= self._showVideoPage return def _onLoading(self, *args, **kwargs): self._vehicle = g_currentVehicle.item self._possibleItems = self._getPossibleItemsForVehicle() self._itemsProgressData = self.__itemsCache.items.inventory.getC11nProgressionDataForVehicle( self._vehicle.intCD) itemIntCD = kwargs.get('itemIntCD') with self.getViewModel().transaction() as model: model.setTankName(self._vehicle.userName) model.setTankLevel(int2roman(self._vehicle.level)) model.setTankType(self._vehicle.typeBigIconResource()) self.__setItems(model) model.setIsRendererPipelineDeferred(isRendererPipelineDeferred()) model.setItemToScroll(0 if itemIntCD is None else itemIntCD) return def _onLoaded(self, *args, **kwargs): self.__blur.enable() self.__settingsCore.serverSettings.setOnceOnlyHintsSettings( {OnceOnlyHints.C11N_PROGRESSION_VIEW_HINT: HINT_SHOWN_STATUS}) def _onSelectItem(self, args=None): if args is not None: intCD = int(args['intCD']) level = int(args['level']) item = self.__customizationService.getItemByCD(intCD) ctx = self.__customizationService.getCtx() def changeTabAndGetItemToHand(): ctx.changeModeWithProgressionDecal(intCD) ctx.events.onGetItemBackToHand(item, level, scrollToItem=True) noveltyCount = self._vehicle.getC11nItemNoveltyCounter( proxy=self.__itemsCache.items, item=item) if noveltyCount: BigWorld.callback( 0.0, lambda: ctx.resetItemsNovelty([item.intCD])) BigWorld.callback(0.0, changeTabAndGetItemToHand) self.destroyWindow() return def _showVideoPage(self, args=None): self.__showVideo() @process def __showVideo(self): url = yield self.__urlMacros.parse(self.__guiSettings.get('url')) webHandlers = webApiCollection(ui_web_api.CloseViewWebApi, sound_web_api.SoundWebApi, sound_web_api.HangarSoundWebApi) ctx = {'url': url, 'webHandlers': webHandlers} showProgressiveItemsBrowserView(ctx) def _getPossibleItemsForVehicle(self): customizationCache = vehicles.g_cache.customization20() vehicleType = self._vehicle.descriptor.type sortedItems = sorted( customizationCache.customizationWithProgression.itervalues(), key=lambda i: i.id) return [ item.compactDescr for item in sortedItems if item.filter.matchVehicleType(vehicleType) ] def __setItems(self, model): for intCD in self._possibleItems: itemModel = ItemModel() item = self.__customizationService.getItemByCD(intCD) itemModel.setItemId(intCD) itemModel.setItemUserString(item.userName) itemModel.setMaxLevel(item.getMaxProgressionLevel()) itemModel.setScaleFactor(item.formfactor) latestOpenedLevel = item.getLatestOpenedProgressionLevel( self._vehicle) itemModel.setCurrentLevel(1 if latestOpenedLevel == -1 else latestOpenedLevel + 1) self.__setEachLevelInfo(itemModel, item) model.progressiveItems.addViewModel(itemModel) def __setEachLevelInfo(self, model, item): for level in xrange(1, model.getMaxLevel() + 1): levelInfo = ItemLevelInfoModel() levelInfo.setLevel(level) levelInfo.setLevelText(getProgressionItemStatusText(level)) levelInfo.setUnlocked(level < model.getCurrentLevel()) icon = item.iconUrlByProgressionLevel( level, _PREVIEW_ICON_SIZE, _PREVIEW_ICON_INNER_SIZE.get(item.formfactor)) levelInfo.setIcon(icon) if level == model.getCurrentLevel(): levelInfo.setInProgress(True) levelInfo.progressBlock.setUnlockCondition( _ms( item.progressionConditions.get(level, {})[0].get( 'description', ''))) currProgress = int( item.getCurrentProgressOnCurrentLevel(self._vehicle)) currProgress = currProgress if currProgress > 0 else 0 maxProgress = int( item.progressionConditions.get(level, {})[0].get('value', '1')) if maxProgress > 1: levelInfo.progressBlock.setProgressionVal(currProgress) levelInfo.progressBlock.setMaxProgressionVal(maxProgress) else: levelInfo.progressBlock.setHideProgressBarAndString(True) model.eachLevelInfo.addViewModel(levelInfo) @staticmethod def __getTooltipData(intCD, tooltip, level): return createTooltipData(isSpecial=True, specialAlias=tooltip, specialArgs=CustomizationTooltipContext( itemCD=intCD, level=level, showOnlyProgressBlock=True))
class ModeSelectorView(ViewImpl): __slots__ = ('__blur', '__dataProvider', '__prevAppBackgroundAlpha', '__isEventEnabled', '__isClickProcessing', '__prevOptimizationEnabled', '__isGraphicsRestored') uiLogger = BaseModeSelectorLogger(LOG_KEYS.MS_WINDOW) uiBootcampLogger = BootcampLogger(LOG_KEYS.MS_WINDOW) _COMMON_SOUND_SPACE = MODE_SELECTOR_SOUND_SPACE __appLoader = dependency.descriptor(IAppLoader) __bootcamp = dependency.descriptor(IBootcampController) __lobbyContext = dependency.descriptor(ILobbyContext) __gui = dependency.descriptor(IGuiLoader) __tooltipByContentID = { R.views.lobby.battle_pass.tooltips.BattlePassNotStartedTooltipView(): BattlePassNotStartedTooltipView, R.views.lobby.battle_pass.tooltips.BattlePassCompletedTooltipView(): BattlePassCompletedTooltipView, R.views.lobby.battle_pass.tooltips.BattlePassInProgressTooltipView(): partial(BattlePassInProgressTooltipView, battleType=QUEUE_TYPE.RANDOMS), R.views.lobby.battle_pass.tooltips.BattlePass3dStyleNotChosenTooltip(): BattlePass3dStyleNotChosenTooltip } layoutID = R.views.lobby.mode_selector.ModeSelectorView() _areWidgetsVisible = False def __init__(self, layoutId, isEventEnabled=False, provider=None): super(ModeSelectorView, self).__init__( ViewSettings(layoutId, ViewFlags.LOBBY_TOP_SUB_VIEW, ModeSelectorModel())) self.__dataProvider = provider if provider else ModeSelectorDataProvider( ) self.__blur = None self.__prevOptimizationEnabled = False self.__prevAppBackgroundAlpha = 0.0 self.__isEventEnabled = isEventEnabled self.__isClickProcessing = False self.__isGraphicsRestored = False self.inputManager.addEscapeListener(self.__handleEscape) return @property def viewModel(self): return self.getViewModel() @property def inputManager(self): app = self.__appLoader.getApp() return app.gameInputManager def createToolTip(self, event): if event.contentID == _R_BACKPORT_TOOLTIP(): tooltipId = event.getArgument('tooltipId') if tooltipId in [ ModeSelectorTooltipsConstants.DISABLED_TOOLTIP, ModeSelectorTooltipsConstants.CALENDAR_TOOLTIP ]: index = int(event.getArgument('index')) modeSelectorItem = self.__dataProvider.getItemByIndex(index) if modeSelectorItem is None: return body = modeSelectorItem.disabledTooltipText if tooltipId == ModeSelectorTooltipsConstants.CALENDAR_TOOLTIP: body = modeSelectorItem.calendarTooltipText return self.__createSimpleTooltip(event, body=body) if tooltipId == ModeSelectorTooltipsConstants.RANDOM_BP_PAUSED_TOOLTIP: return self.__createSimpleTooltip( event, header=backport.text(R.strings.battle_pass.tooltips. entryPoint.disabled.header()), body=backport.text(R.strings.battle_pass.tooltips. entryPoint.disabled.body())) if tooltipId in [ ModeSelectorTooltipsConstants. RANKED_CALENDAR_DAY_INFO_TOOLTIP, ModeSelectorTooltipsConstants.RANKED_STEP_TOOLTIP, ModeSelectorTooltipsConstants. RANKED_BATTLES_LEAGUE_TOOLTIP, ModeSelectorTooltipsConstants. RANKED_BATTLES_EFFICIENCY_TOOLTIP, ModeSelectorTooltipsConstants. RANKED_BATTLES_POSITION_TOOLTIP, ModeSelectorTooltipsConstants.RANKED_BATTLES_BONUS_TOOLTIP, ModeSelectorTooltipsConstants.MAPBOX_CALENDAR_TOOLTIP, ModeSelectorTooltipsConstants.EPIC_BATTLE_CALENDAR_TOOLTIP ]: return createAndLoadBackportTooltipWindow( self.getParentWindow(), tooltipId=tooltipId, isSpecial=True, specialArgs=(None, )) if tooltipId == ModeSelectorTooltipsConstants.RANKED_BATTLES_RANK_TOOLTIP: rankID = int(event.getArgument('rankID')) return createAndLoadBackportTooltipWindow( self.getParentWindow(), tooltipId=tooltipId, isSpecial=True, specialArgs=(rankID, )) return super(ModeSelectorView, self).createToolTip(event) def createToolTipContent(self, event, contentID): if contentID == _R_SIMPLE_TOOLTIP(): return SimpleTooltipContent(contentID, event.getArgument('header', ''), event.getArgument('body', ''), event.getArgument('note', ''), event.getArgument('alert', '')) elif contentID == R.views.lobby.mode_selector.tooltips.SimplyFormatTooltip( ): modeName = event.getArgument('modeName', '') if modeName is None: return tooltipLocal = R.strings.mode_selector.mode.dyn(modeName) if not tooltipLocal: return header = backport.text(tooltipLocal.battlePassTooltip.header()) body = backport.text(tooltipLocal.battlePassTooltip.body()) if not header: return return SimplyFormatTooltipView(header, body) else: tooltipClass = self.__tooltipByContentID.get(contentID) return tooltipClass() if tooltipClass else None def destroyWindow(self): self.uiLogger.log(LOG_ACTIONS.CLOSED, details=LOG_CLOSE_DETAILS.OTHER) super(ModeSelectorView, self).destroyWindow() def createPopOverContent(self, event): return RandomBattlePopover( ) if event.contentID == R.views.lobby.mode_selector.popovers.RandomBattlePopover( ) else super(ModeSelectorView, self).createPopOverContent(event) def close(self): g_eventBus.handleEvent(events.DestroyGuiImplViewEvent(self.layoutID)) def _onLoading(self): self.__gui.windowsManager.onWindowStatusChanged += self.__windowStatusChanged self.__lobbyContext.addHeaderNavigationConfirmator( self.__handleHeaderNavigation) self.viewModel.onItemClicked += self.__itemClickHandler self.viewModel.onShowMapSelectionClicked += self.__showMapSelectionClickHandler self.viewModel.onShowWidgetsClicked += self.__showWidgetsClickHandler self.viewModel.onInfoClicked += self.__infoClickHandler self.__dataProvider.onListChanged += self.__dataProviderListChangeHandler self.__updateViewModel(self.viewModel) self.__blur = CachedBlur(enabled=True, ownLayer=WindowLayer.MARKER) g_eventBus.handleEvent(events.GameEvent( events.GameEvent.HIDE_LOBBY_SUB_CONTAINER_ITEMS), scope=EVENT_BUS_SCOPE.GLOBAL) g_eventBus.handleEvent(events.LobbyHeaderMenuEvent( events.LobbyHeaderMenuEvent.TOGGLE_VISIBILITY, ctx={ 'state': HeaderMenuVisibilityState.NOTHING, 'alias': self.layoutID }), scope=EVENT_BUS_SCOPE.LOBBY) app = self.__appLoader.getApp() self.__prevAppBackgroundAlpha = app.getBackgroundAlpha() app.setBackgroundAlpha(_BACKGROUND_ALPHA) self.__prevOptimizationEnabled = app.graphicsOptimizationManager.getEnable( ) if self.__prevOptimizationEnabled: app.graphicsOptimizationManager.switchOptimizationEnabled(False) def _initialize(self): g_eventBus.handleEvent( FullscreenModeSelectorEvent(FullscreenModeSelectorEvent.NAME, ctx={'showing': True})) def _onLoaded(self): self.uiBootcampLogger.logOnlyFromBootcamp(LOG_ACTIONS.OPENED) self.inputManager.removeEscapeListener(self.__handleEscape) self.uiLogger.log(LOG_ACTIONS.OPENED, isNew=self.__dataProvider.hasNewIndicator, isWidget=self._areWidgetsVisible, isFeatured=self.__isEventEnabled) def _finalize(self): self.uiBootcampLogger.logOnlyFromBootcamp(LOG_ACTIONS.CLOSED) self.__gui.windowsManager.onWindowStatusChanged -= self.__windowStatusChanged self.inputManager.removeEscapeListener(self.__handleEscape) self.__lobbyContext.deleteHeaderNavigationConfirmator( self.__handleHeaderNavigation) self.viewModel.onItemClicked -= self.__itemClickHandler self.viewModel.onShowMapSelectionClicked -= self.__showMapSelectionClickHandler self.viewModel.onShowWidgetsClicked -= self.__showWidgetsClickHandler self.viewModel.onInfoClicked -= self.__infoClickHandler saveBattlePassStateForItems(self.__dataProvider.itemList) self.__dataProvider.onListChanged -= self.__dataProviderListChangeHandler self.__dataProvider.dispose() g_eventBus.handleEvent(events.LobbyHeaderMenuEvent( events.LobbyHeaderMenuEvent.TOGGLE_VISIBILITY, ctx={'state': HeaderMenuVisibilityState.ALL}), scope=EVENT_BUS_SCOPE.LOBBY) g_eventBus.handleEvent( FullscreenModeSelectorEvent(FullscreenModeSelectorEvent.NAME, ctx={'showing': False})) g_eventBus.handleEvent(events.GameEvent( events.GameEvent.REVEAL_LOBBY_SUB_CONTAINER_ITEMS), scope=EVENT_BUS_SCOPE.GLOBAL) self.__restoreGraphics() def __restoreGraphics(self): if self.__isGraphicsRestored: return else: self.__isGraphicsRestored = True if self.__blur: self.__blur.fini() self.__blur = None app = self.__appLoader.getApp() if self.__prevOptimizationEnabled: app.graphicsOptimizationManager.switchOptimizationEnabled(True) app.setBackgroundAlpha(self.__prevAppBackgroundAlpha) return def __createSimpleTooltip(self, event, header='', body=''): window = DecoratedTooltipWindow(content=SimpleTooltipContent( _R_SIMPLE_TOOLTIP(), body=body, header=header), parent=self.getParentWindow()) window.load() window.move(event.mouse.positionX, event.mouse.positionY) return window def __dataProviderListChangeHandler(self): with self.viewModel.transaction() as tx: self.__updateViewModel(tx) def __updateViewModel(self, vm): vm.setIsMapSelectionVisible(self.__dataProvider.isDemonstrator) vm.setIsMapSelectionEnabled(self.__dataProvider.isDemoButtonEnabled) vm.setAreWidgetsVisible(ModeSelectorView._areWidgetsVisible) if self.__bootcamp.isInBootcamp(): vm.setState(ModeSelectorWindowStates.BOOTCAMP) cards = vm.getCardList() cards.clear() for item in self.__dataProvider.itemList: cards.addViewModel(item.viewModel) cards.invalidate() @process def __itemClickHandler(self, event): self.__isClickProcessing = True navigationPossible = yield self.__lobbyContext.isHeaderNavigationPossible( ) if not navigationPossible: self.__isClickProcessing = False return else: index = int(event.get('index')) modeSelectorItem = self.__dataProvider.getItemByIndex(index) if modeSelectorItem is None: self.__isClickProcessing = False return self.uiLogger.log( LOG_ACTIONS.CARD_CLICKED, size=event.get('size'), details=event.get('cardMediaSize'), isNew=modeSelectorItem.viewModel.getIsNew(), mode=modeSelectorItem.modeName, isSelected=modeSelectorItem.viewModel.getIsSelected()) modeSelectorItem.handleClick() if modeSelectorItem.isSelectable: specView = self.__gui.windowsManager.getViewByLayoutID( BattleSessionView.layoutID) if modeSelectorItem.modeName != PREBATTLE_ACTION_NAME.SPEC_BATTLES_LIST and specView is not None: specView.destroyWindow() self.__dataProvider.select(modeSelectorItem.modeName) self.uiLogger.log(LOG_ACTIONS.CLOSED, details=LOG_CLOSE_DETAILS.CARD_CLICKED) self.close() return def __showMapSelectionClickHandler(self): demonstratorWindow = self.__appLoader.getApp( ).containerManager.getView(WindowLayer.WINDOW, criteria={ POP_UP_CRITERIA.VIEW_ALIAS: VIEW_ALIAS.DEMONSTRATOR_WINDOW }) if demonstratorWindow is not None: demonstratorWindow.onWindowClose() else: g_eventBus.handleEvent(LoadViewEvent( SFViewLoadParams(VIEW_ALIAS.DEMONSTRATOR_WINDOW)), scope=EVENT_BUS_SCOPE.LOBBY) return def __showWidgetsClickHandler(self): ModeSelectorView._areWidgetsVisible = not ModeSelectorView._areWidgetsVisible self.viewModel.setAreWidgetsVisible( ModeSelectorView._areWidgetsVisible) def __infoClickHandler(self, event): self.uiBootcampLogger.logOnlyFromBootcamp( LOG_ACTIONS.INFO_PAGE_ICON_CLICKED) index = int(event.get('index')) modeSelectorItem = self.__dataProvider.getItemByIndex(index) if modeSelectorItem is None: return else: self.uiLogger.log(LOG_ACTIONS.INFO_PAGE_ICON_CLICKED, isNew=modeSelectorItem.viewModel.getIsNew(), mode=modeSelectorItem.modeName) modeSelectorItem.handleInfoPageClick() return def __windowStatusChanged(self, uniqueID, newStatus): if newStatus == WindowStatus.LOADED: window = self.__gui.windowsManager.getWindow(uniqueID) parent = None if window.parent is not None and window.parent.content is not None: parent = window.parent.content if window.content == self or parent is not None and parent == self: return if window.layer in _CLOSE_LAYERS: self.__restoreGraphics() if not self.__isClickProcessing: self.uiLogger.log(LOG_ACTIONS.CLOSED, details=LOG_CLOSE_DETAILS.OTHER) self.close() return @adisp. async def __handleHeaderNavigation(self, callback): if self.viewStatus not in (ViewStatus.DESTROYED, ViewStatus.DESTROYING ) and not self.__isClickProcessing: self.close() callback(True) def __handleEscape(self): self.close()
class BattleStrongholdsQueue(BattleStrongholdsQueueMeta, LobbySubView, ClanEmblemsHelper, IGlobalListener): __sound_env__ = BattleQueueEnv itemsCache = dependency.descriptor(IItemsCache) ANIMATION_DEFAULT_DURATION = 5 def __init__(self, _=None): super(BattleStrongholdsQueue, self).__init__() self.__timerCallback = None self.__startAnimationTime = None self.__animationDuration = self.ANIMATION_DEFAULT_DURATION self.__groups = [] self.__battleQueueVO = {} self.__imagesFetchCoordinator = ImagesFetchCoordinator() self._blur = CachedBlur() return @prbEntityProperty def prbEntity(self): return None def exitClick(self): self.prbEntity.exitFromQueue() def onClanEmblem32x32Received(self, clanDbID, emblem): clanEmblem = getTextureLinkByID(self.getMemoryTexturePath(emblem)) if emblem else None self.__battleQueueVO['myClanIcon'] = clanEmblem or '' self.as_setTypeInfoS(self.__battleQueueVO) self.prbEntity.getMatchmakingInfo(callback=self.__onMatchmakingInfo) return def onEscape(self): dialogsContainer = self.app.containerManager.getContainer(WindowLayer.TOP_WINDOW) if not dialogsContainer.getView(criteria={POP_UP_CRITERIA.VIEW_ALIAS: VIEW_ALIAS.LOBBY_MENU}): self.fireEvent(events.LoadViewEvent(SFViewLoadParams(VIEW_ALIAS.LOBBY_MENU)), scope=EVENT_BUS_SCOPE.LOBBY) def onStartBattle(self): self.__stopUpdateScreen() def onStrongholdMaintenance(self, showWindow): self.__showBattleRoom() def onUnitFlagsChanged(self, flags, timeLeft): if not self.prbEntity.canShowStrongholdsBattleQueue(): self.__showBattleRoom() def onUpdateHeader(self, header, isFirstBattle, isUnitFreezed): self.__battleQueueVO['title'] = self.__getTitle() self.as_setTypeInfoS(self.__battleQueueVO) self.__requestClanIcon() def _populate(self): super(BattleStrongholdsQueue, self)._populate() self._blur.enable() self.addListener(events.GameEvent.SHOW_EXTERNAL_COMPONENTS, self._onShowExternals, scope=EVENT_BUS_SCOPE.GLOBAL) self.addListener(events.GameEvent.HIDE_EXTERNAL_COMPONENTS, self._onHideExternals, scope=EVENT_BUS_SCOPE.GLOBAL) self.startPrbListening() self.addListener(events.StrongholdEvent.STRONGHOLD_ON_TIMER, self.__onMatchmakingTimerChanged, scope=EVENT_BUS_SCOPE.STRONGHOLD) g_playerEvents.onArenaCreated += self.onStartBattle if self.prbEntity is not None: permissions = self.prbEntity.getPermissions() self.as_showExitS(permissions.canStopBattleQueue()) self.as_showWaitingS('') self.__battleQueueVO = self.__getBattleQueueVO() self.__requestClanIcon() MusicControllerWWISE.play() return def _dispose(self): self.__stopUpdateScreen() g_playerEvents.onArenaCreated -= self.onStartBattle self.stopPrbListening() self.removeListener(events.StrongholdEvent.STRONGHOLD_ON_TIMER, self.__onMatchmakingTimerChanged, scope=EVENT_BUS_SCOPE.STRONGHOLD) self.__imagesFetchCoordinator.fini() self.removeListener(events.GameEvent.SHOW_EXTERNAL_COMPONENTS, self._onShowExternals, scope=EVENT_BUS_SCOPE.GLOBAL) self.removeListener(events.GameEvent.HIDE_EXTERNAL_COMPONENTS, self._onHideExternals, scope=EVENT_BUS_SCOPE.GLOBAL) self._blur.fini() super(BattleStrongholdsQueue, self)._dispose() def __getBattleQueueVO(self): return {'iconLabel': constants.ARENA_GUI_TYPE_LABEL.LABELS[constants.ARENA_GUI_TYPE.SORTIE_2], 'title': self.__getTitle(), 'leagueIcon': '', 'myClanIcon': '', 'myClanName': '', 'myClanElo': text_styles.highTitleDisabled('--'), 'myClanRating': ''} def __requestClanIcon(self): myClanIcon = self.__battleQueueVO['myClanIcon'] if not myClanIcon: entity = self.prbEntity if entity is not None and entity.isStrongholdSettingsValid(): clan = entity.getStrongholdSettings().getHeader().getClan() self.requestClanEmblem32x32(clan.getId()) self.__battleQueueVO['myClanName'] = getClanTag(clan.getTag(), clan.getColor()) return def __getTitle(self): entity = self.prbEntity if entity is not None and entity.isStrongholdSettingsValid(): header = entity.getStrongholdSettings().getHeader() if header.isSortie(): level = int2roman(header.getMaxLevel()) title = makeString(FORTIFICATIONS.STRONGHOLDINFO_SORTIE) % {'level': level} else: direction = vo_converters.getDirection(header.getDirection()) title = makeString(FORTIFICATIONS.STRONGHOLDINFO_STRONGHOLD) % {'direction': direction} else: title = '' return title @async @process def __parseClanData(self, clanData, serviceLeaguesEnabled, callback): updateData = {} myClanName = getClanTag(clanData.get('tag'), clanData.get('color') or '') if myClanName: updateData['myClanName'] = myClanName myClanIcon = yield self.__imagesFetchCoordinator.fetchImageByUrl(clanData.get('emblem'), oneUse=False) if myClanIcon: updateData['myClanIcon'] = myClanIcon leagueIcon = yield self.__imagesFetchCoordinator.fetchImageByUrl(clanData.get('back_emblem'), oneUse=False) if leagueIcon: updateData['leagueIcon'] = leagueIcon if serviceLeaguesEnabled: myClanRating = clanData.get('position') if isinstance(myClanRating, int): textStyle = text_styles.highTitle updateData['myClanRating'] = textStyle(backport.getNiceNumberFormat(myClanRating)) else: textStyle = text_styles.highTitleDisabled updateData['myClanRating'] = textStyle('--') else: textStyle = text_styles.highTitleDisabled myClanElo = clanData.get('elo') if isinstance(myClanElo, int): updateData['myClanElo'] = textStyle(backport.getNiceNumberFormat(myClanElo)) callback(updateData) @async @process def __parseGroupsData(self, groupsData, callback): groups = [] for group in groupsData: clans = [] for clan in group.get('clans', []): clanVO = {'title': makeString(FORTIFICATIONS.BATTLEQUEUE_CLANPOSITION, position='--'), 'clanName': getClanTag(clan.get('tag'), clan.get('color') or ''), 'clanElo': '--', 'tooltip': ''} leagueIconUrl = clan.get('back_emblem') if leagueIconUrl: clanVO['leagueIcon'] = yield self.__imagesFetchCoordinator.fetchImageByUrl(clan.get('back_emblem'), oneUse=False) if not clanVO['leagueIcon']: callback([]) return clanVO['clanIcon'] = yield self.__imagesFetchCoordinator.fetchImageByUrl(clan.get('emblem'), oneUse=False) if not clanVO['clanIcon']: callback([]) return elo = clan.get('elo') if isinstance(elo, int): clanVO['clanElo'] = backport.getNiceNumberFormat(elo) position = clan.get('position') if isinstance(position, int): position = backport.getNiceNumberFormat(position) clanVO['title'] = makeString(FORTIFICATIONS.BATTLEQUEUE_CLANPOSITION, position=position) clans.append(clanVO) groups.append({'title': group.get('title'), 'leagues': clans}) callback(groups) @process def __onMatchmakingInfo(self, response): if response.getCode() == ResponseCodes.NO_ERRORS and response.getData(): data = response.getData() self.__animationDuration = data.get('animation_time', self.ANIMATION_DEFAULT_DURATION) groupsData = data.get('groups', []) updateData = yield self.__parseClanData(data.get('clan', {}), bool(groupsData)) self.__battleQueueVO.update(updateData) self.as_setTypeInfoS(self.__battleQueueVO) self.__groups = yield self.__parseGroupsData(groupsData) def __stopUpdateScreen(self): if self.__timerCallback is not None: BigWorld.cancelCallback(self.__timerCallback) self.__timerCallback = None return def __onMatchmakingTimerChanged(self, event): data = event.ctx if data['dtime'] > 0 and data['textid'] in (TOOLTIPS.STRONGHOLDS_TIMER_SQUADINQUEUE, FORTIFICATIONS.ROSTERINTROWINDOW_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLESOON): timerLabel = i18n.makeString(FORTIFICATIONS.BATTLEQUEUE_WAITBATTLE) currentTime = data['dtime'] else: _, unit = self.prbEntity.getUnit() currentTime = 0 if unit: timestamp = unit.getModalTimestamp() if timestamp: currentTime = max(0, int(time_utils.getServerUTCTime() - timestamp)) if data['isSortie'] or data['isFirstBattle']: timerLabel = i18n.makeString(FORTIFICATIONS.BATTLEQUEUE_SEARCHENEMY) else: timerLabel = i18n.makeString(FORTIFICATIONS.BATTLEQUEUE_WAITBATTLE) timeLabel = '%d:%02d' % divmod(currentTime, 60) self.as_setTimerS(timerLabel, timeLabel) n = len(self.__groups) if n != 0: self.as_hideWaitingS() if self.__startAnimationTime is None: self.__startAnimationTime = time_utils.getCurrentTimestamp() i, r = divmod(int(time_utils.getCurrentTimestamp() - self.__startAnimationTime), self.__animationDuration) if r == 0: self.as_setLeaguesS(self.__groups[i % n]) return @staticmethod def __showBattleRoom(): g_eventDispatcher.loadStrongholds() g_eventDispatcher.loadHangar() def _onHideExternals(self, _): self._blur.disable() def _onShowExternals(self, _): self._blur.enable()