def _getActiveOutfit(self, vDesc):
     if g_currentPreviewVehicle.isPresent(
     ) and not g_currentPreviewVehicle.isHeroTank:
         vehicleCD = g_currentPreviewVehicle.item.descriptor.makeCompactDescr(
         )
         return self.customizationService.getEmptyOutfitWithNationalEmblems(
             vehicleCD=vehicleCD)
     elif not g_currentVehicle.isPresent():
         if vDesc is not None:
             vehicleCD = vDesc.makeCompactDescr()
             outfit = self.customizationService.getEmptyOutfitWithNationalEmblems(
                 vehicleCD=vehicleCD)
         else:
             _logger.error(
                 'Failed to get base vehicle outfit. VehicleDescriptor is None.'
             )
             outfit = self.itemsFactory.createOutfit()
         return outfit
     else:
         vehicle = g_currentVehicle.item
         season = g_tankActiveCamouflage.get(vehicle.intCD,
                                             SeasonType.UNDEFINED)
         if season == SeasonType.UNDEFINED:
             season = vehicle.getAnyOutfitSeason()
         g_tankActiveCamouflage[vehicle.intCD] = season
         outfit = vehicle.getOutfit(season)
         if not outfit:
             vehicleCD = vehicle.descriptor.makeCompactDescr()
             outfit = self.customizationService.getEmptyOutfitWithNationalEmblems(
                 vehicleCD=vehicleCD)
         return outfit
def showVehiclePreview(vehTypeCompDescr,
                       previewAlias=VIEW_ALIAS.LOBBY_HANGAR,
                       vehStrCD=None):
    from CurrentVehicle import g_currentPreviewVehicle
    if g_currentPreviewVehicle.isPresent():
        g_currentPreviewVehicle.selectVehicle(vehTypeCompDescr)
    else:
        if constants.IS_BOOTCAMP_ENABLED:
            if g_bootcamp.isRunning():
                from debug_utils_bootcamp import LOG_DEBUG_DEV_BOOTCAMP
                LOG_DEBUG_DEV_BOOTCAMP('showVehiclePreview', vehTypeCompDescr,
                                       previewAlias)
                g_eventBus.handleEvent(events.LoadViewEvent(
                    VIEW_ALIAS.BOOTCAMP_VEHICLE_PREVIEW,
                    ctx={
                        'itemCD': vehTypeCompDescr,
                        'previewAlias': previewAlias
                    }),
                                       scope=EVENT_BUS_SCOPE.LOBBY)
                return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.VEHICLE_PREVIEW,
                                                    ctx={
                                                        'itemCD':
                                                        vehTypeCompDescr,
                                                        'previewAlias':
                                                        previewAlias,
                                                        'vehicleStrCD':
                                                        vehStrCD
                                                    }),
                               scope=EVENT_BUS_SCOPE.LOBBY)
Exemple #3
0
 def _validate(self):
     if g_currentPreviewVehicle.isPresent():
         return ValidationResult(
             False, PREBATTLE_RESTRICTION.PREVIEW_VEHICLE_IS_PRESENT)
     if not g_currentVehicle.isReadyToFight():
         if not g_currentVehicle.isPresent():
             return ValidationResult(
                 False, PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT)
         if g_currentVehicle.isInBattle():
             return ValidationResult(
                 False, PREBATTLE_RESTRICTION.VEHICLE_IN_BATTLE)
         if not g_currentVehicle.isCrewFull():
             return ValidationResult(False,
                                     PREBATTLE_RESTRICTION.CREW_NOT_FULL)
         if g_currentVehicle.isBroken():
             return ValidationResult(False,
                                     PREBATTLE_RESTRICTION.VEHICLE_BROKEN)
         if g_currentVehicle.isDisabledInRoaming():
             return ValidationResult(False,
                                     PREBATTLE_RESTRICTION.VEHICLE_ROAMING)
         if g_currentVehicle.isDisabledInPremIGR():
             return ValidationResult(
                 False, PREBATTLE_RESTRICTION.VEHICLE_IN_PREMIUM_IGR_ONLY)
         if g_currentVehicle.isDisabledInRent():
             if g_currentVehicle.isPremiumIGR():
                 return ValidationResult(
                     False,
                     PREBATTLE_RESTRICTION.VEHICLE_IGR_RENTALS_IS_OVER)
             return ValidationResult(
                 False, PREBATTLE_RESTRICTION.VEHICLE_RENTALS_IS_OVER)
         if g_currentVehicle.isRotationGroupLocked():
             return ValidationResult(
                 False, PREBATTLE_RESTRICTION.VEHICLE_ROTATION_GROUP_LOCKED)
     return super(CurrentVehicleActionsValidator, self)._validate()
def readInstalledCamouflages(self):
    if g_currentPreviewVehicle.isPresent():
        vDesc = g_currentPreviewVehicle.item.descriptor
    elif g_currentVehicle.isPresent():
        vDesc = g_currentVehicle.item.descriptor
    else:
        return
    nationName, vehName = vDesc.name.split(':')
    if _config.camouflagesCache.get(nationName, {}).get(vehName) is None:
        return
    for idx in xrange(3):
        self.showGroup(0, idx)
        if _config.camouflagesCache[nationName][vehName].get(CAMOUFLAGE_KIND_INDICES[idx]) is None:
            continue
        camoKindName = CAMOUFLAGE_KIND_INDICES[idx]
        camoName = _config.camouflagesCache[nationName][vehName][camoKindName]
        for itemIdx, item in enumerate(g_customizationController.carousel.items):
            if item['element']._rawData['name'] == camoName:
                self.installCustomizationElement(itemIdx)
                break
        else:
            SystemMessages.pushMessage('PYmods_SM' + _config.i18n['UI_customOrInvalid'].format(
                kind=_config.i18n['UI_customOrInvalid_%s' % CAMOUFLAGE_KIND_INDICES[idx]], name=camoName),
                                       SystemMessages.SM_TYPE.CustomizationForGold)
    g_customizationController._dataAggregator.start()
    try:
        self.backToSelectorGroup()
    except Exception as e:
        if False:
            print e
