def getDisplayableData(self, controlID): if i18n.doesTextExist('#settings:%s/name'): name = i18n.makeString('#settings:%s/name' % controlID) else: name = i18n.makeString('#settings:%s' % controlID) warning = '' if i18n.doesTextExist('#settings:%s/warning'): warning = i18n.makeString('#settings:%s/warning' % controlID) return {'name': name, 'descr': i18n.makeString('#settings:%s/description' % controlID), 'recommended': '', 'status': {'level': 'warning', 'text': warning}}
def _getStateText(self, state): if not doesTextExist(state): return '' stateStr = makeString(state) if stateStr: stateStr = makeHtmlString('html_templates:lobby/clans', 'inviteState', {'state': stateStr}) return stateStr
def __init__(self, ctx): self.__cache = [] self.__isEpic = ctx.get('isEpic', False) for arenaTypeID, arenaType in ArenaType.g_cache.iteritems(): if arenaType.explicitRequestOnly or not gameplay_ctx.isCreationEnabled(arenaType.gameplayName, self.__isEpic): continue try: nameSuffix = '' if arenaType.gameplayName != 'ctf': arenaGameplayName = '#arenas:type/%s/%s/name' % (arenaType.gameplayName, arenaType.geometryName) if i18n.doesTextExist(arenaGameplayName): nameSuffix = i18n.makeString(arenaGameplayName) else: nameSuffix = i18n.makeString('#arenas:type/%s/name' % arenaType.gameplayName) self.__cache.append({'label': '%s - %s' % (arenaType.name, nameSuffix) if nameSuffix else arenaType.name, 'name': arenaType.name, 'arenaType': nameSuffix, 'key': arenaTypeID, 'size': arenaType.maxPlayersInTeam, 'time': arenaType.roundLength / 60, 'description': '', 'icon': formatters.getMapIconPath(arenaType)}) except Exception: LOG_ERROR('There is error while reading arenas cache', arenaTypeID, arenaType) LOG_CURRENT_EXCEPTION() continue self.__cache = sorted(self.__cache, key=lambda x: (x['label'].lower(), x['name'].lower()))
def _errorHandler(self, code, errStr='', ctx=None): if len(errStr) and i18n.doesTextExist( '#system_messages:premium/%s' % errStr): return makeI18nError('premium/%s' % errStr, period=self.period, auxData={'errStr': errStr}) return makeI18nError('premium/server_error', period=self.period, auxData={'errStr': errStr})
def getState(self, invite): stateString = getInviteStatusString(invite.getStatus()) key = '#invites:clubs/state/%s' % stateString if not doesTextExist(key): return '' state = makeString(key) if state: state = makeHtmlString('html_templates:lobby/clubs', 'inviteState', {'state': state}) return state
def getRequestErrorMsg(result, ctx): msgKey = (ctx.getRequestType(), result.code) if msgKey in _CUSTOM_ERR_MESSAGES: errorMsg = _CUSTOM_ERR_MESSAGES[msgKey] else: errorMsg = result.errStr key = ERROR_SYS_MSG_TPL % errorMsg if doesTextExist(key): return makeString(key) return ''
def _getStateText(self, state, isWarning): if not doesTextExist(state): return '' stateStr = makeString(state) if stateStr: if isWarning: stateStr = '<br/><br/>%s' % alert_text_style(stateStr) else: stateStr = '<br/><br/>%s' % standard_text_style(stateStr) return stateStr
def _getDescription(self, condition): camos = [] for camo in condition.getCamos2ids(): camoI18key = '#quests:details/conditions/clanKills/camo/%s' % str(camo) if i18n.doesTextExist(camoI18key): camos.append(i18n.makeString(camoI18key)) i18nKey = '#quests:details/conditions/clanKills' if condition.isNegative(): i18nKey = '%s/not' % i18nKey return packDescriptionField(i18n.makeString(i18nKey, camos=', '.join(camos)))
def makeStatValue(field, value): tooltip = '' tooltipHeader = _STATS_INFOTIP_HEADER_FORMAT.format(field) if i18n.doesTextExist(tooltipHeader): tooltip = makeTooltip( header=i18n.makeString(tooltipHeader), body=i18n.makeString( BATTLE_RESULTS.getTeamStatsInfotipBody(statName=field))) return { 'label': i18n.makeString(BATTLE_RESULTS.getTeamStatsLabel(statName=field)), 'value': value, 'infoTooltip': tooltip }
def _getValue(self): tile = self._tooltip.item level = Vehicle.VEHICLE_STATE_LEVEL.WARNING if tile.isCompleted(): status, level = 'completed', Vehicle.VEHICLE_STATE_LEVEL.INFO elif tile.isInProgress(): status = 'inProgress' elif tile.isUnlocked(): status = 'available' else: status = 'lock' textKey = '#tooltips:privateQuests/status/{0}/{1}'.format(status, 'descr') return {'header': i18n.makeString('#tooltips:privateQuests/status/{0}/{1}'.format(status, 'header')), 'text': i18n.makeString(textKey) if i18n.doesTextExist(textKey) else None, 'level': level}
def getRequestErrorMsg(result, ctx): msgReqKey = ctx.getRequestType() msgKey = (msgReqKey, result.code) if msgKey in _CUSTOM_ERR_MESSAGES: errorMsg = _CUSTOM_ERR_MESSAGES[msgKey] elif msgReqKey in _CUSTOM_ERR_MESSAGES_BY_REQUEST: errorMsg = _CUSTOM_ERR_MESSAGES_BY_REQUEST[msgReqKey] else: errorMsg = result.txtStr msg = '' if callable(errorMsg): msg = errorMsg(result, ctx) else: key = ERROR_SYS_MSG_TPL % errorMsg if doesTextExist(key): msg = makeString(key) return msg
def getRequestErrorMsg(result, ctx): msgReqKey = ctx.getRequestType() msgKey = (msgReqKey, result.code) if msgKey in _CUSTOM_ERR_MESSAGES: errorMsg = _CUSTOM_ERR_MESSAGES[msgKey] elif msgReqKey in _CUSTOM_ERR_MESSAGES_BY_REQUEST: errorMsg = _CUSTOM_ERR_MESSAGES_BY_REQUEST[msgReqKey] else: errorMsg = result.errStr msg = '' if callable(errorMsg): msg = errorMsg(result, ctx) else: key = ERROR_SYS_MSG_TPL % errorMsg if doesTextExist(key): msg = makeString(key) return msg
def _getValue(self): tile = self._tooltip.item level = Vehicle.VEHICLE_STATE_LEVEL.WARNING if tile.isCompleted(): status, level = "completed", Vehicle.VEHICLE_STATE_LEVEL.INFO elif tile.isInProgress(): status = "inProgress" elif tile.isUnlocked(): status = "available" else: status = "lock" textKey = "#tooltips:privateQuests/status/{0}/{1}".format(status, "descr") return { "header": i18n.makeString("#tooltips:privateQuests/status/{0}/{1}".format(status, "header")), "text": i18n.makeString(textKey) if i18n.doesTextExist(textKey) else None, "level": level, }
def _format(self, condition, event): result = [] if not event.isGuiDisabled(): camos = [] for camo in condition.getCamos2ids(): camoI18key = '#quests:details/conditions/clanKills/camo/%s' % str( camo) if i18n.doesTextExist(camoI18key): camos.append(i18n.makeString(camoI18key)) i18nKey = '#quests:details/conditions/clanKills' if condition.isNegative(): i18nKey = '%s/not' % i18nKey if len(camos): result = [ formatters.packTextBlock( i18n.makeString(i18nKey, camos=', '.join(camos))) ] return result
def _errorHandler(self, code, errStr="", ctx=None): if len(errStr) and i18n.doesTextExist("#system_messages:premium/%s" % errStr): return makeI18nError("premium/%s" % errStr, period=self.period, auxData={"errStr": errStr}) return makeI18nError("premium/server_error", period=self.period, auxData={"errStr": errStr})
def getNotificationInfo(self): notificationKey = '#achievements:%s_notification%d' % ( self._getActualName(), self._value) if i18n.doesTextExist(notificationKey): return i18n.makeString(notificationKey) return ''
def getNotificationInfo(self): notificationKey = '#achievements:%s_notification%d' % (self._getActualName(), self._value) if i18n.doesTextExist(notificationKey): return i18n.makeString(notificationKey) return ''
def getUserCondition(self): condKey = '#achievements:%s_condition' % self._getActualName() if i18n.doesTextExist(condKey): return i18n.makeString(condKey) return ''
def getUserHeroInfo(self): heroInfoKey = '#achievements:%s_heroInfo' % self._getActualName() if i18n.doesTextExist(heroInfoKey): return i18n.makeString(heroInfoKey) return ''
def _errorHandler(self, code, errStr = '', ctx = None): if len(errStr) and i18n.doesTextExist('#system_messages:premium/%s' % errStr): return makeI18nError('premium/%s' % errStr, period=self.period, auxData={'errStr': errStr}) return makeI18nError('premium/server_error', period=self.period, auxData={'errStr': errStr})
def getUserCondition(self): condKey = '#achievements:%s_condition' % self._getActualName() return i18n.makeString(condKey) if i18n.doesTextExist(condKey) else ''
def getNotificationInfo(self): notificationKey = '#achievements:%s_notification' % self._getActualName( ) return i18n.makeString(notificationKey) if i18n.doesTextExist( notificationKey) else ''
def getUserHeroInfo(self): heroInfoKey = '#achievements:%s_heroInfo' % self._getActualName() return i18n.makeString(heroInfoKey) if i18n.doesTextExist( heroInfoKey) else ''
def _getConditionText(self): condTextKey = '#achievements:%s_condition_text' % self._getActualName() return text_styles.creditsSmall(i18n.makeString( condTextKey)) if i18n.doesTextExist(condTextKey) else ''