def _dispose(self):
     specialData = getHeroTankPreviewParams() if self.__isHeroTank else None
     if specialData is not None and specialData.exitEvent:
         SoundGroups.g_instance.playSound2D(specialData.exitEvent)
     self.removeListener(CameraRelatedEvents.VEHICLE_LOADING,
                         self.__onVehicleLoading, EVENT_BUS_SCOPE.DEFAULT)
     g_clientUpdateManager.removeObjectCallbacks(self)
     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(
         self.__keepVehicleSelectionEnabled)
     self.removeListener(CameraRelatedEvents.CAMERA_ENTITY_UPDATED,
                         self.handleSelectedEntityUpdated)
     if self._needToResetAppearance:
         g_currentPreviewVehicle.selectNoVehicle()
         g_currentPreviewVehicle.resetAppearance()
     g_eventBus.handleEvent(events.LobbySimpleEvent(
         events.LobbySimpleEvent.VEHICLE_PREVIEW_HIDDEN),
                            scope=EVENT_BUS_SCOPE.LOBBY)
     if self._backAlias == VIEW_ALIAS.VEHICLE_PREVIEW:
         g_currentVehicle.refreshModel()
     self._previewBackCb = None
     self.__unmodifiedItemsPack = None
     super(VehiclePreview, self)._dispose()
     if not self._heroInteractive:
         self.__heroTanksControl.setInteractive(True)
     if self.__vehAppearanceChanged:
         g_currentPreviewVehicle.resetAppearance()
     g_eventBus.removeListener(OFFER_CHANGED_EVENT, self.__onOfferChanged)
     return
예제 #2
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 __getUnlockedVehicleBtnLabel(self, priceType):
     specialData = getHeroTankPreviewParams() if self.__isHeroTank else None
     if specialData is not None and specialData.buyButtonLabel:
         buttonLabel = backport.text(specialData.buyButtonLabel)
     elif priceType == ActualPrice.RESTORE_PRICE:
         buttonLabel = backport.text(
             R.strings.vehicle_preview.buyingPanel.buyBtn.label.restore())
     elif priceType == ActualPrice.RENT_PRICE:
         buttonLabel = backport.text(
             R.strings.vehicle_preview.buyingPanel.buyBtn.label.rent())
     elif self.__isHeroTank and self._heroTanks.isAdventHero():
         buttonLabel = backport.text(R.strings.vehicle_preview.buyingPanel.
                                     buyBtn.label.showAdventCalendar())
     else:
         buttonLabel = backport.text(
             R.strings.vehicle_preview.buyingPanel.buyBtn.label.buy())
     return buttonLabel
 def __getBtnDataLockedVehicle(self, vehicle):
     stats = self._itemsCache.items.stats
     tooltip = ''
     buttonIcon = None
     buttonIconAlign = None
     nodeCD = vehicle.intCD
     _, isXpEnough = g_techTreeDP.isVehicleAvailableToUnlock(
         nodeCD, self._vehicleLevel)
     unlocks = self._itemsCache.items.stats.unlocks
     isNext2Unlock, unlockProps = g_techTreeDP.isNext2Unlock(
         nodeCD,
         unlocked=set(unlocks),
         xps=stats.vehiclesXPs,
         freeXP=stats.freeXP,
         level=self._vehicleLevel)
     isAvailableToUnlock = isXpEnough and isNext2Unlock
     if not isAvailableToUnlock:
         if not isXpEnough:
             tooltip = _buildBuyButtonTooltip('notEnoughXp')
         elif any((bool(cd in unlocks)
                   for cd in g_techTreeDP.getTopLevel(nodeCD))):
             tooltip = _buildBuyButtonTooltip('parentModuleIsLocked')
         else:
             tooltip = _buildBuyButtonTooltip('parentVehicleIsLocked')
     specialData = getHeroTankPreviewParams() if self.__isHeroTank else None
     if specialData is not None and specialData.buyButtonLabel:
         buyLabel = backport.text(specialData.buyButtonLabel)
     else:
         buyLabel = backport.text(
             R.strings.vehicle_preview.buyingPanel.buyBtn.label.research())
     return _ButtonState(enabled=isAvailableToUnlock,
                         itemPrice=getItemUnlockPricesVO(unlockProps),
                         label=buyLabel,
                         icon=buttonIcon,
                         iconAlign=buttonIconAlign,
                         isAction=unlockProps.discount > 0,
                         actionTooltip=None,
                         tooltip=tooltip,
                         title=self.__title,
                         isMoneyEnough=isXpEnough,
                         isUnlock=True,
                         isPrevItemsUnlock=isNext2Unlock,
                         customOffer=None,
                         isShowSpecial=False)
 def __getBtnDataPack(self):
     tooltip = ''
     actionTooltip = None
     customOffer = None
     price = self.__getPackPrice()
     currency = price.getCurrency()
     if self._disableBuyButton:
         tooltip = _buildBuyButtonTooltip('endTime')
         enabled = False
     elif self.__price.isSet(currency):
         enabled = self.__walletAvailableForCurrency(currency) and (
             currency == Currency.GOLD or mayObtainForMoney(price)
             or mayObtainWithMoneyExchange(price))
     else:
         enabled = True
     if self.__currentOffer and self.__currentOffer.bestOffer and self.__currentOffer.eventType:
         actionTooltip = self.__getBestOfferTooltipData(
             self.__currentOffer.eventType)
     buttonIcon = None
     buttonIconAlign = None
     itemPrices = ItemPrice(price=price, defPrice=self.__oldPrice)
     specialData = getHeroTankPreviewParams() if self.__isHeroTank else None
     if specialData is not None and specialData.buyButtonLabel:
         buttonLabel = backport.text(specialData.buyButtonLabel)
     elif self.__isReferralWindow():
         buttonLabel = backport.text(
             R.strings.vehicle_preview.buyingPanel.buyBtn.label.obtain())
     elif self._marathonEvent is not None:
         itemPrices = ITEM_PRICE_EMPTY
         buttonData = self._marathonEvent.getPreviewBuyBtnData()
         buttonLabel = buttonData['label']
         enabled = buttonData['enabled']
         buttonIcon = buttonData['btnIcon']
         buttonIconAlign = buttonData['btnIconAlign']
         tooltip = buttonData['btnTooltip']
         customOffer = buttonData['customOffer']
     elif self.__items and self.__couponInfo is None:
         buttonLabel = backport.text(R.strings.vehicle_preview.buyingPanel.
                                     buyBtn.label.buyItemPack())
     elif self.__offers and self.__currentOffer:
         buttonLabel = backport.text(
             R.strings.vehicle_preview.buyingPanel.buyBtn.label.rent())
         self.__title = self.__getCurrentOfferTitle()
     else:
         buttonLabel = backport.text(
             R.strings.vehicle_preview.buyingPanel.buyBtn.label.buy())
     isAction = self.__oldPrice.isDefined(
     ) and self.__oldPrice != self.__price or actionTooltip is not None or self.__couponInfo and self.__couponInfo.selected
     return _ButtonState(enabled=enabled,
                         itemPrice=getItemPricesVO(itemPrices),
                         label=buttonLabel,
                         icon=buttonIcon,
                         iconAlign=buttonIconAlign,
                         isAction=isAction,
                         actionTooltip=actionTooltip,
                         tooltip=tooltip,
                         title=self.__title,
                         isMoneyEnough=True,
                         isUnlock=False,
                         isPrevItemsUnlock=True,
                         customOffer=customOffer,
                         isShowSpecial=False)