def showVehiclePreview(vehTypeCompDescr, previewAlias = VIEW_ALIAS.LOBBY_HANGAR):
    from CurrentVehicle import g_currentPreviewVehicle
    if g_currentPreviewVehicle.isPresent():
        g_currentPreviewVehicle.selectVehicle(vehTypeCompDescr)
    else:
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.VEHICLE_PREVIEW, ctx={'itemCD': vehTypeCompDescr,
         'previewAlias': previewAlias}), scope=EVENT_BUS_SCOPE.LOBBY)
Exemple #6
0
def new_setVehicleModule(self, newId, oldId, isRemove):
    if not g_currentPreviewVehicle.isPresent():
        slotIdx = self._FittingSelectPopover__logicProvider._slotIndex
        LOG_DEBUG('setVehicleModule: newId=%d, oldId=%d, isRemove=%s, slotIndex=%d' % (newId, oldId, isRemove, slotIdx))
        vehicle = g_currentVehicle.item
        saveDeviceOnVehicle(vehicle, newId, slotIdx, isRemove)
    old_setVehicleModule(self, newId, oldId, isRemove)
Exemple #7
0
def showVehiclePreview(vehTypeCompDescr, previewAlias = VIEW_ALIAS.LOBBY_HANGAR):
    from CurrentVehicle import g_currentPreviewVehicle
    if g_currentPreviewVehicle.isPresent():
        g_currentPreviewVehicle.selectVehicle(vehTypeCompDescr)
    else:
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.VEHICLE_PREVIEW, ctx={'itemCD': vehTypeCompDescr,
         'previewAlias': previewAlias}), scope=EVENT_BUS_SCOPE.LOBBY)
Exemple #8
0
 def _populate(self):
     self.addListener(CameraRelatedEvents.VEHICLE_LOADING,
                      self.__onVehicleLoading, EVENT_BUS_SCOPE.DEFAULT)
     self.setBottomPanel()
     if g_currentPreviewVehicle.intCD == self._vehicleCD:
         self.__fullUpdate()
     if self.__hangarVehicleCD and self.__isHeroTank and self.__vehAppearanceChanged:
         g_currentPreviewVehicle.resetAppearance()
         g_currentPreviewVehicle.selectVehicle(self.__hangarVehicleCD, None)
         g_currentPreviewVehicle.resetAppearance(self.__previewAppearance)
     g_currentPreviewVehicle.selectVehicle(self._vehicleCD,
                                           self.__vehicleStrCD)
     super(VehiclePreview, self)._populate()
     g_currentPreviewVehicle.onChanged += self.__onVehicleChanged
     g_currentPreviewVehicle.onVehicleInventoryChanged += self.__onInventoryChanged
     self.__comparisonBasket.onChange += self.__onCompareBasketChanged
     self.__comparisonBasket.onSwitchChange += self.__updateHeaderData
     self.__hangarSpace.onSpaceCreate += self.__onHangarCreateOrRefresh
     self.__hangarSpace.setVehicleSelectable(True)
     if not g_currentPreviewVehicle.isPresent():
         event_dispatcher.showHangar()
     if not self._heroInteractive:
         self.__heroTanksControl.setInteractive(False)
     self.addListener(CameraRelatedEvents.CAMERA_ENTITY_UPDATED,
                      self.handleSelectedEntityUpdated)
     specialData = getHeroTankPreviewParams() if self.__isHeroTank else None
     if specialData is not None and specialData.enterEvent:
         SoundGroups.g_instance.playSound2D(specialData.enterEvent)
     g_eventBus.addListener(OFFER_CHANGED_EVENT, self.__onOfferChanged)
     _updateCollectorHintParameters()
     _updatePostProgressionParameters()
     return
 def _processBackClick(self, ctx=None):
     if self._previewBackCb:
         self._previewBackCb()
     elif self._backAlias == VIEW_ALIAS.LOBBY_RESEARCH and g_currentPreviewVehicle.isPresent(
     ):
         event_dispatcher.showResearchView(
             self._vehicleCD,
             exitEvent=events.LoadViewEvent(
                 SFViewLoadParams(VIEW_ALIAS.LOBBY_TECHTREE),
                 ctx={'nation': g_currentPreviewVehicle.item.nationName}))
     elif self._backAlias == VIEW_ALIAS.VEHICLE_PREVIEW:
         entity = ctx.get('entity', None) if ctx else None
         if entity:
             compactDescr = entity.typeDescriptor.type.compactDescr
             if self.__itemsCache.items.inventory.getItemData(
                     compactDescr) is not None:
                 event_dispatcher.showHangar()
             else:
                 event_dispatcher.showVehiclePreview(
                     compactDescr, previewAlias=self._previousBackAlias)
         else:
             event_dispatcher.showHangar()
     elif self._backAlias == VIEW_ALIAS.LOBBY_STORE:
         showShop()
     else:
         event = g_entitiesFactories.makeLoadEvent(
             SFViewLoadParams(self._backAlias), {'isBackEvent': True})
         self.fireEvent(event, scope=EVENT_BUS_SCOPE.LOBBY)
     return
 def __updateStatus(self):
     if g_currentPreviewVehicle.isPresent():
         if g_currentPreviewVehicle.isModified():
             icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED, 16, 16, -3, 0)
             text = text_styles.neutral('%s %s' % (icon, _ms(VEHICLE_PREVIEW.MODULESPANEL_STATUS_TEXT)))
         else:
             text = text_styles.main(VEHICLE_PREVIEW.MODULESPANEL_LABEL)
         self.as_updateVehicleStatusS(text)
