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 _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 _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)