def _showAward(self, ctx): _, message = ctx for dataForVehicle in message.data.values(): arenaTypeID = dataForVehicle.get('arenaTypeID', 0) if arenaTypeID > 0 and arenaTypeID in ArenaType.g_cache: arenaType = ArenaType.g_cache[arenaTypeID] else: arenaType = None arenaCreateTime = dataForVehicle.get('arenaCreateTime', None) fairplayViolations = dataForVehicle.get('fairplayViolations', None) if arenaCreateTime and arenaType and fairplayViolations is not None and fairplayViolations[:2] != (0, 0): penaltyType = None violation = None if fairplayViolations[1] != 0: penaltyType = 'penalty' violation = fairplayViolations[1] elif fairplayViolations[0] != 0: penaltyType = 'warning' violation = fairplayViolations[0] from gui.DialogsInterface import showDialog showDialog(I18PunishmentDialogMeta('punishmentWindow', None, {'penaltyType': penaltyType, 'arenaName': i18n.makeString(arenaType.name), 'time': TimeFormatter.getActualMsgTimeStr(arenaCreateTime), 'reason': i18n.makeString(DIALOGS.all('punishmentWindow/reason/%s' % getFairPlayViolationName(violation)))}), lambda *args: None) return
def format(self, message, callback): isSynced = yield self._waitForSyncItems() formatted, settings = (None, None) if isSynced: data = message.data or {} completedQuestIDs = self.getQuestOfThisGroup( data.get('completedQuestIDs', set())) questsData = getRewardsForQuests( message, self.getQuestOfThisGroup(completedQuestIDs)) questsData['popUpRecords'] = self.getPopUps(message) fmt = self._achievesFormatter.formatQuestAchieves( questsData, asBattleFormatter=False) if fmt is not None: operationTime = message.sentTime if operationTime: fDatetime = TimeFormatter.getLongDatetimeFormat( time_utils.makeLocalServerTime(operationTime)) else: fDatetime = 'N/A' formatted = g_settings.msgTemplates.format( self.__TEMPLATE_NAME, ctx={ 'at': fDatetime, 'desc': '', 'op': fmt }) settings = self._getGuiSettings(message, self.__TEMPLATE_NAME) callback([MessageData(formatted, settings)]) return
def _showAward(self, ctx): _, message = ctx arenaTypeID = message.data.get('arenaTypeID', 0) if arenaTypeID > 0 and arenaTypeID in ArenaType.g_cache: arenaType = ArenaType.g_cache[arenaTypeID] else: arenaType = None arenaCreateTime = message.data.get('arenaCreateTime', None) fairplayViolations = message.data.get('fairplayViolations', None) if arenaCreateTime and arenaType and fairplayViolations is not None and fairplayViolations[:2] != ( 0, 0): penaltyType = None violation = None if fairplayViolations[1] != 0: penaltyType = 'penalty' violation = fairplayViolations[1] elif fairplayViolations[0] != 0: penaltyType = 'warning' violation = fairplayViolations[0] showDialog( I18PunishmentDialogMeta( 'punishmentWindow', None, { 'penaltyType': penaltyType, 'arenaName': i18n.makeString(arenaType.name), 'time': TimeFormatter.getActualMsgTimeStr(arenaCreateTime), 'reason': i18n.makeString( DIALOGS.all('punishmentWindow/reason/%s' % getFairPlayViolationName(violation))) }), lambda *args: None) return
def _format(self, message): group = message.group dbID = message.originator if CHAT_MEMBER_GROUP.member.index() == group or isCurrentPlayer(dbID): key = self.usersStorage.getUserGuiType(dbID) else: key = CHAT_MEMBER_GROUP[group].name() playerName = g_lobbyContext.getPlayerFullName(message.originatorNickName, pDBID=dbID) return g_settings.lobby.getMessageFormat(key).format(playerName, TimeFormatter.getMessageTimeFormat(message.time), message.data)
def _format(self, message): group = message.group dbID = message.originator if CHAT_MEMBER_GROUP.member.index() == group or isCurrentPlayer(dbID): key = self.usersStorage.getUserGuiType(dbID) else: key = CHAT_MEMBER_GROUP[group].name() playerName = g_lobbyContext.getPlayerFullName( message.originatorNickName, pDBID=dbID) return g_settings.lobby.getMessageFormat(key).format( playerName, TimeFormatter.getMessageTimeFormat(message.time), message.data)
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 _showAward(self, ctx): _, message = ctx arenaTypeID = message.data.get("arenaTypeID", 0) if arenaTypeID > 0 and arenaTypeID in ArenaType.g_cache: arenaType = ArenaType.g_cache[arenaTypeID] else: arenaType = None arenaCreateTime = message.data.get("arenaCreateTime", None) fairplayViolations = message.data.get("fairplayViolations", None) if arenaCreateTime and arenaType and fairplayViolations is not None and fairplayViolations[:2] != (0, 0): penaltyType = None violation = None if fairplayViolations[1] != 0: penaltyType = "penalty" violation = fairplayViolations[1] elif fairplayViolations[0] != 0: penaltyType = "warning" violation = fairplayViolations[0] from gui.DialogsInterface import showDialog showDialog( I18PunishmentDialogMeta( "punishmentWindow", None, { "penaltyType": penaltyType, "arenaName": i18n.makeString(arenaType.name), "time": TimeFormatter.getActualMsgTimeStr(arenaCreateTime), "reason": i18n.makeString( DIALOGS.all("punishmentWindow/reason/%s" % getFairPlayViolationName(violation)) ), }, ), lambda *args: None, ) return
def getMessageActualTime(self, msTime): return TimeFormatter.getActualMsgTimeStr(msTime)
def getMessageActualTime(self, msTime): """ Is called from AS. Gets formatted actual message time. """ return TimeFormatter.getActualMsgTimeStr(msTime)
def setTime(self, time_): self.__time = TimeFormatter.getMessageTimeFormat(time_) return self
def __pushEnabled(self): expiryTime = self.__battlePassController.getSeasonFinishTime() SystemMessages.pushMessage(text=backport.text(R.strings.system_messages.battlePass.switch_enabled.body(), expiryTime=text_styles.titleFont(TimeFormatter.getLongDatetimeFormat(expiryTime))), type=SystemMessages.SM_TYPE.Warning)
def __formatTime(): operationTime = time_utils.getCurrentLocalServerTimestamp() return TimeFormatter.getLongDatetimeFormat(operationTime) if operationTime else 'N/A'
def getConvertedDateTime(self, time): return TimeFormatter.getShortDatetimeFormat( time_utils.makeLocalServerTime(time))