def __getLogoutWarning(socialNetworkName):
     localizationString = "#menu:login/social/warning/SOCIAL_NETWORK_LOGOUT"
     formatter = {
         "userName": g_loginManager.getPreference("name"),
         "socialNetworkLink": makeHtmlString(
             "html_templates:socialNetworkLogin",
             "socialNetworkLink",
             {
                 "socialNetworkName": socialNetworkName,
                 "socialNetworkOfficialName": _ms("#tooltips:login/social/" + socialNetworkName),
             },
         ),
     }
     if socialNetworkName != SOCIAL_NETWORKS.WGNI:
         localizationString += "_BOTH"
         formatter["wargamingNetLink"] = makeHtmlString(
             "html_templates:socialNetworkLogin",
             "socialNetworkLink",
             {
                 "socialNetworkName": SOCIAL_NETWORKS.WGNI,
                 "socialNetworkOfficialName": _ms("#tooltips:login/social/" + SOCIAL_NETWORKS.WGNI),
             },
         )
     return makeHtmlString(
         "html_templates:socialNetworkLogin",
         "logoutWarning",
         {"warningMessage": _ms(localizationString) % formatter},
     )
Exemple #2
0
 def __setAccountsAttrs(self, isPremiumAccount, premiumExpiryTime = 0):
     disableTTHeader = ''
     disableTTBody = ''
     if isPremiumAccount:
         if not premiumExpiryTime > 0:
             raise AssertionError
             deltaInSeconds = float(time_utils.getTimeDeltaFromNow(time_utils.makeLocalServerTime(premiumExpiryTime)))
             if deltaInSeconds > time_utils.ONE_DAY:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_DAY)
                 timeMetric = i18n.makeString('#menu:header/account/premium/days')
             else:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_HOUR)
                 timeMetric = i18n.makeString('#menu:header/account/premium/hours')
             buyPremiumLabel = i18n.makeString('#menu:headerButtons/doLabel/premium')
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header', 'premium-account-label', {'timeMetric': timeMetric,
              'timeLeft': timeLeft})
             canUpdatePremium = deltaInSeconds < time_utils.ONE_YEAR
         else:
             canUpdatePremium = True
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header', 'base-account-label')
             buyPremiumLabel = i18n.makeString('#menu:common/premiumBuy')
         disableTTHeader = canUpdatePremium or i18n.makeString(TOOLTIPS.LOBBY_HEADER_BUYPREMIUMACCOUNT_DISABLED_HEADER)
         disableTTBody = i18n.makeString(TOOLTIPS.LOBBY_HEADER_BUYPREMIUMACCOUNT_DISABLED_BODY, number=time_utils.ONE_YEAR / time_utils.ONE_DAY)
     self.as_doDisableHeaderButtonS(self.BUTTONS.PREM, canUpdatePremium)
     self.as_setPremiumParamsS(isPremiumAccount, premiumBtnLbl, buyPremiumLabel, canUpdatePremium, disableTTHeader, disableTTBody)
 def _getTimerMsg(self):
     timeLeft = self.event.getFinishTimeLeft()
     if timeLeft <= GUI_SETTINGS.actionComeToEnd:
         return makeHtmlString('html_templates:lobby/quests', 'comeToEnd')
     if timeLeft <= time_utils.THREE_QUARTER_HOUR:
         return makeHtmlString('html_templates:lobby/quests', 'comeToEndInMinutes', {'minutes': getMinutesRoundByTime(timeLeft)})
     return super(_ActionInfo, self)._getTimerMsg()
    def getShellsLayoutFormatedPrice(self, intCD, colorManager, checkMoney=True, joinString=False):
        userCredits = g_itemsCache.items.stats.credits
        userGold = g_itemsCache.items.stats.gold
        creditsColor = colorManager.getColorScheme("textColorCredits").get("rgb")
        goldColor = colorManager.getColorScheme("textColorGold").get("rgb")
        errorColor = colorManager.getColorScheme("textColorError").get("rgb")
        result = []
        for c, g in self.getShellsLayoutPrice(intCD):
            priceLabel = ""
            if g:
                params = {
                    "value": BigWorld.wg_getGoldFormat(g),
                    "color": goldColor if not checkMoney or userGold >= g else errorColor,
                    "icon": getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2),
                }
                priceLabel += makeHtmlString("html_templates:lobby/historicalBattles/ammoStatus", "priceLabel", params)
            if c:
                params = {
                    "value": BigWorld.wg_getIntegralFormat(c),
                    "color": creditsColor if not checkMoney or userCredits >= c else errorColor,
                    "icon": getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2),
                }
                priceLabel += makeHtmlString("html_templates:lobby/historicalBattles/ammoStatus", "priceLabel", params)
            result.append(priceLabel)

        if joinString:
            return i18n.makeString("#historical_battles:ammoPreset/priceConcat").join(result)
        return result
Exemple #5
0
 def __setAccountsAttrs(self, isPremiumAccount, premiumExpiryTime = 0):
     if isPremiumAccount:
         if not premiumExpiryTime > 0:
             raise AssertionError
             deltaInSeconds = float(time_utils.getTimeDeltaFromNow(time_utils.makeLocalServerTime(premiumExpiryTime)))
             if deltaInSeconds > time_utils.ONE_DAY:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_DAY)
                 timeMetric = i18n.makeString('#menu:header/account/premium/days')
             else:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_HOUR)
                 timeMetric = i18n.makeString('#menu:header/account/premium/hours')
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header', 'premium-account-label', {'timeMetric': timeMetric,
              'timeLeft': timeLeft})
             canUpdatePremium = deltaInSeconds < time_utils.ONE_YEAR
             buyPremiumLabel = ''
             if canUpdatePremium:
                 buyPremiumLabel = i18n.makeString('#menu:headerButtons/doLabel/premium')
         else:
             canUpdatePremium = True
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header', 'base-account-label')
             buyPremiumLabel = i18n.makeString('#menu:common/premiumBuy')
         hasPersonalDiscount = len(g_itemsCache.items.shop.personalPremiumPacketsDiscounts) > 0
         tooltip = canUpdatePremium or formatters.getLimitExceededPremiumTooltip()
     elif isPremiumAccount:
         tooltip = TOOLTIPS.HEADER_PREMIUM_EXTEND
     else:
         tooltip = TOOLTIPS.HEADER_PREMIUM_BUY
     self.as_setPremiumParamsS(premiumBtnLbl, buyPremiumLabel, hasPersonalDiscount, tooltip, TOOLTIP_TYPES.COMPLEX)
Exemple #6
0
 def _getValue(self):
     module = self._tooltip.item
     if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS:
         if not module.isRemovable:
             return {'title': gui.makeHtmlString('html_templates:lobby/tooltips', 'permanent_module_title'),
              'text': gui.makeHtmlString('html_templates:lobby/tooltips', 'permanent_module_note', {'gold': g_itemsCache.items.shop.paidRemovalCost})}
     return None
Exemple #7
0
 def getTitle(self, invite):
     if invite.senderFullName:
         creatorName = makeHtmlString('html_templates:lobby/prebattle', 'inviteTitleCreatorName', ctx={'name': invite.senderFullName})
     else:
         creatorName = ''
     return makeHtmlString('html_templates:lobby/prebattle', 'inviteTitle', ctx={'sender': creatorName,
      'battleType': i18n.makeString('#invites:invites/text/fallout/%d' % invite.getExtraData().get('falloutBattleType'))}, sourceKey='FALLOUT')
