Esempio n. 1
0
 def generateOptions(self):
     options = [self._constructOptionVO(self.OPTIONS.MINIMIZE_ALL, MENU.contextmenu('messenger/minimizeAll')),
      self._constructOptionVO(_SEPARATOR_ID),
      self._constructOptionVO(self.OPTIONS.CLOSE_CURRENT, MENU.contextmenu('messenger/closeCurrent'), {'enabled': self._ctx.canCloseCurrent}),
      self._constructOptionVO(_SEPARATOR_ID),
      self._constructOptionVO(self.OPTIONS.CLOSE_ALL_EXCEPT_CURRENT, MENU.contextmenu('messenger/closeAllExceptCurrent'))]
     return options
Esempio n. 2
0
    def _generateOptions(self, ctx = None):
        userCMInfo = self._getUseCmInfo()
        if ctx is not None and not userCMInfo.hasClan:
            try:
                clanAbbrev = ctx.clanAbbrev
                userCMInfo.hasClan = bool(clanAbbrev)
            except:
                LOG_DEBUG('ctx has no property "clanAbbrev"')

        options = [self._makeItem(USER.INFO, MENU.contextmenu(USER.INFO))]
        options = self._addClanProfileInfo(options, userCMInfo)
        options = self._addFriendshipInfo(options, userCMInfo)
        options = self._addChannelInfo(options, userCMInfo)
        options.append(self._makeItem(USER.COPY_TO_CLIPBOARD, MENU.contextmenu(USER.COPY_TO_CLIPBOARD)))
        options = self._addSquadInfo(options, userCMInfo.isIgnored)
        options = self._addPrebattleInfo(options, userCMInfo)
        options = self._addClubInfo(options, userCMInfo)
        options = self._addContactsNoteInfo(options, userCMInfo)
        options = self._addAppealInfo(options)
        options = self._addIgnoreInfo(options, userCMInfo)
        options = self._addMutedInfo(options, userCMInfo)
        options = self._addRejectFriendshipInfo(options, userCMInfo)
        options = self._addRemoveFromGroupInfo(options, userCMInfo)
        options = self._addRemoveFriendInfo(options, userCMInfo)
        options = self._addInviteClanInfo(options, userCMInfo)
        return options
 def __addDyncSquadInfo(self, options):
     make = self._makeItem
     ctx = g_sessionProvider.getCtx()
     if not ctx.isInvitationEnabled() or ctx.hasSquadRestrictions():
         return options
     elif not self.__userInfo.isAlly:
         return options
     else:
         contact = self.usersStorage.getUser(self.__userInfo.databaseID)
         isIgnored = contact is not None and contact.isIgnored()
         status = self.__vInfo.invitationDeliveryStatus
         if status & _D_STATUS.FORBIDDEN_BY_RECEIVER > 0 or status & _D_STATUS.SENT_TO > 0 and not status & _D_STATUS.SENT_INACTIVE:
             optionID = DYN_SQUAD_OPTION_ID.SENT_INVITATION
             isEnabled = False
         elif status & _D_STATUS.RECEIVED_FROM > 0 and not status & _D_STATUS.RECEIVED_INACTIVE:
             optionID = None
         elif self.__vInfo.isSquadMan():
             optionID = DYN_SQUAD_OPTION_ID.IN_SQUAD
             isEnabled = False
         else:
             optionID = DYN_SQUAD_OPTION_ID.SENT_INVITATION
             isEnabled = not isIgnored
         if optionID is not None:
             options.append(self._makeItem(optionID, MENU.contextmenu(optionID), optInitData=self._getOptionInitData(optionID, isEnabled)))
         if status & _D_STATUS.RECEIVED_FROM > 0 and not status & _D_STATUS.RECEIVED_INACTIVE:
             options.append(make(DYN_SQUAD_OPTION_ID.ACCEPT_INVITATION, MENU.contextmenu(DYN_SQUAD_OPTION_ID.ACCEPT_INVITATION), optInitData=self._getOptionInitData(DYN_SQUAD_OPTION_ID.ACCEPT_INVITATION, not isIgnored)))
             options.append(make(DYN_SQUAD_OPTION_ID.REJECT_INVITATION, MENU.contextmenu(DYN_SQUAD_OPTION_ID.REJECT_INVITATION), optInitData=self._getOptionInitData(DYN_SQUAD_OPTION_ID.REJECT_INVITATION, not isIgnored)))
         return options
Esempio n. 4
0
 def _addSquadInfo(self, options, isIgnored):
     if not isIgnored and not self.isSquadCreator():
         canCreate = self.prbDispatcher.getFunctionalCollection().canCreateSquad()
         options.append(self._makeItem(USER.CREATE_SQUAD, MENU.contextmenu(USER.CREATE_SQUAD), optInitData={'enabled': canCreate}))
         if g_eventsCache.isEventEnabled():
             options.append(self._makeItem(USER.CREATE_EVENT_SQUAD, MENU.contextmenu(USER.CREATE_EVENT_SQUAD), optInitData={'enabled': canCreate}))
     return options
 def _generateOptions(self, ctx = None):
     options = [self._makeItem(MODULE.INFO, MENU.contextmenu(MODULE.INFO))]
     if self._isCanceled:
         options.append(self._makeItem(MODULE.CANCEL_BUY, MENU.contextmenu(MODULE.CANCEL_BUY)))
     else:
         options.append(self._makeItem(MODULE.UNLOAD, MENU.contextmenu(MODULE.UNLOAD)))
     return options
Esempio n. 6
0
 def __getPersonalQuestsVO(self, vehicle):
     """ Get part of VO responsible for personal quests flag.
     """
     pqState, quest, chain, tile = _findPersonalQuestsState(self._eventsCache, vehicle)
     if pqState == WIDGET_PQ_STATE.AVAILABLE:
         icon = RES_ICONS.MAPS_ICONS_LIBRARY_OUTLINE_PLUS
     elif pqState == WIDGET_PQ_STATE.AWARD:
         icon = RES_ICONS.MAPS_ICONS_LIBRARY_OUTLINE_REWARD
     elif pqState in WIDGET_PQ_STATE.UNSUITABLE:
         icon = RES_ICONS.vehicleTypeInactiveOutline(vehicle.type)
     else:
         icon = RES_ICONS.vehicleTypeOutline(vehicle.type)
     if pqState in WIDGET_PQ_STATE.UNSUITABLE:
         labelState = LABEL_STATE.INACTIVE
     elif pqState == WIDGET_PQ_STATE.AVAILABLE:
         labelState = LABEL_STATE.EMPTY
     else:
         labelState = LABEL_STATE.ACTIVE
     ctx = {}
     if all((quest, chain, tile)):
         self._personalQuestID = quest.getID()
         chainType = tile.getChainMajorTag(quest.getChainID())
         ctx.update({'questName': quest.getUserName(),
          'description': quest.getUserMainCondition(),
          'current': len(filter(lambda q: q.isCompleted(), chain.itervalues())),
          'total': len(chain),
          'tileName': tile.getUserName(),
          'chainName': _ms(MENU.classesShort(chainType))})
     else:
         self._personalQuestID = None
     return {'personalQuestsLabel': _ms(MENU.hangarHeaderPersonalQuestsLabel(labelState), **ctx),
      'personalQuestsIcon': icon,
      'personalQuestsTooltip': _getPersonalQuestsTooltip(pqState, **ctx),
      'personalQuestsEnable': pqState not in WIDGET_PQ_STATE.UNSUITABLE}
Esempio n. 7
0
 def _addFriendshipInfo(self, options, userCMInfo):
     if not userCMInfo.isFriend:
         options.append(self._makeItem(USER.ADD_TO_FRIENDS, MENU.contextmenu(USER.ADD_TO_FRIENDS), optInitData={'enabled': userCMInfo.isSameRealm}))
     elif self.proto.contacts.isBidiFriendshipSupported():
         if USER_TAG.SUB_NONE in userCMInfo.getTags():
             options.append(self._makeItem(USER.REQUEST_FRIENDSHIP, MENU.contextmenu(USER.ADD_TO_FRIENDS_AGAIN), optInitData={'enabled': userCMInfo.isSameRealm}))
     return options
 def _addPrebattleInfo(self, options, userCMInfo):
     if self.unitFunctional.getPermissions().canKick():
         options.append(self._makeItem(KICK_FROM_UNIT, MENU.contextmenu(KICK_FROM_UNIT)))
     if self._canGiveLeadership():
         options.append(self._makeItem(GIVE_LEADERSHIP, MENU.contextmenu(GIVE_LEADERSHIP)))
     if self._canTakeLeadership():
         options.append(self._makeItem(TAKE_LEADERSHIP, MENU.contextmenu(TAKE_LEADERSHIP)))
     return options