Exemple #11
0
 def getCurrentNation():
     if g_currentPreviewVehicle.isPresent():
         vDesc = g_currentPreviewVehicle.item.descriptor
     elif g_currentVehicle.isPresent():
         vDesc = g_currentVehicle.item.descriptor
     else:
         raise AttributeError('g_currentVehicle.item.descriptor not found')
     return vDesc.type.customizationNationID
Exemple #12
0
 def __selectVehicle(self):
     g_currentPreviewVehicle.selectVehicle(self.__vehicleCD,
                                           style=self._style)
     self.__selectedVehicleEntityId = g_currentPreviewVehicle.vehicleEntityID
     if not g_currentPreviewVehicle.isPresent() or self._style is None:
         event_dispatcher.showHangar()
     self.__heroTanksControl.setInteractive(False)
     return
Exemple #13
0
def getCurrentDesc():
    if g_currentPreviewVehicle.isPresent():
        vDesc = g_currentPreviewVehicle.item.descriptor
    elif g_currentVehicle.isPresent():
        vDesc = g_currentVehicle.item.descriptor
    else:
        raise AttributeError('g_currentVehicle.item.descriptor not found')
    return vDesc
 def showCustomization(self,
                       vehInvID=None,
                       callback=None,
                       season=None,
                       modeId=None,
                       tabId=None):
     if self.__customizationCtx is None:
         lobbyHeaderNavigationPossible = yield self.__lobbyContext.isHeaderNavigationPossible(
         )
         if not lobbyHeaderNavigationPossible:
             return
     self.__showCustomizationKwargs = {
         'vehInvID': vehInvID,
         'callback': callback,
         'season': season,
         'modeId': modeId,
         'tabId': tabId
     }
     shouldSelectVehicle = False
     if self.hangarSpace.space is not None:
         self.hangarSpace.space.turretAndGunAngles.set(
             gunPitch=self.__GUN_PITCH_ANGLE,
             turretYaw=self.__TURRET_YAW_ANGLE)
     if vehInvID is not None:
         vehGuiItem = self.itemsCache.items.getVehicle(vehInvID)
         if vehGuiItem is not None:
             if not vehGuiItem.isCustomizationEnabled():
                 _logger.error(
                     "Can't show customization view for currently non-customizable vehicle '%s'",
                     vehGuiItem.name)
                 return
             if g_currentVehicle.invID != vehInvID:
                 shouldSelectVehicle = True
     if not self.hangarSpace.spaceInited or not self.hangarSpace.isModelLoaded or shouldSelectVehicle:
         if shouldSelectVehicle:
             if g_currentPreviewVehicle.isPresent():
                 hideVehiclePreview(back=False, close=True)
                 g_currentPreviewVehicle.selectNoVehicle()
             BigWorld.callback(
                 0.0,
                 makeCallbackWeak(g_currentVehicle.selectVehicle,
                                  vehInvID=vehInvID))
         _logger.info(
             'Space or vehicle is not presented, customization view loading delayed'
         )
         self.hangarSpace.onVehicleChanged += self.__delayedShowCustomization
         self.hangarSpace.onSpaceChanged += self.__delayedShowCustomization
         return
     else:
         if not shouldSelectVehicle and self.hangarSpace.space is not None:
             vEntity = self.hangarSpace.space.getVehicleEntity()
             if vEntity is not None:
                 vEntity.appearance.rotateTurretForAnchor(None, None)
                 vEntity.appearance.rotateGunToDefault()
         self.__delayedShowCustomization()
         return
    def __fillData(self):
        configuration = self.mapsTrainingController.getConfig()
        trainingMaps = configuration['maps']
        availableMaps = []
        mapIDs = self.lobbyContext.getServerSettings().getPreferredMapsConfig(
        )['mapIDs']
        for geometryID in mapIDs:
            if geometryID not in ArenaType.g_geometryCache:
                continue
            geometryType = ArenaType.g_geometryCache[geometryID]
            availableMaps.append(geometryType)

        with self.viewModel.transaction() as model:
            model.setIncompleteFilter(self.__preferences.incompleteFilter)
            model.setTitleFilter(self.__preferences.titleFilter)
            groupArray = model.getGroups()
            groupArray.clear()
            for groupId in range(self._MAX_MAP_DIFFICULTY):
                groupVM = MapsTrainingGroupModel()
                groupArray.addViewModel(groupVM)
                groupVM.setGroupId(groupId)
                groupVM.setGroupTitle(
                    backport.text(
                        R.strings.maps_training.mapSelection.groupTitle.num(
                            groupId)()))
                groupVM.setIsGroupDisabled(
                    groupId == self._DISABLED_MAP_GROUP_ID)

            mapsModel = model.getMaps()
            mapsModel.clear()
            for geometryType in availableMaps:
                slotModel = MapsTrainingMapModel()
                mapName = geometryType.geometryName
                mapId = geometryType.geometryID
                slotModel.setId(mapName)
                slotModel.setIsEnabled(mapId in trainingMaps)
                data = self.__account.mapsTraining.getGeometryData(mapId)
                slotModel.setIsCompleted(data['total'] >= self._SCENARIO_COUNT)
                slotModel.setGroupId(
                    trainingMaps.get(mapId, self._DEFAULT_MAP_DIFFICULTY) - 1)
                slotModel.setTitle(
                    R.strings.arenas.dyn('c_{}'.format(mapName)).name())
                slotModel.setImage(
                    R.images.gui.maps.icons.map.dyn('c_{}'.format(mapName))())
                mapsModel.addViewModel(slotModel)

            if self.__selectedMap:
                if g_currentPreviewVehicle.isPresent(
                ) and self.__tickCallback is None:
                    self.__onPreviewVehicleChanged()
                self.__updateAllSelections(model)
            model.setIsDataLoaded(True)
        self.__isDataLoaded = True
        Waiting.hide('loadPage')
        return
    def _update(self):
        if g_currentPreviewVehicle.isPresent():
            self.as_setModulesEnabledS(True)
            vehicle = g_currentPreviewVehicle.item
            devices = []
            self.as_setModulesEnabledS(True)
            self.as_setVehicleHasTurretS(vehicle.hasTurrets)
            for slotType in _MODULE_SLOTS:
                data = g_itemsCache.items.getItems(GUI_ITEM_TYPE_INDICES[slotType], REQ_CRITERIA.CUSTOM(lambda item: item.isInstalled(vehicle))).values()
                devices.append(FittingSlotVO(data, vehicle, slotType))

            self.as_setDataS({'devices': devices})
 def __updateBtnState(self, *args):
     if g_currentPreviewVehicle.isPresent():
         btnState = self.__getBtnState()
         isAction = btnState.isAction
         self._actionType = btnState.actionType
         self.as_updateBuyButtonS(btnState.enabled, btnState.label)
         self.as_updatePriceS({'value': btnState.price,
          'icon': btnState.currencyIcon,
          'showAction': isAction,
          'actionTooltipType': TOOLTIPS_CONSTANTS.ACTION_PRICE if isAction else None,
          'actionData': btnState.action})
     return
 def __updateStatus(self):
     if g_currentPreviewVehicle.isPresent():
         if g_currentPreviewVehicle.isModified():
             icon = icons.makeImageTag(
                 RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED, 16, 16,
                 -3, 0)
             text = text_styles.neutral(
                 '%s %s' %
                 (icon, _ms(VEHICLE_PREVIEW.MODULESPANEL_STATUS_TEXT)))
         else:
             text = text_styles.main(VEHICLE_PREVIEW.MODULESPANEL_LABEL)
         self.as_updateVehicleStatusS(text)