Exemple #8
0
 def _getExtraInfo(self, data):
     item = data.getRootItem()
     result = {}
     if item.isPremium:
         if item.isSpecial:
             tag = "special"
         else:
             tag = "premium"
         typeString = i18n.makeString("#tooltips:tankCaruselTooltip/vehicleType/elite/{0:>s}".format(item.type))
         result = {
             "type": item.type,
             "title": gui.makeHtmlString(
                 "html_templates:lobby/research",
                 "premium_title",
                 ctx={
                     "name": item.userName,
                     "type": typeString,
                     "level": i18n.makeString("#tooltips:level/{0:d}".format(item.level)),
                 },
             ),
             "benefitsHead": i18n.makeString("#menu:research/{0:>s}/benefits/head".format(tag)),
             "benefitsList": gui.makeHtmlString(
                 "html_templates:lobby/research",
                 "{0:>s}_benefits".format(tag),
                 ctx={"description": item.fullDescription},
             ),
             "isPremiumIgr": item.isPremiumIGR,
         }
     return result
Exemple #9
0
    def onQueueInfoReceived(self, randomsQueueInfo, companiesQueueInfo, _, eventQueueInfo):
        if gui.prb_control.prb_getters.isCompany():
            data = {"title": "#menu:prebattle/typesCompaniesTitle", "data": list()}
            self.flashObject.as_setPlayers(
                makeHtmlString(
                    "html_templates:lobby/queue/playersLabel", "teams", {"count": sum(companiesQueueInfo["divisions"])}
                )
            )
            vDivisions = companiesQueueInfo["divisions"]
            if vDivisions is not None:
                vClassesLen = len(vDivisions)
                for vDivision in BattleQueue.DIVISIONS_ORDERED:
                    data["data"].append(
                        (
                            "#menu:prebattle/CompaniesTitle/%s" % constants.PREBATTLE_COMPANY_DIVISION_NAMES[vDivision],
                            vDivisions[vDivision] if vDivision < vClassesLen else 0,
                        )
                    )

                self.as_setListByTypeS(data)
            self.as_showStartS(constants.IS_DEVELOPMENT)
        elif self.__isInEventBattles():
            info = dict(eventQueueInfo)
            vClasses = info.get("classes", [])
            vClassesLen = len(vClasses)
            totalPlayers = info.get("players", 0)
            self.flashObject.as_setPlayers(
                makeHtmlString("html_templates:lobby/queue/playersLabel", "players", {"count": totalPlayers})
            )
            if vClassesLen:
                data = {"title": "#menu:prebattle/typesTitle", "data": []}
                vClassesData = data["data"]
                for vClass, message in BattleQueue.TYPES_ORDERED:
                    idx = constants.VEHICLE_CLASS_INDICES[vClass]
                    vClassesData.append((message, vClasses[idx] if idx < vClassesLen else 0))

                self.as_setListByTypeS(data)
        else:
            info = dict(randomsQueueInfo)
            if "classes" in info:
                vClasses = info["classes"]
                vClassesLen = len(vClasses)
            else:
                vClasses = []
                vClassesLen = 0
            self.flashObject.as_setPlayers(
                makeHtmlString("html_templates:lobby/queue/playersLabel", "players", {"count": sum(vClasses)})
            )
            if vClassesLen:
                data = {"title": "#menu:prebattle/typesTitle", "data": []}
                vClassesData = data["data"]
                for vClass, message in BattleQueue.TYPES_ORDERED:
                    idx = constants.VEHICLE_CLASS_INDICES[vClass]
                    vClassesData.append((message, vClasses[idx] if idx < vClassesLen else 0))

                self.as_setListByTypeS(data)
            self.as_showStartS(constants.IS_DEVELOPMENT and sum(vClasses) > 1)
        if not self.__inited:
            self.__inited = True
        return
    def __prepareTankmanData(self):
        items = yield ItemsRequester().request()
        dropSkillsCost = []
        for k in sorted(items.shop.dropSkillsCost.keys()):
            dropSkillsCost.append(items.shop.dropSkillsCost[k])

        skills_count = list(tankmen.ACTIVE_SKILLS)
        availableSkillsCount = len(skills_count) - len(self.__tankman.skills)
        hasNewSkills = self.__tankman.roleLevel == tankmen.MAX_SKILL_LEVEL and availableSkillsCount and (self.__tankman.descriptor.lastSkillLevel == tankmen.MAX_SKILL_LEVEL or not len(self.__tankman.skills))
        self.as_tankManS({'money': (items.stats.credits, items.stats.gold),
         'tankman': packTankman(self.__tankman),
         'dropSkillsCost': dropSkillsCost,
         'hasNewSkills': hasNewSkills,
         'newSkills': self.__tankman.newSkillCount,
         'defaultSavingMode': 0})
        if len(self.__tankman.skills) < 1:
            if self.__tankman.roleLevel < 100:
                self.question = i18n.makeString(DIALOGS.DISMISSTANKMAN_MESSAGE)
            else:
                self.__controlNumber = str(self.__tankman.roleLevel)
                self.question = makeHtmlString('html_templates:lobby/dialogs', 'dismissTankmanMain', {'roleLevel': str(self.__tankman.roleLevel)})
        else:
            if self.__tankman.skills[-1].isPerk:
                skillType = DIALOGS.PROTECTEDDISMISSTANKMAN_ADDITIONALMESSAGE_ISPERK
            else:
                skillType = DIALOGS.PROTECTEDDISMISSTANKMAN_ADDITIONALMESSAGE_ISABILLITY
            self.question = makeHtmlString('html_templates:lobby/dialogs', 'dismissTankmanAdditional', {'skillType': i18n.makeString(skillType),
             'skillName': self.__tankman.skills[-1].userName,
             'roleLevel': str(self.__tankman.skills[-1].level)})
            self.__controlNumber = str(self.__tankman.skills[-1].level)
        self.__updateInputChecker()
