def getUnitMessage(errorCode, errorString): errorName = UNIT_ERROR_NAMES[errorCode] if errorCode in UNIT_ERRORS_TRANSLATE_AS_WARNINGS: msgType = SystemMessages.SM_TYPE.Warning errorKey = SYSTEM_MESSAGES.unit_warnings(errorName) else: msgType = SystemMessages.SM_TYPE.Error errorKey = SYSTEM_MESSAGES.unit_errors(errorName) if errorKey is not None: msgBody = i18n.makeString(errorKey) else: msgBody = errorName + '\n' + errorString return (msgType, msgBody)
def dropCurrentItemInSection(self, section, kind): if g_currentVehicle.isLocked(): SystemMessages.pushI18nMessage( SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error) return elif g_currentVehicle.isBroken(): SystemMessages.pushI18nMessage( SYSTEM_MESSAGES.customization_vehicle( g_currentVehicle.item.getState()), type=SystemMessages.SM_TYPE.Error) return else: dialog = 'customization/{0:>s}Drop'.format(section) isConfirmed = yield DialogsInterface.showI18nConfirmDialog(dialog) if isConfirmed: interface = self.__interfaces.get(section) if interface is not None: self.__returnHangar = False self.__lockUpdate = True Waiting.show('customizationDrop') interface.drop(g_currentVehicle.invID, kind) else: LOG_ERROR('Drop operation, section not found', section) return
def _onKickedWhileLogin(self, peripheryID): Waiting.hide('login') messageType = 'another_periphery' if peripheryID else 'checkout_error' self.as_setErrorMessageS(_ms(SYSTEM_MESSAGES.all(messageType)), INVALID_FIELDS.ALL_VALID) if not self.__loginRetryDialogShown: self.__showLoginRetryDialog({'waitingOpen': WAITING.titles(messageType), 'waitingClose': WAITING.BUTTONS_CEASE, 'message': _ms(WAITING.message(messageType), connectionManager.serverUserName)})
def getUnitBrowserMessage(errorCode, errorString): errorName = UNIT_BROWSER_ERROR_NAMES[errorCode] errorKey = SYSTEM_MESSAGES.unitbrowser_errors(errorName) if errorKey is not None: msgBody = i18n.makeString(errorKey) else: msgBody = errorName + '\n' + errorString return (SystemMessages.SM_TYPE.Error, msgBody)
def lookupName(self, rqTypeID): requestName = rqTypeID if rqTypeID in FORT_REQUEST_TYPE_NAMES: requestName = I18N_SYSTEM_MESSAGES.fortification_request_name(FORT_REQUEST_TYPE_NAMES[rqTypeID]) requestName = i18n.makeString(requestName) else: LOG_WARNING('Request type is not found', rqTypeID) return requestName
def lookupName(self, rqTypeID): requestName = rqTypeID if rqTypeID in REQUEST_TYPE_NAMES: requestName = I18N_SYSTEM_MESSAGES.prebattle_request_name(REQUEST_TYPE_NAMES[rqTypeID]) requestName = i18n.makeString(requestName) else: LOG_WARNING('Request type is not found', rqTypeID) return requestName
def __sendNotification(self, status): msgType = SM_TYPE.Information if status == 'available' else SM_TYPE.Warning if constants.IS_CHINA: if not self.__useFreeXP: status += '_gold' elif not self.__useGold: status += '_freexp' SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.getWalletStatus(status), type=msgType)
def getFortErrorMessage(errorCode, errorString): if errorCode in FORT_ERROR_NAMES: errorName = FORT_ERROR_NAMES[errorCode] i18nKey = I18N_SM.fortification_errors(FORT_ERROR_NAMES[errorCode]) else: errorName = str(errorCode) i18nKey = I18N_SM.FORTIFICATION_ERRORS_UNKNOWN if i18nKey is not None: msg = i18n.makeString(i18nKey) else: msg = errorName + '\n' + errorString return msg
def onUnitRosterChanged(self): super(FortBattleRoomWindow, self).onUnitRosterChanged() chat = self.chat if chat: _, unit = self.unitFunctional.getUnit() commanderID = unit.getCommanderDBID() if commanderID != getPlayerDatabaseID(): getter = storage_getter('users') commander = getter().getUser(commanderID) division = getDivisionNameByUnit(unit) divisionName = i18n.makeString(I18N_SYSTEM_MESSAGES.unit_notification_divisiontype(division)) key = I18N_SYSTEM_MESSAGES.UNIT_NOTIFICATION_CHANGEDIVISION txt = i18n.makeString(key, name=commander.getName(), division=divisionName) chat.addNotification(txt)
def handleKickWhileLogin(self, peripheryID): if peripheryID < 0: self.__kickPeripheryID = peripheryID return g_preDefinedHosts.savePeripheryTL(peripheryID) self.__kickedFromServer = True messageType = 'another_periphery' if peripheryID else 'checkout_error' errorMessage = i18n.makeString(SYSTEM_MESSAGES.all(messageType)) self.onSetStatus(errorMessage, self.ALL_VALID) urls = g_preDefinedHosts.urlIterator(self.__loginDataLoader.host) if urls is not None and urls.end(): urls.cursor = 0 message = i18n.makeString(WAITING.message(messageType), connectionManager.serverUserName) self.onHandleKickWhileLogin(messageType, message) self.__setAutoLoginTimer(self.__getLgNextTimeout())
def lookupName(self, rqTypeID): """ Name for prebattle request action. Args: rqTypeID: request type identifier Returns: name for prebattle request """ requestName = rqTypeID if rqTypeID in REQUEST_TYPE_NAMES: requestName = I18N_SYSTEM_MESSAGES.prebattle_request_name( REQUEST_TYPE_NAMES[rqTypeID]) requestName = i18n.makeString(requestName) else: LOG_WARNING('Request type is not found', rqTypeID) return requestName
def onUnitRosterChanged(self): super(FortBattleRoomWindow, self).onUnitRosterChanged() chat = self.chat if chat: _, unit = self.unitFunctional.getUnit() commanderID = unit.getCommanderDBID() if commanderID != getPlayerDatabaseID(): getter = storage_getter('users') commander = getter().getUser(commanderID) division = getDivisionNameByUnit(unit) divisionName = i18n.makeString( I18N_SYSTEM_MESSAGES.unit_notification_divisiontype( division)) key = I18N_SYSTEM_MESSAGES.UNIT_NOTIFICATION_CHANGEDIVISION txt = i18n.makeString(key, name=commander.getName(), division=divisionName) chat.addNotification(txt)
def dropCurrentItemInSection(self, section, kind): if g_currentVehicle.isLocked(): SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error) return elif g_currentVehicle.isBroken(): SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.customization_vehicle(g_currentVehicle.item.getState()), type=SystemMessages.SM_TYPE.Error) return else: dialog = 'customization/{0:>s}Drop'.format(section) isConfirmed = yield DialogsInterface.showI18nConfirmDialog(dialog) if isConfirmed: interface = self.__interfaces.get(section) if interface is not None: self.__returnHangar = False self.__lockUpdate = True Waiting.show('customizationDrop') interface.drop(g_currentVehicle.invID, kind) else: LOG_ERROR('Drop operation, section not found', section) return
def applyCustomization(self, sections): if g_currentVehicle.isLocked(): SystemMessages.pushI18nMessage( SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error) yield lambda callback=None: callback if g_currentVehicle.isBroken(): SystemMessages.pushI18nMessage( SYSTEM_MESSAGES.customization_vehicle( g_currentVehicle.item.getState()), type=SystemMessages.SM_TYPE.Error) yield lambda callback=None: callback notSelected = [] selected = [] remove = [] selectedNames = [] totalGold = 0 totalCredits = 0 newItemsByType = defaultdict(list) for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: newItems = interface.getNewItems() if newItems is not None: self.__updateNewItemsByType(newItemsByType, newItems, interface._type) for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: newItems = interface.getNewItems() if newItems is not None: removeStr = None hasMatches = self.__hasNewItemsDuplicates( newItemsByType, newItems, interface._type) if not hasMatches: costValue = interface.getSelectedItemCost() if isinstance(costValue, list): for price in costValue: cost = price.get('cost') isGold = price.get('isGold') if cost > 0: if isGold and section.isGold: totalGold += cost elif not isGold and not section.isGold: totalCredits += cost else: cost, isGold = costValue if cost > 0: if isGold: totalGold += cost else: totalCredits += cost if section.sectionName not in selectedNames: selected.append( i18n.makeString( '#menu:customization/change/{0:>s}'.format( section.sectionName))) selectedNames.append(section.sectionName) removeStr = interface.getCurrentItemRemoveStr() if removeStr is not None: remove.extend(removeStr) else: notSelected.append( i18n.makeString( '#menu:customization/items/{0:>s}'.format( section.sectionName))) else: LOG_ERROR('Section not found', section.sectionName) if len(notSelected) > 0: DialogsInterface.showI18nInfoDialog( 'customization/selectNewItems', lambda success: None, I18nInfoDialogMeta( 'customization/selectNewItems', messageCtx={'items': ', '.join(notSelected)})) yield lambda callback=None: callback if totalGold or totalCredits: titleKey = DIALOGS.CUSTOMIZATION_CHANGECONFIRMATION_BUY else: titleKey = DIALOGS.CUSTOMIZATION_CHANGECONFIRMATION_CHANGE isConfirmed = yield DialogsInterface.showDialog( I18nConfirmDialogMeta( 'customization/changeConfirmation', titleCtx={'action': i18n.makeString(titleKey)}, messageCtx={ 'selected': ', '.join(selected), 'remove': '\n'.join(remove) })) if isConfirmed: creditsNotEnough = totalCredits > self.__credits goldNotEnough = totalGold > self.__gold if creditsNotEnough or goldNotEnough: if creditsNotEnough and goldNotEnough: key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_AND_GOLD_NOT_ENOUGH elif goldNotEnough: key = SYSTEM_MESSAGES.CUSTOMIZATION_GOLD_NOT_ENOUGH else: key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_NOT_ENOUGH SystemMessages.pushI18nMessage( key, type=SystemMessages.SM_TYPE.Error) yield lambda callback=None: callback self.__returnHangar = True vehInvID = g_currentVehicle.invID self.__steps = 0 self.__messages = [] self.flashObject.applyButton.disabled = True if len(sections) > 0: Waiting.show('customizationApply') self.__lockUpdate = True selectedNames = [] for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: newItems = interface.getNewItems() if newItems is not None: hasMatches = self.__hasNewItemsDuplicates( newItemsByType, newItems, interface._type) self.__steps += interface.getSelectedItemsCount( section.isGold) if section.sectionName not in selectedNames: interface.change(vehInvID, section, hasMatches) selectedNames.append(section.sectionName) else: LOG_ERROR('Change operation, section not found', section) self.__steps -= 1 if not self.__steps: self.__onServerResponsesReceived() return
def getUnitKickedReasonMessage(reasonStr): return i18n.makeString(SYSTEM_MESSAGES.unit_warnings(reasonStr))
def applyCustomization(self, sections): if g_currentVehicle.isLocked(): SystemMessages.pushI18nMessage( SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error) yield lambda callback=None: callback if g_currentVehicle.isBroken(): SystemMessages.pushI18nMessage( SYSTEM_MESSAGES.customization_vehicle( g_currentVehicle.item.getState()), type=SystemMessages.SM_TYPE.Error) yield lambda callback=None: callback notSelected = [] selected = [] remove = [] selectedNames = [] totalGold = 0 totalCredits = 0 for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: if interface.isNewItemSelected(): costValue = interface.getSelectedItemCost() if type(costValue) is list: for price in costValue: cost = price.get('cost') isGold = price.get('isGold') if cost > 0: if isGold and section.isGold: totalGold += cost elif not isGold and not section.isGold: totalCredits += cost else: cost, isGold = costValue if cost > 0: if isGold: totalGold += cost else: totalCredits += cost if section.sectionName not in selectedNames: selected.append( i18n.makeString( '#menu:customization/change/{0:>s}'.format( section.sectionName))) selectedNames.append(section.sectionName) if interface.isCurrentItemRemove(): remove.append( gui.makeHtmlString( 'html_templates:lobby/customization', 'remove-{0:>s}'.format(section.sectionName))) else: notSelected.append( i18n.makeString( '#menu:customization/items/{0:>s}'.format( section.sectionName))) else: LOG_ERROR('Section not found', section.sectionName) if len(notSelected) > 0: DialogsInterface.showI18nInfoDialog( 'customization/selectNewItems', lambda success: None, I18nInfoDialogMeta( 'customization/selectNewItems', messageCtx={'items': ', '.join(notSelected)})) yield lambda callback=None: callback isConfirmed = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('customization/changeConfirmation', messageCtx={ 'selected': ', '.join(selected), 'remove': '\n'.join(remove) })) if isConfirmed: creditsNotEnough = totalCredits > self.__credits goldNotEnough = totalGold > self.__gold if creditsNotEnough or goldNotEnough: if creditsNotEnough and goldNotEnough: key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_AND_GOLD_NOT_ENOUGH elif goldNotEnough: key = SYSTEM_MESSAGES.CUSTOMIZATION_GOLD_NOT_ENOUGH else: key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_NOT_ENOUGH SystemMessages.pushI18nMessage( key, type=SystemMessages.SM_TYPE.Error) yield lambda callback=None: callback self.__returnHangar = True vehInvID = g_currentVehicle.invID self.__steps = 0 self.__messages = [] self.flashObject.applyButton.disabled = True if len(sections) > 0: Waiting.show('customizationApply') self.__lockUpdate = True selectedNames = [] for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: self.__steps += interface.getSelectedItemsCount( section.isGold) if section.sectionName not in selectedNames: interface.change(vehInvID, section) selectedNames.append(section.sectionName) else: LOG_ERROR('Change operation, section not found', section) self.__steps -= 1 if not self.__steps: self.__onServerResponsesReceived() return
def getUnitPlayerNotification(key, pInfo): return i18n.makeString(SYSTEM_MESSAGES.unit_notification(key), userName=pInfo.getFullName())
def applyCustomization(self, sections): if g_currentVehicle.isLocked(): SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error) yield lambda callback = None: callback if g_currentVehicle.isBroken(): SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.customization_vehicle(g_currentVehicle.item.getState()), type=SystemMessages.SM_TYPE.Error) yield lambda callback = None: callback notSelected = [] selected = [] remove = [] selectedNames = [] totalGold = 0 totalCredits = 0 for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: if interface.isNewItemSelected(): costValue = interface.getSelectedItemCost() if type(costValue) is list: for price in costValue: cost = price.get('cost') isGold = price.get('isGold') if cost > 0: if isGold and section.isGold: totalGold += cost elif not isGold and not section.isGold: totalCredits += cost else: cost, isGold = costValue if cost > 0: if isGold: totalGold += cost else: totalCredits += cost if section.sectionName not in selectedNames: selected.append(i18n.makeString('#menu:customization/change/{0:>s}'.format(section.sectionName))) selectedNames.append(section.sectionName) if interface.isCurrentItemRemove(): remove.append(gui.makeHtmlString('html_templates:lobby/customization', 'remove-{0:>s}'.format(section.sectionName))) else: notSelected.append(i18n.makeString('#menu:customization/items/{0:>s}'.format(section.sectionName))) else: LOG_ERROR('Section not found', section.sectionName) if len(notSelected) > 0: DialogsInterface.showI18nInfoDialog('customization/selectNewItems', lambda success: None, I18nInfoDialogMeta('customization/selectNewItems', messageCtx={'items': ', '.join(notSelected)})) yield lambda callback = None: callback isConfirmed = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('customization/changeConfirmation', messageCtx={'selected': ', '.join(selected), 'remove': '\n'.join(remove)})) if isConfirmed: creditsNotEnough = totalCredits > self.__credits goldNotEnough = totalGold > self.__gold if creditsNotEnough or goldNotEnough: if creditsNotEnough and goldNotEnough: key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_AND_GOLD_NOT_ENOUGH elif goldNotEnough: key = SYSTEM_MESSAGES.CUSTOMIZATION_GOLD_NOT_ENOUGH else: key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_NOT_ENOUGH SystemMessages.pushI18nMessage(key, type=SystemMessages.SM_TYPE.Error) yield lambda callback = None: callback self.__returnHangar = True vehInvID = g_currentVehicle.invID self.__steps = 0 self.__messages = [] self.flashObject.applyButton.disabled = True if len(sections) > 0: Waiting.show('customizationApply') self.__lockUpdate = True selectedNames = [] for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: self.__steps += interface.getSelectedItemsCount(section.isGold) if section.sectionName not in selectedNames: interface.change(vehInvID, section) selectedNames.append(section.sectionName) else: LOG_ERROR('Change operation, section not found', section) self.__steps -= 1 if not self.__steps: self.__onServerResponsesReceived() return
def getUnitWarningMessage(key): return i18n.makeString(SYSTEM_MESSAGES.unit_warnings(key))
def applyCustomization(self, sections): if g_currentVehicle.isLocked(): SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error) yield lambda callback = None: callback if g_currentVehicle.isBroken(): SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.customization_vehicle(g_currentVehicle.item.getState()), type=SystemMessages.SM_TYPE.Error) yield lambda callback = None: callback notSelected = [] selected = [] remove = [] selectedNames = [] totalGold = 0 totalCredits = 0 newItemsByType = defaultdict(list) for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: newItems = interface.getNewItems() if newItems is not None: self.__updateNewItemsByType(newItemsByType, newItems, interface._type) for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: newItems = interface.getNewItems() if newItems is not None: removeStr = None hasMatches = self.__hasNewItemsDuplicates(newItemsByType, newItems, interface._type) if not hasMatches: costValue = interface.getSelectedItemCost() if isinstance(costValue, list): for price in costValue: cost = price.get('cost') isGold = price.get('isGold') if cost > 0: if isGold and section.isGold: totalGold += cost elif not isGold and not section.isGold: totalCredits += cost else: cost, isGold = costValue if cost > 0: if isGold: totalGold += cost else: totalCredits += cost if section.sectionName not in selectedNames: selected.append(i18n.makeString('#menu:customization/change/{0:>s}'.format(section.sectionName))) selectedNames.append(section.sectionName) removeStr = interface.getCurrentItemRemoveStr() if removeStr is not None: remove.extend(removeStr) else: notSelected.append(i18n.makeString('#menu:customization/items/{0:>s}'.format(section.sectionName))) else: LOG_ERROR('Section not found', section.sectionName) if len(notSelected) > 0: DialogsInterface.showI18nInfoDialog('customization/selectNewItems', lambda success: None, I18nInfoDialogMeta('customization/selectNewItems', messageCtx={'items': ', '.join(notSelected)})) yield lambda callback = None: callback if totalGold or totalCredits: titleKey = DIALOGS.CUSTOMIZATION_CHANGECONFIRMATION_BUY else: titleKey = DIALOGS.CUSTOMIZATION_CHANGECONFIRMATION_CHANGE isConfirmed = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('customization/changeConfirmation', titleCtx={'action': i18n.makeString(titleKey)}, messageCtx={'selected': ', '.join(selected), 'remove': '\n'.join(remove)})) if isConfirmed: creditsNotEnough = totalCredits > self.__credits goldNotEnough = totalGold > self.__gold if creditsNotEnough or goldNotEnough: if creditsNotEnough and goldNotEnough: key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_AND_GOLD_NOT_ENOUGH elif goldNotEnough: key = SYSTEM_MESSAGES.CUSTOMIZATION_GOLD_NOT_ENOUGH else: key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_NOT_ENOUGH SystemMessages.pushI18nMessage(key, type=SystemMessages.SM_TYPE.Error) yield lambda callback = None: callback self.__returnHangar = True vehInvID = g_currentVehicle.invID self.__steps = 0 self.__messages = [] self.flashObject.applyButton.disabled = True if len(sections) > 0: Waiting.show('customizationApply') self.__lockUpdate = True selectedNames = [] for section in sections: interface = self.__interfaces.get(section.sectionName) if interface is not None: newItems = interface.getNewItems() if newItems is not None: hasMatches = self.__hasNewItemsDuplicates(newItemsByType, newItems, interface._type) self.__steps += interface.getSelectedItemsCount(section.isGold) if section.sectionName not in selectedNames: interface.change(vehInvID, section, hasMatches) selectedNames.append(section.sectionName) else: LOG_ERROR('Change operation, section not found', section) self.__steps -= 1 if not self.__steps: self.__onServerResponsesReceived() return