Exemple #19
0
 def _populate(self):
     super(VehiclePreviewBuyingPanel, self)._populate()
     g_clientUpdateManager.addMoneyCallback(self.__updateBtnState)
     g_clientUpdateManager.addCallbacks({'stats.freeXP': self.__updateBtnState,
      'inventory': self.__updateBtnState})
     g_currentPreviewVehicle.onVehicleUnlocked += self.__updateBtnState
     g_currentPreviewVehicle.onChanged += self.__onVehicleChanged
     self.restores.onRestoreChangeNotify += self.__onRestoreChanged
     self.lobbyContext.getServerSettings().onServerSettingsChange += self.__onServerSettingsChanged
     if g_currentPreviewVehicle.isPresent():
         self.__updateBtnState()
     self.addListener(CameraRelatedEvents.VEHICLE_LOADING, self.__onVehicleLoading, EVENT_BUS_SCOPE.DEFAULT)
Exemple #20
0
 def fini(self, ctx=None, woEvents=False):
     if ctx and self.__battleRoyaleTournamentController.isSelected():
         self.__battleRoyaleTournamentController.leaveBattleRoyaleTournament()
     if self.__watcher is not None:
         self.__watcher.stop()
         self.__watcher = None
     self.storage.suspend()
     if g_currentPreviewVehicle.isPresent():
         reqFlags = FUNCTIONAL_FLAG.LOAD_PAGE | FUNCTIONAL_FLAG.SWITCH | FUNCTIONAL_FLAG.TRAINING
         if ctx and not ctx.hasFlags(reqFlags):
             g_eventDispatcher.loadHangar()
     return super(BattleRoyaleTournamentEntity, self).fini(ctx, woEvents)