Exemple #11
0
 def __setAccountsAttrs(self, isPremiumAccount, premiumExpiryTime = 0):
     disableTTHeader = ''
     disableTTBody = ''
     isNavigationEnabled = True
     if self.prbDispatcher:
         isNavigationEnabled = not self.prbDispatcher.getFunctionalState().isNavigationDisabled()
     if isPremiumAccount:
         if not premiumExpiryTime > 0:
             raise AssertionError
             deltaInSeconds = float(time_utils.getTimeDeltaFromNow(time_utils.makeLocalServerTime(premiumExpiryTime)))
             if deltaInSeconds > time_utils.ONE_DAY:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_DAY)
                 timeMetric = i18n.makeString('#menu:header/account/premium/days')
             else:
                 timeLeft = math.ceil(deltaInSeconds / time_utils.ONE_HOUR)
                 timeMetric = i18n.makeString('#menu:header/account/premium/hours')
             buyPremiumLabel = i18n.makeString('#menu:headerButtons/doLabel/premium')
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header', 'premium-account-label', {'timeMetric': timeMetric,
              'timeLeft': timeLeft})
             canUpdatePremium = deltaInSeconds < time_utils.ONE_YEAR
         else:
             canUpdatePremium = True
             premiumBtnLbl = makeHtmlString('html_templates:lobby/header', 'base-account-label')
             buyPremiumLabel = i18n.makeString('#menu:common/premiumBuy')
         if not canUpdatePremium:
             disableTTHeader = i18n.makeString(TOOLTIPS.LOBBY_HEADER_BUYPREMIUMACCOUNT_DISABLED_HEADER)
             disableTTBody = i18n.makeString(TOOLTIPS.LOBBY_HEADER_BUYPREMIUMACCOUNT_DISABLED_BODY, number=time_utils.ONE_YEAR / time_utils.ONE_DAY)
         self.as_doDisableHeaderButtonS(self.BUTTONS.PREM, canUpdatePremium and isNavigationEnabled)
         hasPersonalDiscount = len(g_itemsCache.items.shop.personalPremiumPacketsDiscounts) > 0
         tooltip = canUpdatePremium or {'header': disableTTHeader,
          'body': disableTTBody}
     else:
         tooltip = TOOLTIPS.HEADER_PREMIUM_EXTEND if isPremiumAccount else TOOLTIPS.HEADER_PREMIUM_BUY
     self.as_setPremiumParamsS(isPremiumAccount, premiumBtnLbl, buyPremiumLabel, canUpdatePremium, disableTTHeader, disableTTBody, hasPersonalDiscount, tooltip, TOOLTIP_TYPES.COMPLEX)
Exemple #12
0
 def getLogoutWarning(socialNetworkName):
     localizationString = "#menu:login/social/warning/SOCIAL_NETWORK_LOGOUT"
     formatter = {
         "userName": Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readString("user"),
         "socialNetworkLink": makeHtmlString(
             "html_templates:socialNetworkLogin",
             "socialNetworkLink",
             {
                 "socialNetworkName": socialNetworkName,
                 "socialNetworkOfficialName": _ms("#tooltips:login/social/" + socialNetworkName),
             },
         ),
     }
     if socialNetworkName != _SOCIAL_NETWORKS.WGNI:
         localizationString += "_BOTH"
         formatter["wargamingNetLink"] = makeHtmlString(
             "html_templates:socialNetworkLogin",
             "socialNetworkLink",
             {
                 "socialNetworkName": _SOCIAL_NETWORKS.WGNI,
                 "socialNetworkOfficialName": _ms("#tooltips:login/social/" + _SOCIAL_NETWORKS.WGNI),
             },
         )
     return makeHtmlString(
         "html_templates:socialNetworkLogin",
         "logoutWarning",
         {"warningMessage": _ms(localizationString) % formatter},
     )
 def updateHeader(self):
     playersCount = len(g_clanCache.clanMembers)
     openedDirections = len(self.fortCtrl.getFort().getOpenedDirections())
     requiredPlayersCount = self.fortCtrl.getLimits().getDirectionsMembersRequirements().get(openedDirections + 1, 0)
     isAllDirctnsOpened = openedDirections == g_fortCache.maxDirections
     canOpenDirections = False
     ttHeader = ''
     ttDescr = ''
     if isAllDirctnsOpened:
         description = i18n.makeString(FORTIFICATIONS.FORTDIRECTIONSWINDOW_DESCR_COMPLETED)
     elif self._isFortFrozen():
         baseName = makeHtmlString('html_templates:lobby/fortifications', 'baseFrozen', {'baseName': i18n.makeString(FORTIFICATIONS.BUILDINGS_BUILDINGNAME_BASE_BUILDING) + '.'})
         description = i18n.makeString(FORTIFICATIONS.FORTDIRECTIONSWINDOW_DESCR_BASEREPAIRREQUIRE, baseName=baseName)
         ttHeader = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTCREATEDIRWIN_NEWDIRBTN_DISABLEDBYFROZEN_HEADER)
         ttDescr = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTCREATEDIRWIN_NEWDIRBTN_DISABLEDBYFROZEN_BODY)
     else:
         if playersCount >= requiredPlayersCount:
             template = 'valid'
             canOpenDirections = True
             ttHeader = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTCREATEDIRWIN_NEWDIRBTN_ENABLED_HEADER)
             ttDescr = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTCREATEDIRWIN_NEWDIRBTN_ENABLED_BODY)
         else:
             template = 'notValid'
             ttHeader = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTCREATEDIRWIN_NEWDIRBTN_DISABLEDBYPLAYERS_HEADER)
             ttDescr = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTCREATEDIRWIN_NEWDIRBTN_DISABLEDBYPLAYERS_BODY, count=requiredPlayersCount)
         playersLabel = makeHtmlString('html_templates:lobby/fortifications/playersCount', template, {'count': requiredPlayersCount})
         description = i18n.makeString(FORTIFICATIONS.FORTDIRECTIONSWINDOW_DESCR_REQUIREMENTS, count=playersLabel)
     self.as_setDescriptionS(description)
     tooltip = makeTooltip(ttHeader, ttDescr)
     self.as_setupButtonS(canOpenDirections, not isAllDirctnsOpened, tooltip)
 def getCurrentItemRemoveStr(self):
     removeStr = None
     if self._currentItemID is not None and self._currentLifeCycle is not None:
         if self._currentLifeCycle[1] > 0:
             removeStr = [gui.makeHtmlString('html_templates:lobby/customization', 'remove-{0:>s}'.format(self._name))]
         else:
             removeStr = [gui.makeHtmlString('html_templates:lobby/customization', 'store-{0:>s}'.format(self._name))]
     return removeStr
Exemple #15
0
    def _getProgressValues(self, svrEvents=None, pCur=None, pPrev=None):
        current, total, progressType, tooltip = (0, 0, formatters.PROGRESS_BAR_TYPE.NONE, None)
        groupBy = self.event.bonusCond.getGroupByValue()
        condsRoot = self.event.bonusCond.getConditions()
        if self.event.isCompleted(pCur) or condsRoot.isEmpty():
            return (current, total, progressType, tooltip)
        countOfCumulatives = 0
        cumulatives = defaultdict(list)
        for cond in condsRoot.items:
            if isinstance(cond, conditions._Cumulativable):
                countOfCumulatives += 1
                for groupByKey, (cur, tot, _, isCompleted) in cond.getProgressPerGroup(pCur, pPrev).iteritems():
                    if not isCompleted:
                        cumulatives[groupByKey].append((cur, tot))

        if groupBy is None and countOfCumulatives == 1 and len(cumulatives[None]):
            (current, total), progressType = cumulatives[None][0], formatters.PROGRESS_BAR_TYPE.SIMPLE
        else:
            avgProgressesPerGroup = []
            for groupByKey, values in cumulatives.iteritems():
                progressesSum = sum(map(lambda (c, t): c / float(t), values))
                avgProgressesPerGroup.append((groupByKey, int(round(100.0 * progressesSum / len(values))), 100))

            avgProgresses = sorted(avgProgressesPerGroup, key=operator.itemgetter(1), reverse=True)
            if len(avgProgresses):
                (groupByKey, current, total), nearestProgs = avgProgresses[0], avgProgresses[1:]
                progressType = formatters.PROGRESS_BAR_TYPE.COMMON
                if groupBy is not None and groupByKey is not None:
                    name, names = ("", "")
                    if groupBy == "vehicle":
                        name = g_itemsCache.items.getItemByCD(groupByKey).shortUserName
                        names = [g_itemsCache.items.getItemByCD(intCD).shortUserName for intCD, _, __ in nearestProgs]
                    elif groupBy == "nation":
                        name = i18n.makeString("#menu:nations/%s" % groupByKey)
                        names = [i18n.makeString("#menu:nations/%s" % n) for n, _, __ in nearestProgs]
                    elif groupBy == "class":
                        name = i18n.makeString("#menu:classes/%s" % groupByKey)
                        names = [i18n.makeString("#menu:classes/%s" % n) for n, _, __ in nearestProgs]
                    elif groupBy == "level":

                        def makeLvlStr(lvl):
                            return i18n.makeString(QUESTS.TOOLTIP_PROGRESS_GROUPBY_NOTE_LEVEL, int2roman(lvl))

                        name = makeLvlStr(int(groupByKey.replace("level ", "")))
                        names = [makeLvlStr(int(l.replace("level ", ""))) for l, _, __ in nearestProgs]
                    note = None
                    if len(names):
                        note = makeHtmlString(
                            "html_templates:lobby/quests/tooltips/progress",
                            "note",
                            {"names": ", ".join(names[: self.PROGRESS_TOOLTIP_MAX_ITEMS])},
                        )
                    tooltip = {
                        "header": i18n.makeString(QUESTS.TOOLTIP_PROGRESS_GROUPBY_HEADER),
                        "body": makeHtmlString("html_templates:lobby/quests/tooltips/progress", "body", {"name": name}),
                        "note": note,
                    }
        return (current, total, progressType, tooltip)
