def __updateIconForCrewSkin(self, commonData): skinID = self.__tankman.skinID if skinID != NO_CREW_SKIN_ID and self.lobbyContext.getServerSettings( ).isCrewSkinsEnabled(): skinItem = self.itemsCache.items.getCrewSkin(skinID) commonData['tankmanModel']['faceIcon'] = getCrewSkinIconBig( skinItem.getIconID()) commonData['tankmanModel']['name'] = localizedFullName(skinItem)
def __updateTankmanDataByCrewSkin(self, tankman, tankmanData): if tankman.skinID != NO_CREW_SKIN_ID and self.lobbyContext.getServerSettings( ).isCrewSkinsEnabled(): skinItem = self.itemsCache.items.getCrewSkin(tankman.skinID) tankmanData['iconFile'] = getCrewSkinIconSmallWithoutPath( skinItem.getIconID()) tankmanData['fullName'] = localizedFullName(skinItem) tankmanData['lastName'] = makeString(skinItem.getLastName())
def _pack(cls, bonus): result = [] for crewSkin, count, _, _ in sorted(bonus.getItems()): if crewSkin is None or not count: continue label = localizedFullName(crewSkin) result.append(cls._packSingleBonus(bonus, crewSkin, count, label)) return result
def _setTankmanData(self): packedTankman = packTankman(self._tankman) nation = nations.NAMES[packedTankman['nationID']] tankmanIcon = packedTankman['icon']['big'] roleIcon = packedTankman['iconRole']['small'] skinID = self._tankman.skinID if skinID != NO_CREW_SKIN_ID and self.lobbyContext.getServerSettings( ).isCrewSkinsEnabled(): skinItem = self.itemsCache.items.getCrewSkin(skinID) tankmanIcon = getCrewSkinIconBig(skinItem.getIconID()) tankmanName = localizedFullName(skinItem) else: tankmanName = self._tankman.fullUserName skills = packedTankman['skills'] lastSkillIcon = '' lastSkillLevel = 0 skillsCount = len(skills) if skillsCount > 0: lastSkill = skills[-1] lastSkillIcon = lastSkill['icon']['small'] lastSkillLevel = lastSkill['level'] preLastSkillIcon = '' if skillsCount > 1: preLastSkillIcon = skills[-2]['icon']['small'] roleLevel = packedTankman['roleLevel'] hasNewSkill = self._tankman.hasNewSkill(useCombinedRoles=True) isSkilledTankmen = roleLevel == MAX_SKILL_LEVEL or lastSkillIcon != '' or hasNewSkill isProtectedState = self._isDismissState and isSkilledTankmen if not isSkilledTankmen: skillsCount = -1 newSkillsCount, lastNewSkillLevel = self._tankman.newSkillCount if skillsCount == 0 and hasNewSkill: skillsCount = newSkillsCount preLastSkillIcon = SKILLS_CONSTANTS.TYPE_NEW_SKILL lastSkillIcon = SKILLS_CONSTANTS.TYPE_NEW_SKILL lastSkillLevel = lastNewSkillLevel hasNewSkill = False tankmanBlockVO = { 'nation': nation, 'tankmanName': tankmanName, 'tankmanIcon': tankmanIcon, 'roleIcon': roleIcon, 'skillsCount': skillsCount, 'lastSkill': lastSkillIcon, 'lastSkillLevel': lastSkillLevel, 'preLastSkill': preLastSkillIcon, 'hasNewSkill': hasNewSkill, 'newSkillsCount': newSkillsCount, 'lastNewSkillLevel': lastNewSkillLevel, 'roleLevel': roleLevel } vo = self._buildVO() vo.update({ 'isProtectedState': isProtectedState, 'tankmanBlockVO': tankmanBlockVO }) self.as_setDataS(vo)
def _packTankmanData(tankman, itemsCache=None, lobbyContext=None): tankmanVehicle = itemsCache.items.getItemByCD( tankman.vehicleNativeDescr.type.compactDescr) if tankman.isInTank: vehicle = itemsCache.items.getVehicle(tankman.vehicleInvID) vehicleID = vehicle.invID slot = tankman.vehicleSlotIdx isLocked, msg = _getTankmanLockMessage(vehicle) actionBtnEnabled = not isLocked isInCurrentTank = g_currentVehicle.isPresent( ) and tankmanVehicle.invID == g_currentVehicle.invID isInSelfVehicle = vehicle.shortUserName == tankmanVehicle.shortUserName isInSelfVehicleType = vehicle.type == tankmanVehicle.type else: isLocked, msg = False, '' actionBtnEnabled = True isInCurrentTank = False vehicleID = None slot = None isInSelfVehicle = True isInSelfVehicleType = True data = { 'fullName': tankman.fullUserName, 'rank': tankman.rankUserName, 'specializationLevel': tankman.realRoleLevel[0], 'role': tankman.roleUserName, 'vehicleType': tankmanVehicle.shortUserName, 'iconFile': tankman.icon, 'rankIconFile': tankman.iconRank, 'roleIconFile': Tankman.getRoleBigIconPath(tankman.descriptor.role), 'contourIconFile': tankmanVehicle.iconContour, 'tankmanID': tankman.invID, 'nationID': tankman.nationID, 'typeID': tankmanVehicle.innationID, 'roleType': tankman.descriptor.role, 'tankType': tankmanVehicle.type, 'inTank': tankman.isInTank, 'compact': str(tankman.invID), 'lastSkillLevel': tankman.descriptor.lastSkillLevel, 'actionBtnEnabled': actionBtnEnabled, 'inCurrentTank': isInCurrentTank, 'vehicleID': vehicleID, 'slot': slot, 'locked': isLocked, 'lockMessage': msg, 'isInSelfVehicleClass': isInSelfVehicleType, 'isInSelfVehicleType': isInSelfVehicle, 'notRecruited': False } if tankman.skinID != NO_CREW_SKIN_ID and lobbyContext.getServerSettings( ).isCrewSkinsEnabled(): skinItem = itemsCache.items.getCrewSkin(tankman.skinID) iconFile = getCrewSkinIconSmallWithoutPath(skinItem.getIconID()) data['iconFile'] = iconFile data['fullName'] = localizedFullName(skinItem) return data
def repackTankmanWithSkinData(item, data, itemsCache=None, lobbyContext=None): if item.skinID != NO_CREW_SKIN_ID and lobbyContext.getServerSettings( ).isCrewSkinsEnabled(): skinItem = itemsCache.items.getCrewSkin(item.skinID) data['icon']['big'] = Tankman.getCrewSkinIconBig(skinItem.getIconID()) data['firstUserName'] = i18n.makeString(skinItem.getFirstName()) data['lastUserName'] = i18n.makeString(skinItem.getLastName()) data['fullName'] = localizedFullName(skinItem) else: data['fullName'] = item.fullUserName
def __makeTankmanVO(self, tman, avgBattles2NewSkill): prediction = '' if avgBattles2NewSkill > 0: prediction = _ms(BATTLE_RESULTS.COMMON_NEWSKILLPREDICTION, battles=backport.getIntegralFormat(avgBattles2NewSkill)) data = {'title': _ms(BATTLE_RESULTS.COMMON_CREWMEMBER_NEWSKILL), 'prediction': prediction, 'linkEvent': PROGRESS_ACTION.NEW_SKILL_UNLOCK_TYPE, 'linkId': tman.invID} if tman.skinID != NO_CREW_SKIN_ID and self.lobbyContext.getServerSettings().isCrewSkinsEnabled(): skinItem = self.itemsCache.items.getCrewSkin(tman.skinID) data['tankmenIcon'] = getCrewSkinIconSmall(skinItem.getIconID()) fullTankmanName = localizedFullName(skinItem) else: data['tankmenIcon'] = Tankman.getSmallIconPath(tman.nationID, tman.descriptor.iconID) fullTankmanName = tman.fullUserName data['description'] = self.__makeTankmanDescription(tman.roleUserName, fullTankmanName) return data
def __convertCrewSkinData(self, crewSkin, tankman): cache = tankmen.g_cache.crewSkins() LOC_MAP = {} if crewSkin.getRoleID() is not None: LOC_MAP[CREW_SKIN_PROPERTIES_MASKS.ROLE] = i18n.makeString(ITEM_TYPES.tankman_roles(crewSkin.getRoleID())) if crewSkin.getSex() in TANKMAN_SEX.ALL: LOC_MAP[CREW_SKIN_PROPERTIES_MASKS.SEX] = backport.text(R.strings.item_types.tankman.gender.dyn(GenderRestrictionsLocales.KEYS[crewSkin.getSex()])()) if crewSkin.getNation() is not None: LOC_MAP[CREW_SKIN_PROPERTIES_MASKS.NATION] = i18n.makeString(NATIONS.all(crewSkin.getNation())) validation, validationMask, _ = cache.validateCrewSkin(tankman.descriptor, crewSkin.getID()) soundValidation = crewSkin.getRoleID() == tankman.role if crewSkin.getRoleID() is not None else True if not SoundGroups.g_instance.soundModes.currentNationalPreset[1]: soundValidation = False restrictionsMessage = backport.text(R.strings.tooltips.crewSkins.restrictions()) if not validation: restrictions = [ loc for key, loc in LOC_MAP.iteritems() if key & validationMask ] restrictionsMessage += ' ' + ', '.join(restrictions) soundSetID = crewSkin.getSoundSetID() soundSetRes = R.strings.crew_skins.feature.sound.dyn(soundSetID)() if soundSetID != NO_CREW_SKIN_SOUND_SET else R.strings.crew_skins.feature.sound.noSound() return {'id': crewSkin.getID(), 'fullName': localizedFullName(crewSkin), 'description': crewSkin.getDescription(), 'iconID': getCrewSkinIconSmall(crewSkin.getIconID()), 'roleIconID': getCrewSkinRolePath(crewSkin.getRoleID()), 'nationFlagIconID': getCrewSkinNationPath(crewSkin.getNation()), 'rarity': crewSkin.getRarity(), 'maxCount': crewSkin.getMaxCount(), 'freeCount': crewSkin.getFreeCount(), 'historical': crewSkin.getHistorical(), 'soundSetID': crewSkin.getSoundSetID(), 'useCount': len(crewSkin.getTankmenIDs()), 'isEquip': self.tmanInvID in crewSkin.getTankmenIDs(), 'isNew': crewSkin.isNew() and not PersonalCase.crewSkinsHAConfig.checkForViewed(crewSkin.getID()), 'isAvailable': validation, 'notAvailableMessage': restrictionsMessage, 'soundSetName': backport.text(soundSetRes), 'soundSetIsAvailable': soundValidation if crewSkin.getSoundSetID() != NO_CREW_SKIN_SOUND_SET else True}
def _getFullUserName(self, item): if item.skinID != NO_CREW_SKIN_ID and self._lobbyContext.getServerSettings( ).isCrewSkinsEnabled(): skinItem = self._itemsCache.items.getCrewSkin(item.skinID) return localizedFullName(skinItem) return item.fullUserName
def _packBlocks(self, *args, **kwargs): items = super(CrewSkinTooltipDataBlock, self)._packBlocks() item = self.context.buildItem(*args, **kwargs) topBlock = [] topBlock.append( formatters.packTextBlockData( text=text_styles.highTitle(localizedFullName(item)))) topBlock.append( formatters.packTextBlockData(text=text_styles.main( backport.text( R.strings.item_types.crewSkins.itemType.dyn(Rarity.STRINGS[ item.getRarity()])())))) topBlock.append( formatters.packImageTextBlockData( img=RES_ICONS.MAPS_ICONS_TOOLTIP_TOOLTIP_TANKMAN_BACK, padding=formatters.packPadding(18))) if self.lobbyContext.getServerSettings().isCrewSkinsEnabled(): topBlock.append( formatters.packImageTextBlockData( img=getCrewSkinIconBig(item.getIconID()), imgPadding=formatters.packPadding(left=60), padding=formatters.packPadding(-142))) topBlock.append( formatters.packTextBlockData(text=text_styles.main( item.getDescription()), padding=formatters.packPadding(14))) items.append(formatters.packBuildUpBlockData(topBlock)) block = [] soundSetID = item.getSoundSetID() soundSetName = soundSetID if soundSetID != NO_CREW_SKIN_SOUND_SET else backport.text( R.strings.crew_skins.feature.sound.noSound()) block.append( formatters.packTextParameterBlockData( name=text_styles.stats(soundSetName), value=text_styles.main( backport.text(R.strings.tooltips.crewSkins.sound())), valueWidth=115)) block.append( formatters.packTextParameterBlockData( name=text_styles.stats(str(len(item.getTankmenIDs()))), value=text_styles.main( backport.text(R.strings.crew_skins.feature.inUse())), valueWidth=115)) block.append( formatters.packTextParameterBlockData( name=text_styles.stats('{free}({max})'.format( free=item.getFreeCount(), max=item.getMaxCount())), value=text_styles.main( backport.text(R.strings.crew_skins.feature.inStorage())), valueWidth=115)) restrictions = [] if item.getRoleID() is not None: restrictions.append( backport.text( R.strings.item_types.tankman.roles.dyn( item.getRoleID())())) if item.getSex() == TANKMAN_SEX.MALE: restrictions.append( backport.text(R.strings.item_types.tankman.gender.man())) elif item.getSex() == TANKMAN_SEX.FEMALE: restrictions.append( backport.text(R.strings.item_types.tankman.gender.woman())) if item.getNation() is not None: restrictions.append( backport.text(R.strings.nations.dyn(item.getNation())())) if restrictions: restrictionText = ', '.join(restrictions) else: restrictionText = backport.text( R.strings.tooltips.crewSkins.noRestrictions()) block.append( formatters.packTextParameterBlockData( name=text_styles.stats(restrictionText), value=text_styles.main( backport.text( R.strings.tooltips.crewSkins.restrictions())), valueWidth=115)) items.append(formatters.packBuildUpBlockData(block)) skinUsersRoleAndVehicle = _skinUsersRoleAndVehicleText( '{role} ({vehicle})', item) if skinUsersRoleAndVehicle: usedBlock = [] usedBlock.append( formatters.packTextBlockData(text=text_styles.middleTitle( backport.text(R.strings.tooltips.crewSkins.inUse())))) usedBlock.append( formatters.packTextBlockData(text=text_styles.main( _longStringListEllipsisCutoff( ', ', skinUsersRoleAndVehicle, _MAX_USERS_DISPLAYED)))) items.append(formatters.packBuildUpBlockData(usedBlock)) return items
def getRewardTooltipContent(event, storedTooltipData=None, itemsCache=None): if event.contentID not in _COMPENSATION_TOOLTIP_CONTENT_RES_IDS: return else: tooltipData = { 'iconBefore': event.getArgument('iconBefore', ''), 'labelBefore': event.getArgument('labelBefore', ''), 'iconAfter': event.getArgument('iconAfter', ''), 'labelAfter': event.getArgument('labelAfter', ''), 'bonusName': event.getArgument('bonusName', ''), 'countBefore': event.getArgument('countBefore', 1), 'wsFlags': ViewFlags.VIEW, 'viewModelClazz': LootBoxCompensationTooltipModel } if event.contentID == R.views.common.tooltip_window.loot_box_compensation_tooltip.CrewSkinsCompensationTooltipContent( ): if storedTooltipData is None: return specialArgs = storedTooltipData.specialArgs if not specialArgs or not isinstance( specialArgs, (types.ListType, types.TupleType)): return crewSkin = itemsCache.items.getCrewSkin(specialArgs[0]) crewSkinCount = specialArgs[1] tooltipData.update({ 'iconBefore': getCrewSkinIconBig(crewSkin.getIconID()), 'labelBefore': localizedFullName(crewSkin), 'countBefore': crewSkinCount, 'layoutID': R.views.common.tooltip_window.loot_box_compensation_tooltip. CrewSkinsCompensationTooltipContent() }) tooltipType = LootBoxCompensationTooltipTypes.CREW_SKINS elif event.contentID == R.views.common.tooltip_window.loot_box_compensation_tooltip.LootBoxVehicleCompensationTooltipContent( ): tooltipType = LootBoxCompensationTooltipTypes.VEHICLE tooltipData.update({ 'iconBefore': event.getArgument('iconBefore', ''), 'labelBefore': event.getArgument('labelBefore', ''), 'iconAfter': event.getArgument('iconAfter', ''), 'labelAfter': event.getArgument('labelAfter', ''), 'vehicleName': event.getArgument('vehicleName', ''), 'vehicleType': event.getArgument('vehicleType', ''), 'isElite': event.getArgument('isElite', True), 'vehicleLvl': event.getArgument('vehicleLvl', ''), 'viewModelClazz': LootBoxVehicleCompensationTooltipModel, 'layoutID': R.views.common.tooltip_window.loot_box_compensation_tooltip. LootBoxVehicleCompensationTooltipContent() }) else: tooltipType = LootBoxCompensationTooltipTypes.BASE layoutID = R.views.common.tooltip_window.loot_box_compensation_tooltip.LootBoxCompensationTooltipContent( ) tooltipData.update({'layoutID': layoutID}) tooltipData['tooltipType'] = tooltipType return _COMPENSATION_TOOLTIP_CONTENT_CLASSES[tooltipType]( **tooltipData)