Exemple #21
0
 def __getStyleProgressionOutfitData(self, outfit):
     vehicle = None
     if g_currentVehicle.isPresent():
         vehicle = g_currentVehicle.item
     elif g_currentPreviewVehicle.isPresent():
         vehicle = g_currentPreviewVehicle.item
     if vehicle:
         season = g_tankActiveCamouflage.get(vehicle.intCD, vehicle.getAnyOutfitSeason())
         progressionOutfit = camouflages.getStyleProgressionOutfit(outfit, outfit.progressionLevel, season)
         if progressionOutfit:
             return progressionOutfit
     return outfit
 def _getActiveOutfit(self):
     if g_currentPreviewVehicle.isPresent() or not g_currentVehicle.isPresent():
         return self.itemsFactory.createOutfit()
     else:
         vehicle = g_currentVehicle.item
         if not vehicle:
             return None
         season = g_tankActiveCamouflage.get(vehicle.intCD, SeasonType.UNDEFINED)
         if season == SeasonType.UNDEFINED or not vehicle.hasOutfitWithItems(season):
             season = vehicle.getAnyOutfitSeason()
         g_tankActiveCamouflage[vehicle.intCD] = season
         return vehicle.getOutfit(season)
 def _update(self):
     if g_currentPreviewVehicle.isPresent():
         item = g_currentPreviewVehicle.item
         if item.buyPrices.itemPrice.defPrice.get(Currency.GOLD):
             maxDescriptionLength = _MAX_LENGTH_FULL_DESCRIPTION_WITH_KPI
             bonuses = [{
                 'icon':
                 RES_SHOP.MAPS_SHOP_KPI_STAR_ICON_BENEFITS,
                 'title':
                 text_styles.concatStylesToMultiLine(
                     text_styles.highTitle(
                         VEHICLE_PREVIEW.INFOPANEL_PREMIUM_FREEEXPMULTIPLIER
                     ),
                     text_styles.main(
                         VEHICLE_PREVIEW.INFOPANEL_PREMIUM_FREEEXPTEXT))
             }, {
                 'icon':
                 RES_SHOP.MAPS_SHOP_KPI_CROW_BENEFITS,
                 'title':
                 text_styles.concatStylesToMultiLine(
                     text_styles.highTitle(
                         VEHICLE_PREVIEW.INFOPANEL_PREMIUM_CREWTRANSFERTITLE
                     ),
                     text_styles.main(VEHICLE_PREVIEW.
                                      INFOPANEL_PREMIUM_CREWTRANSFERTEXT))
             }]
             if not item.isSpecial:
                 bonuses.insert(
                     1, {
                         'icon':
                         RES_SHOP.MAPS_SHOP_KPI_MONEY_BENEFITS,
                         'title':
                         text_styles.concatStylesToMultiLine(
                             text_styles.highTitle(
                                 VEHICLE_PREVIEW.
                                 INFOPANEL_PREMIUM_CREDITSMULTIPLIER),
                             text_styles.main(
                                 VEHICLE_PREVIEW.
                                 INFOPANEL_PREMIUM_CREDITSTEXT))
                     })
         else:
             maxDescriptionLength = _MAX_LENGTH_FULL_DESCRIPTION_NO_KPI
             bonuses = None
         description = item.fullDescription.decode('utf-8')
         hasTooltip = len(description) > maxDescriptionLength
         if hasTooltip:
             description = description[:maxDescriptionLength - 3] + '...'
         self.as_setDataS(text_styles.main(description), hasTooltip,
                          bonuses)
     return
 def _populate(self):
     super(VehiclePreview, self)._populate()
     g_clientUpdateManager.addCallbacks({'stats.credits': self.__updateBtnState,
      'stats.gold': self.__updateBtnState,
      'stats.freeXP': self.__updateBtnState})
     g_currentPreviewVehicle.onComponentInstalled += self.__updateStatus
     g_currentPreviewVehicle.onVehicleUnlocked += self.__updateBtnState
     g_currentPreviewVehicle.onVehicleInventoryChanged += self.__onInventoryChanged
     g_currentPreviewVehicle.onChanged += self.__onVehicleChanged
     if g_currentPreviewVehicle.isPresent():
         self.as_setStaticDataS(self.__getStaticData())
         self.__fullUpdate()
     else:
         event_dispatcher.showHangar()
Exemple #25
0
 def _update(self):
     if g_currentPreviewVehicle.isPresent():
         item = g_currentPreviewVehicle.item
         isPremium = item.isPremium and (not item.isHidden
                                         or item.isRentable
                                         or item.isRestorePossible())
         if isPremium or self.__isHeroTank:
             maxDescriptionLength = _MAX_LENGTH_FULL_DESCRIPTION_WITH_KPI
             bonuses = [{
                 'icon':
                 RES_SHOP.MAPS_SHOP_KPI_STAR_ICON_BENEFITS,
                 'title':
                 text_styles.concatStylesToMultiLine(
                     text_styles.highTitle(
                         VEHICLE_PREVIEW.INFOPANEL_PREMIUM_FREEEXPMULTIPLIER
                     ),
                     text_styles.main(
                         VEHICLE_PREVIEW.INFOPANEL_PREMIUM_FREEEXPTEXT))
             }, {
                 'icon':
                 RES_SHOP.MAPS_SHOP_KPI_MONEY_BENEFITS,
                 'title':
                 text_styles.concatStylesToMultiLine(
                     text_styles.highTitle(
                         VEHICLE_PREVIEW.INFOPANEL_PREMIUM_CREDITSMULTIPLIER
                     ),
                     text_styles.main(
                         VEHICLE_PREVIEW.INFOPANEL_PREMIUM_CREDITSTEXT))
             }, {
                 'icon':
                 RES_SHOP.MAPS_SHOP_KPI_CROW_BENEFITS,
                 'title':
                 text_styles.concatStylesToMultiLine(
                     text_styles.highTitle(
                         VEHICLE_PREVIEW.INFOPANEL_PREMIUM_CREWTRANSFERTITLE
                     ),
                     text_styles.main(VEHICLE_PREVIEW.
                                      INFOPANEL_PREMIUM_CREWTRANSFERTEXT))
             }]
         else:
             maxDescriptionLength = _MAX_LENGTH_FULL_DESCRIPTION_NO_KPI
             bonuses = None
         description = item.fullDescription.decode('utf-8')
         hasTooltip = len(description) > maxDescriptionLength
         if hasTooltip:
             description = description[:maxDescriptionLength - 3] + '...'
         self.as_setDataS(text_styles.main(description), hasTooltip,
                          bonuses)
     return
    def _update(self):
        if g_currentPreviewVehicle.isPresent():
            vehicle = g_currentPreviewVehicle.item
            devices = []
            self.as_setVehicleHasTurretS(vehicle.hasTurrets)
            for slotType in _MODULE_SLOTS:
                data = self.__itemsCache.items.getItems(GUI_ITEM_TYPE_INDICES[slotType], REQ_CRITERIA.CUSTOM(lambda item: item.isInstalled(vehicle))).values()
                devices.append(FittingSlotVO(data, vehicle, slotType))

            self.__setHasCounter(devices)
            modulesEnabled = self.__hasCounter or vehicle.hasModulesToSelect
            for device in devices:
                device['isDisabledBgVisible'] = modulesEnabled

            self.as_setDataS({'devices': devices})