def makeFriendshipRequestText(user, error):
    result = []
    text = makeHtmlString('html_templates:lobby/friendshipRequest', 'title', ctx={'name': user.getFullName()})
    result.append(text)
    if error:
        text = makeHtmlString('html_templates:lobby/friendshipRequest/note', error.getErrorName(), ctx={'name': user.getFullName(),
         'rosterMaxCount': CONTACT_LIMIT.ROSTER_MAX_COUNT})
        result.append(text)
    return ''.join(result)
 def __makeData(self):
     fort = self.fortCtrl.getFort()
     data = {'numOfFavorites': len(fort.favorites),
      'favoritesLimit': FORT_MAX_ELECTED_CLANS,
      'canAttackDirection': self.fortCtrl.getPermissions().canPlanAttack(),
      'canAddToFavorite': self.fortCtrl.getPermissions().canAddToFavorite(),
      'isOurFortFrozen': self._isFortFrozen(),
      'isSelected': self.__item is not None,
      'haveResults': self.__hasResults}
     if self.__item is not None:
         clanID = self.__item.getClanDBID()
         selectedDefenceHour = time_utils.getDateTimeInLocal(self.__selectedDefencePeriodStart).hour
         if self.__item.getLocalDefHour()[0] != selectedDefenceHour and not self.__weAreAtWar:
             warTime = '%s - %s' % (BigWorld.wg_getShortTimeFormat(self.__selectedDefencePeriodStart), BigWorld.wg_getShortTimeFormat(self.__selectedDefencePeriodEnd))
             warPlannedIcon = makeHtmlString('html_templates:lobby/iconText', 'alert', {})
             warPlannedMsg = makeHtmlString('html_templates:lobby/textStyle', 'alertText', {'message': warTime})
             warPlannedTime = _ms(warPlannedIcon + ' ' + warPlannedMsg)
             data.update({'warPlannedTime': warPlannedTime,
              'warPlannedTimeTT': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_WARTIME, warTime=warTime)})
         if self.__weAreAtWar:
             closestAttack = self.__upcomingAttack or self.__attackInCooldown
             closestAttackTime = closestAttack.getStartTime()
             data.update({'isWarDeclared': self.__upcomingAttack is not None,
              'isAlreadyFought': self.__attackInCooldown is not None and not self.__hasBeenCounterAttacked,
              'warPlannedDate': BigWorld.wg_getLongDateFormat(closestAttackTime),
              'warNextAvailableDate': BigWorld.wg_getLongDateFormat(closestAttackTime + time_utils.ONE_WEEK)})
         isFrozen = fort.isFrozen()
         clanFortBattlesStats = self.__item.getStatistics().getBattlesStats()
         battlesCount = clanFortBattlesStats.getBattlesCount()
         battlesWinsEff = clanFortBattlesStats.getWinsEfficiency()
         MIN_VALUE = 0.01
         clanAvgDefresValue = functions.roundToMinOrZero(clanFortBattlesStats.getProfitFactor(), MIN_VALUE)
         data.update({'dateSelected': BigWorld.wg_getLongDateFormat(self.__selectedDayStart),
          'selectedDayTimestamp': self.__selectedDayStart,
          'clanTag': '[%s]' % self.__item.getClanAbbrev(),
          'clanName': self.__item.getClanName(),
          'clanInfo': self.__item.getClanMotto(),
          'clanId': clanID,
          'clanEmblem': self.__clanEmblem,
          'isFavorite': clanID in fort.favorites,
          'isFrozen': isFrozen,
          'selectedDateText': self.__getSelectedDateText(),
          'clanBattles': {'value': BigWorld.wg_getNiceNumberFormat(battlesCount) if battlesCount else '--',
                          'icon': RES_ICONS.MAPS_ICONS_LIBRARY_DOSSIER_BATTLES40X32,
                          'ttHeader': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_BATTLES_HEADER),
                          'ttBody': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_BATTLES_BODY, wins=BigWorld.wg_getNiceNumberFormat(clanFortBattlesStats.getWinsCount()), defeats=BigWorld.wg_getNiceNumberFormat(clanFortBattlesStats.getLossesCount()))},
          'clanWins': {'value': '%s%%' % BigWorld.wg_getNiceNumberFormat(functions.roundToMinOrZero(battlesWinsEff, MIN_VALUE) * 100) if battlesWinsEff is not None else '--',
                       'icon': RES_ICONS.MAPS_ICONS_LIBRARY_DOSSIER_WINS40X32,
                       'ttHeader': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_WINS_HEADER),
                       'ttBody': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_WINS_BODY)},
          'clanAvgDefres': {'value': BigWorld.wg_getNiceNumberFormat(clanAvgDefresValue) if clanAvgDefresValue else '--',
                            'icon': RES_ICONS.MAPS_ICONS_LIBRARY_DOSSIER_DEFRESRATIO40X32,
                            'ttHeader': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_AVGDEFRES_HEADER),
                            'ttBody': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_AVGDEFRES_BODY)},
          'directions': self.__getDirectionsData()})
     self.as_setDataS(data)
     return
 def __getDurationStr(self, period, cost, hasAction, isEnoughMoney):
     priceStr = ''
     if not hasAction:
         key = 'gold' if isEnoughMoney else 'goldAlert'
         priceStr = makeHtmlString('html_templates:lobby/dialogs/premium', key, ctx={'value': BigWorld.wg_getGoldFormat(cost)})
     duration = i18n.makeString(PREMIUM_PACKET_LOCAL_KEY % period)
     ctx = {'duration': duration,
      'price': priceStr}
     return makeHtmlString('html_templates:lobby/dialogs/premium', 'duration', ctx=ctx)
