def addDefMessage(message): mColor = g_settings.getColorScheme('battle/message').getHexStr('unknown') pColor = g_settings.getColorScheme('battle/player').getHexStr('unknown') return g_settings.battle.messageFormat % {'playerColor': pColor, 'playerName': unicode(g_sessionProvider.getCtx().getFullPlayerName(accID=message.originator), 'utf-8', errors='ignore'), 'messageColor': mColor, 'messageText': message.data}
def addDefMessage(message): mColor = g_settings.getColorScheme("battle/message").getHexStr("unknown") pColor = g_settings.getColorScheme("battle/player").getHexStr("unknown") return g_settings.battle.messageFormat % { "playerColor": pColor, "playerName": unicode(g_battleContext.getFullPlayerName(accID=message.originator), "utf-8", errors="ignore"), "messageColor": mColor, "messageText": message.data, }
def getMessageColors(self, message): dbID = message.originator mColor = g_settings.getColorScheme("battle/message").getHexStr("squad") pColorScheme = g_settings.getColorScheme("battle/player") pColor = pColorScheme.getHexStr("squadman") if isCurrentPlayer(dbID): pColor = pColorScheme.getHexStr("himself") elif g_battleContext.isTeamKiller(accID=dbID): pColor = pColorScheme.getHexStr("teamkiller") return (pColor, mColor)
def setColors(self, dbID): pColorScheme = g_settings.getColorScheme('battle/player') pColor = pColorScheme.getHexStr('squadman') if isCurrentPlayer(dbID): pColor = pColorScheme.getHexStr('himself') elif g_sessionProvider.getCtx().isTeamKiller(accID=dbID): pColor = pColorScheme.getHexStr('teamkiller') self._ctx['playerColor'] = pColor self._ctx['messageColor'] = g_settings.getColorScheme('battle/message').getHexStr('squad') return self
def getMessageColors(self, message): dbID = message.originator mColor = g_settings.getColorScheme('battle/message').getHexStr('squad') pColorScheme = g_settings.getColorScheme('battle/player') pColor = pColorScheme.getHexStr('squadman') if isCurrentPlayer(dbID): pColor = pColorScheme.getHexStr('himself') elif g_sessionProvider.getCtx().isTeamKiller(accID=dbID): pColor = pColorScheme.getHexStr('teamkiller') return (pColor, mColor)
def getMessageColors(self, message): dbID = message.originator mColor = g_settings.getColorScheme('battle/message').getHexStr('squad') pColorScheme = g_settings.getColorScheme('battle/player') pColor = pColorScheme.getHexStr('squadman') if isCurrentPlayer(dbID): pColor = pColorScheme.getHexStr('himself') elif g_battleContext.isTeamKiller(accID=dbID): pColor = pColorScheme.getHexStr('teamkiller') return (pColor, mColor)
def addDefMessage(message): mColor = g_settings.getColorScheme('battle/message').getHexStr('unknown') pColor = g_settings.getColorScheme('battle/player').getHexStr('unknown') return g_settings.battle.messageFormat % { 'playerColor': pColor, 'playerName': unicode(g_battleContext.getFullPlayerName(accID=message.originator), 'utf-8', errors='ignore'), 'messageColor': mColor, 'messageText': message.data }
def setPlayers(self, prbID, roster): foundIdx = -1 getUser = self.usersStorage.getUser getColor = g_settings.getColorScheme('rosters').getColor for idx, item in enumerate(self.__list): if item['prbID'] == prbID: players = [] foundIdx = idx for info in roster: if info.roster is PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1: user = getUser(info.dbID) if user is not None: key = user.getGuiType() else: key = USER_GUI_TYPE.OTHER players.append({ 'label': info.getFullName(), 'userName': info.name, 'clanAbbrev': info.clanAbbrev, 'igrType': info.igrType, 'region': g_lobbyContext.getRegionCode(info.dbID), 'color': getColor(key) }) item['players'] = players else: item['players'] = [] return foundIdx
def buildList(self, members): self.__list = [] members = sorted(members, key=lambda member: member.getName().lower()) getUser = self.usersStorage.getUser getColors = g_settings.getColorScheme("rosters").getColors for member in members: dbID = member.getDatabaseID() isOnline = member.isOnline() user = getUser(dbID) if user: tags = list(user.getTags()) colors = getColors(user.getGuiType()) else: tags = [] colors = getColors(USER_GUI_TYPE.OTHER) self.__list.append( { "dbID": dbID, "userName": member.getFullName(), "isOnline": isOnline, "color": colors[0 if isOnline else 1], "tags": tags, "isPlayerSpeaking": False, } )
def buildList(self, selectedID, result): self.clear() userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors pNameGetter = g_lobbyContext.getPeripheryName ratingFormatter = BigWorld.wg_getIntegralFormat self._selectedIdx = -1 for unitItem in result: creator = unitItem.creator if creator: dbID = creator.dbID creatorVO = makePlayerVO(creator, userGetter(dbID), colorGetter) else: creatorVO = None cfdUnitID = unitItem.cfdUnitID index = len(self.collection) if cfdUnitID == selectedID: self._selectedIdx = index self.mapping[cfdUnitID] = index self.collection.append({'cfdUnitID': cfdUnitID, 'unitMgrID': unitItem.unitMgrID, 'creator': creatorVO, 'creatorName': creatorVO.get('userName', ''), 'rating': ratingFormatter(unitItem.rating), 'playersCount': unitItem.playersCount, 'commandSize': unitItem.commandSize, 'inBattle': unitItem.state.isInArena(), 'isFreezed': unitItem.state.isLocked(), 'isRestricted': unitItem.isRosterSet, 'description': unitItem.description, 'peripheryID': unitItem.peripheryID, 'server': pNameGetter(unitItem.peripheryID)}) return self._selectedIdx
def setPlayers(self, prbID, roster): foundIdx = -1 getUser = self.usersStorage.getUser getColor = g_settings.getColorScheme('rosters').getColor for idx, item in enumerate(self.__list): if item['prbID'] == prbID: players = [] foundIdx = idx for info in roster: if info.roster is PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1: user = getUser(info.dbID) if user is not None: key = user.getGuiType() else: key = USER_GUI_TYPE.OTHER players.append({'label': info.getFullName(), 'userName': info.name, 'clanAbbrev': info.clanAbbrev, 'igrType': info.igrType, 'region': g_lobbyContext.getRegionCode(info.dbID), 'color': getColor(key)}) item['players'] = players else: item['players'] = [] return foundIdx
def __updateHeaderText(self): colorScheme = g_settings.getColorScheme('battle/message') userAnonymized = self.__anonymizerController.isAnonymized anonymizerInfoText = backport.text( _R_SQUAD.simpleChatAlert.anonymizer()) if userAnonymized else '' self.viewModel.headerExtraInfo.setText(anonymizerInfoText) self.viewModel.headerExtraInfo.setColor(colorScheme.getHexStr('alert'))
def setColors(self, avatarSessionID): pColorScheme = g_settings.getColorScheme('battle/player') pColor = pColorScheme.getHexStr('teammate') ctx = self.sessionProvider.getCtx() if isCurrentPlayer(avatarSessionID): pColor = pColorScheme.getHexStr('himself') elif ctx.isTeamKiller(avatarSessionID=avatarSessionID): pColor = pColorScheme.getHexStr('teamkiller') elif ctx.isSquadMan(avatarSessionID=avatarSessionID): pColor = pColorScheme.getHexStr('squadman') elif ctx.isEnemy(avatarSessionID=avatarSessionID): pColor = pColorScheme.getHexStr('enemy') self._ctx['playerColor'] = pColor self._ctx['messageColor'] = g_settings.getColorScheme( 'battle/message').getHexStr('team') return self
def __updateUsersData(self, userDBIDs): diff = [] userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors for userDBID in userDBIDs: data = findFirst(lambda d: d['creator'].get('dbID') == userDBID, self.collection) if data is not None: clubDBID = data['cfdUnitID'] try: index = self.mapping[clubDBID] item = self.collection[index] except (KeyError, IndexError): LOG_ERROR('Item not found', clubDBID) continue creator = userGetter(userDBID) creatorVO = makeUserVO(creator, colorGetter) creatorName = creator.getName() item.update({'creatorName': creatorName, 'rating': self.getGuiUserRating(userDBID)}) if creator.hasValidName(): item['creator'] = creatorVO diff.append(index) if len(diff): self.updateItems(diff) return
def buildList(self, selectedID, result): self.clear() userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors pNameGetter = self.lobbyContext.getPeripheryName ratingFormatter = backport.getIntegralFormat self._selectedIdx = -1 for unitItem in result: creator = unitItem.creator if creator: dbID = creator.dbID creatorVO = makePlayerVO(creator, userGetter(dbID), colorGetter) else: creatorVO = {} cfdUnitID = unitItem.cfdUnitID index = len(self.collection) if cfdUnitID == selectedID: self._selectedIdx = index self.mapping[cfdUnitID] = index self.collection.append({'cfdUnitID': cfdUnitID, 'unitMgrID': unitItem.unitMgrID, 'creator': creatorVO, 'creatorName': creatorVO.get('userName', ''), 'rating': ratingFormatter(unitItem.rating), 'playersCount': unitItem.playersCount, 'commandSize': unitItem.commandSize, 'inBattle': unitItem.flags.isInArena(), 'isFreezed': unitItem.flags.isLocked(), 'isRestricted': unitItem.isRosterSet, 'description': unitItem.description, 'peripheryID': unitItem.peripheryID, 'server': pNameGetter(unitItem.peripheryID)}) return self._selectedIdx
def __updateUsersData(self, userDBIDs): diff = [] userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors for userDBID in userDBIDs: data = findFirst(lambda d: d['creator'].get('dbID') == userDBID, self.collection) if data is not None: clubDBID = data['cfdUnitID'] try: index = self.mapping[clubDBID] item = self.collection[index] except (KeyError, IndexError): LOG_ERROR('Item not found', clubDBID) continue creator = userGetter(userDBID) creatorVO = makeUserVO(creator, colorGetter) creatorName = creator.getName() item.update({ 'creatorName': creatorName, 'rating': self.getGuiUserRating(userDBID) }) if creator.hasValidName(): item['creator'] = creatorVO diff.append(index) if len(diff): self.updateItems(diff) return
def _makeAccountsData(self, accounts): result = [] isPlayerSpeaking = self.bwProto.voipController.isPlayerSpeaking getUser = self.usersStorage.getUser getColors = g_settings.getColorScheme('rosters').getColors accounts = sorted(accounts, cmp=prb_items.getPlayersComparator()) for account in accounts: vContourIcon = '' vShortName = '' vLevel = '' vType = '' user = getUser(account.dbID) if user is not None: key = user.getGuiType() else: key = USER_GUI_TYPE.OTHER if account.isVehicleSpecified(): vehicle = account.getVehicle() vContourIcon = vehicle.iconContour vShortName = vehicle.shortUserName vLevel = int2roman(vehicle.level) vType = vehicle.type result.append({ 'accID': account.accID, 'dbID': account.dbID, 'userName': account.name, 'clanAbbrev': account.clanAbbrev, 'region': self.lobbyContext.getRegionCode(account.dbID), 'fullName': account.getFullName(), 'igrType': account.igrType, 'time': account.time, 'isCreator': account.isCreator, 'state': account.state, 'icon': vContourIcon, 'vShortName': vShortName, 'vLevel': vLevel, 'vType': vType, 'tags': list(user.getTags()) if user else [], 'isPlayerSpeaking': isPlayerSpeaking(account.dbID), 'colors': getColors(key) }) return result
def buildList(self, selectedID, result, syncUserInfo=True): self.clear() userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors ratingFormatter = BigWorld.wg_getIntegralFormat self._selectedIdx = -1 self._lastResult = result data = [] for clubItem in result: cfdUnitID = clubItem.getID() creatorID = clubItem.getCreatorID() rating = self.getUserRating(creatorID) creator = self._UserEntityAdapter(creatorID, clubItem, userGetter(creatorID), self) creatorName = creator.getName() creatorVO = makeUserVO(creator, colorGetter) index = len(self.collection) if cfdUnitID == selectedID: self._selectedIdx = index self.mapping[cfdUnitID] = index data.append((rating, { 'cfdUnitID': cfdUnitID, 'unitMgrID': cfdUnitID, 'creator': creatorVO, 'creatorName': creatorName, 'rating': self.getGuiUserRating(creatorID), 'playersCount': clubItem.getMembersCount(), 'commandSize': clubItem.getCommandSize(), 'inBattle': False, 'isFreezed': False, 'isRestricted': False, 'description': html.escape(clubItem.getShortDescription()), 'peripheryID': -1, 'server': None, 'ladderIcon': getLadderChevron16x16(clubItem.getDivision()), 'isStatic': True })) self.collection.extend( map(lambda (r, c): c, sorted(data, reverse=True, key=operator.itemgetter(0)))) if syncUserInfo: self.syncUsersInfo() return self._selectedIdx
def makeUserItem(user): return {'dbID': user.getID(), 'userName': user.getName(), 'fullName': user.getFullName(), 'tags': list(user.getTags()), 'isOnline': user.isOnline(), 'colors': g_settings.getColorScheme('rosters').getColors(user.getGuiType()), 'clanAbbrev': user.getClanAbbrev()}
def _getColors(cls, name): if not cls._colors: scheme = g_settings.getColorScheme('contacts') cls._colors = {'friend': scheme.getColors('friend'), 'clanMember': scheme.getColors('clanMember'), 'others': scheme.getColors('others'), 'currentUser': scheme.getColors('currentUser')} return cls._colors[name]
def makeUserItem(user): return {'uid': user.getID(), 'userName': user.getName(), 'chatRoster': user.getRoster(), 'online': user.isOnline(), 'himself': user.isCurrentPlayer(), 'displayName': user.getFullName(), 'colors': g_settings.getColorScheme('rosters').getColors(user.getGuiType())}
def _getSlotsData(unitIdx, unit, unitState, pInfo, slotsIter, app = None, levelsRange = None, checkForVehicles = True): isPlayerCreator = pInfo.isCreator() isPlayerInSlot = pInfo.isInSlot slots = [] userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors vehicleGetter = g_itemsCache.items.getItemByCD if app: isPlayerSpeaking = app.voiceChatManager.isPlayerSpeaking else: isPlayerSpeaking = lambda dbID: False if unitState.isFortBattle(): makeVO = makeClanBattlePlayerVO elif unitState.isSortie(): makeVO = makeSortiePlayerVO else: makeVO = makePlayerVO for slotInfo in slotsIter: index = slotInfo.index slotState = slotInfo.state player = slotInfo.player vehicle = slotInfo.vehicle canAssign, vehicles = pInfo.canAssignToSlot(index) vehCount = len(vehicles) slotLevel = 0 vehicleVO = None slotPlayerUI = None if player is not None: dbID = player.dbID slotPlayerUI = makeVO(player, userGetter(dbID), colorGetter, isPlayerSpeaking(dbID)) if vehicle: if 'vehLevel' in vehicle: slotLevel = vehicle['vehLevel'] if 'vehTypeCompDescr' in vehicle: vehicleVO = makeVehicleVO(vehicleGetter(vehicle['vehTypeCompDescr']), levelsRange) slotLabel = makeSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles) playerStatus = getPlayerStatus(slotState, player, unitState.isFortBattle()) if unit is not None: restrictions = makeUnitRosterVO(unit, pInfo, index=index, isSortie=unitState.isSortie(), levelsRange=levelsRange)['conditions'] else: restrictions = [] isFreezed = unitState.isLocked() or unitState.isInSearch() or unitState.isInQueue() or unitState.isInArena() slot = {'rallyIdx': unitIdx, 'isCommanderState': isPlayerCreator, 'isCurrentUserInSlot': isPlayerInSlot, 'playerStatus': playerStatus, 'isClosed': slotState.isClosed, 'isFreezed': isFreezed, 'slotLabel': slotLabel, 'player': slotPlayerUI, 'canBeTaken': canAssign, 'compatibleVehiclesCount': vehCount, 'selectedVehicle': vehicleVO, 'selectedVehicleLevel': 1 if slotState.isClosed else slotLevel, 'restrictions': restrictions} slots.append(slot) return slots
def updateList(self, selectedID, result): isFullUpdate, diff = False, [] self._selectedIdx = None userGetter = storage_getter("users")().getUser colorGetter = g_settings.getColorScheme("rosters").getColors ratingFormatter = BigWorld.wg_getIntegralFormat result = set(result) removed = set(filter(lambda item: item[1] is None, result)) isFullUpdate = len(removed) for cfdUnitID, unitItem in removed: index = self.mapping.pop(cfdUnitID, None) if index is not None: self.collection.pop(index) if cfdUnitID == selectedID: self._selectedIdx = -1 self.rebuildIndexes() if isFullUpdate: updated = result.difference(removed) else: updated = result for cfdUnitID, unitItem in updated: try: index = self.mapping[cfdUnitID] item = self.collection[index] except (KeyError, IndexError): LOG_ERROR("Item not found", unitItem) continue creator = unitItem.creator if creator: dbID = creator.dbID creatorVO = makePlayerVO(creator, userGetter(dbID), colorGetter) else: creatorVO = None item.update( { "creator": creatorVO, "creatorName": creatorVO.get("userName", ""), "rating": ratingFormatter(unitItem.rating), "playersCount": unitItem.playersCount, "commandSize": unitItem.commandSize, "inBattle": unitItem.flags.isInArena() or unitItem.flags.isInPreArena(), "isFreezed": unitItem.flags.isLocked(), "isRestricted": unitItem.isRosterSet, "description": unitItem.description, } ) diff.append(index) if self._selectedIdx is None and selectedID in self.mapping: self._selectedIdx = self.mapping[selectedID] if isFullUpdate: self.refresh() elif len(diff): self.updateItems(diff) return self._selectedIdx
def getGuiUserData(self, userDbID): user = self.getContact(userDbID) colorGetter = g_settings.getColorScheme('rosters').getColors return {'userName': self.getGuiUserName(userDbID), 'clanAbbrev': self.getUserClanAbbrev(userDbID), 'region': self.getUserRegionCode(userDbID), 'tags': user.getTags() if user else [], 'dbID': userDbID, 'colors': colorGetter(user.getGuiType() if user else USER_GUI_TYPE.OTHER)}
def buildGuiUserData(self, user): userDbID = user.getID() colorGetter = g_settings.getColorScheme('rosters').getColors return {'userName': self.getGuiUserName(userDbID), 'clanAbbrev': self.getUserClanAbbrev(userDbID), 'region': self.getUserRegionCode(userDbID), 'tags': user.getTags() if user else [], 'dbID': userDbID, 'colors': colorGetter(user.getGuiType() if user else USER_GUI_TYPE.OTHER)}
def updateList(self, selectedID, result): isFullUpdate, diff = False, [] self._selectedIdx = None userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors ratingFormatter = BigWorld.wg_getIntegralFormat result = set(result) removed = set(filter(lambda item: item[1] is None, result)) isFullUpdate = len(removed) for cfdUnitID, unitItem in removed: index = self.mapping.pop(cfdUnitID, None) if index is not None: self.collection.pop(index) if cfdUnitID == selectedID: self._selectedIdx = -1 self.rebuildIndexes() if isFullUpdate: updated = result.difference(removed) else: updated = result for cfdUnitID, unitItem in updated: try: index = self.mapping[cfdUnitID] item = self.collection[index] except (KeyError, IndexError): LOG_ERROR('Item not found', unitItem) continue creator = unitItem.creator if creator: dbID = creator.dbID creatorVO = makePlayerVO(creator, userGetter(dbID), colorGetter) else: creatorVO = None item.update({ 'creator': creatorVO, 'creatorName': creatorVO.get('userName', ''), 'rating': ratingFormatter(unitItem.rating), 'playersCount': unitItem.playersCount, 'commandSize': unitItem.commandSize, 'inBattle': unitItem.flags.isInArena(), 'isFreezed': unitItem.flags.isLocked(), 'isRestricted': unitItem.isRosterSet, 'description': unitItem.description }) diff.append(index) if self._selectedIdx is None and selectedID in self.mapping: self._selectedIdx = self.mapping[selectedID] if isFullUpdate: self.refresh() elif diff: self.updateItems(diff) return self._selectedIdx
def _buildData(self, candidates): isPlayerSpeaking = self.bwProto.voipController.isPlayerSpeaking userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors mapping = [ (pInfo, userGetter(pInfo.dbID)) for pInfo in candidates.itervalues() ] sortedList = sorted(mapping, cmp=getUnitCandidatesComparator()) for pInfo, user in sortedList: dbID = pInfo.dbID self._mapping[dbID] = len(self._list) self._list.append(self._makePlayerVO(pInfo, user, colorGetter, isPlayerSpeaking(dbID)))
def getMessageColors(self, message): dbID = message.originator mColor = g_settings.getColorScheme('battle/message').getHexStr('common') pColorScheme = g_settings.getColorScheme('battle/player') pColor = pColorScheme.getHexStr('unknown') if isCurrentPlayer(dbID): pColor = pColorScheme.getHexStr('himself') else: channel = self.channelsStorage.getChannel(self._teamChannel) if channel and channel.hasMember(dbID): if g_battleContext.isTeamKiller(accID=dbID): pColor = pColorScheme.getHexStr('teamkiller') elif g_battleContext.isSquadMan(accID=dbID): pColor = pColorScheme.getHexStr('squadman') else: pColor = pColorScheme.getHexStr('teammate') elif self._channel.hasMember(dbID): pColor = pColorScheme.getHexStr('enemy') return (pColor, mColor)
def getMessageColors(self, message): dbID = message.originator mColor = g_settings.getColorScheme("battle/message").getHexStr("common") pColorScheme = g_settings.getColorScheme("battle/player") pColor = pColorScheme.getHexStr("unknown") if isCurrentPlayer(dbID): pColor = pColorScheme.getHexStr("himself") else: channel = self.channelsStorage.getChannel(self._teamChannel) if channel and channel.hasMember(dbID): if g_battleContext.isTeamKiller(accID=dbID): pColor = pColorScheme.getHexStr("teamkiller") elif g_battleContext.isSquadMan(accID=dbID): pColor = pColorScheme.getHexStr("squadman") else: pColor = pColorScheme.getHexStr("teammate") elif self._channel.hasMember(dbID): pColor = pColorScheme.getHexStr("enemy") return (pColor, mColor)
def setColors(self, dbID): pColorScheme = g_settings.getColorScheme('battle/player') pColor = pColorScheme.getHexStr('unknown') if isCurrentPlayer(dbID): pColor = pColorScheme.getHexStr('himself') else: ctx = g_sessionProvider.getCtx() if ctx.isAlly(accID=dbID): if ctx.isTeamKiller(accID=dbID): pColor = pColorScheme.getHexStr('teamkiller') elif ctx.isSquadMan(accID=dbID): pColor = pColorScheme.getHexStr('squadman') else: pColor = pColorScheme.getHexStr('teammate') elif ctx.isEnemy(accID=dbID): pColor = pColorScheme.getHexStr('enemy') self._ctx['playerColor'] = pColor self._ctx['messageColor'] = g_settings.getColorScheme('battle/message').getHexStr('common') return self
def _buildData(self, candidates): isPlayerSpeaking = self.bwProto.voipController.isPlayerSpeaking userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors mapping = map(lambda pInfo: (pInfo, userGetter(pInfo.dbID)), candidates.itervalues()) sortedList = sorted(mapping, cmp=getUnitCandidatesComparator()) for pInfo, user in sortedList: dbID = pInfo.dbID self._mapping[dbID] = len(self._list) self._list.append(self._makePlayerVO(pInfo, user, colorGetter, isPlayerSpeaking(dbID)))
def makeUserItem(user): return { "dbID": user.getID(), "userName": user.getName(), "fullName": user.getFullName(), "tags": list(user.getTags()), "isOnline": user.isOnline(), "colors": g_settings.getColorScheme("rosters").getColors(user.getGuiType()), "clanAbbrev": user.getClanAbbrev(), }
def makeUserItem(user): return {'uid': user.getID(), 'userName': user.getName(), 'chatRoster': user.getRoster(), 'online': user.isOnline(), 'himself': user.isCurrentPlayer(), 'displayName': user.getFullName(), 'colors': g_settings.getColorScheme('rosters').getColors(user.getGuiType()), 'group': user.getGroup(), 'referralType': game_control.g_instance.refSystem.getUserType(user.getID())}
def _getColors(cls, name): if not cls._colors: scheme = g_settings.getColorScheme("contacts") cls._colors = { "friend": scheme.getColors("friend"), "clanMember": scheme.getColors("clanMember"), "others": scheme.getColors("others"), "currentUser": scheme.getColors("currentUser"), } return cls._colors[name]
def sendData(self, data): self._dbID = long(data.dbID) userEntity = self.usersStorage.getUser(self._dbID) if userEntity is None: userProps = {'userName': data.name} else: userProps = ContactConverter.makeBaseUserProps(userEntity) scheme = g_settings.getColorScheme('contacts') userProps['rgb'] = scheme.getColors('clanMember')[0] self.as_setUserPropsS(userProps) return
def _makeVO(self, index, item): isInBattle = item.getState() & UNIT_STATE.IN_ARENA > 0 or item.getState() & UNIT_STATE.IN_QUEUE > 0 or item.getState() & UNIT_STATE.IN_SEARCH > 0 user = self.usersStorage.getUser(item.getCommanderDatabaseID()) if user: colors = g_settings.getColorScheme('rosters').getColors(user.getGuiType()) color = colors[0] if user.isOnline() else colors[1] else: colors = g_settings.getColorScheme(USER_GUI_TYPE.OTHER) color = colors[1] return {'sortieID': item.getID(), 'creatorName': item.getCommanderFullName(), 'divisionName': I18N_FORTIFICATIONS.sortie_division_name(item.getDivisionName()), 'description': self.txtMgr.getText(TextType.STANDARD_TEXT, item.getDescription()), 'isInBattle': isInBattle, 'division': item.getDivision(), 'playersCount': item.itemData.count, 'commandSize': item.itemData.maxCount, 'rallyIndex': index, 'igrType': item.getIgrType(), 'color': color}
def makeUserItem(user): return { 'uid': user.getID(), 'userName': user.getName(), 'chatRoster': user.getRoster(), 'online': user.isOnline(), 'himself': user.isCurrentPlayer(), 'displayName': user.getFullName(), 'colors': g_settings.getColorScheme('rosters').getColors(user.getGuiType()) }
def getMessageColors(self, message): dbID = message.originator mColor = g_settings.getColorScheme('battle/message').getHexStr( 'common') pColorScheme = g_settings.getColorScheme('battle/player') pColor = pColorScheme.getHexStr('unknown') if isCurrentPlayer(dbID): pColor = pColorScheme.getHexStr('himself') else: channel = self.channelsStorage.getChannel(self._teamChannel) if channel and channel.hasMember(dbID): if g_battleContext.isTeamKiller(accID=dbID): pColor = pColorScheme.getHexStr('teamkiller') elif g_battleContext.isSquadMan(accID=dbID): pColor = pColorScheme.getHexStr('squadman') else: pColor = pColorScheme.getHexStr('teammate') elif self._channel.hasMember(dbID): pColor = pColorScheme.getHexStr('enemy') return (pColor, mColor)
def getRecvConfig(self): config = ['', 0, False] receivers = g_settings.battle.receivers if self._receiver in receivers: color = g_settings.getColorScheme('battle/receiver').getHexStr(self._receiver) receiver = receivers[self._receiver]._asdict() byDefault = False if g_settings.userPrefs.storeReceiverInBattle: byDefault = self._receiver == BattleChannelView._lastReceiver config = [receiver['label'] % color, receiver['order'], byDefault] config.extend(receiver['modifiers']) return config
def _buildData(self, candidates): if self.app is not None: isPlayerSpeaking = self.app.voiceChatManager.isPlayerSpeaking else: isPlayerSpeaking = lambda dbID: False userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors mapping = map(lambda pInfo: (pInfo, userGetter(pInfo.dbID)), candidates.itervalues()) sortedList = sorted(mapping, cmp=getUnitCandidatesComparator()) for (pInfo, user,) in sortedList: dbID = pInfo.dbID self._mapping[dbID] = len(self._list) self._list.append(self._makePlayerVO(pInfo, user, colorGetter, isPlayerSpeaking(dbID)))
def updateListItem(self, userDBID): for item in self.collection: creator = item.get('creator', None) if creator is None: return creatorDBID = creator.get('dbID', None) if userDBID == creatorDBID: userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors colors = colorGetter(userGetter(creatorDBID).getGuiType()) creator['colors'] = colors self.refresh() return
def getRecvConfig(self): config = ['', 0, False] receivers = g_settings.battle.receivers if self._receiver in receivers: color = g_settings.getColorScheme('battle/receiver').getHexStr( self._receiver) receiver = receivers[self._receiver]._asdict() byDefault = False if g_settings.userPrefs.storeReceiverInBattle: byDefault = self._receiver == BattleChannelView._lastReceiver config = [receiver['label'] % color, receiver['order'], byDefault] config.extend(receiver['modifiers']) return config
def sendData(self, data): self._dbID = long(data.dbID) userEntity = self.usersStorage.getUser(self._dbID) if userEntity is None: userProps = {'userName': data.name} else: userProps = ContactConverter.makeBaseUserProps(userEntity) scheme = g_settings.getColorScheme('contacts') userProps['rgb'] = scheme.getColors('clanMember')[0] self._note = userEntity.getNote() if userEntity else '' if self._note: self.as_setInputTextS(self._note) self.as_setUserPropsS(userProps)
def updateList(self, selectedID, result): (isFullUpdate, diff,) = (False, []) self._selectedIdx = None userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors ratingFormatter = BigWorld.wg_getIntegralFormat result = set(result) removed = set(filter(lambda item: item[1] is None, result)) isFullUpdate = len(removed) for (cfdUnitID, unitItem,) in removed: index = self.mapping.pop(cfdUnitID, None) if index is not None: self.collection.pop(index) if cfdUnitID == selectedID: self._selectedIdx = -1 self.rebuildIndexes() if isFullUpdate: updated = result.difference(removed) else: updated = result for (cfdUnitID, unitItem,) in updated: try: index = self.mapping[cfdUnitID] item = self.collection[index] except (KeyError, IndexError): LOG_ERROR('Item not found', unitItem) continue creator = unitItem.creator if creator: dbID = creator.dbID creatorVO = makePlayerVO(creator, userGetter(dbID), colorGetter) else: creatorVO = None item.update({'creator': creatorVO, 'rating': ratingFormatter(unitItem.rating), 'playersCount': unitItem.playersCount, 'commandSize': unitItem.commandSize, 'inBattle': unitItem.state.isInArena(), 'isFreezed': unitItem.state.isLocked(), 'isRestricted': unitItem.isRosterSet, 'description': unitItem.description}) diff.append(index) if self._selectedIdx is None and selectedID in self.mapping: self._selectedIdx = self.mapping[selectedID] if isFullUpdate: self.refresh() elif len(diff): self.updateItems(diff) return self._selectedIdx
def _makeAccountsData(self, accounts, playerComparatorType=PREBATTLE_PLAYERS_COMPARATORS.REGULAR): result = [] isPlayerSpeaking = self.bwProto.voipController.isPlayerSpeaking getUser = self.usersStorage.getUser getColors = g_settings.getColorScheme('rosters').getColors accounts = sorted(accounts, cmp=prb_items.getPlayersComparator(playerComparatorType)) for account in accounts: vContourIcon = '' vShortName = '' vLevel = '' vType = '' moduleName = '' badgeVisibility = False user = getUser(account.dbID) if user is not None: key = user.getGuiType() else: key = USER_GUI_TYPE.OTHER if account.isVehicleSpecified(): vehicle = account.getVehicle() badgeVisibility = account.getEnhancementVisibility() if badgeVisibility: moduleName = MODULE_NAME_SEPARATOR.join([ self.__craftmacineConrtoller.getModuleName(module) for module in account.getEnhancementModules() ]) vContourIcon = vehicle.iconContour vShortName = vehicle.shortUserName vLevel = int2roman(vehicle.level) vType = vehicle.type result.append({'accID': account.accID, 'dbID': account.dbID, 'userName': account.name, 'clanAbbrev': account.clanAbbrev, 'region': self.lobbyContext.getRegionCode(account.dbID), 'fullName': account.getFullName(), 'igrType': account.igrType, 'time': account.time, 'isCreator': account.isCreator, 'state': account.state, 'icon': vContourIcon, 'vShortName': vShortName, 'isCurrentPayer': account.isCurrentPlayer(), 'vLevel': vLevel, 'vType': vType, 'tags': list(user.getTags()) if user else [], 'isPlayerSpeaking': isPlayerSpeaking(account.dbID), 'colors': getColors(key), 'isExperimentalModule': bool(badgeVisibility), 'experimentalModuleName': moduleName, 'hasPermissions': False}) return result
def updateListItem(self, userDBID): for item in self.collection: creator = item.get("creator", None) if creator is None: return creatorDBID = creator.get("dbID", None) if userDBID == creatorDBID: userGetter = storage_getter("users")().getUser colorGetter = g_settings.getColorScheme("rosters").getColors colors = colorGetter(userGetter(creatorDBID).getGuiType()) creator["colors"] = colors self.refresh() return return
def _buildData(self, candidates): if self.app is not None: isPlayerSpeaking = self.app.voiceChatManager.isPlayerSpeaking else: isPlayerSpeaking = lambda dbID: False userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors mapping = map(lambda pInfo: (pInfo, userGetter(pInfo.dbID)), candidates.itervalues()) sortedList = sorted(mapping, cmp=getUnitCandidatesComparator()) for pInfo, user in sortedList: dbID = pInfo.dbID self._mapping[dbID] = len(self._list) self._list.append( self._makePlayerVO(pInfo, user, colorGetter, isPlayerSpeaking(dbID)))
def buildList(self, selectedID, result, syncUserInfo=True): self.clear() userGetter = storage_getter("users")().getUser colorGetter = g_settings.getColorScheme("rosters").getColors ratingFormatter = BigWorld.wg_getIntegralFormat self._selectedIdx = -1 self._lastResult = result data = [] for clubItem in result: cfdUnitID = clubItem.getID() creatorID = clubItem.getCreatorID() rating = self.getUserRating(creatorID) creator = self._UserEntityAdapter(creatorID, clubItem, userGetter(creatorID), self) creatorName = creator.getName() creatorVO = makeUserVO(creator, colorGetter) index = len(self.collection) if cfdUnitID == selectedID: self._selectedIdx = index self.mapping[cfdUnitID] = index data.append( ( rating, { "cfdUnitID": cfdUnitID, "unitMgrID": cfdUnitID, "creator": creatorVO, "creatorName": creatorName, "rating": self.getGuiUserRating(creatorID), "playersCount": clubItem.getMembersCount(), "commandSize": clubItem.getCommandSize(), "inBattle": False, "isFreezed": False, "isRestricted": False, "description": html.escape(clubItem.getShortDescription()), "peripheryID": -1, "server": None, "ladderIcon": getLadderChevron16x16(clubItem.getDivision()), "isStatic": True, }, ) ) self.collection.extend(map(lambda (r, c): c, sorted(data, reverse=True, key=operator.itemgetter(0)))) if syncUserInfo: self.syncUsersInfo() return self._selectedIdx
def __addMessage(self, message): with self.viewModel.transaction() as model: messagesArray = model.getMessages() guiType = LobbyMessageBuilder().setGuiType( message.accountDBID).getGuiType() colorScheme = g_settings.getColorScheme('rosters') msgModel = ChatMessageModel() msgModel.text.setText(message.text) msgModel.text.setColor(colorScheme.getHexStr('squad_message')) msgModel.playerName.setText(message.accountName) msgModel.playerName.setColor(colorScheme.getHexStr(guiType)) if message.sentAt: msgModel.timeStamp.setText( TimeFormatter.getMessageTimeFormat(message.sentAt)) msgModel.timeStamp.setColor(colorScheme.getHexStr(guiType)) msgModel.setKey(self.__messageCount) self.__messageCount += 1 messagesArray.addViewModel(msgModel) messagesArray.invalidate()
def buildList(self, members): self.__list = [] members = sorted(members, key=lambda member: member.getName().lower()) getUser = self.usersStorage.getUser getColors = g_settings.getColorScheme('rosters').getColors for member in members: dbID = member.getDatabaseID() isOnline = member.isOnline() user = getUser(dbID) if user: tags = list(user.getTags()) colors = getColors(user.getGuiType()) else: tags = [] colors = getColors(USER_GUI_TYPE.OTHER) self.__list.append({'dbID': dbID, 'userName': member.getFullName(), 'isOnline': isOnline, 'color': colors[0 if isOnline else 1], 'tags': tags, 'isPlayerSpeaking': False})
def _makeAccountsData(self, accounts): result = [] isPlayerSpeaking = self.app.voiceChatManager.isPlayerSpeaking getUser = self.usersStorage.getUser getColors = g_settings.getColorScheme('rosters').getColors accounts = sorted(accounts, cmp=info.getPlayersComparator()) for account in accounts: vContourIcon = '' vShortName = '' vLevel = '' vType = '' user = getUser(account.dbID) if user is not None: key = user.getGuiType() else: key = USER_GUI_TYPE.OTHER if account.isVehicleSpecified(): vehicle = account.getVehicle() vContourIcon = vehicle.iconContour vShortName = vehicle.shortUserName vLevel = int2roman(vehicle.level) vType = vehicle.type result.append({'accID': account.accID, 'uid': account.dbID, 'userName': account.name, 'fullName': account.getFullName(), 'time': account.time, 'himself': account.isCurrentPlayer(), 'isCreator': account.isCreator, 'state': account.state, 'icon': vContourIcon, 'vShortName': vShortName, 'vLevel': vLevel, 'vType': vType, 'chatRoster': user.getRoster() if user else 0, 'isPlayerSpeaking': isPlayerSpeaking(account.dbID), 'colors': getColors(key)}) return result
def _makeVO(self, index, item): isInBattle = item.getFlags() & UNIT_FLAGS.IN_ARENA > 0 or item.getFlags() & UNIT_FLAGS.IN_QUEUE > 0 or item.getFlags() & UNIT_FLAGS.IN_SEARCH > 0 user = self.usersStorage.getUser(item.getCommanderDatabaseID()) scheme = g_settings.getColorScheme('rosters') if user: colors = scheme.getColors(user.getGuiType()) color = colors[0] if user.isOnline() else colors[1] else: colors = scheme.getColors(USER_GUI_TYPE.OTHER) color = colors[1] return {'sortieID': item.getID(), 'creatorName': item.getCommanderFullName(), 'divisionName': I18N_FORTIFICATIONS.sortie_division_name(item.getDivisionName()), 'description': text_styles.standard(item.getDescription()), 'descriptionForTT': item.getDescription(), 'isInBattle': isInBattle, 'division': item.getDivision(), 'playersCount': item.itemData.count, 'commandSize': item.itemData.maxCount, 'rallyIndex': index, 'igrType': item.getIgrType(), 'color': color}
def buildList(self, members): self.__list = [] members = sorted(members, key=lambda member: member.getName().lower()) getUser = self.usersStorage.getUser getColor = g_settings.getColorScheme('rosters').getColor for member in members: dbID = member.getID() user = getUser(dbID) if user: roster = user.getRoster() himself = user.isCurrentPlayer() color = getColor(user.getGuiType()) else: roster = 0 himself = False color = getColor(USER_GUI_TYPE.OTHER) self.__list.append({ 'uid': dbID, 'userName': member.getFullName(), 'color': color, 'chatRoster': roster, 'himself': himself, 'isPlayerSpeaking': False })
def _getSlotsData(unitMgrID, fullData, app=None, levelsRange=None, checkForVehicles=True, maxPlayerCount=MAX_PLAYER_COUNT_ALL): pInfo = fullData.playerInfo isPlayerCreator = pInfo.isCommander() isPlayerInSlot = pInfo.isInSlot slots = [] userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors itemsCache = dependency.instance(IItemsCache) vehicleGetter = itemsCache.items.getItemByCD canTakeSlot = not pInfo.isLegionary() bwPlugin = proto_getter(PROTO_TYPE.BW_CHAT2)(None) isPlayerSpeaking = bwPlugin.voipController.isPlayerSpeaking unit = fullData.unit makeVO = makePlayerVO rosterSlots = {} isDefaultSlot = False if unit is not None: roster = unit.getRoster() rosterSlots = roster.slots isDefaultSlot = roster.isDefaultSlot unitState = fullData.flags playerCount = 0 for slotInfo in fullData.slotsIterator: index = slotInfo.index slotState = slotInfo.state player = slotInfo.player vehicle = slotInfo.vehicle canAssign, vehicles = pInfo.canAssignToSlot(index) vehCount = len(vehicles) slotLevel = 0 vehicleVO = None slotPlayerUI = None if player is not None: dbID = player.dbID slotPlayerUI = makeVO(player, userGetter(dbID), colorGetter, isPlayerSpeaking(dbID)) isCurrentPlayer = player.isCurrentPlayer() if vehicle: slotLevel = vehicle.vehLevel if vehicle.vehTypeCompDescr: vehicleVO = makeVehicleVO(vehicleGetter( vehicle.vehTypeCompDescr), levelsRange, isCurrentPlayer=isCurrentPlayer) isRequired = False slotLabel = makeSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles, isRequired=isRequired) if unit.isPrebattlesSquad(): playerStatus = getSquadPlayerStatus(slotState, player) else: playerStatus = getPlayerStatus(slotState, player) if unit is not None: restrictions = makeUnitRosterConditions(rosterSlots, isDefaultSlot, index=index, levelsRange=levelsRange) else: restrictions = [] rating = '' isLegionaries = False role = 0 if player is not None: isLegionaries = player.isLegionary() rating = BigWorld.wg_getIntegralFormat(player.rating) role = player.role if maxPlayerCount == MAX_PLAYER_COUNT_ALL or playerCount < maxPlayerCount: isLocked = False else: isLocked = True slot = { 'rallyIdx': unitMgrID, 'isCommanderState': isPlayerCreator, 'isCurrentUserInSlot': isPlayerInSlot, 'playerStatus': playerStatus, 'isClosed': slotState.isClosed, 'isFreezed': unitState.isFreezed(), 'slotLabel': slotLabel, 'player': slotPlayerUI, 'canBeTaken': canAssign and canTakeSlot, 'compatibleVehiclesCount': vehCount, 'selectedVehicle': vehicleVO, 'selectedVehicleLevel': 1 if slotState.isClosed else slotLevel, 'restrictions': restrictions, 'isFallout': False, 'rating': rating, 'isLegionaries': isLegionaries, 'isLocked': isLocked, 'role': role } if unit.isSquad(): eventsCache = dependency.instance(IEventsCache) if eventsCache.isBalancedSquadEnabled(): isVisibleAdtMsg = player and player.isCurrentPlayer( ) and not isPlayerCreator and not vehicle and unit and bool( unit.getVehicles()) if isVisibleAdtMsg: rangeString = toRomanRangeString(levelsRange, 1) additionMsg = text_styles.main( i18n.makeString( MESSENGER.DIALOGS_SIMPLESQUAD_VEHICLELEVEL, level=rangeString)) else: additionMsg = '' slot.update({ 'isVisibleAdtMsg': isVisibleAdtMsg, 'additionalMsg': additionMsg }) elif eventsCache.isSquadXpFactorsEnabled(): vehicles = unit.getVehicles() levels = unit.getSelectedVehicleLevels() isVisibleAdtMsg = False additionalMsg = '' unitHasXpBonus = True unitHasXpPenalty = False if vehicles: distance = levels[-1] - levels[0] unitHasXpBonus = distance in eventsCache.getSquadBonusLevelDistance( ) unitHasXpPenalty = distance in eventsCache.getSquadPenaltyLevelDistance( ) isVisibleAdtMsg = unitHasXpBonus and player and player.isCurrentPlayer( ) and not vehicle if isVisibleAdtMsg: maxDistance = max( eventsCache.getSquadBonusLevelDistance()) minLevel = max(MIN_VEHICLE_LEVEL, levels[0] - maxDistance) maxLevel = min(MAX_VEHICLE_LEVEL, levels[0] + maxDistance) rangeString = toRomanRangeString( range(minLevel, maxLevel + 1), 1) additionalMsg = text_styles.main( i18n.makeString( MESSENGER.DIALOGS_SIMPLESQUAD_VEHICLELEVEL, level=rangeString)) slotNotificationIcon = '' slotNotificationIconTooltip = '' if vehicle: if unitHasXpPenalty: slotNotificationIcon = RES_ICONS.MAPS_ICONS_LIBRARY_CYBERSPORT_ALERTICON slotNotificationIconTooltip = makeTooltip( TOOLTIPS. SQUADWINDOW_SIMPLESLOTNOTIFICATION_ALERT_HEADER, TOOLTIPS. SQUADWINDOW_SIMPLESLOTNOTIFICATION_ALERT_BODY, None, TOOLTIPS. SQUADWINDOW_SIMPLESLOTNOTIFICATION_ALERT_ALERT) elif not unitHasXpBonus: slotNotificationIcon = RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICON slotNotificationIconTooltip = makeTooltip( TOOLTIPS. SQUADWINDOW_SIMPLESLOTNOTIFICATION_INFO_HEADER, TOOLTIPS. SQUADWINDOW_SIMPLESLOTNOTIFICATION_INFO_BODY) slot.update({ 'isVisibleAdtMsg': isVisibleAdtMsg, 'additionalMsg': additionalMsg, 'slotNotificationIconTooltip': slotNotificationIconTooltip, 'slotNotificationIcon': slotNotificationIcon }) if unit.isEvent(): isVisibleAdtMsg = player and player.isCurrentPlayer( ) and not vehicle additionMsg = '' if isVisibleAdtMsg: eventsCache = dependency.instance(IEventsCache) vehiclesNames = [ veh.userName for veh in eventsCache.getEventVehicles() ] additionMsg = text_styles.main( i18n.makeString(MESSENGER.DIALOGS_EVENTSQUAD_VEHICLE, vehName=', '.join(vehiclesNames))) slot.update({ 'isVisibleAdtMsg': isVisibleAdtMsg, 'additionalMsg': additionMsg }) slots.append(slot) playerCount += 1 return slots
def _getSlotsData(unitIdx, unit, unitState, pInfo, slotsIter, app=None, levelsRange=None, checkForVehicles=True): isPlayerCreator = pInfo.isCreator() isPlayerInSlot = pInfo.isInSlot slots = [] userGetter = storage_getter('users')().getUser colorGetter = g_settings.getColorScheme('rosters').getColors vehicleGetter = g_itemsCache.items.getItemByCD canTakeSlot = not pInfo.isLegionary() if app: isPlayerSpeaking = app.voiceChatManager.isPlayerSpeaking else: isPlayerSpeaking = lambda dbID: False if unit.isSquad(): falloutBattleType = unit.getExtra().eventType isFallout = falloutBattleType != FALLOUT_BATTLE_TYPE.UNDEFINED falloutCfg = g_eventsCache.getFalloutConfig(falloutBattleType) else: falloutBattleType = FALLOUT_BATTLE_TYPE.UNDEFINED isFallout = False falloutCfg = None if unit is None: makeVO = makePlayerVO elif unit.isFortBattle(): makeVO = makeClanBattlePlayerVO elif unit.isSortie(): makeVO = makeSortiePlayerVO elif unit.isClub(): makeVO = makeStaticFormationPlayerVO else: makeVO = makePlayerVO for slotInfo in slotsIter: index = slotInfo.index slotState = slotInfo.state player = slotInfo.player vehicle = slotInfo.vehicle canAssign, vehicles = pInfo.canAssignToSlot(index) vehCount = len(vehicles) slotLevel = 0 vehicleVO = None slotPlayerUI = None if player is not None: dbID = player.dbID slotPlayerUI = makeVO(player, userGetter(dbID), colorGetter, isPlayerSpeaking(dbID)) isCurrentPlayer = player.isCurrentPlayer() if vehicle: if 'vehLevel' in vehicle: slotLevel = vehicle['vehLevel'] if 'vehTypeCompDescr' in vehicle: vehicleVO = makeVehicleVO(vehicleGetter( vehicle['vehTypeCompDescr']), levelsRange, isCurrentPlayer=isCurrentPlayer) if unit is not None and unit.isClub(): slotLabel = makeStaticSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles, pInfo.isLegionary(), unit.isRated()) else: isRequired = falloutBattleType == FALLOUT_BATTLE_TYPE.MULTITEAM slotLabel = makeSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles, isRequired=isRequired) if unit.isSquad(): playerStatus = getSquadPlayerStatus(slotState, player) else: playerStatus = getPlayerStatus(slotState, player) if unit is not None: restrictions = makeUnitRosterVO( unit, pInfo, index=index, isSortie=unit.isSortie(), levelsRange=levelsRange)['conditions'] else: restrictions = [] slot = { 'rallyIdx': unitIdx, 'isCommanderState': isPlayerCreator, 'isCurrentUserInSlot': isPlayerInSlot, 'playerStatus': playerStatus, 'isClosed': slotState.isClosed, 'isFreezed': unitState.isFreezed(), 'slotLabel': slotLabel, 'player': slotPlayerUI, 'canBeTaken': canAssign and canTakeSlot, 'compatibleVehiclesCount': vehCount, 'selectedVehicle': vehicleVO, 'selectedVehicleLevel': 1 if slotState.isClosed else slotLevel, 'restrictions': restrictions, 'isFallout': isFallout } if isFallout: vehiclesNotify = [None, None, None] selectedVehicles = [None, None, None] if player is not None: dbID = player.dbID isCurrentPlayer = player.isCurrentPlayer() if isCurrentPlayer: if falloutBattleType == FALLOUT_BATTLE_TYPE.MULTITEAM: vehiclesNotify[0] = [ i18n.makeString( MESSENGER. DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYMULTITEAM ) ] else: vehiclesNotify[0] = [ i18n.makeString( MESSENGER. DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFY, level=text_styles.main( int2roman( falloutCfg.vehicleLevelRequired))) ] if len(falloutCfg.allowedLevels) > 1: statusTemplate = i18n.makeString( MESSENGER. DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYRANGE, level=text_styles.main( toRomanRangeString( list(falloutCfg.allowedLevels), 1))) else: statusTemplate = i18n.makeString( MESSENGER. DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYMULTITEAM) for slotIdx in range(1, falloutCfg.minVehiclesPerPlayer): vehiclesNotify[slotIdx] = statusTemplate for idx, (vInvID, vehIntCD) in enumerate( unit.getExtra().accountVehicles.get(dbID, ())): selectedVehicles[idx] = makeVehicleVO( vehicleGetter(vehIntCD), falloutCfg.allowedLevels, isCurrentPlayer=isCurrentPlayer) slot['vehiclesNotify'] = vehiclesNotify slot['selectedVehicle'] = selectedVehicles slots.append(slot) return slots