Exemple #27
0
    def _update(self):
        if g_currentPreviewVehicle.isPresent():
            self.as_setModulesEnabledS(True)
            vehicle = g_currentPreviewVehicle.item
            devices = []
            self.as_setModulesEnabledS(True)
            self.as_setVehicleHasTurretS(vehicle.hasTurrets)
            for slotType in _MODULE_SLOTS:
                data = g_itemsCache.items.getItems(
                    GUI_ITEM_TYPE_INDICES[slotType],
                    REQ_CRITERIA.CUSTOM(
                        lambda item: item.isInstalled(vehicle))).values()
                devices.append(FittingSlotVO(data, vehicle, slotType))

            self.as_setDataS({'devices': devices})
 def __init__(self, ctx=None, customProviderClass=None):
     data_ = ctx['data']
     self.__preferredLayout = data_.preferredLayout
     self.__slotIndex = data_.slotIndex
     if g_currentPreviewVehicle.isPresent():
         providerClass = _PreviewLogicProvider
         vehicle = g_currentPreviewVehicle.item
     else:
         providerClass = _HangarLogicProvider
         vehicle = g_currentVehicle.item
     providerClass = customProviderClass or providerClass
     logicProvider = providerClass(data_.slotType, data_.slotIndex)
     super(ModuleFittingSelectPopover, self).__init__(vehicle, logicProvider, ctx)
     if self._slotType is not None and self._slotType not in FITTING_MODULES:
         _logger.error('Using ModuleFittingSelectPopover for not module type: %s', self._slotType)
     return
Exemple #29
0
def new_removeSlot(base, self, cType, slotIdx):
    if cType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
        if g_currentPreviewVehicle.isPresent():
            vDesc = g_currentPreviewVehicle.item.descriptor
        else:
            vDesc = g_currentVehicle.item.getCustomizedDescriptor()
        nationName, vehName = vDesc.name.split(':')
        item = [item for item in g_customizationController.cart.items if item['idx'] == slotIdx][0]
        camoKind = CAMOUFLAGE_KIND_INDICES[slotIdx]
        camoName = item['object']._rawData['name']
        if _config.camouflagesCache.get(nationName, {}).get(vehName) is not None:
            vehDict = _config.camouflagesCache[nationName][vehName]
            if vehDict.get(camoKind) is not None and vehDict[camoKind] == camoName:
                del vehDict[camoKind]
            PYmodsCore.loadJson(_config.ID, 'camouflagesCache', _config.camouflagesCache, _config.configPath, True)
    base(self, cType, slotIdx)
 def __init__(self, ctx=None):
     """
     @param ctx: dictionary with data from AS, which contains:
                 -slotType - one of ITEM_TYPE_NAMES;
                 -slotIndex - number of slot in panel. Is important for optional device, as they have many
                 slots of same type;
     """
     super(FittingSelectPopover, self).__init__(ctx)
     data = ctx.get("data")
     self._slotType = data.slotType
     if g_currentPreviewVehicle.isPresent():
         self.__logicProvider = _PreviewLogicProvider(data.slotType, data.slotIndex)
         self.__vehicle = g_currentPreviewVehicle.item
     else:
         self.__logicProvider = _HangarLogicProvider(data.slotType, data.slotIndex)
         self.__vehicle = g_currentVehicle.item