Exemple #19
0
 def getTitle(self, invite):
     user = self.users.getUser(invite.getInviterDbID())
     if user:
         creatorFullName = user.getFullName()
     else:
         creatorFullName = ''
     if creatorFullName:
         creatorFullName = makeHtmlString('html_templates:lobby/prebattle', 'inviteTitleCreatorName', ctx={'name': creatorFullName})
     return makeHtmlString('html_templates:lobby/clubs', 'inviteTitle', ctx={'sender': creatorFullName})
Exemple #20
0
 def _getValue(self):
     tile = self._tooltip.item
     if tile is not None:
         _, awardTokensCount = tile.getTokensCount()
         totalTokensCount = tile.getTotalTokensCount()
         icon = makeHtmlString('html_templates:lobby/tooltips', 'private_quests_icon')
         return makeHtmlString('html_templates:lobby/tooltips', 'private_quests_conditions', {'condition1': self.__formatCondition('vehicle', awardTokensCount, icon),
          'condition2': self.__formatCondition('anim', totalTokensCount, icon)})
     return ''
Exemple #21
0
    def onQueueInfoReceived(self, randomsQueueInfo, companiesQueueInfo, historicalQueueInfo):
        if prb_control.isCompany():
            data = {'title': '#menu:prebattle/typesCompaniesTitle',
             'data': list()}
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'teams', {'count': sum(companiesQueueInfo['divisions'])}))
            vDivisions = companiesQueueInfo['divisions']
            if vDivisions is not None:
                vClassesLen = len(vDivisions)
                for vDivision in BattleQueue.DIVISIONS_ORDERED:
                    data['data'].append(('#menu:prebattle/CompaniesTitle/%s' % constants.PREBATTLE_COMPANY_DIVISION_NAMES[vDivision], vDivisions[vDivision] if vDivision < vClassesLen else 0))

                self.as_setListByTypeS(data)
            self.as_showStartS(constants.IS_DEVELOPMENT)
        elif prb_control.isInHistoricalQueue():
            battleID = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
            battleData = historicalQueueInfo[battleID]
            battle = g_eventsCache.getHistoricalBattles(False)[battleID]
            teamA = battleData.get(HistoricalBattle.SIDES.A, {})
            teamB = battleData.get(HistoricalBattle.SIDES.B, {})
            countA = sum(teamA.get('by_class', {}).values())
            countB = sum(teamB.get('by_class', {}).values())
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'twoSides', {'sideA': battle.getSideUserName(HistoricalBattle.SIDES.A),
             'countA': countA,
             'sideB': battle.getSideUserName(HistoricalBattle.SIDES.B),
             'countB': countB}))
            data = {'title': '#menu:prebattle/typesTitle',
             'data': []}
            vClassesData = data['data']
            for vClass, message in BattleQueue.TYPES_ORDERED:
                byClassA = teamA.get('by_class', {}).get(vClass, 0)
                byClassB = teamB.get('by_class', {}).get(vClass, 0)
                vClassesData.append((message, byClassA + byClassB))

            self.as_setListByTypeS(data)
        else:
            info = dict(randomsQueueInfo)
            if 'classes' in info:
                vClasses = info['classes']
                vClassesLen = len(vClasses)
            else:
                vClasses = []
                vClassesLen = 0
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'players', {'count': sum(vClasses)}))
            if vClassesLen:
                data = {'title': '#menu:prebattle/typesTitle',
                 'data': []}
                vClassesData = data['data']
                for vClass, message in BattleQueue.TYPES_ORDERED:
                    idx = constants.VEHICLE_CLASS_INDICES[vClass]
                    vClassesData.append((message, vClasses[idx] if idx < vClassesLen else 0))

                self.as_setListByTypeS(data)
            self.as_showStartS(constants.IS_DEVELOPMENT and sum(vClasses) > 1)
        if not self.__inited:
            self.__inited = True
        return
Exemple #22
0
 def getLogoutWarning(socialNetworkName):
     localizationString = '#menu:login/social/warning/SOCIAL_NETWORK_LOGOUT'
     formatter = {'userName': Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readString('user'),
      'socialNetworkLink': makeHtmlString('html_templates:socialNetworkLogin', 'socialNetworkLink', {'socialNetworkName': socialNetworkName,
                            'socialNetworkOfficialName': _ms('#tooltips:login/social/' + socialNetworkName)})}
     if socialNetworkName != _SOCIAL_NETWORKS.WGNI:
         localizationString += '_BOTH'
         formatter['wargamingNetLink'] = makeHtmlString('html_templates:socialNetworkLogin', 'socialNetworkLink', {'socialNetworkName': _SOCIAL_NETWORKS.WGNI,
          'socialNetworkOfficialName': _ms('#tooltips:login/social/' + _SOCIAL_NETWORKS.WGNI)})
     return makeHtmlString('html_templates:socialNetworkLogin', 'logoutWarning', {'warningMessage': _ms(localizationString) % formatter})
Exemple #23
0
 def getLogoutWarning(socialNetworkName, logoutBoth = True):
     localizationString = '#menu:login/social/warning/SOCIAL_NETWORK_LOGOUT'
     formatter = {'userName': Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readString('user'),
      'socialNetworkLink': makeHtmlString('html_templates:socialNetworkLogin', 'socialNetworkLink', {'socialNetworkName': socialNetworkName,
                            'socialNetworkOfficialName': _SOCIAL_NETWORK_TO_DOMAIN_MAPPING[socialNetworkName][0]})}
     if logoutBoth and socialNetworkName != _SOCIAL_NETWORKS.WGNI:
         localizationString += '_BOTH'
         formatter['wargamingNetLink'] = makeHtmlString('html_templates:socialNetworkLogin', 'socialNetworkLink', {'socialNetworkName': _SOCIAL_NETWORKS.WGNI,
          'socialNetworkOfficialName': _SOCIAL_NETWORK_TO_DOMAIN_MAPPING[_SOCIAL_NETWORKS.WGNI][0]})
     return makeHtmlString('html_templates:socialNetworkLogin', 'logoutWarning', {'warningMessage': i18n.makeString(localizationString) % formatter})
 def __getLogoutWarning(socialNetworkName):
     localizationString = '#menu:login/social/warning/SOCIAL_NETWORK_LOGOUT'
     formatter = {'userName': g_loginManager.getPreference('name'),
      'socialNetworkLink': makeHtmlString('html_templates:socialNetworkLogin', 'socialNetworkLink', {'socialNetworkName': socialNetworkName,
                            'socialNetworkOfficialName': _ms('#tooltips:login/social/' + socialNetworkName)})}
     if socialNetworkName != SOCIAL_NETWORKS.WGNI:
         localizationString += '_BOTH'
         formatter['wargamingNetLink'] = makeHtmlString('html_templates:socialNetworkLogin', 'socialNetworkLink', {'socialNetworkName': SOCIAL_NETWORKS.WGNI,
          'socialNetworkOfficialName': _ms('#tooltips:login/social/' + SOCIAL_NETWORKS.WGNI)})
     return makeHtmlString('html_templates:socialNetworkLogin', 'logoutWarning', {'warningMessage': _ms(localizationString) % formatter})
 def __makeMinMaxString(self, value, limit):
     minValue, maxValue = limit
     if value and value < minValue:
         minString = makeHtmlString('html_templates:lobby/prebattle', 'markInvalidValue', {'value': minValue})
     else:
         minString = str(minValue)
     if value > maxValue:
         maxString = makeHtmlString('html_templates:lobby/prebattle', 'markInvalidValue', {'value': maxValue})
     else:
         maxString = str(maxValue)
     return '{0:>s}-{1:>s}'.format(minString, maxString)