Esempio n. 9
0
def formatters_formatModuleParamName(base, paramName):
    builder = text_styles.builder()
    if weightTooHeavy and paramName == 'weight':
        builder.addStyledText(text_styles.error, MENU.moduleinfo_params(paramName))
        builder.addStyledText(text_styles.error, param_formatter.MEASURE_UNITS.get(paramName, ''))
    else:
        builder.addStyledText(text_styles.main, MENU.moduleinfo_params(paramName))
        builder.addStyledText(text_styles.standard, param_formatter.MEASURE_UNITS.get(paramName, ''))
    return builder.render()
Esempio n. 10
0
def formatVehicleParamName(paramName, showMeasureUnit = True):
    if isRelativeParameter(paramName):
        return text_styles.middleTitle(MENU.tank_params(paramName))
    else:
        builder = text_styles.builder()
        builder.addStyledText(text_styles.main, MENU.tank_params(paramName))
        if showMeasureUnit:
            builder.addStyledText(text_styles.standard, MEASURE_UNITS.get(paramName, ''))
        return builder.render()
Esempio n. 11
0
 def _generateOptions(self, ctx = None):
     options = [self._makeItem(MODULE.INFO, MENU.contextmenu(MODULE.INFO)), self._makeSeparator(), self._makeItem(MODULE.UNLOCK, MENU.contextmenu(MODULE.UNLOCK), {'enabled': NODE_STATE.isAvailable2Unlock(self._nodeState)})]
     if NODE_STATE.isUnlocked(self._nodeState):
         if NODE_STATE.inInventory(self._nodeState) or NODE_STATE.isInstalled(self._nodeState):
             options.extend([self._makeItem(MODULE.EQUIP, MENU.contextmenu(MODULE.EQUIP), {'enabled': self._isAvailable2Install()}), self._makeSeparator(), self._makeItem(MODULE.SELL, MENU.CONTEXTMENU_SELLFROMINVENTORY, {'enabled': not NODE_STATE.isInstalled(self._nodeState)})])
         else:
             options.extend([self._makeItem(MODULE.BUY_AND_EQUIP, MENU.CONTEXTMENU_BUYANDEQUIP, {'enabled': self._isAvailable2Buy()}), self._makeSeparator(), self._makeItem(MODULE.SELL, MENU.CONTEXTMENU_SELLFROMINVENTORY, {'enabled': NODE_STATE.isAvailable2Sell(self._nodeState)})])
     else:
         options.extend([self._makeItem(MODULE.BUY_AND_EQUIP, MENU.CONTEXTMENU_BUYANDEQUIP, {'enabled': False}), self._makeSeparator(), self._makeItem(MODULE.SELL, MENU.CONTEXTMENU_SELLFROMINVENTORY, {'enabled': False})])
     return options
Esempio n. 12
0
 def _addVehicleInfo(self, options):
     if self._vehicleCD > 0:
         vehicle = g_itemsCache.items.getItemByCD(self._vehicleCD)
         if not vehicle.isSecret:
             if vehicle.isPreviewAllowed():
                 action = USER.VEHICLE_PREVIEW
                 label = MENU.contextmenu(USER.VEHICLE_PREVIEW)
             else:
                 action = USER.VEHICLE_INFO
                 label = MENU.contextmenu(USER.VEHICLE_INFO)
             options.append(self._makeItem(action, label))
     return options
Esempio n. 13
0
 def generateOptions(self):
     options = []
     vehicle = g_itemsCache.items.getVehicle(self._itemId)
     vehicleWasInBattle = False
     accDossier = g_itemsCache.items.getAccountDossier(None)
     if accDossier:
         wasInBattleSet = set(accDossier.getTotalStats().getVehicles().keys())
         if vehicle.intCD in wasInBattleSet:
             vehicleWasInBattle = True
     if vehicle is not None:
         options.append(self._constructOptionVO(self.VEHICLE.INFO, MENU.contextmenu(self.VEHICLE.INFO)))
         options.append(self._constructOptionVO(self.VEHICLE.STATISTIC, MENU.contextmenu(self.VEHICLE.STATISTIC), {'enabled': vehicleWasInBattle}))
         options.append(self._constructOptionVO(_SEPARATOR_ID))
         if vehicle.isRented:
             if not vehicle.isPremiumIGR:
                 money = g_itemsCache.items.stats.money
                 (canBuyOrRent, _,) = vehicle.mayRentOrBuy(money)
                 options.append(self._constructOptionVO(self.VEHICLE.BUY, MENU.contextmenu(self.VEHICLE.BUY), {'enabled': canBuyOrRent}))
             options.append(self._constructOptionVO(self.VEHICLE.REMOVE, MENU.contextmenu(self.VEHICLE.REMOVE), {'enabled': vehicle.canSell and vehicle.rentalIsOver}))
         else:
             options.append(self._constructOptionVO(self.VEHICLE.SELL, MENU.contextmenu(self.VEHICLE.SELL), {'enabled': vehicle.canSell}))
         options.append(self._constructOptionVO(_SEPARATOR_ID))
         options.append(self._constructOptionVO(self.VEHICLE.RESEARCH, MENU.contextmenu(self.VEHICLE.RESEARCH)))
         if vehicle.isFavorite:
             options.append(self._constructOptionVO(self.VEHICLE.UNCHECK, MENU.contextmenu(self.VEHICLE.UNCHECK)))
         else:
             options.append(self._constructOptionVO(self.VEHICLE.CHECK, MENU.contextmenu(self.VEHICLE.CHECK)))
     return options
Esempio n. 14
0
 def _addVehicleInfo(self, options):
     if self._vehicleCD > 0:
         vehicle = g_itemsCache.items.getItemByCD(self._vehicleCD)
         if not vehicle.isSecret:
             isEnabled = True
             if vehicle.isPreviewAllowed():
                 isEnabled = not self.prbDispatcher.getFunctionalState().isNavigationDisabled()
                 action = USER.VEHICLE_PREVIEW
                 label = MENU.contextmenu(USER.VEHICLE_PREVIEW)
             else:
                 action = USER.VEHICLE_INFO
                 label = MENU.contextmenu(USER.VEHICLE_INFO)
             options.append(self._makeItem(action, label, optInitData={'enabled': isEnabled}))
     return options
Esempio n. 15
0
 def _addClubInfo(self, options, userCMInfo):
     club = self.clubsCtrl.getClub(self.__clubDbID)
     if club is not None:
         profile = self.clubsCtrl.getProfile()
         limits = self.clubsState.getLimits()
         member = club.getMember(self.databaseID)
         if limits.canTransferOwnership(profile, club).success:
             options.append(self._makeItem(GIVE_LEADERSHIP, MENU.contextmenu(GIVE_LEADERSHIP)))
         if member.isPrivate():
             if limits.canAssignOfficer(profile, club).success:
                 options.append(self._makeItem(ASSIGN_OFFICER, MENU.contextmenu(ASSIGN_OFFICER)))
         if member.isOfficer():
             if limits.canAssignPrivate(profile, club).success:
                 options.append(self._makeItem(ASSIGN_PRIVATE, MENU.contextmenu(ASSIGN_PRIVATE)))
     return options
 def _generateOptions(self, ctx = None):
     options = []
     vehicle = self.__getVehicle(self.vehCD)
     self._manageStartOptions(options, vehicle)
     if vehicle.isPurchased:
         options.append(self._makeItem(VEHICLE.SELL, MENU.contextmenu(VEHICLE.SELL), {'enabled': vehicle.canSell}))
     elif vehicle.isUnlocked:
         items = g_itemsCache.items
         label = MENU.CONTEXTMENU_RESTORE if vehicle.isRestoreAvailable() else MENU.CONTEXTMENU_BUY
         options.append(self._makeItem(VEHICLE.BUY, label, {'enabled': vehicle.mayObtainWithMoneyExchange(items.stats.money, items.shop.exchangeRate)}))
     else:
         isAvailableToUnlock, _, _ = g_techTreeDP.isVehicleAvailableToUnlock(self.vehCD)
         options.append(self._makeItem(VEHICLE.RESEARCH, MENU.contextmenu(VEHICLE.RESEARCH), {'enabled': isAvailableToUnlock}))
     self._manageEndOptions(options, vehicle)
     return options
