def getParentControlNotificationMeta(self): from gui.Scaleform.daapi.view.dialogs import I18nInfoDialogMeta if self.isPlayTimeBlock: return I18nInfoDialogMeta('koreaPlayTimeNotification') else: notifyStartTime, blockTime = self.getCurfewBlockTime() formatter = lambda t: time.strftime('%H:%M', time.localtime(t)) return I18nInfoDialogMeta('koreaParentNotification', messageCtx={'preBlockTime': formatter(notifyStartTime), 'blockTime': formatter(blockTime)})
def showI18nInfoDialog(i18nKey, callback, meta = None): if g_sessionProvider.isBattleUILoaded(): customMsg = None if meta is not None: customMsg.getMessage() showInformationDialog(i18nKey, callback, customMessage=customMsg, ns='battle') else: showDialog(I18nInfoDialogMeta(i18nKey, meta=meta), callback)
def onDossierReceived(databaseID, _): clanID, clanInfo = g_itemsCache.items.getClanInfo(databaseID) if clanID != 0: clanInfo = ClanInfo(*clanInfo) shared_events.showClanProfileWindow(clanID, clanInfo.getClanAbbrev()) else: from gui import DialogsInterface key = 'clan data is not available' DialogsInterface.showI18nInfoDialog(key, lambda result: None, I18nInfoDialogMeta(key, messageCtx={'userName': key}))
def showI18nInfoDialog(i18nKey, callback, meta=None): if g_battleContext.isInBattle: customMsg = None if meta is not None: customMsg.getMessage() showInformationDialog(i18nKey, callback, customMessage=customMsg, ns='battle') else: showDialog(I18nInfoDialogMeta(i18nKey, meta=meta), callback) return
def requestProfile(databaseID, userName, successCallback): userDossier, _, isHidden = yield g_itemsCache.items.requestUserDossier(databaseID) if userDossier is None: if isHidden: key = 'messenger/userInfoHidden' else: key = 'messenger/userInfoNotAvailable' from gui import DialogsInterface DialogsInterface.showI18nInfoDialog(key, lambda result: None, I18nInfoDialogMeta(key, messageCtx={'userName': userName})) else: successCallback(databaseID, userName) return
def showI18nInfoDialog(i18nKey, callback, meta=None): if g_appLoader.getSpaceID( ) == GUI_GLOBAL_SPACE_ID.BATTLE and not GUI_SETTINGS.useAS3Battle: customMsg = None if meta is not None: customMsg.getMessage() showInformationDialog(i18nKey, callback, customMessage=customMsg, ns='battle') else: showDialog(I18nInfoDialogMeta(i18nKey, meta=meta), callback) return
def showUserInfo(self, uid, userName): userDossier, isHidden = yield g_itemsCache.items.requestUserDossier( int(uid)) if userDossier is None: if isHidden: key = 'messenger/userInfoHidden' else: key = 'messenger/userInfoNotAvailable' DialogsInterface.showI18nInfoDialog( key, lambda result: None, I18nInfoDialogMeta(key, messageCtx={'userName': userName})) else: self.fireEvent( events.ShowWindowEvent( events.ShowWindowEvent.SHOW_PROFILE_WINDOW, { 'userName': userName, 'databaseID': int(uid) }), EVENT_BUS_SCOPE.LOBBY) return
def _makeMeta(self): return I18nInfoDialogMeta(self.localeKey, self.ctx, self.ctx)
def showI18nInfoDialog(i18nKey, callback, meta=None): showDialog(I18nInfoDialogMeta(i18nKey, meta=meta), callback)
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 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