def getQuestProgress(q, quests = None):
    result = (0,
     0,
     '',
     PROGRESS_BAR_TYPE.NONE,
     None)
    if q.isCompleted():
        return result
    elif q.isStrategic():
        subtasks = tuple((st for st in makeQuestGroup(q, quests) if st.getID() != q.getID()))
        if len(subtasks):
            return (len(filter(lambda t: t.isCompleted(), subtasks)),
             len(subtasks) + 1,
             '',
             PROGRESS_BAR_TYPE.STRATEGIC,
             None)
        return result
    p = q.getProgress()
    if p is not None:
        groupBy = q.getCumulativeGroup()
        groupByKey, current, total, label, nearestProgs = p
        progressType = PROGRESS_BAR_TYPE.NONE if current == 0 and total == 0 else PROGRESS_BAR_TYPE.SIMPLE
        tooltip = None
        if groupBy is not None and groupByKey is not None:
            name, names = ('', '')
            if groupBy == 'vehicle':
                name = g_itemsCache.items.getItemByCD(groupByKey).shortUserName
                names = [ g_itemsCache.items.getItemByCD(intCD).shortUserName for intCD in nearestProgs ]
            elif groupBy == 'nation':
                name = i18n.makeString('#menu:nations/%s' % groupByKey)
                names = [ i18n.makeString('#menu:nations/%s' % n) for n in nearestProgs ]
            elif groupBy == 'class':
                name = i18n.makeString('#menu:classes/%s' % groupByKey)
                names = [ i18n.makeString('#menu:classes/%s' % n) for n in nearestProgs ]
            elif groupBy == 'level':

                def makeLvlStr(lvl):
                    return i18n.makeString('#quests:tooltip/progress/groupBy/note/level', int2roman(lvl))

                name = makeLvlStr(int(groupByKey.replace('level ', '')))
                names = [ makeLvlStr(int(l.replace('level ', ''))) for l in nearestProgs ]
            note = None
            if len(names):
                note = makeHtmlString('html_templates:lobby/quests/tooltips/progress', 'note', {'names': ', '.join(names[:_PROGRESS_TOOLTIP_MAX_ITEMS])})
            tooltip = {'header': i18n.makeString('#quests:tooltip/progress/groupBy/header'),
             'body': makeHtmlString('html_templates:lobby/quests/tooltips/progress', 'body', {'name': name}),
             'note': note}
        return (current,
         total,
         label,
         progressType,
         tooltip)
    else:
        return result
def makeFriendshipRequestText(user, error):
    result = []
    text = makeHtmlString("html_templates:lobby/friendshipRequest", "title", ctx={"name": user.getFullName()})
    result.append(text)
    if error:
        text = makeHtmlString(
            "html_templates:lobby/friendshipRequest/note",
            error.getErrorName(),
            ctx={"name": user.getFullName(), "rosterMaxCount": CONTACT_LIMIT.ROSTER_MAX_COUNT},
        )
        result.append(text)
    return "".join(result)
Exemple #28
0
 def _getValue(self):
     module = self._tooltip.item
     if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS:
         if not module.isRemovable:
             return {
                 "title": gui.makeHtmlString("html_templates:lobby/tooltips", "permanent_module_title"),
                 "text": gui.makeHtmlString(
                     "html_templates:lobby/tooltips",
                     "permanent_module_note",
                     {"gold": g_itemsCache.items.shop.paidRemovalCost},
                 ),
             }
    def getCurrentItemRemoveStr(self):
        removeStr = None
        for kind, item in self.currentItemsByKind.iteritems():
            lifeCycle = item.get('lifeCycle')
            if item.get('id') is not None and item.get('newItemID') and lifeCycle is not None:
                if removeStr is None:
                    removeStr = []
                if lifeCycle[1] > 0:
                    removeStr.append(gui.makeHtmlString('html_templates:lobby/customization', 'remove-camouflage-{0}'.format(kind)))
                else:
                    removeStr.append(gui.makeHtmlString('html_templates:lobby/customization', 'store-camouflage-{0}'.format(kind)))

        return removeStr
Exemple #30
0
def formatDiscount(discountVal, discountType):
    multiplier = "+" if discountVal < 0 else ""
    if discountType == DISCOUNT_TYPE.GOLD:
        return makeHtmlString(
            "html_templates:lobby/quests/actions",
            "gold",
            {"value": multiplier + BigWorld.wg_getGoldFormat(abs(long(discountVal)))},
        )
    return makeHtmlString(
        "html_templates:lobby/quests/actions",
        discountType,
        {"value": multiplier + BigWorld.wg_getIntegralFormat(abs(int(discountVal)))},
    )
Exemple #31
0
def makeFreeXpLabel(value, canBeFaded = False):
    if canBeFaded and not value:
        template = 'free_xp_small_inactive_label'
    else:
        template = 'free_xp_small_label'
    return makeHtmlString('html_templates:lobby/battle_results', template, {'value': BigWorld.wg_getIntegralFormat(int(value))})
Exemple #32
0
def makeIGRBonusValue(factor):
    return makeHtmlString('html_templates:lobby/battle_results', 'igr_bonus', {'value': BigWorld.wg_getNiceNumberFormat(factor)})
Exemple #33
0
def makeRankedPointHugeValue(pointsValue):
    return makeHtmlString('html_templates:lobby/battle_results', 'xp_small_label', {'value': text_styles.hightlight(pointsValue)})
Exemple #34
0
def markValueAsEmpty(value):
    return makeHtmlString('html_templates:lobby/battle_results', 'empty_stat_value', {'value': value})
Exemple #35
0
def _makeModuleTooltipLabel(module, suffix):
    return makeHtmlString('html_templates:lobby/battle_results', 'tooltip_crit_label', {'image': '{0}{1}'.format(module, suffix),
     'value': i18n.makeString('#item_types:{0}/name'.format(module))})
Exemple #36
0
def _formatIcon(iconName, width = 32, height = 32):
    return makeHtmlString('html_templates:lobby/messengerBar', 'iconTemplate', {'iconName': iconName,
     'width': width,
     'height': height})
Exemple #37
0
def _getStyle(style, ctx=None):
    if ctx is None:
        ctx = {}
    return makeHtmlString('html_templates:lobby/textStyle', style, ctx)
Exemple #38
0
 def __readEULAShort(self):
     return makeHtmlString(
         'html_templates:lobby/dialogs', 'eula',
         {'eulaURL': GUI_SETTINGS.eula.url.format(getClientLanguage())})
Exemple #39
0
 def __wrapServerName(self, name):
     if constants.IS_CHINA:
         return makeHtmlString('html_templates:lobby/serverStats',
                               'serverName', {'name': name})
     return name
