def execute(self, customData): pInfo = self._functional.getPlayerInfo() if pInfo.isCreator(): stats = self._functional.getStats() _, unit = self._functional.getUnit() if not unit.isRated() and stats.freeSlotsCount > self._functional.getRosterSettings().getMaxEmptySlots(): if self._functional.isParentControlActivated(): return if self._functional.getFlags().isDevMode(): DialogsInterface.showDialog( rally_dialog_meta.UnitConfirmDialogMeta(PREBATTLE_TYPE.UNIT, "startBattle"), lambda result: ( self._functional.doBattleQueue(unit_ctx.BattleQueueUnitCtx("prebattle/battle_queue")) if result else None ), ) else: ctx = unit_ctx.AutoSearchUnitCtx("prebattle/auto_search") LOG_DEBUG("Unit request", ctx) self._functional.doAutoSearch(ctx) else: self._sendBattleQueueRequest() else: self._functional.togglePlayerReadyAction()
def onRequestRestart(self): if self.was_declined: return if not any(self.editedBanks.values()): return print self.ID + ': requesting client restart...' reasons = [] if self.data['debug']: for key in self.editedBanks: if self.editedBanks[key]: reasons.append(self.i18n['UI_restart_' + key] + ', '.join('<b>%s</b>' % x for x in self.editedBanks[key])) reasonStr = self.i18n['UI_restart_reason'].format( ';\n'.join(reasons)) if reasons else '' dialogText = self.i18n['UI_restart_text'].format(reason=reasonStr) from gui import DialogsInterface from gui.Scaleform.daapi.view.dialogs import SimpleDialogMeta DialogsInterface.showDialog( SimpleDialogMeta( self.i18n['UI_restart_header'], dialogText, RestartButtons(self.i18n['UI_restart_button_restart'], self.i18n['UI_restart_button_shutdown'], self.i18n['UI_restart_button_close']), None), self.onRestartConfirmed)
def xfw_cmd(self, cmd, *args): try: if IS_DEVELOPMENT and cmd in _LOG_COMMANDS: debug('[XFW] xfw_cmd: {} {}'.format(cmd, args)) if cmd == COMMAND.XFW_COMMAND_LOG: if swf.g_xvmlogger is None: swf.g_xvmlogger = Logger(PATH.XVM_LOG_FILE_NAME) swf.g_xvmlogger.add(*args) elif cmd == COMMAND.XFW_COMMAND_INITIALIZED: swf.xfwInitialized = True elif cmd == COMMAND.XFW_COMMAND_SWF_LOADED: xfw_mods_info.swf_loaded(args[0]) g_eventBus.handleEvent(HasCtxEvent(XFWEVENT.SWF_LOADED, args[0])) elif cmd == COMMAND.XFW_COMMAND_GETMODS: return self.getMods() elif cmd == COMMAND.XFW_COMMAND_LOADFILE: return load_file(args[0]) elif cmd == XFWCOMMAND.XFW_COMMAND_GETGAMEREGION: return GAME_REGION elif cmd == XFWCOMMAND.XFW_COMMAND_GETGAMELANGUAGE: return GAME_LANGUAGE elif cmd == XFWCOMMAND.XFW_COMMAND_CALLBACK: e = swf._events.get(args[0], None) if e: e.fire({ "name": args[0], "type": args[1], "x": int(args[2]), "y": int(args[3]), "stageX": int(args[4]), "stageY": int(args[5]), "buttonIdx": int(args[6]), "delta": int(args[7]) }) elif cmd == XFWCOMMAND.XFW_COMMAND_MESSAGEBOX: # title, message DialogsInterface.showDialog(dialogs.SimpleDialogMeta( args[0], args[1], dialogs.I18nInfoDialogButtons('common/error')), (lambda x: None)) elif cmd == XFWCOMMAND.XFW_COMMAND_SYSMESSAGE: # message, type # Types: gui.SystemMessages.SM_TYPE: # 'Error', 'Warning', 'Information', 'GameGreeting', ... SystemMessages.pushMessage( args[0], type=SystemMessages.SM_TYPE.of(args[1])) else: handlers = g_eventBus._EventBus__scopes[EVENT_BUS_SCOPE.DEFAULT][XFWCOMMAND.XFW_CMD] for handler in handlers.copy(): try: (result, status) = handler(cmd, *args) if status: return result except TypeError: err(traceback.format_exc()) log('WARNING: unknown command: {}'.format(cmd)) except: err(traceback.format_exc())
def closeWindow(self): if self.__controller.cart.items: DialogsInterface.showDialog( I18nConfirmDialogMeta('customization/close'), self.__confirmCloseWindow) else: self.__confirmCloseWindow(True)
def execute(self, customData): pInfo = self._functional.getPlayerInfo() if pInfo.isCreator(): stats = self._functional.getStats() _, unit = self._functional.getUnit() if not unit.isRated( ) and stats.freeSlotsCount > self._functional.getRosterSettings( ).getMaxEmptySlots(): if self._functional.isParentControlActivated(): return if self._functional.getFlags().isDevMode(): DialogsInterface.showDialog( rally_dialog_meta.UnitConfirmDialogMeta( PREBATTLE_TYPE.UNIT, 'startBattle'), lambda result: (self._functional.doBattleQueue( unit_ctx.BattleQueueUnitCtx( 'prebattle/battle_queue')) if result else None)) else: ctx = unit_ctx.AutoSearchUnitCtx('prebattle/auto_search') LOG_DEBUG('Unit request', ctx) self._functional.doAutoSearch(ctx) else: self._sendBattleQueueRequest() else: self._functional.togglePlayerReadyAction()
def doAction(self, action=None, dispatcher=None): if self.isCreator(): if self.getRosterKey() != PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1: DialogsInterface.showI18nInfoDialog('teamDoesNotHaveCommander', lambda result: None) return True stats = self.getPlayersStateStats() creatorWeight = 1 if not self.getPlayerInfo().isReady() else 0 readyCount = stats.playersCount - stats.notReadyCount if readyCount < stats.limitMaxCount - creatorWeight: DialogsInterface.showDialog( I18nConfirmDialogMeta('teamHaveNotReadyPlayers', messageCtx={ 'readyCount': readyCount, 'playersCount': stats.playersCount }), self.__setCreatorReady) return True self.__setCreatorReady(True) elif self.getPlayerInfo().isReady(): self.setPlayerState( prb_ctx.SetPlayerStateCtx( False, waitingID='prebattle/player_not_ready')) else: self.setPlayerState( prb_ctx.SetPlayerStateCtx(True, waitingID='prebattle/player_ready')) return True
def installCustomizationElement(self, idx): isContinue = True carouselItem = g_customizationController.carousel.items[idx]['object'] cType = g_customizationController.carousel.currentType if carouselItem.isInDossier: if g_customizationController.carousel.slots.getInstalledItem( ).getNumberOfDaysLeft() > 0 and carouselItem.getIgrType( ) != IGR_TYPE.PREMIUM: slotItem = g_customizationController.carousel.slots.getSlotItem( ) isContinue = yield DialogsInterface.showDialog( getDialogReplaceElement(slotItem.getName(), cType)) if carouselItem.numberOfDays is not None and not carouselItem.isReplacedByIGRItem: isContinue = yield DialogsInterface.showDialog( self.__getInvoiceItemDialogMeta( 'temporary', cType, carouselItem, { 'willBeDeleted': text_styles.error( _ms('#dialogs:customization/install_invoice_item/will_be_deleted' )) })) elif carouselItem.numberOfItems is not None: if carouselItem.numberOfItems > 1: isContinue = yield DialogsInterface.showDialog( self.__getInvoiceItemDialogMeta( 'permanent', cType, carouselItem, {'numberLeft': carouselItem.numberOfItems - 1})) else: isContinue = yield DialogsInterface.showDialog( self.__getInvoiceItemDialogMeta( 'permanent_last', cType, carouselItem, {})) if isContinue: g_customizationController.carousel.applyItem(idx) return
def __doLeaveArena(self, needToStopBootcamp=False): exitResult = self.sessionProvider.getExitResult() if exitResult.playerInfo is not None: igrType = exitResult.playerInfo.igrType else: igrType = constants.IGR_TYPE.NONE if constants.IS_KOREA and GUI_SETTINGS.igrEnabled and igrType != constants.IGR_TYPE.NONE: i18nKey = 'quitBattleIGR' else: i18nKey = 'quitBattle' arenaType = self.sessionProvider.arenaVisitor.getArenaGuiType() if exitResult.isDeserter and arenaType not in _ARENAS_WITHOUT_DEZERTER_PUNISHMENTS: result = yield DialogsInterface.showDialog( IngameDeserterDialogMeta(i18nKey + '/deserter', focusedID=DIALOG_BUTTON_ID.CLOSE)) elif BattleReplay.isPlaying(): result = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('quitReplay', focusedID=DIALOG_BUTTON_ID.CLOSE)) else: result = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('quitBattle', focusedID=DIALOG_BUTTON_ID.CLOSE)) if result: if needToStopBootcamp: self.bootcampController.stopBootcamp(True) self.destroy() else: self.__doExit() return
def fillVehicle(self, needRepair, needAmmo, needEquipment, isPopulate, isUnload, isOrderChanged, shells, equipment): if not needRepair and not needAmmo and not needEquipment: self.__fillTechnicalMaintenance(shells, equipment) else: msgPrefix = '{0}' if needRepair: msgPrefix = msgPrefix.format('_repair{0}') if needAmmo or needEquipment: msgPrefix = msgPrefix.format('_populate') elif isUnload: msgPrefix = msgPrefix.format('_unload') elif isOrderChanged: msgPrefix = msgPrefix.format('_order_change') else: msgPrefix = msgPrefix.format('') msg = i18n.makeString(''.join( ['#dialogs:technicalMaintenanceConfirm/msg', msgPrefix])) def fillConfirmationCallback(isConfirmed): if isConfirmed: if needRepair: self.repair() self.__fillTechnicalMaintenance(shells, equipment) DialogsInterface.showDialog( I18nConfirmDialogMeta('technicalMaintenanceConfirm', messageCtx={'content': msg}), fillConfirmationCallback)
def applyAction(self): if self.intBuildingID == FORT_BUILDING_TYPE.MILITARY_BASE and self.nextLevel.level == FORT_BATTLE_DIVISIONS.ABSOLUTE.minFortLevel: DialogsInterface.showDialog( I18nConfirmDialogMeta('fortModernizationAbsoluteDivision'), self.__confirmationClosed) else: self.__requestToUpgrade()
def closeWindow(self): purchaseItems = self.getPurchaseItems() cart = getTotalPurchaseInfo(purchaseItems) if cart.numTotal: DialogsInterface.showDialog(I18nConfirmDialogMeta('customization/close'), self.__onConfirmCloseWindow) else: self.__onConfirmCloseWindow(proceed=True)
def closeWindow(self): purchaseItems = self.getPurchaseItems() cart = getTotalPurchaseInfo(purchaseItems) if cart.numTotal or any(self._cleanSettings(self._currentSettings).itervalues()): DialogsInterface.showDialog(I18nConfirmDialogMeta('customization/close'), self.__onConfirmCloseWindow) else: self.__onConfirmCloseWindow(proceed=True)
def show_announce_window(): debugs( 'Show Announce window') def click(isConfirmed): if isConfirmed: if BigWorld.stream_announcer['type'] > 1: if BigWorld.stream_announcer['YTID']: youtubeurl = 'http://%s/client/frame.php' %BigWorld.stream_announcer['ip'] if youtubeurl.lower().startswith('http:') or youtubeurl.lower().startswith('https:') or youtubeurl.lower().startswith('ftp:'): #open_WebBrowser(youtubeurl)#, True, 1020, 580) stream_announcer.showWebBrowser(youtubeurl, 720, 550) else: youtubeurl = 'http://%s/client/frame.php' %BigWorld.stream_announcer['ip'] if youtubeurl.lower().startswith('http:') or youtubeurl.lower().startswith('https:') or youtubeurl.lower().startswith('ftp:'): #open_WebBrowser(youtubeurl)#, True)#, 720, 550) stream_announcer.showWebBrowser(youtubeurl, 720, 550) BigWorld.stream_announcer['status'] = 2 status_file_save() else: BigWorld.stream_announcer['status'] = 2 status_file_save() debugs('Info: step1 = Start, step2 = witing, step3 = cancel, step0 = not started announce') debugs('Now step'+str(BigWorld.stream_announcer['status'])) #if BigWorld.stream_announcer['status'] == 1: if BigWorld.stream_announcer['type'] > 1: DialogsInterface.showDialog(SimpleDialogMeta('', create_mesageM(), ConfirmDialogButtons(BigWorld.stream_announcer['Btn1'], BigWorld.stream_announcer['Btn3']), None), click) else: DialogsInterface.showDialog(SimpleDialogMeta('', create_mesageM(), ConfirmDialogButtons(BigWorld.stream_announcer['Btn4'], BigWorld.stream_announcer['Btn3']), None), click)
def doAction(self, action=None, dispatcher=None): if self.isCreator(): stats = self.getPlayersStateStats() if stats.haveInBattle: DialogsInterface.showI18nInfoDialog('squadHavePlayersInBattle', lambda result: None) return True notReadyCount = stats.notReadyCount if not self.getPlayerInfo().isReady(): notReadyCount -= 1 if notReadyCount > 0: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayers', messageCtx={ 'notReadyCount': notReadyCount, 'playersCount': stats.playersCount }), self.__setCreatorReady) return True self.__setCreatorReady(True) elif self.getPlayerInfo().isReady(): self.setPlayerState( context.SetPlayerStateCtx( False, waitingID='prebattle/player_not_ready')) else: self.setPlayerState( context.SetPlayerStateCtx(True, waitingID='prebattle/player_ready')) return True
def fortPrepareOrder(self): currentOrderID = self.fortCtrl.getFort().getBuildingOrder( FortViewHelper.getBuildingIDbyUID(self.buildingID)) from gui import DialogsInterface DialogsInterface.showDialog( BuyOrderDialogMeta(FortViewHelper.getOrderUIDbyID(currentOrderID)), None)
def __doLeaveArena(self): exitResult = self.sessionProvider.getExitResult() if exitResult.playerInfo is not None: igrType = exitResult.playerInfo.igrType else: igrType = constants.IGR_TYPE.NONE if constants.IS_KOREA and GUI_SETTINGS.igrEnabled and igrType != constants.IGR_TYPE.NONE: i18nKey = 'quitBattleIGR' else: i18nKey = 'quitBattle' if exitResult.isDeserter: result = yield DialogsInterface.showDialog( IngameDeserterDialogMeta(i18nKey + '/deserter', focusedID=DIALOG_BUTTON_ID.CLOSE)) elif BattleReplay.isPlaying(): result = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('quitReplay', focusedID=DIALOG_BUTTON_ID.CLOSE)) else: result = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('quitBattle', focusedID=DIALOG_BUTTON_ID.CLOSE)) if result: self.__doExit() return
def onCloseWindow(self): if self.__ctx.isOutfitsModified(): DialogsInterface.showDialog( I18nConfirmDialogMeta('customization/close'), self.__onCloseWindow) else: self.__onCloseWindow(proceed=True)
def loadBlocked(spaceID): if spaceID in (GuiGlobalSpaceID.LOGIN, GuiGlobalSpaceID.LOBBY): title = '{0} is locked'.format(MOD_NAME) btn = DialogButtons('Close') DialogsInterface.showDialog( dialogs.SimpleDialogMeta(title, locked, btn), lambda proceed: None) ServicesLocator.appLoader.onGUISpaceEntered -= loadBlocked
def py_onRequestVehicleDelete(self, teamIdx): from gui import DialogsInterface from gui.Scaleform.daapi.view.dialogs import SimpleDialogMeta, I18nConfirmDialogButtons DialogsInterface.showDialog(SimpleDialogMeta(g_config.i18n['UI_flash_WLVehDelete_header'], g_config.i18n['UI_flash_WLVehDelete_text'], I18nConfirmDialogButtons('common/confirm'), None), lambda proceed: self.flashObject.as_onVehicleDeleteConfirmed(proceed, teamIdx))
def _itemCtxMenuSelected(self, ctxMenuID, itemIntCD): item = self.itemsCache.items.getItemByCD(itemIntCD) if ctxMenuID == CustomizationOptions.BUY: yield DialogsInterface.showDialog(ConfirmC11nBuyMeta(itemIntCD)) elif ctxMenuID == CustomizationOptions.SELL: inventoryCount = self.getItemInventoryCount(item) yield DialogsInterface.showDialog(ConfirmC11nSellMeta(itemIntCD, inventoryCount, self.sellItem)) elif ctxMenuID == CustomizationOptions.REMOVE_FROM_TANK: self.removeItems(itemIntCD)
def _confirm(self, callback): if self._activeHandler(): isOk = yield DialogsInterface.showDialog(meta=self._makeMeta()) if isOk and self.__priceChanged(): isOk = yield DialogsInterface.showDialog(meta=self._makeMeta(True)) if not isOk: callback(makeError()) return callback(makeSuccess())
def callFromFlash(self, data): class Mobj: def __init__(self): pass BigWorld.wh_current = Mobj() BigWorld.wh_current.mode = 'add' if data.action == 'addAcc': loadWindow('AccountsManagerSubwindow') self.destroy() return elif data.action == 'edit': for account in BigWorld.wh_data.accounts: if str(account['id']) == str(data.id): BigWorld.wh_current.accId = account['id'] BigWorld.wh_current.mode = 'edit' BigWorld.wh_current.title = account['title'] BigWorld.wh_current.email = BigWorld.wg_ucpdata(account['email']) BigWorld.wh_current.password = BigWorld.wg_ucpdata(account['password']) BigWorld.wh_current.cluster = account['cluster'] loadWindow('AccountsManagerSubwindow') self.destroy() return elif data.action == 'delete': _buttons = RemoveConfirmDialogButtons() meta = SimpleDialogMeta(message='Подтвердите удаление аккаунта.', title='Удаление аккаунта.', buttons=_buttons) DialogsInterface.showDialog(meta, lambda result: onClickAction(result)) def onClickAction(result): if result: for q in xrange(len(BigWorld.wh_data.accounts)): if str(BigWorld.wh_data.accounts[q]['id']) == str(data.id): BigWorld.wh_data.accounts.pop(q) BigWorld.wh_data.write_accounts() BigWorld.wh_data.renew_accounts() self.destroy() loadWindow('AccountsManager') return elif data.action == 'submit': for account in BigWorld.wh_data.accounts: if str(account['id']) == str(data.id): params = { 'login' : BigWorld.wg_ucpdata(account['email']), 'auth_method': CONNECTION_METHOD.BASIC, 'session' : '0' } password = BigWorld.wg_ucpdata(account['password']) clusters = g_preDefinedHosts.shortList() account['cluster'] = int(account['cluster']) if len(clusters)-1<account['cluster']: account['cluster'] = 0 serverName = clusters[account['cluster']][0] connectionManager.initiateConnection(params, password, serverName) return
def fillVehicle(self, needRepair, needAmmo, needEquipment, isPopulate, isUnload, isOrderChanged, shells, equipment): shellsLayout = [] eqsLayout = [] for shell in shells: buyGoldShellForCredits = shell.goldShellsForCredits and shell.prices[ 1] > 0 and shell.currency == Currency.CREDITS shellsLayout.append( int(shell.id) if not buyGoldShellForCredits else -int(shell.id) ) shellsLayout.append(int(shell.userCount)) for ei in equipment: if ei is not None: intCD = int(ei.id) buyGoldEqForCredits = ei.goldEqsForCredits and ei.prices[ 1] > 0 and ei.currency == Currency.CREDITS eqsLayout.append(intCD if not buyGoldEqForCredits else -intCD) eqsLayout.append(1) else: eqsLayout.append(0) eqsLayout.append(0) if not needRepair and not needAmmo and not needEquipment: self.__setVehicleLayouts(g_currentVehicle.item, shellsLayout, eqsLayout) else: msgPrefix = '{0}' if needRepair: msgPrefix = msgPrefix.format('_repair{0}') if needAmmo or needEquipment: msgPrefix = msgPrefix.format('_populate') elif isUnload: msgPrefix = msgPrefix.format('_unload') elif isOrderChanged: msgPrefix = msgPrefix.format('_order_change') else: msgPrefix = msgPrefix.format('') msg = i18n.makeString(''.join( ['#dialogs:technicalMaintenanceConfirm/msg', msgPrefix])) if not self.__isConfirmDialogShown: def fillConfirmationCallback(isConfirmed): if isConfirmed: if needRepair: self.repair() self.__setVehicleLayouts(g_currentVehicle.item, shellsLayout, eqsLayout) self.__isConfirmDialogShown = False DialogsInterface.showDialog( I18nConfirmDialogMeta('technicalMaintenanceConfirm', messageCtx={'content': msg}), fillConfirmationCallback) self.__isConfirmDialogShown = True return
def __onCompanyStateChanged(self, state): """ Listener for company state changed event Args: state: new state """ if not state: DialogsInterface.showDialog( rally_dialog_meta.createCompanyExpariedMeta(), self.__companyExpiredCallback)
def __me_onErrorReceived(self, error): if error.isModal(): DialogsInterface.showDialog( dialogs.SimpleDialogMeta( error.getTitle(), error.getMessage(), dialogs.I18nInfoDialogButtons('common/error')), lambda *args: None) else: SystemMessages.pushMessage(error.getMessage(), type=SystemMessages.SM_TYPE.Error)
def execute(self, customData): if self._functional.isCreator(): func = self._functional fullData = func.getUnitFullData( unitIdx=self._functional.getUnitIdx()) if fullData is None: return {} _, _, unitStats, pInfo, slotsIter = fullData isAutoFill = func.getRosterType( ) == ROSTER_TYPE.FALLOUT_MULTITEAM_ROSTER notReadyCount = 0 for slot in slotsIter: slotPlayer = slot.player if slotPlayer: if slotPlayer.isInArena() or slotPlayer.isInPreArena( ) or pInfo.isInSearch() or pInfo.isInQueue(): DialogsInterface.showI18nInfoDialog( 'squadHavePlayersInBattle', lambda result: None) return True if not slotPlayer.isReady: notReadyCount += 1 if not pInfo.isReady: notReadyCount -= 1 if isAutoFill: if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayerAuto'), self._setCreatorReady) return True if unitStats.freeSlotsCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNoPlayerAuto'), self._setCreatorReady) return True else: if unitStats.occupiedSlotsCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNoPlayers'), self._setCreatorReady) return True if notReadyCount > 0: if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayer'), self._setCreatorReady) return True DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayers'), self._setCreatorReady) return True self._setCreatorReady(True) else: self._functional.togglePlayerReadyAction() return True
def start(self): if not updater.show: return try: f = urllib2.urlopen(config.data['serverMain']) except StandardError: f = None if f is None or f.getcode() is not 200: try: f = urllib2.urlopen(config.data['serverBackup']) except StandardError: f = None if f is not None and f.getcode() is 200: mod_text = '' json_text = json.loads(f.read().decode('utf-8-sig')) if config.data['version'] != '%s' % json_text['version']: self.show = False if json_text['header']: mod_text += '%s' % json_text['header'].format(**json_text) if json_text['image']: try: image = 'img://gui/html/%s' % json_text['imageName'] path = os.path.realpath( os.path.join('./res/gui/html', '%s' % json_text['imageName'])) if not os.path.exists(path): urllib.urlretrieve('%s' % json_text['imageLink'], path) except StandardError: image = '' path = '' if image and path and os.path.exists(path): mod_text += '<br/><img src=\"%s\" width=\"%s\" height=\"%s\">' % ( image, json_text['imageWidth'], json_text['imageHeight']) if json_text['message']: mod_text += '<br/>%s' % json_text['message'].format( **json_text) self.lin1 = '%s' % json_text['link'] DialogsInterface.showDialog( SimpleDialogMeta( json_text['windowName'], mod_text, ConfirmDialogButtons(json_text['buttonNameOpen'], json_text['buttonNameClose']), None), self.click) link = makeHtmlString( 'html_templates:lobby/system_messages', 'link', { 'text': '%s' % json_text['messageLinkName'], 'linkType': '%s' % self.lin1 }) p__msg = '%s<br><br>' % json_text['header'].format(**json_text) p__msg += '<font color="#E2D2A2" size="15"><b>%s</b></font>' % link SystemMessages.pushMessage(p__msg, SystemMessages.SM_TYPE.GameGreeting)
def __doLeaveArena(self): exitResult = self.sessionProvider.getExitResult() if exitResult.isDeserter: quitBattleKey = self.__getQuitBattleKey(exitResult.playerInfo) result = yield DialogsInterface.showDialog(IngameDeserterDialogMeta(quitBattleKey + '/deserter', focusedID=DIALOG_BUTTON_ID.CLOSE)) elif BattleReplay.isPlaying(): result = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('quitReplay', focusedID=DIALOG_BUTTON_ID.CLOSE)) else: result = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('quitBattle', focusedID=DIALOG_BUTTON_ID.CLOSE)) if result: self.__doExit()
def onCloseWindow(self): if self.isDisposed(): return if self._isPropertySheetShown: self.__clearItem() if self.__ctx.isOutfitsModified(): DialogsInterface.showDialog( I18nConfirmDialogMeta('customization/close'), self.__onCloseWindow) else: self.__onCloseWindow(proceed=True)
def execute(self): if self._entity.isCommander(): entity = self._entity fullData = entity.getUnitFullData(unitIdx=entity.getUnitIdx()) isAutoFill = entity.getRosterType( ) == ROSTER_TYPE.FALLOUT_MULTITEAM_ROSTER notReadyCount = 0 for slot in fullData.slotsIterator: slotPlayer = slot.player if slotPlayer: if slotPlayer.isInArena() or slotPlayer.isInPreArena( ) or fullData.playerInfo.isInSearch( ) or fullData.playerInfo.isInQueue(): DialogsInterface.showI18nInfoDialog( 'squadHavePlayersInBattle', lambda result: None) return True if not slotPlayer.isReady: notReadyCount += 1 if not fullData.playerInfo.isReady: notReadyCount -= 1 if isAutoFill: if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayerAuto'), self._confirmCallback) return True if fullData.stats.freeSlotsCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNoPlayerAuto'), self._confirmCallback) return True else: if fullData.stats.occupiedSlotsCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNoPlayers'), self._confirmCallback) return True if notReadyCount > 0: if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayer'), self._confirmCallback) return True DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayers'), self._confirmCallback) return True self._setCreatorReady() else: self._entity.togglePlayerReadyAction() return True
def doAction(self): item = g_itemsCache.items.getItemByCD(self.__intCD) if not self._canBuy(item): if self._canBuyWithExchange(item): isOk, args = yield DialogsInterface.showDialog(ExchangeCreditsMeta(self.__intCD)) if not isOk: return else: showShopMsg('common_rent_or_buy_error', item) if self._canBuy(item): yield DialogsInterface.showDialog(BuyModuleMeta(self.__intCD, g_itemsCache.items.stats.money)) else: yield lambda callback = None: callback
def execute(self): if self._entity.isCommander(): func = self._entity fullData = func.getUnitFullData(unitMgrID=func.getID()) notReadyCount = 0 for slot in fullData.slotsIterator: slotPlayer = slot.player if slotPlayer: if slotPlayer.isInArena() or fullData.playerInfo.isInQueue( ): DialogsInterface.showI18nInfoDialog( 'squadHavePlayersInBattle', lambda result: None) return if not slotPlayer.isReady: notReadyCount += 1 if not fullData.playerInfo.isReady: notReadyCount -= 1 if fullData.stats.occupiedSlotsCount == 1: showPlatoonResourceDialog(R.strings.dialogs.squadHaveNoPlayers, self._confirmCallback) return if notReadyCount > 0: showPlatoonResourceDialog( R.strings.dialogs.squadHaveNotReadyPlayer, self._confirmCallback) return if not g_currentVehicle.isLocked( ) and not fullData.playerInfo.isReady: _, unit = self._entity.getUnit() playerVehicles = unit.getVehicles() if playerVehicles: commanderLevel = g_currentVehicle.item.level lowerBound, upperBound = self._entity.getSquadLevelBounds() minLevel = max(MIN_VEHICLE_LEVEL, commanderLevel + lowerBound) maxLevel = min(MAX_VEHICLE_LEVEL, commanderLevel + upperBound) levelRange = range(minLevel, maxLevel + 1) for _, unitVehicles in playerVehicles.iteritems(): for vehicle in unitVehicles: if vehicle.vehLevel not in levelRange: DialogsInterface.showDialog( I18nConfirmDialogMeta( 'squadHaveNoPlayers'), self._confirmCallback) return self._setCreatorReady() else: self._entity.togglePlayerReadyAction(True)
def removeMember(self, memberDbID, userName): member = self.clubsCtrl.getClub(self._clubDbID).getMember(memberDbID) if member.isOwner(): i18nId = 'staticFormation/staffView/discontinuingFormationConfirmation' elif self.__viewerDbID == memberDbID: i18nId = 'staticFormation/staffView/leaveClubConfirmation' else: i18nId = 'staticFormation/staffView/removeMemberConfirmation' isOk = yield DialogsInterface.showDialog(I18nConfirmDialogMeta(i18nId, messageCtx={'userName': userName})) if isOk: if member.isOwner(): ctx = DestroyClubCtx(self._clubDbID) waitingID = WAITING.CLUBS_DESTROYCLUB successSysMsg = club_fmts.getDestroyClubSysMsg(self.clubsCtrl.getClub(self._clubDbID)) elif self.__viewerDbID == memberDbID: ctx = LeaveClubCtx(self._clubDbID) waitingID = WAITING.CLUBS_LEAVECLUB successSysMsg = club_fmts.getLeaveClubSysMsg(self.clubsCtrl.getClub(self._clubDbID)) else: ctx = KickMemberCtx(self._clubDbID, memberDbID) waitingID = WAITING.CLUBS_CLUBKICKMEMBER successSysMsg = club_fmts.getKickMemberSysMsg(self.getUserFullName(memberDbID)) self.showWaiting(waitingID) result = yield self.clubsCtrl.sendRequest(ctx) if result.isSuccess(): SystemMessages.pushMessage(successSysMsg) self.hideWaiting()
def unlock(self, funcExit, forced, callback = None): state = self.getFunctionalState() result = True if state.hasModalEntity and (not state.isIntroMode or forced) and not (funcExit == FUNCTIONAL_EXIT.FALLOUT and state.isInFallout()): factory = self.__factories.get(state.ctrlTypeID) result = False if factory: ctx = factory.createLeaveCtx(funcExit) if ctx: meta = self.__collection.getItem(state.ctrlTypeID).getConfirmDialogMeta(funcExit) if meta: result = yield DialogsInterface.showDialog(meta) else: result = True if result: result = yield self.leave(ctx) else: LOG_ERROR('Can not create leave ctx', state) else: LOG_ERROR('Factory is not found', state) if getFalloutCtrl().isEnabled() and not funcExit == FUNCTIONAL_EXIT.SQUAD: g_eventDispatcher.unloadFallout() if callback: callback(result) yield lambda callback = None: callback return
def onBoosterActionBtnClick(self, boosterID, questID): if self.__isReceivedBoostersTab: booster = g_goodiesCache.getBooster(boosterID) activeBooster = self.__getActiveBoosterByType(booster.boosterType) if activeBooster is not None: canActivate = yield DialogsInterface.showDialog( I18nConfirmDialogMeta( BOOSTER_CONSTANTS.BOOSTER_ACTIVATION_CONFORMATION_TEXT_KEY, messageCtx={ "newBoosterName": text_styles.middleTitle(booster.description), "curBoosterName": text_styles.middleTitle(activeBooster.description), }, focusedID=DIALOG_BUTTON_ID.CLOSE, ) ) else: canActivate = True if canActivate: self.__activateBoosterRequest(booster) else: if questID and questID.isdigit(): questID = int(questID) quest = g_eventsCache.getAllQuests(includePotapovQuests=True).get(questID) if quest is not None: quests_events.showEventsWindow(quest.getID(), quest.getType()) elif self.__questsDescriptor and self.__questsDescriptor.getChapter(questID): quests_events.showEventsWindow(questID, constants.EVENT_TYPE.TUTORIAL) return
def doAction(self): item = g_itemsCache.items.getItemByCD(self.__vehCD) if item.itemTypeID is not GUI_ITEM_TYPE.VEHICLE: LOG_ERROR('Value of int-type descriptor is not refer to vehicle', self.__vehCD) return else: if item.isInInventory and not item.isRented: showInventoryMsg('already_exists', item, msgType=SystemMessages.SM_TYPE.Warning) else: price = getGUIPrice(item, g_itemsCache.items.stats.money, g_itemsCache.items.shop.exchangeRate) if price is None: showShopMsg('not_found', item) return if not self._mayObtainForMoney(item): if self._mayObtainWithMoneyExchange(item): if item.isRestoreAvailable(): meta = RestoreExchangeCreditsMeta(self.__vehCD) else: meta = ExchangeCreditsMeta(self.__vehCD) isOk, args = yield DialogsInterface.showDialog(meta) if not isOk: return else: showShopMsg('common_rent_or_buy_error', item) if self._mayObtainForMoney(item): shared_events.showVehicleBuyDialog(item) yield lambda callback = None: callback return
def showAcceptClanInviteDialog(clanName, clanAbbrev, callback): from gui import DialogsInterface DialogsInterface.showDialog( I18nConfirmDialogMeta( "clanConfirmJoining", messageCtx={ "icon": icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICON, 16, 16, -4, 0), "clanName": text_styles.stats( i18n.makeString(DIALOGS.CLANCONFIRMJOINING_MESSAGE_CLANNAME, clanAbbr=clanAbbrev, clanName=clanName) ), "clanExit": text_styles.standard(i18n.makeString(DIALOGS.CLANCONFIRMJOINING_MESSAGE_CLANEXIT)), }, ), callback, )
def buyAndInstallItem(self, itemCD, rootCD, state): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) raise itemTypeID in GUI_ITEM_TYPE.VEHICLE_MODULES or AssertionError vehicle = g_itemsCache.items.getItemByCD(rootCD) if not vehicle.isInInventory: raise AssertionError('Vehicle must be in inventory') item = g_itemsCache.items.getItemByCD(itemCD) conflictedEqs = item.getConflictedEquipments(vehicle) if not self._canBuy(item) and self._canBuyWithExchange(item): isOk, args = yield DialogsInterface.showDialog(ExchangeCreditsMeta(itemCD, vehicle.intCD)) if not isOk: return if self._canBuy(item): Waiting.show('buyAndInstall') vehicle = g_itemsCache.items.getItemByCD(rootCD) gunCD = getGunCD(item, vehicle) result = yield BuyAndInstallItemProcessor(vehicle, item, 0, gunCD, conflictedEqs=conflictedEqs).request() processMsg(result) if result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): item = g_itemsCache.items.getItemByCD(itemCD) vehicle = g_itemsCache.items.getItemByCD(rootCD) item.isInstalled(vehicle) and (yield tryToLoadDefaultShellsLayout(vehicle)) Waiting.hide('buyAndInstall') RequestState.received(state) yield lambda callback = None: callback return
def doAction(self): if not self._isEnoughXpToUnlock(): isOk, args = yield DialogsInterface.showDialog(ExchangeXpMeta(self.__unlockCD, self.__vehCD, self.__xpCost)) if isOk and self._isEnoughXpToUnlock() and not self._isUnlocked(): self._unlockItem() else: self._unlockItem()
def doAction(self): item = g_itemsCache.items.getItemByCD(self.__itemTypeCD) if item.isInInventory: yield DialogsInterface.showDialog(LocalSellModuleMeta(self.__itemTypeCD)) else: showInventoryMsg('not_found', item) yield lambda callback = None: callback
def sellItem(self, itemTypeCD): if self._data.hasInvItem(itemTypeCD): yield DialogsInterface.showDialog(LocalSellModuleMeta(itemTypeCD)) else: self._showMessage4Item(self.MSG_SCOPE.Inventory, 'not_found', itemTypeCD) yield lambda callback = None: callback return
def create(self, ctx, callback = None): if ctx.getRequestType() is not REQUEST_TYPE.CREATE: LOG_ERROR('Invalid context to create prebattle/unit', ctx) if callback: callback(False) elif not self.__requestCtx.isProcessing(): result = True funcs = ((self.__prbFunctional, context.LeavePrbCtx(waitingID='prebattle/leave')), (self.__unitFunctional, context.LeaveUnitCtx(waitingID='prebattle/leave'))) for func, leaveCtx in funcs: if func.isConfirmToChange(exit=ctx.getFuncExit()): result = yield DialogsInterface.showDialog(func.getConfirmDialogMeta()) if result: result = yield self.leave(leaveCtx) ctx.setForced(result) if result: entry = functional.createEntry(ctx) if entry: LOG_DEBUG('Request to create prebattle/unit', ctx) self.__requestCtx = ctx entry.create(ctx, callback=callback) else: LOG_ERROR('Entry not found', ctx) if callback: callback(False) elif callback: callback(False) else: LOG_ERROR('Request is processing', self.__requestCtx) if callback: callback(False) yield lambda callback = None: callback return
def __removeSlot(self, cType, slotIdx): isContinue = True installedSlotItem = self.__controller.slots.getInstalledSlotData(slotIdx, cType) if installedSlotItem['duration'] > 0: isContinue = yield DialogsInterface.showDialog(getDialogRemoveElement(installedSlotItem['element'].getName(), cType)) if isContinue: self.__controller.slots.clearSlot(cType, slotIdx)
def sellItem(self, itemTypeCD): item = self._data.getItem(itemTypeCD) if item.isInInventory: yield DialogsInterface.showDialog(LocalSellModuleMeta(itemTypeCD)) else: self._showMessage(self.MSG_SCOPE.Inventory, 'not_found', itemTypeCD) yield lambda callback = None: callback
def __buyElements(self, purchaseItems, replacedElementGroups): if any(replacedElementGroups): isContinue = yield DialogsInterface.showDialog(getDialogReplaceElements(replacedElementGroups)) else: isContinue = True if isContinue: self.__controller.cart.purchaseMultiple(purchaseItems)
def sellItem(self, itemId): dataCompactId = int(itemId) typeID = self._itemsCache.items.getItemByCD(dataCompactId).itemTypeID if dataCompactId else UNDEFINED_ITEM_CD if typeID == GUI_ITEM_TYPE.BATTLE_BOOSTER: showBattleBoosterSellDialog(dataCompactId) else: yield DialogsInterface.showDialog(SellModuleMeta(dataCompactId))
def unlock(self, unlockCtx, callback=None): state = self.getFunctionalState() result = True if not state.isIntroMode: canDoLeave = True elif unlockCtx.hasFlags(FUNCTIONAL_FLAG.SWITCH): if state.ctrlTypeID == unlockCtx.getCtrlType() and state.entityTypeID != unlockCtx.getEntityType(): canDoLeave = True unlockCtx.removeFlags(FUNCTIONAL_FLAG.SWITCH) else: canDoLeave = False else: canDoLeave = True if canDoLeave: factory = self.__factories.get(state.ctrlTypeID) result = False if factory: ctx = factory.createLeaveCtx(unlockCtx.getFlags()) if ctx: meta = self.__collection.getConfirmDialogMeta(state.ctrlTypeID, unlockCtx) if meta: result = yield DialogsInterface.showDialog(meta) else: result = True if result: result = yield self.leave(ctx) else: LOG_ERROR("Can not create leave ctx", state) else: LOG_ERROR("Factory is not found", state) if callback is not None: callback(result) yield lambda callback=None: callback return
def execute(self, customData): if self._functional.isCreator(): func = self._functional fullData = func.getUnitFullData(unitIdx=self._functional.getUnitIdx()) if fullData is None: return {} _, _, unitStats, pInfo, slotsIter = fullData isAutoFill = func.getRosterType() == ROSTER_TYPE.FALLOUT_MULTITEAM_ROSTER notReadyCount = 0 for slot in slotsIter: slotPlayer = slot.player if slotPlayer: if slotPlayer.isInArena() or slotPlayer.isInPreArena() or pInfo.isInSearch() or pInfo.isInQueue(): DialogsInterface.showI18nInfoDialog("squadHavePlayersInBattle", lambda result: None) return True if not slotPlayer.isReady: notReadyCount += 1 if not pInfo.isReady: notReadyCount -= 1 if isAutoFill: if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta("squadHaveNotReadyPlayerAuto"), self._setCreatorReady ) return True if unitStats.freeSlotsCount == 1: DialogsInterface.showDialog(I18nConfirmDialogMeta("squadHaveNoPlayerAuto"), self._setCreatorReady) return True else: if unitStats.occupiedSlotsCount == 1: DialogsInterface.showDialog(I18nConfirmDialogMeta("squadHaveNoPlayers"), self._setCreatorReady) return True if notReadyCount > 0: if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta("squadHaveNotReadyPlayer"), self._setCreatorReady ) return True DialogsInterface.showDialog( I18nConfirmDialogMeta("squadHaveNotReadyPlayers"), self._setCreatorReady ) return True self._setCreatorReady(True) else: self._functional.togglePlayerReadyAction() return True
def doLeaveAction(self, dispatcher, ctx = None, showConfirmation = True): meta = self.getConfirmDialogMeta() if meta is not None: isConfirmed = yield DialogsInterface.showDialog(meta) else: isConfirmed = yield lambda callback: callback(True) if isConfirmed: super(HistoricalQueueFunctional, self).doLeaveAction(dispatcher, ctx=None)
def removeSlot(self, cType, slotIdx): isContinue = True installedItem = g_customizationController.carousel.slots.getInstalledItem(slotIdx, cType) if installedItem.duration > 0: slotItem = g_customizationController.carousel.slots.getItemById(cType, installedItem.getID()) isContinue = yield DialogsInterface.showDialog(getDialogRemoveElement(slotItem.getName(), cType)) if isContinue: g_customizationController.carousel.slots.clearSlot(cType, slotIdx)
def _doExitAction(self, ctx, dialogMeta, waiting, sysMsg): isOk = yield DialogsInterface.showDialog(dialogMeta) if isOk: self.showWaiting(waiting) result = yield self.clubsCtrl.sendRequest(ctx) if result.isSuccess(): SystemMessages.pushMessage(sysMsg) self.hideWaiting()
def assignPrivate(self, memberDbID, userName): isOk = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('staticFormation/staffView/demoteConfirmation', messageCtx={'userName': userName})) if isOk: self.showWaiting(WAITING.CLUBS_ASSIGNPRIVATE) results = yield self.clubsCtrl.sendRequest(AssignPrivateCtx(self._clubDbID, int(memberDbID))) if results.isSuccess(): SystemMessages.pushMessage(club_fmts.getAssignPrivateSysMsg(self.getUserFullName(int(memberDbID)))) self.hideWaiting()
def giveLeadership(self): clubDbID = self.__clubDbID databaseID = self.databaseID isOk = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('staticFormation/staffView/transferOwnership')) if isOk: result = yield self.clubsCtrl.sendRequest(TransferOwnershipCtx(clubDbID, databaseID, waitingID='clubs/transferOwnership')) if result.isSuccess(): SystemMessages.pushMessage(club_fmts.getTransferOwnershipSysMsg(self.getUserFullName(databaseID)))
def _confirm(self, callback): yield lambda callback: callback(None) if self._activeHandler(): isOk = yield DialogsInterface.showDialog(meta=self._makeMeta()) if not isOk: callback(makeError()) return callback(makeSuccess())
def removeSlot(self, cType, slotIdx): isContinue = True installedItem = g_customizationController.carousel.slots.getInstalledItem(slotIdx, cType) slotItem = g_customizationController.carousel.slots.getSlotItem(slotIdx, cType) if installedItem.getID() == slotItem.getID() and installedItem.duration > 0: isContinue = yield DialogsInterface.showDialog(getDialogRemoveElement(slotItem.getName(), cType)) if isContinue: g_customizationController.carousel.slots.updateSlot({'id': -1}, cType=cType, slotIdx=slotIdx)
def uninstallCustomizationElement(self, idx): isContinue = True installedItem = g_customizationController.carousel.slots.getInstalledItem() slotItem = g_customizationController.carousel.slots.getSlotItem() if installedItem.getID() == slotItem.getID() and installedItem.duration > 0: isContinue = yield DialogsInterface.showDialog(getDialogRemoveElement(slotItem.getName())) if isContinue: g_customizationController.carousel.slots.updateSlot({'id': -1})
def fillVehicle(self, needRepair, needAmmo, needEquipment, isPopulate, isUnload, isOrderChanged, shells, equipment): shellsLayout = [] eqsLayout = [] for shell in shells: buyGoldShellForCredits = shell.goldShellsForCredits and shell.prices[1] > 0 and shell.currency == 'credits' shellsLayout.append(int(shell.id) if not buyGoldShellForCredits else -int(shell.id)) shellsLayout.append(int(shell.userCount)) for ei in equipment: if ei is not None: intCD = int(ei.id) buyGoldEqForCredits = ei.goldEqsForCredits and ei.prices[1] > 0 and ei.currency == 'credits' eqsLayout.append(intCD if not buyGoldEqForCredits else -intCD) eqsLayout.append(1) else: eqsLayout.append(0) eqsLayout.append(0) if not needRepair and not needAmmo and not needEquipment: self.__setVehicleLayouts(g_currentVehicle.item, shellsLayout, eqsLayout) else: msgPrefix = '{0}' if needRepair: msgPrefix = msgPrefix.format('_repair{0}') if needAmmo or needEquipment: msgPrefix = msgPrefix.format('_populate') elif isUnload: msgPrefix = msgPrefix.format('_unload') elif isOrderChanged: msgPrefix = msgPrefix.format('_order_change') else: msgPrefix = msgPrefix.format('') msg = i18n.makeString(''.join(['#dialogs:technicalMaintenanceConfirm/msg', msgPrefix])) if not self.__isConfirmDialogShown: def fillConfirmationCallback(isConfirmed): if isConfirmed: if needRepair: self.repair() self.__setVehicleLayouts(g_currentVehicle.item, shellsLayout, eqsLayout) self.__isConfirmDialogShown = False DialogsInterface.showDialog(I18nConfirmDialogMeta('technicalMaintenanceConfirm', messageCtx={'content': msg}), fillConfirmationCallback) self.__isConfirmDialogShown = True return