def _prepareAndSendData(self): item = self.meta.getItem() if item is not None: actualPrices = self.meta.getActualPrices(item) defaultPrices = self.meta.getDefaultPrices(item) currency = self.meta.getCurrency(item) setCurrencies = actualPrices.toSignDict() hasAlternativePrice = len(setCurrencies) > 1 action = None if actualPrices != defaultPrices: action = self.meta.getActionVO(item) iconWidth = iconHeight = 59 if item.isWide(): iconWidth = 118 if item.itemTypeID == GUI_ITEM_TYPE.INSCRIPTION else 161 smallSlotVO = {'itemIcon': item.icon, 'isBgVisible': False, 'isFrameVisible': True, 'iconWidth': iconWidth, 'iconHeight': iconHeight} resultData = {'id': item.intCD, 'price': getMoneyVO(actualPrices), 'actionPriceData': action, 'name': item.userName, 'description': item.userType, 'currency': currency, 'defaultValue': self.meta.getDefaultValue(item), 'maxAvailableCount': self.meta.getMaxAvailableItemsCount(item), 'hasSeveralPrices': hasAlternativePrice, 'smallSlotVO': smallSlotVO} self.as_setDataS(resultData) else: LOG_ERROR("Couldn't find given customization item: ", self.meta.getItem()) self.onWindowClose() return
def getStorageVehicleVo(vehicle): name = getVehicleName(vehicle) description = _getVehicleDescription(vehicle) imageSmall = func_utils.makeFlashPath( vehicle.getShopIcon(STORE_CONSTANTS.ICON_SIZE_SMALL)) stateIcon, stateText = _getVehicleInfo(vehicle) if not imageSmall and not stateText: stateText = text_styles.vehicleStatusInfoText( _ms(STORAGE.INHANGAR_NOIMAGE)) vo = createStorageDefVO( vehicle.intCD, name, description, vehicle.inventoryCount, getItemPricesVO(vehicle.getSellPrice())[0], imageSmall, RES_SHOP.getVehicleIcon(STORE_CONSTANTS.ICON_SIZE_SMALL, 'empty_tank'), itemType=vehicle.getHighlightType(), nationFlagIcon=RES_SHOP.getNationFlagIcon( nations.NAMES[vehicle.nationID]), contextMenuId=CONTEXT_MENU_HANDLER_TYPE.STORAGE_VEHICLES_REGULAR_ITEM) vo.update({'infoImgSrc': stateIcon, 'infoText': stateText}) if vehicle.canTradeOff: vo.update( {'tradeOffPrice': { 'price': getMoneyVO(vehicle.tradeOffPrice) }}) return vo
def __setBottomPanelBillData(self, *_): purchaseItems = self.__ctx.getPurchaseItems() cartInfo = getTotalPurchaseInfo(purchaseItems) totalPriceVO = getItemPricesVO(cartInfo.totalPrice) if cartInfo.totalPrice != ITEM_PRICE_EMPTY: label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_BUY) else: label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_APPLY) tooltip = VEHICLE_CUSTOMIZATION.CUSTOMIZATION_BUYDISABLED_BODY fromStorageCount = 0 toByeCount = 0 for item in purchaseItems: if item.isFromInventory: fromStorageCount += 1 if not item.isDismantling: toByeCount += 1 if fromStorageCount > 0 or toByeCount > 0: self.__showBill() else: self.__hideBill() tooltip = VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTSELECTEDITEMS fromStorageCount = text_styles.stats('({})'.format(fromStorageCount)) toByeCount = text_styles.stats('({})'.format(toByeCount)) outfitsModified = self.__ctx.isOutfitsModified() self.as_setBottomPanelPriceStateS({ 'buyBtnEnabled': outfitsModified, 'buyBtnLabel': label, 'buyBtnTooltip': tooltip, 'isHistoric': self.__ctx.currentOutfit.isHistorical(), 'billVO': { 'title': text_styles.highlightText( _ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_RESULT)), 'priceLbl': text_styles.main('{} {}'.format( _ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_PRICE), toByeCount)), 'fromStorageLbl': text_styles.main('{} {}'.format( _ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_FROMSTORAGE), fromStorageCount)), 'isEnoughStatuses': getMoneyVO( Money(outfitsModified, outfitsModified, outfitsModified)), 'pricePanel': totalPriceVO[0] } })
def _prepareAndSendData(self): item = self.meta.getItem() if item is not None: actualPrices = self.meta.getActualPrices(item) defaultPrices = self.meta.getDefaultPrices(item) currency = self.meta.getCurrency(item) setCurrencies = actualPrices.toSignDict() hasAlternativePrice = len(setCurrencies) > 1 action = None if actualPrices != defaultPrices: action = self.meta.getActionVO(item) iconWidth = iconHeight = CustomizationItemIconWidth.SMALL if item.isWide(): iconWidth = CustomizationItemIconWidth.MEDIUM if item.itemTypeID == GUI_ITEM_TYPE.INSCRIPTION or item.itemTypeID == GUI_ITEM_TYPE.PERSONAL_NUMBER else CustomizationItemIconWidth.BIG countLabel = '' if item.isRentable and item.rentCount: countLabel = VEHICLE_CUSTOMIZATION.CONFIRMITEMDIALOG_COUNTLABEL if item.isProgressive and self.meta.vehicle is not None: progressionLevel = item.getLatestOpenedProgressionLevel( self.meta.vehicle) icon = item.iconByProgressionLevel(progressionLevel) else: icon = item.icon smallSlotVO = { 'itemIcon': icon, 'isBgVisible': False, 'isFrameVisible': True, 'iconWidth': iconWidth, 'iconHeight': iconHeight } stepFactor = self.meta.getStepFactor(item) resultData = { 'id': item.intCD, 'price': getMoneyVO(actualPrices), 'actionPriceData': action, 'name': item.userName, 'description': item.userType, 'currency': currency, 'defaultValue': self.meta.getDefaultValue(item) * stepFactor, 'maxAvailableCount': self.meta.getMaxAvailableItemsCount(item), 'hasSeveralPrices': hasAlternativePrice, 'smallSlotVO': smallSlotVO, 'countLabel': countLabel, 'stepSize': stepFactor } self.as_setDataS(resultData) else: LOG_ERROR("Couldn't find given customization item: ", self.meta.getItem()) self.onWindowClose() return
def __setBottomPanelBillData(self, *_): purchaseItems = self.__ctx.getPurchaseItems() cartInfo = getTotalPurchaseInfo(purchaseItems) totalPriceVO = getItemPricesVO(cartInfo.totalPrice) label = _ms(CUSTOMIZATION.COMMIT_APPLY) tooltip = CUSTOMIZATION.CUSTOMIZATION_NOTSELECTEDITEMS fromStorageCount = 0 toBuyCount = 0 for item in purchaseItems: if item.isFromInventory: fromStorageCount += 1 if not item.isDismantling: toBuyCount += 1 if cartInfo.totalPrice != ITEM_PRICE_EMPTY: label = _ms(CUSTOMIZATION.COMMIT_BUY) outfitsModified = self.__ctx.isOutfitsModified() fromStorageCount = text_styles.stats('({})'.format(fromStorageCount)) toBuyCount = text_styles.stats('({})'.format(toBuyCount)) self.as_setBottomPanelPriceStateS({ 'buyBtnEnabled': outfitsModified, 'buyBtnLabel': label, 'buyBtnTooltip': tooltip, 'isHistoric': self.__ctx.currentOutfit.isHistorical(), 'billVO': { 'title': text_styles.highlightText(_ms( CUSTOMIZATION.BUYPOPOVER_RESULT)), 'priceLbl': text_styles.main('{} {}'.format( _ms(CUSTOMIZATION.BUYPOPOVER_PRICE), toBuyCount)), 'fromStorageLbl': text_styles.main('{} {}'.format( _ms(CUSTOMIZATION.BUYPOPOVER_FROMSTORAGE), fromStorageCount)), 'isEnoughStatuses': getMoneyVO(Money(True, True, True)), 'pricePanel': totalPriceVO[0] } }) self.as_setItemsPopoverBtnEnabledS( any(i[1].isFilled() for i in self.__ctx.currentOutfit.itemsFull())) if outfitsModified: BigWorld.callback(0, self.__showBill) else: self.__hideBill()
def _prepareAndSendData(self): """ Create necessary object which expects flash component and pass it through DAAPI """ items = self.itemsCache.items item = items.getItemByCD(self.meta.getTypeCompDescr()) if item is not None: shop = self.itemsCache.items.shop actualPrices = self.meta.getActualPrices(item) defaultPrices = self.meta.getDefaultPrices(item) currency = self.meta.getCurrency(item) setCurrencies = actualPrices.toSignDict() hasAlternativePrice = len(setCurrencies) > 1 if hasAlternativePrice and Currency.CREDITS in setCurrencies: if item.itemTypeID == GUI_ITEM_TYPE.SHELL: hasAlternativePrice = shop.isEnabledBuyingGoldShellsForCredits elif item.itemTypeID == GUI_ITEM_TYPE.EQUIPMENT: hasAlternativePrice = shop.isEnabledBuyingGoldEqsForCredits icon = self.__getIcon(item) extraData = None if item.itemTypeID == GUI_ITEM_TYPE.GUN and item.isClipGun(): extraData = CLIP_ICON_PATH action = None if actualPrices != defaultPrices: action = self.meta.getActionVO(item) resultData = { 'id': self.meta.getTypeCompDescr(), 'price': getMoneyVO(actualPrices), 'actionPriceData': action, 'icon': icon, 'name': item.userName, 'description': item.getShortInfo(), 'currency': currency, 'defaultValue': self.meta.getDefaultValue(item), 'maxAvailableCount': self.meta.getMaxAvailableItemsCount(item), 'isActionNow': hasAlternativePrice, 'moduleLabel': item.getGUIEmblemID(), 'level': item.level, 'linkage': CONFIRM_DIALOG_ALIASES.MODULE_ICON, EXTRA_MODULE_INFO: extraData, FIELD_HIGHLIGHT_TYPE: self.__getHighlightType(item) } self.as_setDataS(resultData) else: LOG_ERROR("Couldn't find module with given compact:", self.meta.getTypeCompDescr()) self.onWindowClose() return
def _prepareAndSendData(self): items = self.itemsCache.items item = items.getItemByCD(self.meta.getTypeCompDescr()) if item is not None: shop = self.itemsCache.items.shop actualPrices = self.meta.getActualPrices(item) defaultPrices = self.meta.getDefaultPrices(item) currency = self.meta.getCurrency(item) setCurrencies = actualPrices.toSignDict() hasSeveralPrices = len(setCurrencies) > 1 if hasSeveralPrices and Currency.CREDITS in setCurrencies: if item.itemTypeID == GUI_ITEM_TYPE.SHELL: hasSeveralPrices = shop.isEnabledBuyingGoldShellsForCredits elif item.itemTypeID == GUI_ITEM_TYPE.EQUIPMENT: hasSeveralPrices = shop.isEnabledBuyingGoldEqsForCredits icon = self.__getIcon(item) extraData = item.getExtraIconInfo() action = None if actualPrices != defaultPrices: action = self.meta.getActionVO(item) resultData = { 'id': self.meta.getTypeCompDescr(), 'price': getMoneyVO(actualPrices), 'actionPriceData': action, 'icon': icon, 'name': item.userName, 'description': item.getShortInfo(), 'currency': currency, 'defaultValue': self.meta.getDefaultValue(item), 'maxAvailableCount': self.meta.getMaxAvailableItemsCount(item), 'hasSeveralPrices': hasSeveralPrices, 'moduleLabel': item.getGUIEmblemID(), 'level': item.level, 'linkage': CONFIRM_DIALOG_ALIASES.MODULE_ICON, EXTRA_MODULE_INFO: extraData, FIELD_HIGHLIGHT_TYPE: item.getHighlightType(), 'overlayType': item.getOverlayType() } self.as_setDataS(resultData) else: LOG_ERROR("Couldn't find module with given compact:", self.meta.getTypeCompDescr()) self.onWindowClose() return
def __makeBoosterData(self): booster = self.meta.getBooster() if booster is not None: action = self.meta.getActionVO() itemPrices = self.meta.getPrices() price = itemPrices.getMaxValuesAsMoney() self.as_setDataS({ 'id': self.meta.getBoosterID(), 'price': getMoneyVO(price), 'actionPriceData': action, 'name': booster.userName, 'description': text_styles.concatStylesToMultiLine( booster.description, booster.getExpiryDateStr()), 'currency': self.meta.getCurrency(), 'defaultValue': DEFAULT_VALUE, 'maxAvailableCount': self.meta.getMaxAvailableItemsCount(), 'isActionNow': itemPrices.hasAltPrice(), 'boosterData': self.__makeBoosterVO(booster), 'linkage': CONFIRM_DIALOG_ALIASES.BOOSTER_ICON }) else: LOG_ERROR("Couldn't find booster with given ID:", self.meta.getBoosterID()) self.onWindowClose() return
def __setBottomPanelBillData(self, *_): purchaseItems = self.__ctx.mode.getPurchaseItems() purchaseItems = self.__processBillDataPurchaseItems(purchaseItems) cartInfo = getTotalPurchaseInfo(purchaseItems) totalPriceVO = getItemPricesVO(cartInfo.totalPrice) label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_APPLY) fromStorageCount = 0 toBuyCount = 0 for pItem in purchaseItems: if not pItem.item.isHiddenInUI(): if pItem.isFromInventory: fromStorageCount += 1 else: toBuyCount += 1 for pItem in purchaseItems: if pItem.item.itemTypeID != GUI_ITEM_TYPE.PERSONAL_NUMBER: continue if not pItem.component.isFilled(): hasEmptyNumber = True break else: hasEmptyNumber = False if hasEmptyNumber: tooltip = VEHICLE_CUSTOMIZATION.CUSTOMIZATION_EMPTYPERSONALNUMBER elif self.__ctx.mode.isOutfitsEmpty(): tooltip = VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTSELECTEDITEMS else: tooltip = VEHICLE_CUSTOMIZATION.CUSTOMIZATION_ALREADYAPPLIED buyBtnEnabled = self.__ctx.isOutfitsModified() if buyBtnEnabled and cartInfo.totalPrice != ITEM_PRICE_EMPTY: label = _ms(VEHICLE_CUSTOMIZATION.COMMIT_BUY) outfitsModified = self.__ctx.mode.isOutfitsModified() if outfitsModified: if fromStorageCount > 0 or toBuyCount > 0: self.__showBill() else: self.__hideBill() else: self.__hideBill() fromStorageCount = text_styles.stats('({})'.format(fromStorageCount)) toBuyCount = text_styles.stats('({})'.format(toBuyCount)) self.as_setBottomPanelPriceStateS({ 'buyBtnEnabled': buyBtnEnabled, 'buyBtnLabel': label, 'buyBtnTooltip': tooltip, 'customizationDisplayType': self.__ctx.mode.currentOutfit.customizationDisplayType(), 'billVO': { 'title': text_styles.highlightText( _ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_RESULT)), 'priceLbl': text_styles.main('{} {}'.format( _ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_PRICE), toBuyCount)), 'fromStorageLbl': text_styles.main('{} {}'.format( _ms(VEHICLE_CUSTOMIZATION.BUYPOPOVER_FROMSTORAGE), fromStorageCount)), 'isEnoughStatuses': getMoneyVO(Money(True, True, True)), 'pricePanel': totalPriceVO[0] } }) itemsPopoverBtnEnabled = False for intCD, component, _, _, _ in self.__ctx.mode.currentOutfit.itemsFull( ): if component.isFilled(): item = self.service.getItemByCD(intCD) if item.isHiddenInUI(): continue itemsPopoverBtnEnabled = True break self.as_setItemsPopoverBtnEnabledS(itemsPopoverBtnEnabled)
def __getInitialVO(self): vehicle = self.itemsCache.items.getItemByCD(self.__vehicleIntCD) rentalTermSlots = [] statsMoney = self.itemsCache.items.stats.money isRestoreAvailable = vehicle.isRestoreAvailable() if isRestoreAvailable: isEnough = vehicle.restorePrice <= statsMoney or isIngameShopEnabled( ) isEnoughStatuses = Money.makeFromMoneyTuple( (isEnough, isEnough, isEnough)) enabled = isRestoreAvailable or not (constants.IS_CHINA and vehicle.rentalIsActive) rentalTermSlots.append({ 'itemId': -1, 'label': i18n.makeString(STORE.BUYVEHICLEWINDOW_RESTORE), 'price': getItemPricesVO( ItemPrice(vehicle.restorePrice, vehicle.restorePrice)), 'enabled': enabled, 'selected': self.__selectedRentTerm <= _NOT_RENT_IDX, 'isEnough': isEnough, 'isEnoughStatuses': getMoneyVO(isEnoughStatuses) }) rentPackages = vehicle.rentPackages for rentPackageId in xrange(len(rentPackages)): rentPackage = rentPackages[rentPackageId] days = rentPackage['days'] standartRentDays = STORE.getRentTermDays(days) price = ItemPrice(rentPackage['rentPrice'], rentPackage['defaultRentPrice']) isEnough = statsMoney >= price.price or isIngameShopEnabled() isEnoughStatuses = Money.makeFromMoneyTuple( (isEnough, isEnough, isEnough)) enabled = vehicle.maxRentDuration - vehicle.rentLeftTime >= days * time_utils.ONE_DAY rentalTermSlots.append({ 'itemId': rentPackageId, 'label': standartRentDays if standartRentDays is not None else i18n.makeString(STORE.RENTALTERMSELECTIONPOPOVER_TERMSLOTANY, days=days), 'price': getItemPricesVO(price), 'enabled': enabled, 'selected': self.__selectedRentTerm == days, 'isEnough': isEnough, 'isEnoughStatuses': getMoneyVO(isEnoughStatuses) }) if not isRestoreAvailable: isEnough = vehicle.buyPrices.itemPrice.price <= statsMoney or isIngameShopEnabled( ) isEnoughStatuses = Money.makeFromMoneyTuple( (isEnough, isEnough, isEnough)) enabled = not vehicle.isDisabledForBuy and not vehicle.isHidden rentalTermSlots.append({ 'itemId': _NOT_RENT_IDX, 'label': i18n.makeString( STORE.RENTALTERMSELECTIONPOPOVER_TERMSLOTUNLIM), 'price': getItemPricesVO(vehicle.buyPrices.itemPrice), 'enabled': enabled, 'selected': self.__selectedRentTerm <= _NOT_RENT_IDX, 'isEnough': isEnough, 'isEnoughStatuses': getMoneyVO(isEnoughStatuses) }) return { 'titleLabel': text_styles.highTitle(STORE.RENTALTERMSELECTIONPOPOVER_TITLELABEL), 'rentalTermSlots': rentalTermSlots }
def __getInitialVO(self): vehicle = self.itemsCache.items.getItemByCD(self.__vehicleIntCD) isEnoughStatuses = getMoneyVO( Money.makeFromMoneyTuple((True, True, True))) rentalTermSlots = [] isRestoreAvailable = vehicle.isRestoreAvailable() if isRestoreAvailable: enabled = isRestoreAvailable or not (constants.IS_CHINA and vehicle.rentalIsActive) rentalTermSlots.append({ 'itemId': -1, 'label': i18n.makeString(STORE.BUYVEHICLEWINDOW_RESTORE), 'price': getItemPricesVO( ItemPrice(vehicle.restorePrice, vehicle.restorePrice)), 'enabled': enabled, 'selected': self.__selectedRentID <= _NOT_RENT_IDX, 'isEnoughStatuses': isEnoughStatuses }) rentPackages = vehicle.rentPackages currentSeasonRent = vehicle.currentSeasonRent isSeasonRented = currentSeasonRent is not None for rentPackageIdx, rentPackage in enumerate(rentPackages): rentID = rentPackage['rentID'] rentType, packageID = parseRentID(rentID) if rentType == constants.RentType.TIME_RENT: days = packageID standardRentDays = STORE.getRentTermDays(days) if standardRentDays is not None: label = standardRentDays else: label = i18n.makeString( STORE.RENTALTERMSELECTIONPOPOVER_TERMSLOTANY, days=days) inMaxRentTime = isWithinMaxRentTime(vehicle.maxRentDuration, vehicle.rentLeftTime, days) enabled = not isSeasonRented and inMaxRentTime elif rentType in (constants.RentType.SEASON_RENT, constants.RentType.SEASON_CYCLE_RENT): seasonType = rentPackage['seasonType'] label = i18n.makeString( _SEASON_RENT_TERMS[seasonType][rentType]) if rentType == constants.RentType.SEASON_RENT: enabled = not isSeasonRented or isSeasonRented and currentSeasonRent.duration == SeasonRentDuration.SEASON_CYCLE else: enabled = not isSeasonRented else: raise SoftException( 'Unsupported rental type [{}]!'.format(rentType)) price = ItemPrice(rentPackage['rentPrice'], rentPackage['defaultRentPrice']) rentalTermSlots.append({ 'itemId': rentPackageIdx, 'label': label, 'price': getItemPricesVO(price), 'enabled': enabled, 'selected': self.__selectedRentID == rentID, 'isEnoughStatuses': isEnoughStatuses }) if not isRestoreAvailable: enabled = not vehicle.isDisabledForBuy and not vehicle.isHidden rentalTermSlots.append({ 'itemId': _NOT_RENT_IDX, 'label': i18n.makeString( STORE.RENTALTERMSELECTIONPOPOVER_TERMSLOTUNLIM), 'price': getItemPricesVO(vehicle.buyPrices.itemPrice), 'enabled': enabled, 'selected': self.__selectedRentID <= _NOT_RENT_IDX, 'isEnoughStatuses': isEnoughStatuses }) return { 'titleLabel': text_styles.highTitle(STORE.RENTALTERMSELECTIONPOPOVER_TITLELABEL), 'rentalTermSlots': rentalTermSlots }