Exemple #40
0
    def _packBlocks(self, *args, **kwargs):
        items = super(TankmanTooltipDataBlock, self)._packBlocks()
        item = self.context.buildItem(*args, **kwargs)
        self.item = item
        vehicle = None
        nativeVehicle = self.itemsCache.items.getItemByCD(
            item.vehicleNativeDescr.type.compactDescr)
        if item.isInTank:
            vehicle = self.itemsCache.items.getVehicle(item.vehicleInvID)
        items.append(
            formatters.packImageTextBlockData(
                title=text_styles.highTitle(item.fullUserName),
                desc=text_styles.main(item.rankUserName)))
        innerBlock = []
        if vehicle:
            innerBlock.append(
                formatters.packTextBlockData(text=makeHtmlString(
                    'html_templates:lobby/textStyle', 'grayTitle',
                    {'message': makeString(TOOLTIPS.HANGAR_CREW_ASSIGNEDTO)})))
            innerBlock.append(
                formatters.packImageTextBlockData(
                    img=vehicle.iconContour,
                    txtGap=-4,
                    padding=formatters.packPadding(bottom=0, top=10, left=0),
                    title=text_styles.stats(vehicle.shortUserName),
                    desc=text_styles.stats('#menu:header/vehicleType/%s' %
                                           vehicle.type),
                    flipHorizontal=True))
        if innerBlock:
            items.append(
                formatters.packBuildUpBlockData(
                    innerBlock,
                    padding=formatters.packPadding(left=0,
                                                   right=50,
                                                   top=-5,
                                                   bottom=0),
                    linkage=BLOCKS_TOOLTIP_TYPES.
                    TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE))
        commonStatsBlock = [
            formatters.packTextBlockData(text=makeHtmlString(
                'html_templates:lobby/textStyle', 'grayTitle',
                {'message': makeString(TOOLTIPS.HANGAR_CREW_SPECIALTY_SKILLS)})
                                         )
        ]
        penalty = self._getBonusValue(
            item, [TankmanRoleBonusesField.BONUSES.PENALTY])
        addition = self._getBonusValue(item, [
            TankmanRoleBonusesField.BONUSES.COMMANDER,
            TankmanRoleBonusesField.BONUSES.EQUIPMENTS,
            TankmanRoleBonusesField.BONUSES.DEVICES,
            TankmanRoleBonusesField.BONUSES.BROTHERHOOD
        ])
        addition_ = '' if addition == 0 else self._getSign(addition) + str(
            addition)
        penalty_ = '' if penalty == 0 else self._getSign(penalty) + str(
            penalty)
        if penalty != 0 or addition != 0:
            addRoleLevels = ' (' + str(
                item.roleLevel) + addition_ + penalty_ + ')'
        else:
            addRoleLevels = ''
        if not vehicle or nativeVehicle.shortUserName == vehicle.shortUserName:
            vehicleName = text_styles.main(nativeVehicle.shortUserName)
        else:
            vehicleName = text_styles.critical(nativeVehicle.shortUserName)
        commonStatsBlock.append(
            formatters.packTextParameterBlockData(
                text_styles.main(item.roleUserName + ' ') + vehicleName,
                text_styles.stats(
                    str(item.roleLevel + penalty + addition) + '%' +
                    addRoleLevels),
                valueWidth=90,
                padding=formatters.packPadding(left=0,
                                               right=0,
                                               top=5,
                                               bottom=0)))
        field = TankmanSkillListField(self, 'skills')
        _, value = field.buildData()
        skills = value
        maxPopUpBlocks = 14
        for skill in skills[:maxPopUpBlocks]:
            commonStatsBlock.append(
                formatters.packTextParameterBlockData(
                    text_styles.main(skill['label']),
                    text_styles.stats(str(skill['level']) + '%'),
                    valueWidth=90))

        if len(skills) > maxPopUpBlocks:
            diff = str(len(skills) - maxPopUpBlocks)
            commonStatsBlock.append(
                formatters.packAlignedTextBlockData(
                    text=text_styles.middleTitle(
                        makeString(TOOLTIPS.HANGAR_CREW_MORESKILLS,
                                   skill_cnt=diff)),
                    align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER))
        items.append(formatters.packBuildUpBlockData(commonStatsBlock, gap=5))
        field = TankmanNewSkillCountField(self, '')
        _, newSkillCount = field.buildData()
        if newSkillCount > 0:
            items.append(
                formatters.packImageTextBlockData(
                    img='../maps/icons/tankmen/skills/small/new_skill.png',
                    txtOffset=20,
                    padding=formatters.packPadding(bottom=0, top=5, left=0),
                    imgPadding=formatters.packPadding(left=0, top=3),
                    title=makeHtmlString(
                        'html_templates:lobby/textStyle', 'goldTextTitle', {
                            'message':
                            makeString(TOOLTIPS.
                                       HANGAR_CREW_NEW_SKILL_AVAILABLE_HEADER)
                        }),
                    desc=makeHtmlString(
                        'html_templates:lobby/textStyle', 'goldTextField', {
                            'message':
                            makeString(
                                TOOLTIPS.HANGAR_CREW_NEW_SKILL_AVAILABLE_TEXT)
                        })))
        field = TankmanStatusField(self, '')
        _, status = field.buildData()
        if status['header'] != '':
            items.append(
                formatters.packImageTextBlockData(
                    title=text_styles.warning(status['header']),
                    desc=makeHtmlString('html_templates:lobby/textStyle',
                                        'statusWarningField',
                                        {'message': status['text']})))
        return items
# Python bytecode 2.7 (decompiled from Python 2.7)
# Embedded file name: scripts/client/gui/Scaleform/daapi/view/battle/shared/respawn/respawn_utils.py
import BigWorld
from gui import makeHtmlString
from gui.impl import backport
from gui.impl.gen import R
from gui.shared.gui_items.Vehicle import VEHICLE_TAGS
from helpers import time_utils
FLAG_ICON_TEMPLATE = '../maps/icons/battle/respawn/optimize_flags_160x100/%s.png'
VEHICLE_TYPE_TEMPLATE = '../maps/icons/vehicleTypes/%s.png'
VEHICLE_FORMAT = makeHtmlString('html_templates:igr/premium-vehicle', 'name',
                                {})
VEHICLE_ELITE_TYPE_TEMPLATE = '../maps/icons/vehicleTypes/elite/%s.png'


def getVehicleName(vehicle):
    tags = vehicle.type.tags
    isIGR = bool(VEHICLE_TAGS.PREMIUM_IGR in tags)
    vehicleName = vehicle.type.shortUserString if isIGR else vehicle.type.userString
    if isIGR:
        vehicleName = VEHICLE_FORMAT % {'vehicle': vehicleName}
    return vehicleName


def getSlotsStatesData(vehs, cooldowns, disabled, limits={}):
    result = []
    for v in vehs.itervalues():
        compactDescr = v.intCD
        cooldownTime = cooldowns.get(compactDescr, 0)
        cooldownStr = ''
        cooldown = cooldownTime - BigWorld.serverTime()
 def __makeHyperLink(cls, linkType, textId):
     return makeHtmlString('html_templates:lobby/fortifications', 'link', {
         'linkType': linkType,
         'text': i18n.makeString(textId)
     })
Exemple #43
0
def convertState(vState):
    if vState in _IGNORED_VEHICLE_STATES:
        return ''
    return makeHtmlString('html_templates:lobby', 'inPremiumIgrOnly') if vState == Vehicle.VEHICLE_STATE.IN_PREMIUM_IGR_ONLY else makeString(MENU.tankcarousel_vehiclestates(vState))