Esempio n. 17
0
def makeVehicleVO(vehicle, levelsRange = None):
    if vehicle is None:
        return
    else:
        vState, vStateLvl = vehicle.getState()
        isReadyToFight = vehicle.isReadyToFight
        if vState == Vehicle.VEHICLE_STATE.UNDAMAGED or vState == Vehicle.VEHICLE_STATE.IN_PREBATTLE:
            vState = ''
            isReadyToFight = True
        elif vState == Vehicle.VEHICLE_STATE.IN_PREMIUM_IGR_ONLY:
            vState = makeHtmlString('html_templates:lobby', 'inPremiumIgrOnly')
        else:
            vState = i18n.makeString(MENU.tankcarousel_vehiclestates(vState))
        enabled, tooltip = True, None
        if levelsRange is not None and vehicle.level not in levelsRange:
            enabled, tooltip = False, TOOLTIPS.VEHICLESELECTOR_OVERFLOWLEVEL
        elif vehicle.isOnlyForEventBattles:
            enabled, tooltip = False, '#tooltips:redButton/disabled/vehicle/not_supported'
        return {'intCD': vehicle.intCD,
         'nationID': vehicle.nationID,
         'name': vehicle.name,
         'userName': vehicle.userName,
         'shortUserName': vehicle.shortUserName,
         'level': vehicle.level,
         'type': vehicle.type,
         'typeIndex': VEHICLE_TABLE_TYPES_ORDER_INDICES[vehicle.type],
         'smallIconPath': '../maps/icons/vehicle/small/{0}.png'.format(vehicle.name.replace(':', '-')),
         'isReadyToFight': isReadyToFight,
         'enabled': enabled,
         'tooltip': tooltip,
         'state': vState}
Esempio n. 18
0
 def _packBlocks(self, paramName):
     extendedData = self.context.getComparator().getExtendedData(paramName)
     self.__paramName = extendedData.name
     title = text_styles.highTitle(MENU.tank_params(paramName))
     if param_formatter.isRelativeParameter(paramName):
         value = param_formatter.colorizedFormatParameter(extendedData, self.context.formatters)
         title += ' ' + text_styles.warning(_ms(TOOLTIPS.VEHICLEPARAMS_TITLE_VALUETEMPLATE, value=value))
     else:
         title += ' ' + text_styles.middleTitle(MEASURE_UNITS.get(paramName, ''))
     desc = _ms(TOOLTIPS.tank_params_desc(paramName))
     possibleBonuses = sorted(extendedData.possibleBonuses, _bonusCmp)
     if possibleBonuses is not None and len(possibleBonuses) > 0:
         desc += ' ' + _ms(TOOLTIPS.VEHICLEPARAMS_POSSIBLEBONUSES_DESC)
         desc += '\n' + self.__createBonusesStr(possibleBonuses)
     blocks = [formatters.packTitleDescBlock(title, text_styles.main(desc))]
     bonuses = sorted(extendedData.bonuses, _bonusCmp)
     if bonuses is not None and len(bonuses) > 0:
         blocks.append(formatters.packTitleDescBlock(text_styles.middleTitle(TOOLTIPS.VEHICLEPARAMS_BONUSES_TITLE), text_styles.main(self.__createBonusesStr(bonuses))))
     penalties = extendedData.penalties
     actualPenalties, nullPenaltyTypes = self.__getNumNotNullPenaltyTankman(penalties)
     penaltiesLen = len(penalties)
     numNotNullPenaltyTankman = len(actualPenalties)
     if numNotNullPenaltyTankman > 0:
         blocks.append(formatters.packTitleDescBlock(text_styles.critical(TOOLTIPS.VEHICLEPARAMS_PENALTIES_TITLE), text_styles.main(self.__createPenaltiesStr(actualPenalties))))
     if penaltiesLen > numNotNullPenaltyTankman:
         blocks.append(formatters.packImageTextBlockData(self.__createTankmanIsOutStr(nullPenaltyTypes), img=RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED, imgPadding=formatters.packPadding(top=2, left=3, right=6)))
     return blocks
Esempio n. 19
0
 def __makeOffDayData(self):
     alertMessage = ''
     blockBtnEnabled = True
     fort = self.fortCtrl.getFort()
     inProcess, inCooldown = fort.getOffDayProcessing()
     conditionPostfix = self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, fort.getOffDayStr())
     blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNENABLED
     descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DAYOFFDESCRIPTION
     if inProcess:
         offDayChangeDate, nextOffDayUTC, _ = fort.events[FORT_EVENT_TYPE.OFF_DAY_CHANGE]
         nextOffDayLocal = adjustOffDayToLocal(nextOffDayUTC, self.fortCtrl.getFort().getLocalDefenceHour()[0])
         if nextOffDayLocal > NOT_ACTIVATED:
             value = i18n.makeString(MENU.datetime_weekdays_full(str(nextOffDayLocal + 1)))
         else:
             value = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_NOWEEKEND)
         msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_INPROGRESS, value=value, date=BigWorld.wg_getLongDateFormat(offDayChangeDate))
         alertMessage = self.app.utilsManager.textManager.getText(TextType.ALERT_TEXT, msgString)
         blockBtnEnabled = False
         blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED
     elif inCooldown:
         msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_RECENTLYSCHEDULED)
         alertMessage = self.app.utilsManager.textManager.getText(TextType.ALERT_TEXT, msgString)
         blockBtnEnabled = False
         blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED
     conditionPrefix = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, i18n.makeString(FORTIFICATIONS.settingswindow_blockcondition('weekEnd')))
     blockDescr = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, i18n.makeString(FORTIFICATIONS.settingswindow_blockdescr('weekEnd')))
     if alertMessage:
         alertMessage = self.app.utilsManager.textManager.getIcon(TextIcons.ALERT_ICON) + ' ' + alertMessage
     return {'blockBtnEnabled': blockBtnEnabled,
      'blockDescr': blockDescr,
      'blockCondition': conditionPrefix + ' ' + conditionPostfix,
      'alertMessage': alertMessage,
      'blockBtnToolTip': blockBtnToolTip,
      'descriptionTooltip': descriptionTooltip}
Esempio n. 20
0
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': nationID,
          'label': MENU.nations(nations.NAMES[int(nationID)])}]
        classesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': tankType,
          'label': DIALOGS.recruitwindow_vehicleclassdropdown(tankType)}]
        typesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        modulesAll = g_itemsCache.items.getVehicles(self.__getRoleCriteria(nationID, tankType, typeID)).values()
        modulesAll.sort()
        for module in modulesAll:
            typesDP.append({'id': module.innationID,
             'label': module.shortUserName})
            for role in module.descriptor.type.crewRoles:
                if role[0] == roleType:
                    rolesDP.append({'id': role[0],
                     'label': convert(getSkillsConfig()[role[0]]['userString'])})

            break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP, rolesDP)
        return
 def __getVehicleDetails(self, vehicleCD):
     details = {}
     item = g_itemsCache.items.getItemByCD(vehicleCD)
     details['type'] = item.typeUserName
     details['nation'] = i18n.makeString(MENU.nations(item.nationName))
     details['vehicle'] = item.userName
     return details