Exemple #31
0
 def _populate(self):
     g_currentPreviewVehicle.selectVehicle(self._vehicleCD,
                                           self.__vehicleStrCD)
     super(VehiclePreview20, self)._populate()
     g_currentPreviewVehicle.onChanged += self.__onVehicleChanged
     self.comparisonBasket.onChange += self.__onCompareBasketChanged
     self.comparisonBasket.onSwitchChange += self.__updateHeaderData
     self.hangarSpace.onSpaceCreate += self.__onHangarCreateOrRefresh
     self.hangarSpace.setVehicleSelectable(True)
     serverSettings = self.lobbyContext.getServerSettings()
     serverSettings.onServerSettingsChange += self.__onServerSettingsChanged
     if not g_currentPreviewVehicle.isPresent():
         event_dispatcher.showHangar()
     if self.__itemsPack or self._backAlias == VIEW_ALIAS.LOBBY_STORE:
         self.heroTanks.setInteractive(False)
     self.addListener(CameraRelatedEvents.CAMERA_ENTITY_UPDATED,
                      self.handleSelectedEntityUpdated)
 def _populate(self):
     g_currentPreviewVehicle.selectVehicle(self.__vehicleCD, self.__vehicleStrCD)
     super(VehiclePreview, self)._populate()
     g_clientUpdateManager.addMoneyCallback(self._updateBtnState)
     g_clientUpdateManager.addCallbacks({'stats.freeXP': self._updateBtnState})
     g_currentPreviewVehicle.onComponentInstalled += self.__updateStatus
     g_currentPreviewVehicle.onVehicleUnlocked += self._updateBtnState
     g_currentPreviewVehicle.onVehicleInventoryChanged += self.__onInventoryChanged
     g_currentPreviewVehicle.onChanged += self.__onVehicleChanged
     self.comparisonBasket.onChange += self.__onCompareBasketChanged
     self.comparisonBasket.onSwitchChange += self.__updateHeaderData
     self.restores.onRestoreChangeNotify += self.__onRestoreChanged
     g_hangarSpace.onSpaceCreate += self.__onHangarCreateOrRefresh
     if g_currentPreviewVehicle.isPresent():
         self.__fullUpdate()
     else:
         event_dispatcher.showHangar()
 def __init__(self, ctx = None, logicProvider = None):
     data_ = ctx['data']
     slotType = data_.slotType
     self.__slotIndex = data_.slotIndex
     if g_currentPreviewVehicle.isPresent():
         _logicProvider = _PreviewLogicProvider(slotType, self.__slotIndex)
         vehicle = g_currentPreviewVehicle.item
     else:
         if self.bootcampController.isInBootcamp():
             _logicProvider = _BootCampLogicProvider(slotType, self.__slotIndex)
         else:
             _logicProvider = _HangarLogicProvider(slotType, self.__slotIndex)
         vehicle = g_currentVehicle.item
     if logicProvider is None:
         logicProvider = _logicProvider
     super(HangarFittingSelectPopover, self).__init__(vehicle, logicProvider, ctx)
     return
 def _populate(self):
     super(VehiclePreview, self)._populate()
     g_clientUpdateManager.addCallbacks({'stats.credits': self.__updateBtnState,
      'stats.gold': self.__updateBtnState,
      'stats.freeXP': self.__updateBtnState})
     g_currentPreviewVehicle.onComponentInstalled += self.__updateStatus
     g_currentPreviewVehicle.onVehicleUnlocked += self.__updateBtnState
     g_currentPreviewVehicle.onVehicleInventoryChanged += self.__onInventoryChanged
     g_currentPreviewVehicle.onChanged += self.__onVehicleChanged
     comparisonBasket = getVehicleComparisonBasketCtrl()
     comparisonBasket.onChange += self.__onCompareBasketChanged
     comparisonBasket.onSwitchChange += self.__updateHeaderData
     if g_currentPreviewVehicle.isPresent():
         self.__updateHeaderData()
         self.__fullUpdate()
     else:
         event_dispatcher.showHangar()
Exemple #35
0
 def __init__(self, ctx=None):
     """
     @param ctx: dictionary with data from AS, which contains:
                 -slotType - one of ITEM_TYPE_NAMES;
                 -slotIndex - number of slot in panel. Is important for optional device, as they have many
                 slots of same type;
     """
     super(FittingSelectPopover, self).__init__(ctx)
     data = ctx.get('data')
     self._slotType = data.slotType
     if g_currentPreviewVehicle.isPresent():
         self.__logicProvider = _PreviewLogicProvider(
             data.slotType, data.slotIndex)
         self.__vehicle = g_currentPreviewVehicle.item
     else:
         self.__logicProvider = _HangarLogicProvider(
             data.slotType, data.slotIndex)
         self.__vehicle = g_currentVehicle.item
 def __updateBtnState(self, *args):
     if g_currentPreviewVehicle.isPresent():
         btnState = self.__getBtnState()
         isAction = btnState.isAction
         self._actionType = btnState.actionType
         self.as_updateBuyButtonS(btnState.enabled, btnState.label)
         self.as_updatePriceS({
             'value':
             btnState.price,
             'icon':
             btnState.currencyIcon,
             'showAction':
             isAction,
             'actionTooltipType':
             TOOLTIPS_CONSTANTS.ACTION_PRICE if isAction else None,
             'actionData':
             btnState.action
         })
     return
    def _update(self):
        if g_currentPreviewVehicle.isPresent():
            self.as_setModulesEnabledS(True)
            vehicle = g_currentPreviewVehicle.item
            self.as_setVehicleHasTurretS(vehicle.hasTurrets)
            devices = []
            itemsGetter = g_itemsCache.items.getItems
            for slotType in _MODULE_SLOTS:
                if slotType == ITEM_TYPE_NAMES[ITEM_TYPES.vehicleTurret] and not vehicle.hasTurrets:
                    tooltipType = ''
                else:
                    tooltipType = TOOLTIPS_CONSTANTS.PREVIEW_MODULE
                data = itemsGetter(GUI_ITEM_TYPE_INDICES[slotType], REQ_CRITERIA.VEHICLE.SUITABLE([vehicle], [GUI_ITEM_TYPE_INDICES[slotType]])).values()
                data.sort(reverse=True)
                dataProvider = []
                selectedIndex = -1
                for idx, module in enumerate(data):
                    isFit, installReason = module.mayInstall(vehicle)
                    target = _getPreviewModuleTarget(module, vehicle)
                    isSelected = target == FITTING_TYPES.TARGET_CURRENT
                    if isSelected:
                        selectedIndex = idx
                    moduleData = {'id': module.intCD,
                     'type': slotType,
                     'name': module.userName,
                     'desc': module.getShortInfo(),
                     'target': target,
                     'moduleLabel': module.getGUIEmblemID(),
                     'icon': module.level,
                     'showPrice': False,
                     'removable': True,
                     'isSelected': isSelected,
                     'status': _getStatus(installReason),
                     'disabled': not isFit,
                     'tooltipType': tooltipType}
                    if slotType == ITEM_TYPE_NAMES[ITEM_TYPES.vehicleGun]:
                        if module.isClipGun(vehicle.descriptor):
                            moduleData[EXTRA_MODULE_INFO] = CLIP_ICON_PATH
                    dataProvider.append(moduleData)

                _addDevice(devices, dataProvider, slotType, selectedIndex, tooltipType)

            self.as_setDataS({'devices': devices})
