def _loadTopLevel(self, rootItem, unlockStats): """ Fourth, loads vehicles in top level. :param rootItem: instance of gui item for root. @see gui.shared.gui_items. :param unlockStats: instance of unlockStats. """ itemGetter = self.getItem rootCD = self.getRootCD() for nodeCD in g_techTreeDP.getTopLevel(rootCD): node = self._getNodeData(nodeCD, rootItem, itemGetter(nodeCD), unlockStats, makeDefUnlockProps(), set(), topLevel=True) self._addTopNode(nodeCD, node)
def __loadTopLevel(self, rootItem, unlockStats): itemGetter = self.getItem rootCD = self.getRootCD() for nodeCD in g_techTreeDP.getTopLevel(rootCD): node = self._getNodeData(nodeCD, rootItem, itemGetter(nodeCD), unlockStats, makeDefUnlockProps(), set(), topLevel=True) self._addTopNode(nodeCD, node)
def __getContextHintsID(self): rootCD = self._data.getRootCD() hasParents = len(g_techTreeDP.getTopLevel(rootCD)) hasChildren = len(g_techTreeDP.getNextLevel(rootCD)) if hasParents and hasChildren: return RESEARCH_HINT_ID.BASE elif hasParents: return RESEARCH_HINT_ID.TOP elif hasChildren: return RESEARCH_HINT_ID.ROOT else: return RESEARCH_HINT_ID.ALONE
def _loadTopLevel(self, rootItem, unlockStats): itemGetter = self.getItem rootCD = self.getRootCD() for nodeCD in g_techTreeDP.getTopLevel(rootCD): node = self._getNodeData(nodeCD, rootItem, itemGetter(nodeCD), unlockStats, DEFAULT_UNLOCK_PROPS, set(), topLevel=True) self._addTopNode(nodeCD, node)
def __getContextHintsID(self): rootCD = self._data.getRootCD() hasParents = len(g_techTreeDP.getTopLevel(rootCD)) hasChildren = len(g_techTreeDP.getNextLevel(rootCD)) vehicle = self.itemsCache.items.getItemByCD(rootCD) if hasParents and hasChildren: return RESEARCH_HINT_ID.BASE elif hasParents: return RESEARCH_HINT_ID.TOP elif hasChildren: return RESEARCH_HINT_ID.ROOT else: return RESEARCH_HINT_ID.PREMIUM if vehicle is not None and vehicle.isPremium else RESEARCH_HINT_ID.IGR
def __getContextHintsID(self): rootCD = self._data.getRootCD() hasParents = len(g_techTreeDP.getTopLevel(rootCD)) hasChildren = len(g_techTreeDP.getNextLevel(rootCD)) vehicle = g_itemsCache.items.getItemByCD(rootCD) if hasParents and hasChildren: return RESEARCH_HINT_ID.BASE elif hasParents: return RESEARCH_HINT_ID.TOP elif hasChildren: return RESEARCH_HINT_ID.ROOT elif vehicle is not None and vehicle.isPremium: return RESEARCH_HINT_ID.PREMIUM else: return RESEARCH_HINT_ID.IGR_OR_FALLOUT return
def __getBtnDataLockedVehicle(self, vehicle): stats = self.itemsCache.items.stats tooltip = '' nodeCD = vehicle.intCD isAvailableToUnlock, xpCost, _ = g_techTreeDP.isVehicleAvailableToUnlock(nodeCD) if not isAvailableToUnlock: g_techTreeDP.load() unlocks = self.itemsCache.items.stats.unlocks next2Unlock, _ = g_techTreeDP.isNext2Unlock(nodeCD, unlocked=set(unlocks), xps=stats.vehiclesXPs, freeXP=stats.freeXP) if next2Unlock: tooltip = _buildBuyButtonTooltip('notEnoughXp') elif any((bool(cd in unlocks) for cd in g_techTreeDP.getTopLevel(nodeCD))): tooltip = _buildBuyButtonTooltip('parentModuleIsLocked') else: tooltip = _buildBuyButtonTooltip('parentVehicleIsLocked') return _ButtonState(isAvailableToUnlock, ['xp', xpCost], VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESEARCH, None, tooltip, self.__packTitle)
def __loadTopLevel(self, rootCD): xpGetter = self._xps.get invID = g_currentVehicle.invID if g_currentVehicle.isPresent() else -1 while len(self._topLevel): self._topLevel.pop().clear() self._topLevelCDs.clear() for nodeCD in g_techTreeDP.getTopLevel(rootCD): node = self._getNodeData(nodeCD, xpGetter(nodeCD, 0), makeDefUnlockProps(), set(), topLevel=True) item = self.getInvItem(nodeCD) if item is not None and invID == item.inventoryId: node['state'] |= NODE_STATE.SELECTED self._topLevelCDs[nodeCD] = len(self._topLevel) self._topLevel.append(node) return
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 __getBtnData(self): vehicle = g_currentPreviewVehicle.item stats = self.itemsCache.items.stats tooltip = '' if vehicle.isUnlocked: money = stats.money money = self.tradeIn.addTradeInPriceIfNeeded(vehicle, money) exchangeRate = self.itemsCache.items.shop.exchangeRate price = getGUIPrice(vehicle, money, exchangeRate) currency = price.getCurrency(byWeight=True) action = getActionPriceData(vehicle) mayObtainForMoney = vehicle.mayObtainWithMoneyExchange(money, exchangeRate) if currency == Currency.GOLD: currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICONBIG if mayObtainForMoney: formatter = text_styles.goldTextBig else: formatter = text_styles.errCurrencyTextBig tooltip = _buildBuyButtonTooltip('notEnoughGold') else: currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICONBIG formatter = text_styles.creditsTextBig if mayObtainForMoney else text_styles.errCurrencyTextBig if not mayObtainForMoney: tooltip = _buildBuyButtonTooltip('notEnoughCredits') if self._disableBuyButton: mayObtainForMoney = False return _ButtonState(mayObtainForMoney, formatter(BigWorld.wg_getIntegralFormat(price.getSignValue(currency))), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESTORE if vehicle.isRestorePossible() else VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_BUY, action is not None, currencyIcon, action, tooltip) else: nodeCD = vehicle.intCD currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICONBIG isAvailableToUnlock, xpCost, possibleXp = g_techTreeDP.isVehicleAvailableToUnlock(nodeCD) formatter = text_styles.creditsTextBig if possibleXp >= xpCost else text_styles.errCurrencyTextBig if not isAvailableToUnlock: unlocks = self.itemsCache.items.stats.unlocks next2Unlock, _ = g_techTreeDP.isNext2Unlock(nodeCD, unlocked=set(unlocks), xps=stats.vehiclesXPs, freeXP=stats.freeXP) if next2Unlock: tooltip = _buildBuyButtonTooltip('notEnoughXp') elif any(map(lambda cd: cd in unlocks, g_techTreeDP.getTopLevel(nodeCD))): tooltip = _buildBuyButtonTooltip('parentModuleIsLocked') else: tooltip = _buildBuyButtonTooltip('parentVehicleIsLocked') return _ButtonState(isAvailableToUnlock, formatter(BigWorld.wg_getIntegralFormat(xpCost)), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESEARCH, False, currencyIcon, None, tooltip) return None