Esempio n. 22
0
    def updateAllDropdowns(self, nationID, tankType, typeID, roleType):
        nationsDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': nationID,
          'label': MENU.nations(nations.NAMES[int(nationID)])}]
        classesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}, {'id': tankType,
          'label': DIALOGS.recruitwindow_vehicleclassdropdown(tankType)}]
        typesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        rolesDP = [{'id': None,
          'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        unlocks = yield StatsRequester().getUnlocks()
        modulesAll = yield Requester('vehicle').getFromShop()
        for module in modulesAll:
            compdecs = module.descriptor.type.compactDescr
            if compdecs in unlocks and module.descriptor.type.id[0] == nationID and module.descriptor.type.id[1] == typeID:
                typesDP.append({'id': module.descriptor.type.id[1],
                 'label': module.descriptor.type.shortUserString})
                for role in module.descriptor.type.crewRoles:
                    if role[0] == roleType:
                        rolesDP.append({'id': role[0],
                         'label': convert(getSkillsConfig()[role[0]]['userString'])})

                break

        self.flashObject.as_setAllDropdowns(nationsDP, classesDP, typesDP, rolesDP)
        return
Esempio n. 23
0
    def __updateLimits(self, teamLimits, rosters):
        levelLimits = {}
        for className in constants.VEHICLE_CLASSES:
            classLvlLimits = prb_control.getClassLevelLimits(teamLimits, className)
            levelLimits[className] = {'minLevel': classLvlLimits[0],
             'maxLevel': classLvlLimits[1],
             'maxCurLevel': 0}

        for roster, players in rosters.iteritems():
            if roster & PREBATTLE_ROSTER.ASSIGNED:
                for player in players:
                    vehicle = player.getVehicle()
                    levelLimits[vehicle.type]['maxCurLevel'] = max(levelLimits[vehicle.type]['maxCurLevel'], vehicle.level)

        strlevelLimits = dict(((t, '') for t in constants.VEHICLE_CLASSES))
        classesLimitsAreIdentical, commonInfo = self.__compareVehicleLimits(levelLimits)
        if classesLimitsAreIdentical:
            strlevelLimits['lightTank'] = self.__makeMinMaxString(commonInfo)
        else:
            for className in constants.VEHICLE_CLASSES:
                strlevelLimits[className] = self.__makeMinMaxString(levelLimits[className])

        self.as_setClassesLimitsS(strlevelLimits, classesLimitsAreIdentical)
        nationsLimits = prb_control.getNationsLimits(teamLimits)
        nationsLimitsResult = None
        if nationsLimits is not None and len(nationsLimits) != len(nations.AVAILABLE_NAMES):
            nationsLimitsResult = []
            for nation in nationsLimits:
                nationsLimitsResult.append({'icon': self.NATION_ICON_PATH % {'nation': nation},
                 'tooltip': MENU.nations(nation)})

        self.as_setNationsLimitsS(nationsLimitsResult)
Esempio n. 24
0
 def _getParameterValue(self, paramName, paramsDict, rawParamsDict):
     paramsMap = {'speedLimits': MENU.TANK_PARAMS_MPH,
      'enginePowerPerTon': MENU.TANK_PARAMS_PT,
      'chassisRotationSpeed': MENU.TANK_PARAMS_GPS,
      'circularVisionRadius': MENU.TANK_PARAMS_M,
      'damageAvgPerMinute': MENU.TANK_PARAMS_VPM,
      'hullArmor': MENU.TANK_PARAMS_FACEFRONTBOARDINMM,
      'turretArmor': MENU.TANK_PARAMS_FACEFRONTBOARDINMM,
      'damageAvg': MENU.TANK_PARAMS_VAL,
      'piercingPower': MENU.TANK_PARAMS_MM,
      'explosionRadius': MENU.TANK_PARAMS_M,
      'shotDispersionAngle': MENU.TANK_PARAMS_M,
      'aimingTime': MENU.TANK_PARAMS_S,
      'reloadTimeSecs': MENU.TANK_PARAMS_S,
      'enginePower': MENU.TANK_PARAMS_P}
     if paramName not in paramsMap:
         LOG_ERROR('There is no key "' + paramName + '" in paramsMap')
         return None
     htmlText = text_styles.main(_ms(MENU.tank_params(paramName))) + text_styles.standard(_ms(paramsMap[paramName]))
     if paramName == 'enginePowerPerTon':
         return (htmlText, BigWorld.wg_getNiceNumberFormat(rawParamsDict[paramName]))
     elif paramName == 'damageAvgPerMinute':
         return (htmlText, _int(rawParamsDict[paramName]))
     elif paramName == 'damageAvg':
         return (htmlText, BigWorld.wg_getNiceNumberFormat(rawParamsDict[paramName]))
     elif paramName == 'reloadTimeSecs':
         return (htmlText, _int(rawParamsDict[paramName]))
     elif paramName == 'explosionRadius':
         return (htmlText, BigWorld.wg_getNiceNumberFormat(rawParamsDict[paramName]))
     elif paramName == 'shotDispersionAngle':
         return (htmlText, BigWorld.wg_getNiceNumberFormat(rawParamsDict[paramName]))
     elif paramName in paramsDict:
         return (htmlText, paramsDict.get(paramName))
     else:
         return (htmlText, rawParamsDict.get(paramName))
Esempio n. 25
0
 def appeal(self, uid, userName, topic):
     topicID = self.DENUNCIATIONS.get(topic)
     if topicID is not None:
         BigWorld.player().makeDenunciation(uid, topicID, constants.VIOLATOR_KIND.UNKNOWN)
         topicStr = i18n.makeString(MENU.denunciation(topicID))
         sysMsg = i18n.makeString(SYSTEM_MESSAGES.DENUNCIATION_SUCCESS) % {'name': userName,
          'topic': topicStr}
         SystemMessages.pushMessage(sysMsg, type=SystemMessages.SM_TYPE.Information)
Esempio n. 26
0
 def _addContactsNoteInfo(self, options, userCMInfo):
     if self.proto.contacts.isNoteSupported():
         userNote = userCMInfo.getNote()
         if userNote:
             options.extend([self._makeItem(CONTACTS_ACTION_ID.EDIT_CONTACT_NOTE, MENU.contextmenu(CONTACTS_ACTION_ID.EDIT_CONTACT_NOTE)), self._makeItem(CONTACTS_ACTION_ID.REMOVE_CONTACT_NOTE, MENU.contextmenu(CONTACTS_ACTION_ID.REMOVE_CONTACT_NOTE))])
         else:
             options.append(self._makeItem(CONTACTS_ACTION_ID.CREATE_CONTACT_NOTE, MENU.contextmenu(CONTACTS_ACTION_ID.CREATE_CONTACT_NOTE)))
     return options
Esempio n. 27
0
 def __addFriendshipInfo(self, options):
     isEnabled = self.__userInfo.isSameRealm
     if self.__userInfo.isFriend:
         optionID = USER.REMOVE_FROM_FRIENDS
     else:
         optionID = USER.ADD_TO_FRIENDS
     options.append(self._makeItem(optionID, MENU.contextmenu(optionID), optInitData=self._getOptionInitData(optionID, isEnabled)))
     return options
Esempio n. 28
0
 def _generateOptions(self, ctx = None):
     userCMInfo = self._getUseCmInfo()
     options = [self._makeItem(USER.INFO, MENU.contextmenu(USER.INFO))]
     options = self._addFriendshipInfo(options, userCMInfo)
     options = self._addChannelInfo(options, userCMInfo)
     options.append(self._makeItem(USER.COPY_TO_CLIPBOARD, MENU.contextmenu(USER.COPY_TO_CLIPBOARD)))
     options = self._addSquadInfo(options, userCMInfo.isIgnored)
     options = self._addPrebattleInfo(options, userCMInfo)
     options = self._addClubInfo(options, userCMInfo)
     options = self._addContactsNoteInfo(options, userCMInfo)
     options = self._addAppealInfo(options)
     options = self._addIgnoreInfo(options, userCMInfo)
     options = self._addMutedInfo(options, userCMInfo)
     options = self._addRejectFriendshipInfo(options, userCMInfo)
     options = self._addRemoveFromGroupInfo(options, userCMInfo)
     options = self._addRemoveFriendInfo(options, userCMInfo)
     return options
Esempio n. 29
0
 def __addIgnoreInfo(self, options):
     data = {'enabled': self.__userInfo.isSameRealm}
     if self.__userInfo.isIgnored:
         optionID = USER.REMOVE_FROM_IGNORED
     else:
         optionID = USER.ADD_TO_IGNORED
     options.append(self._makeItem(optionID, MENU.contextmenu(optionID), optInitData=data))
     return options
 def _populate(self):
     super(ReferralReferralsIntroWindow, self)._populate()
     contentKey = 'referrals' if self.__isNewbie else 'phenix'
     referrerNameFmt = text_styles.warning(self.__referrerName)
     handIcon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_REFERRAL_REFERRALSMALLHAND, 16, 16, -4, 0)
     self.as_setDataS({'titleTF': text_styles.promoTitle(i18n.makeString(MENU.REFERRALREFERRALSINTROWINDOW_TEXT_BLOCK_TITLE, userName=getattr(BigWorld.player(), 'name', 'Unknown'))),
      'bodyTF': text_styles.main(i18n.makeString(MENU.referralreferralsintrowindow_text_block_body(contentKey), referrerName=referrerNameFmt, handIcon=handIcon)),
      'squadTF': text_styles.main(i18n.makeString(MENU.REFERRALREFERRALSINTROWINDOW_TEXT_BLOCK_SQUAD_TEXT))})
Esempio n. 31
0
 def __getData(self):
     vehicle = g_currentPreviewVehicle.item
     if vehicle.isElite:
         vehicleTitle = text_styles.bonusPreviewText(
             '%s %s, %s' %
             (_ms(MENU.header_vehicletype_elite(vehicle.type)),
              _ms(VEHICLE_PREVIEW.INFOPANEL_LEVEL,
                  level=_ms(MENU.header_level(vehicle.level))),
              _ms(MENU.nations(vehicle.nationName))))
     else:
         vehicleTitle = text_styles.playerOnline(
             '%s %s, %s' %
             (_ms(MENU.header_vehicletype(vehicle.type)),
              _ms(VEHICLE_PREVIEW.INFOPANEL_LEVEL,
                  level=_ms(MENU.header_level(vehicle.level))),
              _ms(MENU.nations(vehicle.nationName))))
     if vehicle.isPremiumIGR:
         vehicleTitle = makeHtmlString('html_templates:igr/premium-vehicle',
                                       'name', {'vehicle': vehicleTitle})
     compareBtnEnabled, compareBtnTooltip = resolveStateTooltip(
         self.comparisonBasket, vehicle,
         VEH_COMPARE.STORE_COMPAREVEHICLEBTN_TOOLTIPS_ADDTOCOMPARE,
         VEH_COMPARE.STORE_COMPAREVEHICLEBTN_TOOLTIPS_DISABLED)
     result = {
         'closeBtnLabel': VEHICLE_PREVIEW.HEADER_CLOSEBTN_LABEL,
         'backBtnLabel': VEHICLE_PREVIEW.HEADER_BACKBTN_LABEL,
         'backBtnDescrLabel': self.__getBackBtnLabel(),
         'vehicleTitle': vehicleTitle,
         'vehicleName': vehicle.descriptor.type.shortUserString.upper(),
         'showCloseBtn': self._showCloseBtn,
         'compareBtnTooltip': compareBtnTooltip,
         'showCompareBtn': compareBtnEnabled
     }
     return result
Esempio n. 32
0
 def _generateOptions(self, ctx = None):
     options = []
     vehicle = g_itemsCache.items.getVehicle(self.getVehInvID())
     vehicleWasInBattle = False
     accDossier = g_itemsCache.items.getAccountDossier(None)
     isEventVehicle = vehicle.isOnlyForEventBattles
     if vehicle is None:
         return options
     else:
         if accDossier:
             wasInBattleSet = set(accDossier.getTotalStats().getVehicles().keys())
             if vehicle.intCD in wasInBattleSet:
                 vehicleWasInBattle = True
         if vehicle is not None:
             options.extend([self._makeItem(VEHICLE.INFO, MENU.contextmenu(VEHICLE.INFO)), self._makeItem(VEHICLE.STATS, MENU.contextmenu(VEHICLE.STATS), {'enabled': vehicleWasInBattle}), self._makeSeparator()])
             self._manageVehCompareOptions(options, vehicle)
             options.append(self._makeItem(VEHICLE.RESEARCH, MENU.contextmenu(VEHICLE.RESEARCH)))
             if vehicle.isRented:
                 if not vehicle.isPremiumIGR:
                     items = g_itemsCache.items
                     enabled = vehicle.mayObtainWithMoneyExchange(items.stats.money, items.shop.exchangeRate)
                     label = MENU.CONTEXTMENU_RESTORE if vehicle.isRestoreAvailable() else MENU.CONTEXTMENU_BUY
                     options.append(self._makeItem(VEHICLE.BUY, label, {'enabled': enabled}))
                 options.append(self._makeItem(VEHICLE.SELL, MENU.contextmenu(VEHICLE.REMOVE), {'enabled': vehicle.canSell and vehicle.rentalIsOver}))
             else:
                 options.append(self._makeItem(VEHICLE.SELL, MENU.contextmenu(VEHICLE.SELL), {'enabled': vehicle.canSell and not isEventVehicle}))
             if vehicle.isFavorite:
                 options.append(self._makeItem(VEHICLE.UNCHECK, MENU.contextmenu(VEHICLE.UNCHECK)))
             else:
                 options.append(self._makeItem(VEHICLE.CHECK, MENU.contextmenu(VEHICLE.CHECK), {'enabled': not isEventVehicle}))
         return options
Esempio n. 33
0
 def _generateOptions(self, ctx = None):
     options = []
     vehicle = g_itemsCache.items.getVehicle(self.getVehInvID())
     vehicleWasInBattle = False
     accDossier = g_itemsCache.items.getAccountDossier(None)
     isEventVehicle = vehicle.isOnlyForEventBattles
     if vehicle is None:
         return options
     else:
         if accDossier:
             wasInBattleSet = set(accDossier.getTotalStats().getVehicles().keys())
             if vehicle.intCD in wasInBattleSet:
                 vehicleWasInBattle = True
         if vehicle is not None:
             options.extend([self._makeItem(VEHICLE.INFO, MENU.contextmenu(VEHICLE.INFO)), self._makeItem(VEHICLE.STATS, MENU.contextmenu(VEHICLE.STATS), {'enabled': vehicleWasInBattle}), self._makeSeparator()])
             if vehicle.isRented:
                 if not vehicle.isPremiumIGR:
                     money = g_itemsCache.items.stats.money
                     canBuyOrRent, _ = vehicle.mayRentOrBuy(money)
                     options.append(self._makeItem(VEHICLE.BUY, MENU.contextmenu(VEHICLE.BUY), {'enabled': canBuyOrRent}))
                 options.append(self._makeItem(VEHICLE.SELL, MENU.contextmenu(VEHICLE.REMOVE), {'enabled': vehicle.canSell and vehicle.rentalIsOver}))
             else:
                 options.append(self._makeItem(VEHICLE.SELL, MENU.contextmenu(VEHICLE.SELL), {'enabled': vehicle.canSell and not isEventVehicle}))
             options.extend([self._makeSeparator(), self._makeItem(VEHICLE.RESEARCH, MENU.contextmenu(VEHICLE.RESEARCH))])
             if vehicle.isFavorite:
                 options.append(self._makeItem(VEHICLE.UNCHECK, MENU.contextmenu(VEHICLE.UNCHECK)))
             else:
                 options.append(self._makeItem(VEHICLE.CHECK, MENU.contextmenu(VEHICLE.CHECK), {'enabled': not isEventVehicle}))
         return options
Esempio n. 34
0
    def updateNationDropdown(self):
        vehsItems = self.itemsCache.items.getVehicles(
            self.__getNationsCriteria())
        data = [{'id': None, 'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
        for name in GUI_NATIONS:
            nationIdx = nations.INDICES[name]
            vehiclesAvailable = len(
                vehsItems.filter(REQ_CRITERIA.NATIONS([nationIdx]))) > 0
            if name in nations.AVAILABLE_NAMES and vehiclesAvailable:
                data.append({'id': nationIdx, 'label': MENU.nations(name)})

        self.flashObject.as_setNations(data)
        return
Esempio n. 35
0
 def appeal(self, uid, userName, topic):
     topicID = self.DENUNCIATIONS.get(topic)
     if topicID is not None:
         BigWorld.player().makeDenunciation(uid, topicID,
                                            constants.VIOLATOR_KIND.UNKNOWN)
         topicStr = i18n.makeString(MENU.denunciation(topicID))
         sysMsg = i18n.makeString(SYSTEM_MESSAGES.DENUNCIATION_SUCCESS) % {
             'name': userName,
             'topic': topicStr
         }
         SystemMessages.pushMessage(sysMsg,
                                    type=SystemMessages.SM_TYPE.Information)
     return
def _getVehStatsByNation(battlesStats):
    tDict = battlesStats[1]
    nationRes = []
    for guiNationIdx, _ in enumerate(GUI_NATIONS):
        nationIdx = getNationIndex(guiNationIdx)
        nationName = nations.NAMES[nationIdx]
        nationRes.append({'xField': i18n.makeString(MENU.nations(nationName)),
         'icon': '../maps/icons/filters/nations/{0}.png'.format(nationName),
         'yField': tDict[nationIdx],
         'tooltip': PROFILE.SECTION_STATISTICS_CHART_NATION_TOOLTIP})

    _setChartDataPercentages(nationRes)
    return nationRes
Esempio n. 37
0
 def _getTitle(self):
     if self.__questID:
         quest = self.eventsCache.personalMissions.getQuests()[
             self.__questID]
         return text_styles.highTitle(
             ms(QUESTS.PERSONALMISSION_VEHICLESELECTOR_TITLE,
                vehType=', '.join([
                    ms(MENU.classesShort(vehType))
                    for vehType in quest.getVehicleClasses()
                ]),
                minLevel=quest.getVehMinLevel(),
                maxLevel=quest.getVehMaxLevel()))
     return ''
Esempio n. 38
0
 def _addSquadInfo(self, options, isIgnored):
     if not isIgnored and not self.isSquadCreator() and self.prbDispatcher is not None:
         canCreate = self.prbEntity.getPermissions().canCreateSquad()
         if not self._isSquadAlreadyCreated(PREBATTLE_TYPE.SQUAD):
             options.append(self._makeItem(USER.CREATE_SQUAD, MENU.contextmenu(USER.CREATE_SQUAD), optInitData={'enabled': canCreate}))
         if self.__eventBattlesCtrl.isEnabled() and not self._isSquadAlreadyCreated(PREBATTLE_TYPE.EVENT):
             options.append(self._makeItem(USER.CREATE_EVENT_SQUAD, MENU.contextmenu(USER.CREATE_EVENT_SQUAD), optInitData={'enabled': canCreate,
              'textColor': 13347959}))
         if self.__battleRoyale.isEnabled() and not self._isSquadAlreadyCreated(PREBATTLE_TYPE.BATTLE_ROYALE_TOURNAMENT) and not self._isSquadAlreadyCreated(PREBATTLE_TYPE.BATTLE_ROYALE):
             primeTimeStatus, _, _ = self.__battleRoyale.getPrimeTimeStatus()
             options.append(self._makeItem(USER.CREATE_BATTLE_ROYALE_SQUAD, MENU.contextmenu(USER.CREATE_BATTLE_ROYALE_SQUAD), optInitData={'enabled': canCreate and primeTimeStatus == PrimeTimeStatus.AVAILABLE,
              'textColor': 13347959}))
         if self.__mapboxCtrl.isEnabled() and not self._isSquadAlreadyCreated(PREBATTLE_TYPE.MAPBOX):
             isOptionEnabled = canCreate and self.__mapboxCtrl.isActive() and self.__mapboxCtrl.isInPrimeTime()
             options.append(self._makeItem(USER.CREATE_MAPBOX_SQUAD, backport.text(R.strings.menu.contextMenu.createMapboxSquad()), optInitData={'enabled': isOptionEnabled,
              'textColor': 13347959}))
         funRandomCtrl = self.__funRandomController
         if funRandomCtrl.isEnabled():
             isOptionEnabled = canCreate and funRandomCtrl.canGoToMode() and funRandomCtrl.isInPrimeTime()
             options.append(self._makeItem(USER.CREATE_FUN_RANDOM_SQUAD, backport.text(R.strings.menu.contextMenu.createFunRandomSquad()), optInitData={'enabled': isOptionEnabled,
              'textColor': 13347959}))
     return options
Esempio n. 39
0
 def _addInviteClanInfo(self, options, userCMInfo):
     if self.lobbyContext.getServerSettings().clanProfile.isEnabled() and userCMInfo.user is not None and not userCMInfo.hasClan:
         profile = self.clanCtrl.getAccountProfile()
         canHandleClanInvites = profile.getMyClanPermissions().canHandleClanInvites()
         if profile.isInClan() and canHandleClanInvites:
             isEnabled = self.clanCtrl.isAvailable()
             canHandleClanInvites = profile.getMyClanPermissions().canHandleClanInvites()
             if isEnabled:
                 profile = self.clanCtrl.getAccountProfile()
                 dossier = profile.getClanDossier()
                 isEnabled = canHandleClanInvites and not dossier.isClanInviteSent(userCMInfo.databaseID) and not dossier.hasClanApplication(userCMInfo.databaseID)
             options.append(self._makeItem(USER.SEND_CLAN_INVITE, MENU.contextmenu(USER.SEND_CLAN_INVITE), optInitData={'enabled': isEnabled}))
     return options
Esempio n. 40
0
 def __addDyncSquadInfo(self, options):
     make = self._makeItem
     ctx = g_sessionProvider.getCtx()
     if not ctx.isInvitationEnabled() or ctx.hasSquadRestrictions():
         return options
     elif not g_sessionProvider.getArenaDP().isAllyTeam(self.__vInfo.team):
         return options
     else:
         contact = self.usersStorage.getUser(self.__userInfo.databaseID)
         isIgnored = contact is not None and contact.isIgnored()
         status = self.__vInfo.invitationDeliveryStatus
         if status & _D_STATUS.FORBIDDEN_BY_RECEIVER > 0 or status & _D_STATUS.RECEIVED_FROM > 0 and not status & _D_STATUS.RECEIVED_INACTIVE or status & _D_STATUS.SENT_TO > 0 and not status & _D_STATUS.SENT_INACTIVE:
             options.append(
                 make(DYN_SQUAD_OPTION_ID.SENT_INVITATION,
                      MENU.contextmenu(DYN_SQUAD_OPTION_ID.SENT_INVITATION),
                      optInitData={'enabled': False}))
         elif self.__vInfo.isSquadMan():
             options.append(
                 make(DYN_SQUAD_OPTION_ID.IN_SQUAD,
                      MENU.contextmenu(DYN_SQUAD_OPTION_ID.IN_SQUAD),
                      optInitData={'enabled': False}))
         else:
             options.append(
                 make(DYN_SQUAD_OPTION_ID.SENT_INVITATION,
                      MENU.contextmenu(DYN_SQUAD_OPTION_ID.SENT_INVITATION),
                      optInitData={'enabled': not isIgnored}))
         if status & _D_STATUS.RECEIVED_FROM > 0 and not status & _D_STATUS.RECEIVED_INACTIVE:
             options.append(
                 make(DYN_SQUAD_OPTION_ID.ACCEPT_INVITATION,
                      MENU.contextmenu(
                          DYN_SQUAD_OPTION_ID.ACCEPT_INVITATION),
                      optInitData={'enabled': not isIgnored}))
             options.append(
                 make(
                     DYN_SQUAD_OPTION_ID.REJECT_INVITATION,
                     MENU.contextmenu(
                         DYN_SQUAD_OPTION_ID.REJECT_INVITATION)))
         return options
Esempio n. 41
0
 def getTitleBlock(self):
     tankInfo = ''
     tankType = ''
     item = g_currentVehicle.item
     if item is not None:
         tankInfo = text_styles.concatStylesToMultiLine(
             text_styles.promoSubTitle(item.userName),
             text_styles.stats(MENU.levels_roman(item.level)))
         tankType = '../maps/icons/vehicleTypes/big/%s.png' % item.type
     return {
         'title': self.getTitle(),
         'tankType': tankType,
         'tankInfo': tankInfo
     }
Esempio n. 42
0
 def _getSubmenuData(self):
     if self._isAlly or self._arenaGuiType in (ARENA_GUI_TYPE.UNKNOWN,
                                               ARENA_GUI_TYPE.TRAINING):
         order = DENUNCIATIONS.ORDER
     else:
         order = DENUNCIATIONS.ENEMY_ORDER
     make = self._makeItem
     return [
         make(denunciation,
              MENU.contextmenu(denunciation),
              optInitData={
                  'enabled': self._isAppealsForTopicEnabled(denunciation)
              }) for denunciation in order
     ]
Esempio n. 43
0
 def _generateOptions(self, ctx=None):
     vehicle = self.itemsCache.items.getItemByCD(self.__vehCD)
     options = []
     if not vehicle.isSecret or vehicle.isInInventory:
         options.append(
             self._makeItem(PROFILE.VEHICLE_INFO,
                            MENU.CONTEXTMENU_VEHICLEINFOEX))
     if self.comparisonBasket.isEnabled():
         options.append(
             self._makeItem(
                 PROFILE.VEHICLE_COMPARE,
                 MENU.contextmenu(PROFILE.VEHICLE_COMPARE),
                 {'enabled': self.comparisonBasket.isReadyToAdd(vehicle)}))
     return options
def packNationsFilter():
    result = [{
        'label': MENU.NATIONS_ALL,
        'data': -1,
        'icon': getNationsFilterAssetPath('all')
    }]
    for idx, nation in enumerate(GUI_NATIONS):
        result.append({
            'label': MENU.nations(nation),
            'data': idx,
            'icon': getNationsFilterAssetPath(nation)
        })

    return result
 def getFormattedStartFinishText(self):
     startDate, finishDate = self.__getGroupStartFinishTime()
     startDateStruct = getTimeStructInLocal(startDate)
     finishDateStruct = getTimeStructInLocal(finishDate)
     startDateText = text_styles.main(
         _ms(TOOLTIPS.BLOGGERS_DATE,
             day=startDateStruct.tm_mday,
             month=i18n.makeString(
                 MENU.datetime_months(startDateStruct.tm_mon)),
             hour=startDateStruct.tm_hour,
             minutes=i18n.makeString('%02d', startDateStruct.tm_min)))
     finishDateText = text_styles.main(
         _ms(TOOLTIPS.BLOGGERS_DATE,
             day=finishDateStruct.tm_mday,
             month=i18n.makeString(
                 MENU.datetime_months(startDateStruct.tm_mon)),
             hour=finishDateStruct.tm_hour,
             minutes=i18n.makeString('%02d', finishDateStruct.tm_min)))
     text = text_styles.main(
         _ms(TOOLTIPS.BLOGGERS_SUBTITLE,
             startDate=startDateText,
             finishDate=finishDateText))
     return (None, text)
Esempio n. 46
0
    def makeAppeal(self, violatorID, userName, topic):
        topicID = _DENUNCIATIONS_MAP.get(topic)
        player = BigWorld.player()
        violatorKind = self._getViolatorKind(player, violatorID)
        try:
            player.makeDenunciation(violatorID, topicID, violatorKind)
        except (AttributeError, TypeError):
            LOG_ERROR('Cannot make a denunciation')
            return

        topicStr = i18n.makeString(MENU.denunciation(topicID))
        message = i18n.makeString(SYSTEM_MESSAGES.DENUNCIATION_SUCCESS)
        message = message % {'name': userName, 'topic': topicStr}
        self._makeNotification(message)
Esempio n. 47
0
 def __addMutedInfo(self, options):
     isVisible = self.bwProto.voipController.isVOIPEnabled() and (
         self.__userInfo.isAlly or self.arenaGuiType.isTrainingBattle())
     isEnabled = not self.__userInfo.isIgnored or self.__userInfo.isTemporaryIgnored
     if self.__userInfo.isMuted:
         optionID = USER.UNSET_MUTED
     else:
         optionID = USER.SET_MUTED
     if isVisible:
         options.append(
             self._makeItem(optionID,
                            MENU.contextmenu(optionID),
                            optInitData=self._getOptionInitData(
                                optionID, isEnabled)))
     return options
Esempio n. 48
0
 def __addIgnoreInfo(self, options):
     isEnabled = self.__userInfo.isSameRealm
     if self.__userInfo.isTemporaryIgnored:
         optionID = USER.ADD_TO_IGNORED
         isEnabled = False
     elif self.__userInfo.isIgnored:
         optionID = USER.REMOVE_FROM_IGNORED
     else:
         optionID = USER.ADD_TO_IGNORED
     options.append(
         self._makeItem(optionID,
                        MENU.contextmenu(optionID),
                        optInitData=self._getOptionInitData(
                            optionID, isEnabled)))
     return options
Esempio n. 49
0
 def __addDenunciationsInfo(self, options):
     make = self._makeItem
     sub = [
         make(value, MENU.contextmenu(value))
         for value in DENUNCIATIONS.ORDER
     ]
     label = '{} ({})'.format(i18n.makeString(MENU.CONTEXTMENU_APPEAL),
                              self.__denunciator.getDenunciationsLeft())
     options.append(
         make(
             DENUNCIATIONS.APPEAL,
             label,
             optInitData={'enabled': self.__denunciator.isAppealsEnabled()},
             optSubMenu=sub))
     return options
Esempio n. 50
0
 def __getBattleQuestsVO(self, vehicle):
     quests = [ q for q in self._questController.getQuestForVehicle(vehicle) if not isDailyEpic(q.getGroupID()) and not isDailyQuest(q.getID()) and not isPremium(q.getID()) and not isRankedQuestID(q.getID()) ]
     totalCount = len(quests)
     completedQuests = len([ q for q in quests if q.isCompleted() ])
     festivityFlagData = self._festivityController.getHangarQuestsFlagData()
     if totalCount > 0:
         if completedQuests != totalCount:
             label = _ms(MENU.hangarHeaderBattleQuestsLabel(LABEL_STATE.ACTIVE), total=totalCount - completedQuests)
         else:
             label = icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_OUTLINE_QUESTS_ALL_DONE)
         commonQuestsIcon = festivityFlagData.icon or RES_ICONS.MAPS_ICONS_LIBRARY_OUTLINE_QUESTS_AVAILABLE
     else:
         commonQuestsIcon = festivityFlagData.iconDisabled or RES_ICONS.MAPS_ICONS_LIBRARY_OUTLINE_QUESTS_DISABLED
         label = ''
     quests = [self._headerQuestFormaterVo(totalCount > 0, commonQuestsIcon, label, HANGAR_HEADER_QUESTS.QUEST_TYPE_COMMON, flag=festivityFlagData.flagBackground, tooltip=TOOLTIPS_CONSTANTS.QUESTS_PREVIEW, isTooltipSpecial=True)]
     return self._wrapQuestGroup(HANGAR_HEADER_QUESTS.QUEST_GROUP_COMMON, '', quests)
Esempio n. 51
0
 def __addCommunicationInfo(self, options):
     if self.__userInfo.isAlly and not self.arenaGuiType.isTrainingBattle():
         isEnabled = self.__userInfo.isSameRealm
         if self.__userInfo.isTemporaryIgnored:
             optionID = BATTLE_CHAT_OPTION_ID.ENABLE_COMMUNICATIONS
         elif not self.__userInfo.isIgnored:
             optionID = BATTLE_CHAT_OPTION_ID.DISABLE_COMMUNICATIONS
         else:
             optionID = BATTLE_CHAT_OPTION_ID.DISABLE_COMMUNICATIONS
             isEnabled = False
         options.append(
             self._makeItem(optionID,
                            MENU.contextmenu(optionID),
                            optInitData=self._getOptionInitData(
                                optionID, isEnabled)))
     return options
Esempio n. 52
0
 def _addSendGiftInfo(self, options, userCMInfo):
     eventHub = self.__giftsController.getEventHub(GiftEventID.NY_HOLIDAYS)
     if self.__nyController.isEnabled(
     ) and eventHub and eventHub.getSettings(
     ).isEnabled and userCMInfo.isAnySub:
         isEnabled = self.prbEntity is None or not self.prbEntity.isInQueue(
         )
         options.insert(
             0,
             self._makeItem(CONTACTS_ACTION_CONSTS.NY_SEND_GIFT,
                            MENU.contextmenu(
                                CONTACTS_ACTION_CONSTS.NY_SEND_GIFT),
                            iconType=CONTACTS_ACTION_CONSTS.NY_SEND_GIFT,
                            linkage='NYContextMenuItemUI',
                            optInitData={'enabled': isEnabled}))
     return options
Esempio n. 53
0
 def handleInvalidPassword(self, status, message):
     errorMessage = i18n.makeString(MENU.login_status(status))
     errCode = self.LOGIN_PWD_INVALID
     if len(self.__loginDataLoader.token2):
         self.resetToken()
         self.onHandleInvalidPasswordWithToken(
             self.__loginDataLoader.user,
             self.__loginDataLoader.rememberPwd)
         lastLoginType = Settings.g_instance.userPrefs[
             Settings.KEY_LOGIN_INFO].readString('lastLoginType', 'basic')
         if lastLoginType != 'basic':
             errorMessage = i18n.makeString(
                 '#menu:login/status/SOCIAL_SESSION_END')
         else:
             errorMessage = i18n.makeString(MENU.LOGIN_STATUS_SESSION_END)
         errCode = self.ALL_VALID
     self.onSetStatus(errorMessage, errCode)
def getStatusStrings(vState,
                     vStateLvl=Vehicle.VEHICLE_STATE_LEVEL.INFO,
                     substitute='',
                     style=None,
                     ctx=None):
    ctx = ctx or {}
    state = MENU.tankcarousel_vehiclestates(vState)
    status = ms(state, **ctx)
    if style is None:
        smallStyle, largeStyle = getStatusCountStyle(vStateLvl)
    else:
        smallStyle = largeStyle = style
    if status:
        return (smallStyle(status), largeStyle(status))
    else:
        return (text_styles.middleTitle(substitute),
                status) if substitute else (status, status)
Esempio n. 55
0
 def _packBlocks(self, paramName):
     extendedData = self.context.getComparator().getExtendedData(paramName)
     self.__paramName = extendedData.name
     title = text_styles.highTitle(MENU.tank_params(paramName))
     if param_formatter.isRelativeParameter(paramName):
         value = ''
         if self.context.showTitleValue:
             value = param_formatter.colorizedFormatParameter(
                 extendedData, self.context.formatters)
         title += ' ' + text_styles.warning(
             _ms(TOOLTIPS.VEHICLEPARAMS_TITLE_VALUETEMPLATE, value=value))
     else:
         title += ' ' + text_styles.middleTitle(
             MEASURE_UNITS.get(paramName, ''))
     desc = _ms(TOOLTIPS.tank_params_desc(paramName))
     possibleBonuses = sorted(extendedData.possibleBonuses, _bonusCmp)
     if possibleBonuses is not None and len(possibleBonuses) > 0:
         desc += ' ' + _ms(TOOLTIPS.VEHICLEPARAMS_POSSIBLEBONUSES_DESC)
         desc += '\n' + self.__createBonusesStr(possibleBonuses)
     blocks = [formatters.packTitleDescBlock(title, text_styles.main(desc))]
     bonuses = sorted(extendedData.bonuses, _bonusCmp)
     if bonuses is not None and len(bonuses) > 0:
         blocks.append(
             formatters.packTitleDescBlock(
                 text_styles.middleTitle(
                     TOOLTIPS.VEHICLEPARAMS_BONUSES_TITLE),
                 text_styles.main(self.__createBonusesStr(bonuses))))
     penalties = extendedData.penalties
     actualPenalties, nullPenaltyTypes = self.__getNumNotNullPenaltyTankman(
         penalties)
     penaltiesLen = len(penalties)
     numNotNullPenaltyTankman = len(actualPenalties)
     if numNotNullPenaltyTankman > 0:
         blocks.append(
             formatters.packTitleDescBlock(
                 text_styles.critical(
                     TOOLTIPS.VEHICLEPARAMS_PENALTIES_TITLE),
                 text_styles.main(
                     self.__createPenaltiesStr(actualPenalties))))
     if penaltiesLen > numNotNullPenaltyTankman:
         blocks.append(
             formatters.packImageTextBlockData(
                 self.__createTankmanIsOutStr(nullPenaltyTypes),
                 img=RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED,
                 imgPadding=formatters.packPadding(top=2, left=3, right=6)))
     return blocks
Esempio n. 56
0
    def _getBody(self, eventID):
        items = []
        source = self._questController.getAllAvailableQuests()
        svrEvents = {e.getID():e for e in source}
        event = svrEvents.get(eventID)
        weekDays = event.getWeekDays()
        if weekDays:
            days = [ _ms(MENU.datetime_weekdays_full(idx)) for idx in event.getWeekDays() ]
            items.append(self._getSubBlock(TOOLTIPS.QUESTS_SCHEDULE_WEEKDAYS, days))
        intervals = event.getActiveTimeIntervals()
        if intervals:
            times = []
            for low, high in intervals:
                times.append('{} - {}'.format(backport.getShortTimeFormat(low), backport.getShortTimeFormat(high)))

            items.append(self._getSubBlock(TOOLTIPS.QUESTS_SCHEDULE_INTERVALS, times, formatters.packPadding(top=18)))
        return formatters.packBuildUpBlockData(blocks=items, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, padding=formatters.packPadding(top=-3))
def packNationsFilter(nations=GUI_NATIONS):
    if nations is not GUI_NATIONS:
        nations = sorted(nations,
                         key=lambda nation: GUI_NATIONS_ORDER_INDEX[nation])
    result = [{
        'label': MENU.NATIONS_ALL,
        'data': -1,
        'icon': getNationsFilterAssetPath('all')
    }]
    for nation in nations:
        result.append({
            'label': MENU.nations(nation),
            'data': INDICES[nation],
            'icon': getNationsFilterAssetPath(nation)
        })

    return result
 def _generateOptions(self, ctx=None):
     options = []
     vehicle = self.itemsCache.items.getVehicle(self.getVehInvID())
     if vehicle is None:
         return options
     else:
         options.extend([
             self._makeItem(VEHICLE.STATS, MENU.contextmenu(VEHICLE.STATS),
                            {'enabled': True})
         ])
         rentState = self.__rentVehiclesController.getRentState(self.vehCD)
         if rentState != EquipmentPanelCmpRentStates.STATE_NORMAL:
             testDriveStates = (
                 EquipmentPanelCmpRentStates.STATE_TEST_DRIVE_AVAILABLE,
                 EquipmentPanelCmpRentStates.STATE_TEST_DRIVE_ACTIVE)
             rentStates = (EquipmentPanelCmpRentStates.STATE_RENT_AVAILABLE,
                           EquipmentPanelCmpRentStates.STATE_RENT_ACTIVE)
             if rentState in testDriveStates:
                 days = self.__rentVehiclesController.getNextTestDriveDaysTotal(
                     self.vehCD)
                 text = backport.text(R.strings.menu.battleRoyale.
                                      contextMenu.takeTestDrive(),
                                      days=days)
                 options.extend([
                     self._makeItem(
                         VEHICLE.TAKE_TEST_DRIVE, text, {
                             'enabled':
                             rentState == EquipmentPanelCmpRentStates.
                             STATE_TEST_DRIVE_AVAILABLE
                         })
                 ])
             elif rentState in rentStates:
                 isEnough = self.__rentVehiclesController.isEnoughMoneyToPurchase(
                     self.vehCD)
                 isEnabled = rentState == EquipmentPanelCmpRentStates.STATE_RENT_AVAILABLE and isEnough
                 days = self.__rentVehiclesController.getNextRentDaysTotal(
                     self.vehCD)
                 text = backport.text(
                     R.strings.menu.battleRoyale.contextMenu.takeRent(),
                     days=days)
                 options.extend([
                     self._makeItem(VEHICLE.TAKE_RENT, text,
                                    {'enabled': isEnabled})
                 ])
         return options
Esempio n. 59
0
    def __updateLimits(self, teamLimits, rosters):
        levelLimits = {}
        for className in constants.VEHICLE_CLASSES:
            classLvlLimits = prb_getters.getClassLevelLimits(
                teamLimits, className)
            levelLimits[className] = {
                'minLevel': classLvlLimits[0],
                'maxLevel': classLvlLimits[1],
                'maxCurLevel': 0
            }

        for roster, players in rosters.iteritems():
            if roster & PREBATTLE_ROSTER.ASSIGNED:
                for player in players:
                    vehicle = player.getVehicle()
                    levelLimits[vehicle.type]['maxCurLevel'] = max(
                        levelLimits[vehicle.type]['maxCurLevel'],
                        vehicle.level)

        strlevelLimits = dict(((t, '') for t in constants.VEHICLE_CLASSES))
        classesLimitsAreIdentical, commonInfo = self.__compareVehicleLimits(
            levelLimits)
        if classesLimitsAreIdentical:
            strlevelLimits['lightTank'] = self.__makeMinMaxString(commonInfo)
        else:
            for className in constants.VEHICLE_CLASSES:
                strlevelLimits[className] = self.__makeMinMaxString(
                    levelLimits[className])

        self.as_setClassesLimitsS(strlevelLimits, classesLimitsAreIdentical)
        nationsLimits = prb_getters.getNationsLimits(teamLimits)
        nationsLimitsResult = None
        if nationsLimits is not None and len(nationsLimits) != len(
                nations.AVAILABLE_NAMES):
            nationsLimitsResult = []
            for nation in nationsLimits:
                nationsLimitsResult.append({
                    'icon': self.NATION_ICON_PATH % {
                        'nation': nation
                    },
                    'tooltip': MENU.nations(nation)
                })

        self.as_setNationsLimitsS(nationsLimitsResult)
        return
Esempio n. 60
0
    def updateNationDropdown(self):
        try:
            vehsItems = g_itemsCache.items.getVehicles(REQ_CRITERIA.UNLOCKED)
            data = [{'id': None, 'label': DIALOGS.RECRUITWINDOW_MENUEMPTYROW}]
            for name in GUI_NATIONS:
                nationIdx = nations.INDICES[name]
                vehiclesAvailable = len(
                    vehsItems.filter(REQ_CRITERIA.NATIONS([nationIdx]))) > 0
                if name in nations.AVAILABLE_NAMES and vehiclesAvailable:
                    data.append({'id': nationIdx, 'label': MENU.nations(name)})

            self.flashObject.as_setNations(data)
        except Exception:
            LOG_ERROR(
                'There is exception while setting data to the recruit window')
            LOG_CURRENT_EXCEPTION()

        return