コード例 #1
0
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)
コード例 #2
0
ファイル: messages.py プロジェクト: 19colt87/WOTDecompiled
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)
コード例 #3
0
 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
コード例 #4
0
ファイル: loginview.py プロジェクト: webiumsk/WOT-0.9.15-CT
 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)})
コード例 #5
0
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)
コード例 #6
0
ファイル: fort_ext.py プロジェクト: webiumsk/WOT-0.9.12
 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
コード例 #7
0
 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
コード例 #8
0
 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)
コード例 #9
0
ファイル: messages.py プロジェクト: 19colt87/WOTDecompiled
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)
コード例 #10
0
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
コード例 #11
0
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
コード例 #12
0
 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)
コード例 #13
0
ファイル: logindispatcher.py プロジェクト: kblw/wot_client
 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())
コード例 #14
0
 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())
コード例 #15
0
 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
コード例 #16
0
 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)
コード例 #17
0
 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
コード例 #18
0
    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
コード例 #19
0
ファイル: messages.py プロジェクト: 19colt87/WOTDecompiled
def getUnitKickedReasonMessage(reasonStr):
    return i18n.makeString(SYSTEM_MESSAGES.unit_warnings(reasonStr))
コード例 #20
0
    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
コード例 #21
0
ファイル: messages.py プロジェクト: webiumsk/WOT-0.9.12
def getUnitPlayerNotification(key, pInfo):
    return i18n.makeString(SYSTEM_MESSAGES.unit_notification(key), userName=pInfo.getFullName())
コード例 #22
0
    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
コード例 #23
0
def getUnitWarningMessage(key):
    return i18n.makeString(SYSTEM_MESSAGES.unit_warnings(key))
コード例 #24
0
def getUnitKickedReasonMessage(reasonStr):
    return i18n.makeString(SYSTEM_MESSAGES.unit_warnings(reasonStr))
コード例 #25
0
def getUnitPlayerNotification(key, pInfo):
    return i18n.makeString(SYSTEM_MESSAGES.unit_notification(key),
                           userName=pInfo.getFullName())
コード例 #26
0
    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