Exemple #44
0
def makeBattleRoyaleSlotLabel(slotState):
    slotLabel = SLOT_LABEL.DEFAULT
    if slotState.isFree:
        slotLabel = makeHtmlString('html_templates:lobby/cyberSport/unit',
                                   SLOT_LABEL.BATTLE_ROYALE)
    return slotLabel
Exemple #45
0
def makeTankmenTooltipLabel(role):
    return makeHtmlString('html_templates:lobby/battle_results', 'tooltip_crit_label', {'image': '{0}Destroyed'.format(role),
     'value': i18n.makeString('#item_types:tankman/roles/{0}'.format(role))})
Exemple #46
0
def makeUnitStateLabel(unitState):
    return makeHtmlString(
        'html_templates:lobby/cyberSport',
        'teamUnlocked' if unitState.isOpened() else 'teamLocked', {})
Exemple #47
0
def getTooltipParamsStyle(paramKey = None):
    if paramKey is None:
        paramKey = BATTLE_RESULTS.COMMON_TOOLTIP_PARAMS_VAL
    return makeHtmlString('html_templates:lobby/battle_results', 'tooltip_params_style', {'text': i18n.makeString(paramKey)})
Exemple #48
0
def formatIndex(index, msg):
    return makeHtmlString('html_templates:lobby/quests', 'index', {
        'index': index,
        'label': msg
    })
Exemple #49
0
def makeMarksOfMasteryText(marksOfMastery, totalVehicles):
    return makeHtmlString('html_templates:lobby/profileStatistics', 'marksOfMasteryText', {'marksOfMastery': marksOfMastery,
     'totalVehicles': totalVehicles})
Exemple #50
0
def formatGold(msg, *args, **kwargs):
    return makeHtmlString('html_templates:lobby/quests', 'goldTemplate',
                          {'msg': i18n.makeString(msg, *args, **kwargs)})
Exemple #51
0
def markValueAsError(value):
    return makeHtmlString('html_templates:lobby/battle_results', 'negative_value', {'value': value})
Exemple #52
0
def formatVehicleLevel(value):
    return makeHtmlString('html_templates:lobby/quests/actions',
                          'vehicleLevel', {'value': value})
Exemple #53
0
def makeDailyXPFactorValue(value):
    return makeHtmlString('html_templates:lobby/battle_results', 'multy_xp_small_label', {'value': int(value)})
Exemple #54
0
def formatPercentValue(value):
    return makeHtmlString('html_templates:lobby/quests/actions', 'percent',
                          {'value': value})
Exemple #55
0
def makeIGRIcon(igrType):
    if igrType == IGR_TYPE.PREMIUM:
        iconName = 'premium'
    else:
        iconName = 'basic'
    return makeHtmlString('html_templates:igr/iconSmall', iconName)
Exemple #56
0
def formatMultiplierValue(value):
    return makeHtmlString('html_templates:lobby/quests/actions', 'multiplier',
                          {'value': value})
 def makeIconTag(cls, key='imgTag', iconPath=''):
     if iconPath:
         ctx = {'iconName': iconPath}
     else:
         ctx = None
     return makeHtmlString('html_templates:contacts/contact', key, ctx=ctx)
    def _getProgressValues(self, svrEvents=None, pCur=None, pPrev=None):
        current, total, progressType, tooltip = (
            0, 0, formatters.PROGRESS_BAR_TYPE.NONE, None)
        groupBy = self.event.bonusCond.getGroupByValue()
        condsRoot = self.event.bonusCond.getConditions()
        if self.event.isCompleted(pCur) or condsRoot.isEmpty():
            return (current, total, progressType, tooltip)
        else:
            countOfCumulatives = 0
            cumulatives = defaultdict(list)
            for cond in condsRoot.items:
                if isinstance(cond, conditions._Cumulativable):
                    countOfCumulatives += 1
                    for groupByKey, (cur, tot, _,
                                     isCompleted) in cond.getProgressPerGroup(
                                         pCur, pPrev).iteritems():
                        if not isCompleted:
                            cumulatives[groupByKey].append((cur, tot))

            if groupBy is None and countOfCumulatives == 1 and cumulatives[
                    None]:
                (current, total), progressType = cumulatives[None][
                    0], formatters.PROGRESS_BAR_TYPE.SIMPLE
            else:
                avgProgressesPerGroup = []
                for groupByKey, values in cumulatives.iteritems():
                    progressesSum = sum([c / float(t) for c, t in values])
                    avgProgressesPerGroup.append(
                        (groupByKey,
                         int(round(100.0 * progressesSum / len(values))), 100))

                avgProgresses = sorted(avgProgressesPerGroup,
                                       key=operator.itemgetter(1),
                                       reverse=True)
                if avgProgresses:
                    (groupByKey, current,
                     total), nearestProgs = avgProgresses[0], avgProgresses[1:]
                    progressType = formatters.PROGRESS_BAR_TYPE.COMMON
                    if groupBy is not None and groupByKey is not None:
                        name, names = ('', '')
                        if groupBy == 'vehicle':
                            name = self.itemsCache.items.getItemByCD(
                                groupByKey).shortUserName
                            names = [
                                self.itemsCache.items.getItemByCD(
                                    intCD).shortUserName
                                for intCD, _, __ in nearestProgs
                            ]
                        elif groupBy == 'nation':
                            name = i18n.makeString('#menu:nations/%s' %
                                                   groupByKey)
                            names = [
                                i18n.makeString('#menu:nations/%s' % n)
                                for n, _, __ in nearestProgs
                            ]
                        elif groupBy == 'class':
                            name = i18n.makeString('#menu:classes/%s' %
                                                   groupByKey)
                            names = [
                                i18n.makeString('#menu:classes/%s' % n)
                                for n, _, __ in nearestProgs
                            ]
                        elif groupBy == 'level':

                            def makeLvlStr(lvl):
                                return i18n.makeString(
                                    QUESTS.TOOLTIP_PROGRESS_GROUPBY_NOTE_LEVEL,
                                    int2roman(lvl))

                            name = makeLvlStr(
                                int(groupByKey.replace('level ', '')))
                            names = [
                                makeLvlStr(int(l.replace('level ', '')))
                                for l, _, __ in nearestProgs
                            ]
                        note = None
                        if names:
                            note = makeHtmlString(
                                'html_templates:lobby/quests/tooltips/progress',
                                'note', {
                                    'names':
                                    ', '.join(
                                        names[:self.
                                              PROGRESS_TOOLTIP_MAX_ITEMS])
                                })
                        tooltip = {
                            'header':
                            i18n.makeString(
                                QUESTS.TOOLTIP_PROGRESS_GROUPBY_HEADER),
                            'body':
                            makeHtmlString(
                                'html_templates:lobby/quests/tooltips/progress',
                                'body', {'name': name}),
                            'note':
                            note
                        }
            return (current, total, progressType, tooltip)
Exemple #59
0
def makeHyperLink(linkType, textId):
    text = i18n.makeString(textId)
    attrs = {'linkType': linkType, 'text': text}
    linkHtml = makeHtmlString('html_templates:lobby/system_messages', 'link',
                              attrs)
    return linkHtml
Exemple #60
0
 def getTeamScoreFormat(self):
     padding = makeHtmlString('html_templates:battle', 'multiteamPadding',
                              {})
     return self._getHTMLString('falloutSelfGold',
                                self._ui.colorManager) + padding