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 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 showParentControlNotification(self): from gui import game_control, DialogsInterface if game_control.g_instance.gameSession.isPlayTimeBlock: key = 'koreaPlayTimeNotification' else: key = 'koreaParentNotification' DialogsInterface.showI18nInfoDialog(key, lambda *args: None)
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 onDossierReceived(databaseID, _): clanID, _ = g_itemsCache.items.getClanInfo(databaseID) if clanID != 0: shared_events.showClanProfileWindow(clanID) else: from gui import DialogsInterface key = 'clan data is not available' DialogsInterface.showI18nInfoDialog(key, lambda result: None, I18nInfoDialogMeta(key, messageCtx={'userName': key}))
def relogin(self, peripheryID): if g_preDefinedHosts.isRoamingPeriphery(peripheryID): success = yield DialogsInterface.showI18nConfirmDialog('changeRoamingPeriphery') else: success = yield DialogsInterface.showI18nConfirmDialog('changePeriphery') if success: game_control.g_instance.roaming.relogin(peripheryID) self.as_setPeripheryChangingS(success)
def onEscape(self): def buttonHandler(isOk): if isOk: self.destroy() BigWorld.quit() DialogsInterface.showI18nConfirmDialog('quit', buttonHandler, focusedID=DIALOG_BUTTON_ID.CLOSE)
def __relogin(self, peripheryID): self.__isGuiUpdateSuppressed = True if g_preDefinedHosts.isRoamingPeriphery(peripheryID): success = yield DialogsInterface.showI18nConfirmDialog('changeRoamingPeriphery') else: success = yield DialogsInterface.showI18nConfirmDialog('changePeriphery') if success: game_control.g_instance.relogin.doRelogin(peripheryID, extraChainSteps=self.__ctx.getExtraChainSteps())
def showWarningDialog(self, dialogID, settings, isCloseWnd): def callback(isOk): if isOk: self.applySettings(settings, False) self.as_confirmWarningDialogS(isOk, dialogID) if isCloseWnd and isOk: self.onWindowClose() DialogsInterface.showI18nConfirmDialog(dialogID, callback)
def onReplayFinished(self): if not self.scriptModalWindowsEnabled: self.stop() return if self.__isPlayingPlayList: self.stop() BigWorld.callback(1.0, self.play) return DialogsInterface.showI18nInfoDialog('replayStopped', self.stop)
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 relogin(self, peripheryID): self.__isGuiUpdateSuppressed = True if g_preDefinedHosts.isRoamingPeriphery(peripheryID): success = yield DialogsInterface.showI18nConfirmDialog('changeRoamingPeriphery') else: success = yield DialogsInterface.showI18nConfirmDialog('changePeriphery') if success: game_control.g_instance.relogin.doRelogin(peripheryID) self.__isGuiUpdateSuppressed = False self.as_setPeripheryChangingS(success)
def relogin(self, peripheryID): if g_preDefinedHosts.isRoamingPeriphery(peripheryID): LOG_DEBUG('g_preDefinedHosts.isRoamingPeriphery(peripheryID)', peripheryID) success = yield DialogsInterface.showI18nConfirmDialog('changeRoamingPeriphery') else: success = yield DialogsInterface.showI18nConfirmDialog('changePeriphery') if success: game_control.g_instance.relogin.doRelogin(peripheryID) if not success: self.as_changePeripheryFailedS()
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.LoadViewEvent(VIEW_ALIAS.PROFILE_WINDOW, getViewName(VIEW_ALIAS.PROFILE_WINDOW, uid), {'userName': userName, 'databaseID': int(uid)}), EVENT_BUS_SCOPE.LOBBY)
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 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 onReplayFinished(self): if not self.scriptModalWindowsEnabled: self.stop() return if self.__isPlayingPlayList: self.stop() BigWorld.callback(1.0, self.play) return self.__isMenuShowed = False DialogsInterface.showI18nInfoDialog('replayStopped', self.stop) self.__isFinished = True self.setPlaybackSpeedIdx(0)
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 showUserInfo(self): databaseID = self.databaseID userName = self.userName 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: shared_events.showProfileWindow(databaseID, userName) 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 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 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(True) return True
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 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 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 if not g_currentVehicle.isLocked(): _, unit = self._functional.getUnit() playerVehicles = unit.getVehicles() if playerVehicles: commanderLevel = g_currentVehicle.item.level lowerBound, upperBound = self._functional.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._setCreatorReady ) return True self._setCreatorReady(True) else: self._functional.togglePlayerReadyAction(True) return True
def applySettings(self, settings, isCloseWnd): settings = flashObject2Dict(settings) applyMethod = self.params.getApplyMethod(settings) def confirmHandler(isOk): self.__commitSettings(settings, isOk) if isOk and isCloseWnd: self.closeWindow() if applyMethod == APPLY_METHOD.RESTART: DialogsInterface.showI18nConfirmDialog('graphicsPresetRestartConfirmation', confirmHandler) elif applyMethod == APPLY_METHOD.DELAYED: DialogsInterface.showI18nConfirmDialog('graphicsPresetDelayedConfirmation', confirmHandler) else: confirmHandler(True)
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 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 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 __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 __buyElements(self, purchaseItems, replacedElementGroups): if any(replacedElementGroups): isContinue = yield DialogsInterface.showDialog(getDialogReplaceElements(replacedElementGroups)) else: isContinue = True if isContinue: self.__controller.cart.purchaseMultiple(purchaseItems)
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 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 showAlertMessage(self, notification): self.__actualDisplayingAlerts += 1 yield DialogsInterface.showDialog(SystemMessageMeta(notification)) self.__actualDisplayingAlerts -= 1 if self.__actualDisplayingAlerts == 0: self.onAllAlertsClosed()
def showParentControlNotification(cls): from gui import game_control, DialogsInterface DialogsInterface.showDialog(game_control.g_instance.gameSession.getParentControlNotificationMeta(), lambda *args: None)
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 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 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 if not g_currentVehicle.isLocked(): _, unit = self._functional.getUnit() playerVehicles = unit.getVehicles() if playerVehicles: commanderLevel = g_currentVehicle.item.level lowerBound, upperBound = self._functional.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._setCreatorReady) return True self._setCreatorReady(True) else: self._functional.togglePlayerReadyAction(True) return True
def _showDialog(text, callback): from gui import DialogsInterface from gui.Scaleform.daapi.view.dialogs.CaptchaDialogMeta import CaptchaDialogMeta return DialogsInterface.showDialog(CaptchaDialogMeta(text), callback)
def __loginRejectedUpdateNeeded(self): success = yield DialogsInterface.showI18nConfirmDialog('updateNeeded') if success and not BigWorld.wg_quitAndStartLauncher(): self.as_setErrorMessageS(_ms(MENU.LOGIN_STATUS_LAUNCHERNOTFOUND), INVALID_FIELDS.ALL_VALID)
def showParentControlNotification(self): from gui import DialogsInterface DialogsInterface.showDialog( self.gameSession.getParentControlNotificationMeta(), lambda *args: None)
def showDisconnectDialog(self, appNS, description): if appNS == _SPACE.SF_LOBBY: DialogsInterface.showDisconnect(*description)
def _showDialog(self, key): """ Show a modal dialog with the message in the key provided. :param key: key for the message """ DialogsInterface.showI18nInfoDialog(key, lambda result: None)
def __showElenPopupDlg(self): yield DialogsInterface.showI18nInfoDialog('elenDisabled') g_eventBus.handleEvent(g_entitiesFactories.makeLoadEvent(SFViewLoadParams(VIEW_ALIAS.LOBBY_HANGAR)), scope=EVENT_BUS_SCOPE.LOBBY)
def sellItem(self): yield DialogsInterface.showDialog(SellModuleMeta(int(self._intCD)))
def __showI18nDialog(self, key, callback): from gui import DialogsInterface return DialogsInterface.showI18nConfirmDialog(key, callback)
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 sellItem(self, itemId): yield DialogsInterface.showDialog(SellModuleMeta(int(itemId)))
def doAction(self): vehicle = self.itemsCache.items.getVehicle(self.__vehInvID) if vehicle is None: return else: isUseMoney = self.__isRemove and self.__oldItemCD is not None LOG_DEBUG('isUseMoney, self.__isRemove, self.__oldItemCD', isUseMoney, self.__isRemove, self.__oldItemCD) newComponentItem = self.itemsCache.items.getItemByCD( int(self.__newItemCD)) if newComponentItem is None: return oldComponentItem = None if self.__oldItemCD: oldComponentItem = self.itemsCache.items.getItemByCD( int(self.__oldItemCD)) if not self.__isRemove: if oldComponentItem and oldComponentItem.itemTypeID in ( GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.BATTLE_BOOSTER): Waiting.show('installEquipment') result = yield getInstallerProcessor( vehicle, oldComponentItem, self.__slotIdx, False, True, skipConfirm=self.skipConfirm).request() processMsg(result) Waiting.hide('installEquipment') if not result.success: return if not self.__isRemove and not newComponentItem.isInInventory and not newComponentItem.itemTypeID == GUI_ITEM_TYPE.BATTLE_ABILITY: conflictedEqs = newComponentItem.getConflictedEquipments( vehicle) if not self._mayObtainForMoney( newComponentItem) and self._mayObtainWithMoneyExchange( newComponentItem): isOk, _ = yield DialogsInterface.showDialog( ExchangeCreditsSingleItemMeta(newComponentItem.intCD, vehicle.intCD)) if not isOk: return if self._mayObtainForMoney(newComponentItem): Waiting.show('buyAndInstall') vehicle = self.itemsCache.items.getVehicle(self.__vehInvID) gunCD = getGunCD(newComponentItem, vehicle) result = yield BuyAndInstallItemProcessor( vehicle, newComponentItem, self.__slotIdx, gunCD, conflictedEqs=conflictedEqs, skipConfirm=self.skipConfirm).request() processMsg(result) if result.success and newComponentItem.itemTypeID in ( GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): newComponentItem = self.itemsCache.items.getItemByCD( int(self.__newItemCD)) vehicle = self.itemsCache.items.getItemByCD( vehicle.intCD) if newComponentItem.isInstalled(vehicle): yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('buyAndInstall') else: yield lambda callback=None: callback else: Waiting.show('applyModule') conflictedEqs = newComponentItem.getConflictedEquipments( vehicle) result = yield getInstallerProcessor( vehicle, newComponentItem, self.__slotIdx, not self.__isRemove, isUseMoney, conflictedEqs, self.skipConfirm).request() processMsg(result) if result.success and newComponentItem.itemTypeID in ( GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): newComponentItem = self.itemsCache.items.getItemByCD( int(self.__newItemCD)) vehicle = self.itemsCache.items.getItemByCD(vehicle.intCD) if newComponentItem.isInstalled(vehicle): yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('applyModule') 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 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) 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()
def __doLeaveTutorial(self): result = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('refuseTraining', focusedID=DIALOG_BUTTON_ID.CLOSE)) if result: self.fireEvent(events.TutorialEvent(events.TutorialEvent.STOP_TRAINING)) self.destroy()
def openBuyOrderWindow(self): currentOrderID = self.fortCtrl.getFort().getBuildingOrder( self._buildingID) DialogsInterface.showDialog( BuyOrderDialogMeta(self.getOrderUIDbyID(currentOrderID)), None)