def __packUseFreeSheetsAwardTutorData(self, hasPawned): if self.getBranch() == PM_BRANCH.REGULAR: iconSource = RES_ICONS.MAPS_ICONS_PERSONALMISSIONS_REGULAR_ORDER_BLANK freeSheetsDescr = PERSONAL_MISSIONS.FOURFREESHEETSOBTAINEDPOPUP_REGULAR_DESCR freeSheetsPawnedDescr = PERSONAL_MISSIONS.FOURFREESHEETSOBTAINEDPOPUP_REGULAR_PAWNEDDESCR else: iconSource = RES_ICONS.MAPS_ICONS_PERSONALMISSIONS_PM2_ORDER_BLANK freeSheetsDescr = PERSONAL_MISSIONS.FOURFREESHEETSOBTAINEDPOPUP_PM2_DESCR freeSheetsPawnedDescr = PERSONAL_MISSIONS.FOURFREESHEETSOBTAINEDPOPUP_PM2_PAWNEDDESCR questName = self.__getLastQuest().getShortUserName() if hasPawned: description = _ms(freeSheetsPawnedDescr, pawnedCount=self.__PMCache.getPawnedTokensCount( self.getBranch()), questName=questName) else: description = _ms(freeSheetsDescr, questName=questName) return { 'icon0': { 'icon': AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.BIG), 'label': 'x' + str(PM_BRANCH_TO_FINAL_PAWN_COST[self.getBranch()]) }, 'icon1': { 'icon': iconSource, 'label': questName }, 'icon2': { 'icon': RES_ICONS.MAPS_ICONS_PERSONALMISSIONS_GEAR_BIG, 'label': 'x1' }, 'description': description, 'header': PERSONAL_MISSIONS.FOURFREESHEETSOBTAINEDPOPUP_HEADER }
def __getQuestStatusData(self, chainID, quest): questId = quest.getID() state = PERSONAL_MISSIONS_ALIASES.REGION_NOT_COMPLETED isFinal = quest.isFinal() areTokensPawned = quest.areTokensPawned() isUnlocked = quest.isUnlocked() isFullCompleted = quest.isFullCompleted() isDisabled = quest.isDisabled() isOnPause = quest.isOnPause if isDisabled: state = PERSONAL_MISSIONS_ALIASES.REGION_DISABLED elif quest.isInProgress(): if isOnPause: state = PERSONAL_MISSIONS_ALIASES.REGION_ON_PAUSE else: state = PERSONAL_MISSIONS_ALIASES.REGION_IN_PROGRESS elif isFullCompleted: state = PERSONAL_MISSIONS_ALIASES.REGION_FULLY_COMPLETED elif quest.isMainCompleted(): state = PERSONAL_MISSIONS_ALIASES.REGION_COMPLETED elif not isUnlocked and (not isFinal or not quest.canBePawned()): state = PERSONAL_MISSIONS_ALIASES.REGION_NOT_AVAILABLE vo = {'id': questId, 'state': state, 'isLocked': isFinal and not isUnlocked and not areTokensPawned or isDisabled, 'isOnPause': isOnPause, 'tooltipData': getMapRegionTooltipData(state, quest), 'isTokenPawned': areTokensPawned, 'isFinal': isFinal, 'vehType': chainID, 'sheet': AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.TINY)} return vo
def __packTutorData(self, hasPawned): questName = self.__getLastQuest().getShortUserName() if hasPawned: description = _ms( PERSONAL_MISSIONS.FOURFREESHEETSOBTAINEDPOPUP_DESCR2, pawnedCount=self.__PMCache.getPawnedTokensCount( self.getBranch()), questName=questName) else: description = _ms( PERSONAL_MISSIONS.FOURFREESHEETSOBTAINEDPOPUP_DESCR1, questName=questName) return { 'icon0': { 'icon': AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.BIG), 'label': 'x' + str(PM_BRANCH_TO_FINAL_PAWN_COST[self.getBranch()]) }, 'icon1': { 'icon': RES_ICONS.MAPS_ICONS_PERSONALMISSIONS_ORDER_BLANK, 'label': questName }, 'icon2': { 'icon': RES_ICONS.MAPS_ICONS_PERSONALMISSIONS_GEAR_BIG, 'label': 'x1' }, 'description': description, 'header': PERSONAL_MISSIONS.FOURFREESHEETSOBTAINEDPOPUP_HEADER }
def _packBlocks(self, *args, **kwargs): blocks = super(BasicFreeSheetTooltip, self)._packBlocks(*args, **kwargs) campaign = self.context.buildItem(*args, **kwargs) topItems = [ formatters.packTextBlockData( text_styles.highTitle( _ms(TOOLTIPS.PERSONALMISSIONS_FREESHEET_TITLE, campaignName=campaign.getUserName()))), formatters.packImageBlockData( AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.BIG), BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER, padding=formatters.packPadding(top=-5, bottom=11)) ] blocks.append(formatters.packBuildUpBlockData(topItems)) infoBlock = self._getInfoBlock() if infoBlock is not None: blocks.append(infoBlock) bottomItems = [] for block in self._getDescriptionBlock(): if block is not None: bottomItems.append(block) blocks.append(formatters.packBuildUpBlockData(bottomItems)) return blocks
def __getAvailableStatus(self, pawnsCount): return text_styles.warning( _ms(PERSONAL_MISSIONS.TANKMODULETOOLTIPDATA_STATUS_AVAILABLE, count=pawnsCount, img=icons.makeImageTag( AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.TINY), 24, 24, -6, 0)))
def getOperations(branch, currOperationID): _eventsCache = dependency.instance(IEventsCache) operations = [] for oID, o in sorted(_eventsCache.getPersonalMissions().getOperationsForBranch(branch).iteritems(), key=operator.itemgetter(0)): state = PERSONAL_MISSIONS_ALIASES.OPERATION_UNLOCKED_STATE descr = text_styles.stats(PERSONAL_MISSIONS.OPERATIONS_UNLOCKED_DESC) title = text_styles.highTitle(o.getShortUserName()) if o.isDisabled(): state, _ = getPostponedOperationState(oID) descr = text_styles.error(PERSONAL_MISSIONS.OPERATIONS_LOCKED_DESC) elif not o.isUnlocked(): state = PERSONAL_MISSIONS_ALIASES.OPERATION_LOCKED_STATE descr = text_styles.error(PERSONAL_MISSIONS.OPERATIONS_LOCKED_DESC) elif o.isFullCompleted(): state = PERSONAL_MISSIONS_ALIASES.OPERATION_COMPLETE_FULL_STATE descr = text_styles.bonusAppliedText(PERSONAL_MISSIONS.OPERATIONS_FULLYCOMPLETED_DESC) elif o.isAwardAchieved(): state = PERSONAL_MISSIONS_ALIASES.OPERATION_COMPLETE_STATE descr = text_styles.bonusAppliedText(PERSONAL_MISSIONS.OPERATIONS_COMPLETED_DESC) elif o.isInProgress(): state = PERSONAL_MISSIONS_ALIASES.OPERATION_CURRENT_STATE descr = text_styles.neutral(PERSONAL_MISSIONS.OPERATIONS_CURRENT_DESC) elif not o.hasRequiredVehicles(): state = PERSONAL_MISSIONS_ALIASES.OPERATION_LOCKED_STATE descr = text_styles.error(PERSONAL_MISSIONS.OPERATIONS_LOCKED_DESC) if state != PERSONAL_MISSIONS_ALIASES.OPERATION_UNLOCKED_STATE: iconStateSource = RES_ICONS.getPersonalMissionOperationState(state) else: iconStateSource = None freeSheetIcon = '' freeSheetCounter = '' tokensPawned = o.getTokensPawnedCount() if tokensPawned: freeSheetIcon = AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.X_16, o.getBranch()) freeSheetCounter = text_styles.counter('x%d' % tokensPawned) if state == PERSONAL_MISSIONS_ALIASES.OPERATION_POSTPONED_STATE: tooltipAlias = TOOLTIPS_CONSTANTS.OPERATION_POSTPONED else: tooltipAlias = TOOLTIPS_CONSTANTS.OPERATION operationVO = {'title': title, 'desc': descr, 'iconSource': RES_ICONS.getPersonalMissionOperationImage(oID), 'iconStateSource': iconStateSource, 'freeSheetIconSource': freeSheetIcon, 'freeSheetCounter': freeSheetCounter, 'state': state, 'isSelected': oID == currOperationID, 'id': oID, 'tooltipAlias': tooltipAlias} operations.append(operationVO) return operations
def __getQuestStatusData(self, chainID, quest): questId = quest.getID() state = PERSONAL_MISSIONS_ALIASES.REGION_NOT_COMPLETED isFinal = quest.isFinal() areTokensPawned = quest.areTokensPawned() isUnlocked = quest.isUnlocked() isFullCompleted = quest.isFullCompleted() if quest.isDisabled(): state = PERSONAL_MISSIONS_ALIASES.REGION_DISABLED elif quest.isInProgress(): state = PERSONAL_MISSIONS_ALIASES.REGION_IN_PROGRESS elif isFullCompleted: state = PERSONAL_MISSIONS_ALIASES.REGION_FULLY_COMPLETED elif quest.isMainCompleted(): state = PERSONAL_MISSIONS_ALIASES.REGION_COMPLETED elif not isUnlocked and (not isFinal or not quest.canBePawned()): state = PERSONAL_MISSIONS_ALIASES.REGION_NOT_AVAILABLE if isFullCompleted: tooltipData = { 'tooltip': makeTooltip( header=quest.getUserName(), body=_ms(TOOLTIPS. PERSONALMISSIONS_MAPREGION_DESCR_EXCELLENTDONE)), 'isSpecial': False, 'specialArgs': [] } else: tooltipData = { 'specialAlias': TOOLTIPS_CONSTANTS.PERSONAL_MISSIONS_MAP_REGION, 'isSpecial': True, 'specialArgs': [questId, state] } vo = { 'id': questId, 'state': state, 'isLocked': isFinal and not isUnlocked and not areTokensPawned, 'tooltipData': tooltipData, 'isTokenPawned': areTokensPawned, 'vehType': chainID, 'sheet': AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.TINY) } return vo
def __getOperationTitle(self): currentOperation = self.getOperation() chainState = self.__getChainState(self.getChain()) state = PERSONAL_MISSIONS_ALIASES.OPERATION_UNLOCKED_STATE tooltip = { 'tooltip': None, 'isSpecial': False, 'specialAlias': None, 'specialArgs': None } if not currentOperation.isUnlocked(): label = text_styles.stats( PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_LOCKED) state = PERSONAL_MISSIONS_ALIASES.OPERATION_LOCKED_STATE elif chainState.isFullCompleted: label = text_styles.bonusAppliedText( PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_EXCELLENTDONE) state = PERSONAL_MISSIONS_ALIASES.OPERATION_COMPLETE_FULL_STATE elif chainState.isCompleted: infoIcon = icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_NOTIF_FILTERS_INFORMATION_16X16, 16, 16, -2) state = PERSONAL_MISSIONS_ALIASES.OPERATION_COMPLETE_STATE currentCount = currentOperation.getFreeTokensCount() totalCount = currentOperation.getFreeTokensTotalCount() if currentCount < totalCount: icon = icons.makeImageTag( AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.MID), 24, 24, -22) count = str(currentCount) total = str(totalCount) label = text_styles.stats( _ms(PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_DONE, icon=icon, count=count, total=total, infoIcon=infoIcon)) tooltip.update({ 'isSpecial': True, 'specialAlias': TOOLTIPS_CONSTANTS.FREE_SHEET, 'specialArgs': [currentOperation.getCampaignID()] }) else: count = str(len(currentOperation.getFullCompletedQuests())) total = str(currentOperation.getQuestsCount()) label = text_styles.stats( _ms(PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_TOMASTER, count=count, total=total, infoIcon=infoIcon)) tooltip[ 'tooltip'] = TOOLTIPS.PERSONALMISSIONS_OPERATIONTITLE_COMPLETESTATE elif chainState.questInProgress: if self.getBranch() == PM_BRANCH.PERSONAL_MISSION_2: vehData = ' ' template = PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_INPROGRESS_PM2 else: vehData = '' template = PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_INPROGRESS_REGULAR vehData += getChainVehRequirements(currentOperation, self.getChainID(), useIcons=True) label = text_styles.stats(_ms(template, vehData=vehData)) state = PERSONAL_MISSIONS_ALIASES.OPERATION_CURRENT_STATE elif not chainState.hasVehicle: if self.getBranch() == PM_BRANCH.PERSONAL_MISSION_2: vehData = ' ' template = PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_NOVEHICLE_PM2 else: vehData = '' template = PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_NOVEHICLE_REGULAR vehData += getChainVehRequirements(currentOperation, self.getChainID(), useIcons=True) label = text_styles.stats(_ms(template, vehData=vehData)) state = PERSONAL_MISSIONS_ALIASES.OPERATION_NO_VEHICLE_STATE else: if self.getBranch() == PM_BRANCH.PERSONAL_MISSION_2: vehData = ' ' template = text_styles.stats( PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_UNLOCKED_PM2) else: vehData = '' template = text_styles.stats( PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_UNLOCKED_REGULAR) vehData += getChainVehRequirements(currentOperation, self.getChainID(), useIcons=True) label = text_styles.stats(_ms(template, vehData=vehData)) return { 'title': text_styles.promoTitle( _ms(PERSONAL_MISSIONS.OPERATIONTITLE_TITLE, title=_ms('#personal_missions:operations/title%d' % currentOperation.getID()))), 'label': label, 'state': state, 'tooltip': tooltip }
def __updateFooter(self): chainState = self.__getChainState(self.getChain()) isQuestInProgress = False btnVisible = False btnEnabled = False btnLabel = '' descr = '' currentOperation = self.getOperation() chainClassifier = currentOperation.getChainClassifier( self.getChainID()) vehicleClass = getTypeShortUserName(chainClassifier.classificationAttr) pm = self._eventsCache.getPersonalMissions() branch = self.getBranch() freeSheets = pm.getFreeTokensCount(branch) pawnedSheets = pm.getPawnedTokensCount(branch) if not chainState.hasUnlocked: status = text_styles.concatStylesWithSpace( icons.markerBlocked(), text_styles.error(PERSONAL_MISSIONS.STATUSPANEL_STATUS_LOCKED)) elif chainState.questInProgress is not None: quest = chainState.questInProgress if quest.isOnPause: status = text_styles.concatStylesWithSpace( icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_ONPAUSE, 16, 16, -3, 8), text_styles.playerOnline(quest.getUserName())) else: isQuestInProgress = True status = text_styles.concatStylesWithSpace( icons.inProgress(), text_styles.tutorial(quest.getUserName())) if quest.areTokensPawned(): descr = text_styles.neutral( _ms(PERSONAL_MISSIONS.STATUSPANEL_STATUS_PAWNED, count=quest.getPawnCost(), icon=getHtmlAwardSheetIcon(quest.getQuestBranch()))) elif quest.isMainCompleted(): descr = text_styles.neutral( PERSONAL_MISSIONS.STATUSPANEL_STATUS_IMPROVE) elif quest.canBePawned() and not quest.isDisabled(): btnVisible = True pawnCost = quest.getPawnCost() btnLabel = _ms( PERSONAL_MISSIONS.STATUSPANEL_FREESHEETBTN_LABEL, count=pawnCost, icon=getHtmlAwardSheetIcon(quest.getQuestBranch())) if pawnCost <= freeSheets: btnEnabled = True elif chainState.isFullCompleted: status = text_styles.concatStylesWithSpace( icons.doubleCheckmark(1), text_styles.bonusAppliedText( _ms(PERSONAL_MISSIONS.STATUSPANEL_STATUS_ALLEXCELLENTDONE, vehicleClass=vehicleClass))) elif chainState.isCompleted: status = text_styles.concatStylesWithSpace( icons.checkmark(-2), text_styles.bonusAppliedText( _ms(PERSONAL_MISSIONS.STATUSPANEL_STATUS_ALLDONE, vehicleClass=vehicleClass))) elif not chainState.hasVehicle: if self.getBranch() == PM_BRANCH.PERSONAL_MISSION_2: template = PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_NOVEHICLE_PM2 else: template = PERSONAL_MISSIONS.OPERATIONTITLE_LABEL_NOVEHICLE_REGULAR vehData = getChainVehRequirements(currentOperation, self.getChainID(), useIcons=False) status = text_styles.concatStylesWithSpace( icons.markerBlocked(), text_styles.error(_ms(template, vehData=vehData))) else: status = text_styles.concatStylesWithSpace( icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED, 16, 16, -2), text_styles.neutral( PERSONAL_MISSIONS.STATUSPANEL_STATUS_SELECTTASK)) tankwomanQuests = [] for operation in pm.getAllOperations().itervalues(): tankwomanQuests.extend( operation.getQuestsByFilter( PersonalMission.needToGetTankWoman).itervalues()) counterText = '' tankwomanVisible = False if tankwomanQuests: counterText = text_styles.highlightText('x%s' % len(tankwomanQuests)) tankwomanVisible = True self.as_setStatusDataS({ 'statusText': status, 'descrText': descr, 'btnVisible': btnVisible, 'btnEnabled': btnEnabled, 'btnLabel': btnLabel, 'sheetsBlockData': { 'freeSheetsIcon': AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.MID), 'freeSheetsText': text_styles.main( _ms(PERSONAL_MISSIONS.STATUSPANEL_FREESHEETS, count=text_styles.highlightText(freeSheets))), 'pawnedSheetsText': text_styles.main( _ms(PERSONAL_MISSIONS.STATUSPANEL_PAWNEDSHEETS, count=text_styles.highlightText(pawnedSheets))), 'tooltipData': { 'isSpecial': True, 'specialAlias': TOOLTIPS_CONSTANTS.FREE_SHEET_RETURN if freeSheets or pawnedSheets else TOOLTIPS_CONSTANTS.FREE_SHEET, 'specialArgs': [currentOperation.getCampaignID()] }, 'popover': PERSONAL_MISSIONS_ALIASES.FREE_SHEET_POPOVER, 'popoverData': { 'branch': branch } }, 'tankgirlsBlockData': { 'counterText': counterText, 'visible': tankwomanVisible, 'tooltipData': { 'isSpecial': True, 'specialAlias': TOOLTIPS_CONSTANTS.PERSONAL_MISSIONS_TANKWOMAN, 'specialArgs': [] }, 'popover': PERSONAL_MISSIONS_ALIASES.TANK_GIRLS_POPOVER }, 'tooltip': None, 'isQuestInProgress': isQuestInProgress }) return
def __update(self): freeSheetsQuests = [] pawnedSheets = 0 for _, o in sorted(self.__eventsCache.getPersonalMissions(). getOperationsForBranch(self.__branch).iteritems(), key=operator.itemgetter(0)): if o.isUnlocked(): operationName = _ms(PERSONAL_MISSIONS.OPERATIONTITLE_TITLE, title=o.getShortUserName()) idx = 1 for classifier in o.getIterationChain(): _, quests = o.getChainByClassifierAttr(classifier) for quest in sorted(quests.itervalues(), key=lambda q: q.getID()): if quest.areTokensPawned(): freeSheetsQuests.append({ 'taskId': str(quest.getID()), 'taskText': text_styles.standard(operationName), 'descrText': text_styles.main(quest.getUserName()), 'animDelay': self.__ANIMATION_DELAY * idx if self.__playAnimation else -1 }) idx += 1 pawnedSheets += quest.getPawnCost() freeSheets = self.__eventsCache.getPersonalMissions( ).getFreeTokensCount(self.__branch) if pawnedSheets == 0: pawnedSheetsDescrText = PERSONAL_MISSIONS.FREESHEETPOPOVER_PAWNEDSHEETSINFO_DESCR_NOONE else: pawnedSheetsDescrText = PERSONAL_MISSIONS.FREESHEETPOPOVER_PAWNEDSHEETSINFO_DESCR self.as_setDataS({ 'titleText': text_styles.highTitle(PERSONAL_MISSIONS.FREESHEETPOPOVER_TITLE), 'freeSheetsInfo': { 'imgSource': AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.SMALL), 'titleText': text_styles.middleTitle( _ms(PERSONAL_MISSIONS. FREESHEETPOPOVER_FREESHEETSINFO_TITLE, count=freeSheets)), 'descrText': text_styles.standard( PERSONAL_MISSIONS.FREESHEETPOPOVER_FREESHEETSINFO_DESCR) }, 'pawnedSheetsInfo': { 'imgSource': AwardSheetPresenter.getPawnedIcon(), 'titleText': text_styles.middleTitle( _ms(PERSONAL_MISSIONS. FREESHEETPOPOVER_PAWNEDSHEETSINFO_TITLE, count=pawnedSheets)), 'descrText': text_styles.standard(pawnedSheetsDescrText) }, 'hasPawnedSheets': pawnedSheets > 0 }) if pawnedSheets > 0: self.as_setListDataProviderS(freeSheetsQuests)
def getIcon(self): return AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.BIG)
def getHtmlAwardSheetIcon(branch=None): return icons.makeImageTag(AwardSheetPresenter.getIcon(AwardSheetPresenter.Size.X_16, branch), 16, 16, -3, 0)