def __getAlertStatusText(self, timeLeft, unsuitablePeriphery, hasAvailableServers): rAlertMsgBlock = R.strings.battle_royale.widgetAlertMessageBlock alertStr = '' if hasAvailableServers: if unsuitablePeriphery: alertStr = backport.text( R.strings.battle_royale.alertMessage.unsuitablePeriphery()) else: alertStr = backport.text( rAlertMsgBlock.somePeripheriesHalt(), serverName=self.__connectionMgr.serverUserNameShort) else: currSeason = self.__battleRoyaleController.getCurrentSeason() currTime = time_utils.getCurrentLocalServerTimestamp() primeTime = self.__battleRoyaleController.getPrimeTimes().get( self.__connectionMgr.peripheryID) isCycleNow = currSeason and currSeason.hasActiveCycle( currTime) and primeTime and primeTime.getPeriodsBetween( currTime, currSeason.getCycleEndDate()) if isCycleNow: if self.__connectionMgr.isStandalone(): key = rAlertMsgBlock.singleModeHalt else: key = rAlertMsgBlock.allPeripheriesHalt timeLeftStr = time_utils.getTillTimeString( timeLeft, EPIC_BATTLE.STATUS_TIMELEFT, removeLeadingZeros=True) alertStr = backport.text(key(), time=timeLeftStr) else: nextSeason = currSeason or self.__battleRoyaleController.getNextSeason( ) if nextSeason is not None: nextCycle = nextSeason.getNextByTimeCycle(currTime) if nextCycle is not None: cycleNumber = nextCycle.getEpicCycleNumber() timeLeftStr = time_utils.getTillTimeString( nextCycle.startDate - currTime, EPIC_BATTLE.STATUS_TIMELEFT, removeLeadingZeros=True) alertStr = backport.text( rAlertMsgBlock.startIn.single() if nextSeason.isSingleCycleSeason() else rAlertMsgBlock.startIn.multi(), cycle=int2roman(cycleNumber), time=timeLeftStr) if not alertStr: prevSeason = currSeason or self.__battleRoyaleController.getPreviousSeason( ) if prevSeason is not None: prevCycle = prevSeason.getLastActiveCycleInfo(currTime) if prevCycle is not None: cycleNumber = prevCycle.getEpicCycleNumber() alertStr = backport.text( rAlertMsgBlock.noCycleMessage.single() if prevSeason.isSingleCycleSeason() else rAlertMsgBlock.noCycleMessage.multi(), cycle=int2roman(cycleNumber)) return text_styles.vehicleStatusCriticalText(alertStr)
def _getTillEndBlock(self, timeLeft): return formatters.packTextBlockData( text_styles.main(RANKED_BATTLES.SELECTORTOOLTIP_TILLEND) + ' ' + text_styles.stats( time_utils.getTillTimeString( timeLeft, MENU.HEADERBUTTONS_BATTLE_TYPES_RANKED_AVAILABILITY)))
def __setShortLeftTime(self, leftTime): self.as_updateLeftTimeS(formattedTime='{} {}'.format( self.__timeLeftIcon, text_styles.tutorial( time_utils.getTillTimeString( leftTime, MENU.VEHICLEPREVIEW_TIMELEFTSHORT))), hasHoursAndMinutes=True)
def __update(self, timeLeft=0): timeLeftStr = time_utils.getTillTimeString( timeLeft, RANKED_BATTLES.STATUS_TIMELEFT) statusText = text_styles.vehicleStatusCriticalText( _ms(RANKED_BATTLES.PRIMETIMEALERTMESSAGEBLOCK_MESSAGE, time=timeLeftStr)) self.as_setDataS({ 'alertIcon': RES_ICONS.MAPS_ICONS_LIBRARY_ALERTBIGICON, 'buttonIcon': RES_ICONS.MAPS_ICONS_BUTTONS_CALENDAR, 'buttonLabel': '', 'buttonVisible': True, 'buttonTooltip': makeTooltip( RANKED_BATTLES. RANKEDBATTLEVIEW_STATUSBLOCK_CALENDARBTNTOOLTIP_HEADER, RANKED_BATTLES. RANKEDBATTLEVIEW_STATUSBLOCK_CALENDARBTNTOOLTIP_BODY), 'statusText': statusText, 'popoverAlias': RANKEDBATTLES_ALIASES.RANKED_BATTLES_CALENDAR_POPOVER, 'bgVisible': True, 'shadowFilterVisible': True })
def __getAvailabilityStr(self): _, time, _ = self.epicQueueController.getPrimeTimeStatus() timeLeftStr = time_utils.getTillTimeString(time, EPIC_BATTLE.STATUS_TIMELEFT) if not self.epicQueueController.isInPrimeTime(): availablePrimeTime = self.epicQueueController.hasAnySeason( ) and self.epicQueueController.getPrimeTimeStatus()[1] != 0 if availablePrimeTime: return text_styles.main( i18n.makeString(EPIC_BATTLE.TOOLTIP_EPICBATTLE_AVAILABLEIN, time=timeLeftStr)) return None currPerformanceGroup = self.epicQueueController.getPerformanceGroup() if currPerformanceGroup == EPIC_PERF_GROUP.HIGH_RISK: attention = text_styles.error( MENU.HEADERBUTTONS_BATTLE_MENU_ATTENTION_LOWPERFORMANCE) return icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_MARKER_BLOCKED, vSpace=-3) + ' ' + attention elif currPerformanceGroup == EPIC_PERF_GROUP.MEDIUM_RISK: attention = text_styles.neutral( MENU.HEADERBUTTONS_BATTLE_MENU_ATTENTION_REDUCEDPERFORMANCE) return icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICON, vSpace=-3) + ' ' + attention else: return None
def __getTimeText(self, serverInfo): if serverInfo: timeLeft = serverInfo.getTimeLeft() isAvailable = serverInfo.isAvailable() serverName = serverInfo.getName() else: _, timeLeft, isAvailable = self.__eventProgression.getPrimeTimeStatus( ) serverName = '' currentSeason = self.__eventProgression.getCurrentSeason() if currentSeason and not timeLeft: return _ms(EPIC_BATTLE.PRIMETIME_ENDOFCYCLE, server=serverName) if not timeLeft and not isAvailable and not currentSeason: nextSeason = self.__eventProgression.getNextSeason() if nextSeason: currTime = time_utils.getCurrentLocalServerTimestamp() primeTime = self.__eventProgression.getPrimeTimes().get( serverInfo.getPeripheryID()) startTime = primeTime.getNextPeriodStart( currTime, nextSeason.getEndDate()) if startTime: timeLeft = startTime - currTime else: self.destroy() return '' timeLeftStr = time_utils.getTillTimeString(timeLeft, MENU.TIME_TIMEVALUESHORT) i18nKey = EPIC_BATTLE.PRIMETIME_PRIMEISAVAILABLE if isAvailable else EPIC_BATTLE.PRIMETIME_PRIMEWILLBEAVAILABLE return _ms(i18nKey, server=serverName, time=text_styles.neutral(timeLeftStr))
def getVehicleRestoreInfo(vehicle): info = vehicle.restoreInfo if info.isInCooldown(): enabled = False timeLeft = info.getRestoreCooldownTimeLeft() icon = RES_ICONS.MAPS_ICONS_LIBRARY_ICON_SAND_WATCH if timeLeft > time_utils.ONE_DAY: description = i18n.makeString( MENU.VEHICLE_RESTORECOOLDOWNLEFT_DAYS, time=int(timeLeft / time_utils.ONE_DAY)) else: if timeLeft > time_utils.ONE_HOUR: timeValue = int(timeLeft / time_utils.ONE_HOUR) else: timeValue = '<1' description = i18n.makeString( MENU.VEHICLE_RESTORECOOLDOWNLEFT_HOURS, time=timeValue) else: enabled = True timeLeft = 0 if info.isUnlimited() else info.getRestoreTimeLeft() description = i18n.makeString( STORAGE.CARD_VEHICLE_HOVER_RESTOREAVAILABLELABEL) icon = RES_ICONS.MAPS_ICONS_LIBRARY_CLOCKICON_1 if timeLeft: timeStr = time_utils.getTillTimeString(timeLeft, MENU.TIME_TIMEVALUESHORT) else: timeStr = i18n.makeString(STORAGE.RESTORETIMELEFT_TIMELESS) return (enabled, timeStr, description, icon)
def __getTillTimeString(self, endTime): timeDelta = time_utils.getTimeDeltaFromNow(endTime) if timeDelta > time_utils.ONE_DAY: formatter = text_styles.neutral else: formatter = text_styles.alert return formatter(time_utils.getTillTimeString(timeDelta, RANKED_BATTLES.STATUS_TIMELEFT))
def _prepareData(self, serverList, serverName, serverTimeLeft): if len(serverList) == 1: serversDDEnabled = False else: serversDDEnabled = True applyButtonLabel = _ms(RANKED_BATTLES.PRIMETIME_APPLYBTN) title = text_styles.epicTitle(RANKED_BATTLES.PRIMETIME_TITLE) if self._isEnabled: timeLeftStr = time_utils.getTillTimeString( serverTimeLeft, MENU.HEADERBUTTONS_BATTLE_TYPES_RANKED_AVAILABILITY) status = text_styles.main( _ms(RANKED_BATTLES.PRIMETIME_STATUS_THISENABLE, server=serverName, time=text_styles.warning(timeLeftStr))) mainBackground = RES_ICONS.MAPS_ICONS_RANKEDBATTLES_PRIMETIME_PRIME_TIME_BACK_DEFAULT title = text_styles.epicTitle( RANKED_BATTLES.PRIMETIME_TITLEWELCOME) else: applyButtonLabel = _ms(RANKED_BATTLES.PRIMETIME_CONTINUEBTN) status = '{} {}\n{}'.format( icons.alert(-3), text_styles.alert( RANKED_BATTLES.PRIMETIME_STATUS_DISABLEFIRST), text_styles.main(RANKED_BATTLES.PRIMETIME_STATUS_DISABLE)) mainBackground = RES_ICONS.MAPS_ICONS_RANKEDBATTLES_PRIMETIME_PRIME_TIME_BACK_BW return { 'title': title, 'apply': applyButtonLabel, 'mainBackground': mainBackground, 'status': status, 'serversDDEnabled': serversDDEnabled, 'serverDDVisible': True }
def __getAttentionText(self): key = RANKED_BATTLES.RANKEDBATTLEVIEW_STATUSBLOCK_CALENDARPOPOVER_ATTENTIONTEXT cycleNumber = self.__seasonInfo.getCycleOrdinalNumber() timeDelta = time_utils.getTimeDeltaFromNow(self.__seasonInfo.getCycleEndDate()) endTimeStr = time_utils.getTillTimeString(timeDelta, RANKED_BATTLES.STATUS_TIMELEFT) if timeDelta <= time_utils.ONE_HOUR: formatter = text_styles.alert else: formatter = text_styles.neutral return formatter(i18n.makeString(key, cycleNumber=cycleNumber, timeLeft=endTimeStr))
def __makePeripheryBtnToolTip(self, btnEnabled, timeLeft): ttHeader = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_PEREPHERYBTN_HEADER if btnEnabled: ttBody = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_PEREPHERYBTN_ENABLED_BODY else: ttBody = i18n.makeString( TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_PEREPHERYBTN_DISABLED_BODY, period=time_utils.getTillTimeString(timeLeft, MENU.TIME_TIMEVALUE), ) return makeTooltip(ttHeader, ttBody)
def _getTillEndBlock(self, timeLeft): _, status = self.epicController.getSeasonEndTime() if status: endKey = EPIC_BATTLE.SELECTORTOOLTIP_EPICBATTLE_DISABLED_TILLEND else: endKey = EPIC_BATTLE.SELECTORTOOLTIP_EPICBATTLE_DISABLED_STARTIN return formatters.packTextBlockData( text_styles.main(endKey) + ' ' + text_styles.stats( time_utils.getTillTimeString( timeLeft, MENU.HEADERBUTTONS_BATTLE_TYPES_RANKED_AVAILABILITY)))
def getTillTimeByResource(seconds, resource, useRoundUp=False, removeLeadingZeros=False): def stringGen(key, **kwargs): return backport.text(resource.dyn(key)(), **kwargs) return time_utils.getTillTimeString(seconds, isRoundUp=useRoundUp, sourceStrGenerator=stringGen, removeLeadingZeros=removeLeadingZeros)
def __makePeripheryBtnToolTip(self, btnEnabled, timeLeft): ttHeader = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_PEREPHERYBTN_HEADER if btnEnabled: ttBody = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_PEREPHERYBTN_ENABLED_BODY else: ttBody = i18n.makeString( TOOLTIPS. FORTIFICATION_FORTSETTINGSWINDOW_PEREPHERYBTN_DISABLED_BODY, period=time_utils.getTillTimeString(timeLeft, MENU.TIME_TIMEVALUE)) return makeTooltip(ttHeader, ttBody)
def updateRemainimgTime(self): battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID) if battle.isFuture(): timeRemaining = battle.getStartTimeLeft() else: timeRemaining = battle.getFinishTimeLeft() headerTimerText = '' footerTimerText = '' if battle.isFuture() or timeRemaining <= self.COOLDOWN_TRESHOLD: remainingText = time_utils.getTillTimeString(timeRemaining, MENU.TIME_TIMEVALUE) headerTimerText = i18n.makeString(HISTORICAL_BATTLES.TIMER_TOSTART if battle.isFuture() else HISTORICAL_BATTLES.TIMER_TOFINISH, time=remainingText) footerTimerText = i18n.makeString(HISTORICAL_BATTLES.BATTLESTATUS_REMAININGTIME, time=remainingText) self.as_updateTimerS(headerTimerText, footerTimerText)
def __timerTick(self): timeLeft = int( self.__teaserData.get('finishTime') - time_utils.getServerUTCTime()) if timeLeft > 0: timerStr = time_utils.getTillTimeString( timeLeft, MENU.PROMO_TEASERTIMEFORMAT) if self.__prevTimerValue != timerStr: self.__viewProxy.as_setTeaserTimerS(self.__timeIcon + timerStr) self.__prevTimerValue = timerStr self.__callbackID = BigWorld.callback(self._TIMER_PERIOD, self.__timerTick) else: self.__stopTimer()
def _getRentTooltipData(offer): rents = offer.rent if rents: seasons = [ rent['season'] for rent in rents if rent.get('season') ] cycles = [ rent['cycle'] for rent in rents if rent.get('cycle') ] cyclesLeft, timeLeft = offer.left if seasons or len(cycles) > 1: key = backport.text(R.strings.vehicle_preview.buyingPanel.offer.rent.frontline.tooltip.body.cyclesLeft()) value = str(cyclesLeft) else: key = backport.text(R.strings.vehicle_preview.buyingPanel.offer.rent.frontline.tooltip.body.timeLeft()) value = getTillTimeString(timeLeft, MENU.TIME_TIMEVALUE) return {'key': key, 'value': text_styles.stats(value)} else: return None
def __packWotPlus(self, tankman): tankManIsEligible = False tankHasPassiveXp = False if tankman.vehicleDescr: validator = CrewValidator(tankman.vehicleDescr.type) result = validator.validateCrewSlot(tankman.strCD) tankManIsEligible = not result.isEmpty and result.tManValidRes.isValid tankHasPassiveXp = self._renewableSubInfo.vehicleCrewHasIdleXP(tankman.vehicleInvID) xpPerMinute = self._lobbyContext.getServerSettings().getRenewableSubCrewXPPerMinute() xpPerSecond = float(xpPerMinute) / _SECONDS_IN_MINUTE secUntilNextLevel = tankman.getNextLevelXpCost() / xpPerSecond timeStr = time_utils.getTillTimeString(secUntilNextLevel, MENU.TIME_TIMEVALUE, removeLeadingZeros=True) if tankManIsEligible and secUntilNextLevel else '--' return {'name': 'timeUntilNextLevel', 'value': timeStr, 'secondValue': timeStr, 'isLabelActive': tankHasPassiveXp and tankManIsEligible, 'isValueActive': tankHasPassiveXp and tankManIsEligible and not self.__currentVehicleIsPremium, 'isSecondValueActive': tankHasPassiveXp and tankManIsEligible and self.__currentVehicleIsPremium}
def _prepareData(self, serverList, serverName, serverTimeLeft): enableTitle, enableWelcomeTitle, enableBtnTitle, disableTitle, disableStatusTitle, disableStatusDescr, disableBtnTitle = self._getLocaleData() enableBackground, disableBackground = self._getImgsData() if self._isEnabled: timeLeftStr = time_utils.getTillTimeString(serverTimeLeft, MENU.HEADERBUTTONS_BATTLE_TYPES_RANKED_AVAILABILITY) status = text_styles.main(_ms(enableTitle, server=serverName, time=text_styles.warning(timeLeftStr))) mainBackground = enableBackground title = text_styles.epicTitle(enableWelcomeTitle) applyButtonLabel = _ms(enableBtnTitle) else: status = '{} {}\n{}'.format(icons.alert(-3), text_styles.alert(disableStatusTitle), text_styles.main(disableStatusDescr)) mainBackground = disableBackground title = text_styles.epicTitle(disableTitle) applyButtonLabel = _ms(disableBtnTitle) return {'title': title, 'apply': applyButtonLabel, 'mainBackground': mainBackground, 'status': status, 'serversDDEnabled': len(serverList) > 1, 'serverDDVisible': True}
def __updateData(self): selectedIdx = self.__serversDP.getSelectedIdx() serverItem = self.__serversList[selectedIdx] selectedItem = self.__serversDP.getVO(selectedIdx) currentServerName = selectedItem['label'] if len(self.__serversList) == 1: serverDDName = text_styles.concatStylesToSingleLine( text_styles.main(currentServerName), ' ', selectedItem['pingValue']) serversDDEnabled = False else: serverDDName = '' serversDDEnabled = True applyButtonLabel = _ms(RANKED_BATTLES.PRIMETIME_APPLYBTN) title = _ms(RANKED_BATTLES.PRIMETIME_TITLE) if self.__isEnabled: timeLeftStr = time_utils.getTillTimeString( serverItem['timeLeft'], MENU.HEADERBUTTONS_BATTLE_TYPES_RANKED_AVAILABILITY) status = text_styles.main( _ms(RANKED_BATTLES.PRIMETIME_STATUS_THISENABLE, server=currentServerName, time=text_styles.warning(timeLeftStr))) mainBackground = RES_ICONS.MAPS_ICONS_RANKEDBATTLES_PRIMETIME_PRIME_TIME_BACK_DEFAULT title = _ms(RANKED_BATTLES.PRIMETIME_TITLEWELCOME) else: applyButtonLabel = _ms(RANKED_BATTLES.PRIMETIME_CONTINUEBTN) status = '{} {}'.format( icons.alert(-3), text_styles.main(_ms(RANKED_BATTLES.PRIMETIME_STATUS_DISABLE))) mainBackground = RES_ICONS.MAPS_ICONS_RANKEDBATTLES_PRIMETIME_PRIME_TIME_BACK_BW self.as_setDataS({ 'title': title, 'apply': applyButtonLabel, 'mainBackground': mainBackground, 'status': status, 'serversDDEnabled': serversDDEnabled, 'serverDDVisible': True })
def _buildTooltip(self, peripheryID): if not self.getTimeLeft(): tooltipStr = text_styles.expText( _ms(EPIC_BATTLE.PRIMETIME_ENDOFCYCLE, server=self.getName())) else: timeStr = text_styles.neutral( time_utils.getTillTimeString(self.getTimeLeft(), MENU.TIME_TIMEVALUESHORT)) if self._getIsAvailable(): tooltipStr = text_styles.expText( _ms(EPIC_BATTLE.PRIMETIME_SERVERTOOLTIP, server=self.getName(), time=timeStr)) else: tooltipStr = text_styles.expText( _ms(EPIC_BATTLE.PRIMETIME_SERVERUNAVAILABLETOOLTIP, time=timeStr)) return { 'tooltip': tooltipStr, 'specialArgs': [], 'specialAlias': None, 'isSpecial': None }
def __fillViewModel(self): with self.viewModel.transaction() as vm: season = self.__battleRoyaleController.getCurrentSeason() or self.__battleRoyaleController.getNextSeason() currTime = time_utils.getCurrentLocalServerTimestamp() if season is None: return self.__resetViewModel(vm) if season.hasActiveCycle(currTime): if self.__battleRoyaleController.isEnabled(): timeLeftStr = time_utils.getTillTimeString(season.getCycleEndDate() - currTime, EPIC_BATTLE.STATUS_TIMELEFT, removeLeadingZeros=True) vm.setTimeLeft(timeLeftStr) self._addReward(ModeSelectorRewardID.CREDITS) self._addReward(ModeSelectorRewardID.OTHER) else: cycleInfo = season.getNextByTimeCycle(currTime) if cycleInfo is not None: if cycleInfo.announceOnly: text = backport.text(R.strings.battle_royale.modeSelector.cycleIsComing()) else: text = backport.text(R.strings.battle_royale.modeSelector.cycleNotStarted(), date=backport.getShortDateFormat(cycleInfo.startDate)) vm.setStatusNotActive(text) vm.setTimeLeft('') setBattlePassState(self.viewModel) return
def getTimeStr(self, time): return time_utils.getTillTimeString(time, MENU.TIME_TIMEVALUE)
def getShortLeftTimeStr(self): return time_utils.getTillTimeString(self.getUsageLeftTime(), MENU.TIME_TIMEVALUESHORT)
def _getTillTimeString(cls, timeValue): return time_utils.getTillTimeString(timeValue, MENU.TIME_TIMEVALUE)
def getEffectTimeStr(self): return time_utils.getTillTimeString(self.effectTime, MENU.TIME_TIMEVALUE)
def getBonusTimeLeftStr(self): _, timeLeft = self.getBonus() if timeLeft: return time_utils.getTillTimeString(timeLeft, MENU.TIME_TIMEVALUE) return ''
def getTimeDurationStr(seconds, useRoundUp = False): return time_utils.getTillTimeString(seconds, MENU.TIME_TIMEVALUE, useRoundUp)
def getTimeDurationStr(seconds, useRoundUp=False): return time_utils.getTillTimeString(seconds, MENU.TIME_TIMEVALUE, useRoundUp)
def _getLocalizedTime(self, seconds, locale): return time_utils.getTillTimeString(seconds, locale)
def getUsageLeftTimeStr(self): return time_utils.getTillTimeString(self.getUsageLeftTime(), MENU.BOOSTERS_TIMELEFT, removeLeadingZeros=True)
def __getAlertStatusText(self, timeLeft): timeLeftStr = time_utils.getTillTimeString( timeLeft, RANKED_BATTLES.STATUS_TIMELEFT) return text_styles.vehicleStatusCriticalText( _ms(RANKED_BATTLES.PRIMETIMEALERTMESSAGEBLOCK_MESSAGE, time=timeLeftStr))
def getTimeDurationStr(self, seconds): return time_utils.getTillTimeString(seconds, MENU.TIME_TIMEVALUE)
def getEffectTimeStr(self, hoursOnly=False): return _ms(MENU.VEHICLEPREVIEW_TIMELEFTSHORT_HOURS, hour=str(time.gmtime(self.effectTime).tm_hour) ) if hoursOnly else time_utils.getTillTimeString( self.effectTime, MENU.TIME_TIMEVALUE)