Exemple #38
0
 def registerSettings(self):
     super(self.__class__, self).registerSettings()
     if hasattr(BigWorld, 'g_modsListApi'):
         kwargs = dict(id='CamoSelectorUI',
                       name=self.i18n['UI_flash_header'],
                       description=self.i18n['UI_flash_header_tooltip'],
                       icon='gui/flash/CamoSelector.png',
                       enabled=self.data['enabled'],
                       login=False,
                       lobby=True,
                       callback=lambda: None if g_currentVehicle.isInBattle(
                       ) or g_currentPreviewVehicle.isPresent() else
                       (self.onMSAPopulate(), g_appLoader.getDefLobbyApp().
                        loadView(ViewLoadParams('CamoSelectorMainView'))))
         try:
             BigWorld.g_modsListApi.addModification(**kwargs)
         except AttributeError:
             BigWorld.g_modsListApi.addMod(**kwargs)
         self.isModAdded = True
 def _populate(self):
     super(VehiclePreview, self)._populate()
     g_clientUpdateManager.addCallbacks({
         'stats.credits':
         self.__updateBtnState,
         'stats.gold':
         self.__updateBtnState,
         'stats.freeXP':
         self.__updateBtnState
     })
     g_currentPreviewVehicle.onComponentInstalled += self.__updateStatus
     g_currentPreviewVehicle.onVehicleUnlocked += self.__updateBtnState
     g_currentPreviewVehicle.onVehicleInventoryChanged += self.__onInventoryChanged
     g_currentPreviewVehicle.onChanged += self.__onVehicleChanged
     if g_currentPreviewVehicle.isPresent():
         self.as_setStaticDataS(self.__getStaticData())
         self.__fullUpdate()
     else:
         event_dispatcher.showHangar()
 def canPlayerDoAction(self):
     canDo, restriction = self.__collection.canPlayerDoAction(False)
     if canDo:
         if g_currentPreviewVehicle.isPresent():
             canDo = False
             restriction = PREBATTLE_RESTRICTION.PREVIEW_VEHICLE_IS_PRESENT
         elif not g_currentVehicle.isReadyToFight():
             if not g_currentVehicle.isPresent():
                 canDo = False
                 restriction = PREBATTLE_RESTRICTION.VEHICLE_NOT_PRESENT
             elif g_currentVehicle.isInBattle():
                 canDo = False
                 restriction = PREBATTLE_RESTRICTION.VEHICLE_IN_BATTLE
             elif not g_currentVehicle.isCrewFull():
                 canDo = False
                 restriction = PREBATTLE_RESTRICTION.CREW_NOT_FULL
             elif g_currentVehicle.isBroken():
                 canDo = False
                 restriction = PREBATTLE_RESTRICTION.VEHICLE_BROKEN
             elif g_currentVehicle.isFalloutOnly() and not game_control.getFalloutCtrl().isSelected():
                 canDo = False
                 restriction = PREBATTLE_RESTRICTION.VEHICLE_FALLOUT_ONLY
             elif g_currentVehicle.isDisabledInRoaming():
                 canDo = False
                 restriction = PREBATTLE_RESTRICTION.VEHICLE_ROAMING
             elif g_currentVehicle.isDisabledInPremIGR():
                 canDo = False
                 restriction = PREBATTLE_RESTRICTION.VEHICLE_IN_PREMIUM_IGR_ONLY
             elif g_currentVehicle.isDisabledInRent():
                 unit = self.getUnitFunctional()
                 if unit is not None and unit.getFlags().isInPreArena():
                     canDo = True
                 else:
                     canDo = False
                     if g_currentVehicle.isPremiumIGR():
                         restriction = PREBATTLE_RESTRICTION.VEHICLE_IGR_RENTALS_IS_OVER
                     else:
                         restriction = PREBATTLE_RESTRICTION.VEHICLE_RENTALS_IS_OVER
         if canDo:
             canDo, restriction = self.__collection.canPlayerDoAction(True)
     return (canDo, restriction)
 def __onInventoryChanged(self, *arg):
     if not g_currentPreviewVehicle.isPresent():
         event_dispatcher.selectVehicleInHangar(self.__vehicleCD)
 def __onVehicleChanged(self, *args):
     if g_currentPreviewVehicle.isPresent():
         self.__vehicleCD = g_currentPreviewVehicle.item.intCD
         self.__fullUpdate()