def onAccountShowGUI(ctx): g_lobbyContext.onAccountShowGUI(ctx) yield g_itemsCache.update() yield g_questsCache.update() yield g_settingsCache.update() if not g_itemsCache.isSynced(): return g_settingsCore.serverSettings.applySettings() game_control.g_instance.onAccountShowGUI(g_lobbyContext.getGuiCtx()) accDossier = g_itemsCache.items.getAccountDossier() g_rareAchievesCache.request(accDossier.getRecord('rareAchievements')) MusicController.g_musicController.setAccountAttrs(g_itemsCache.items.stats.attributes) MusicController.g_musicController.play(MusicController.MUSIC_EVENT_LOBBY) MusicController.g_musicController.play(MusicController.AMBIENT_EVENT_LOBBY) premium = isPremiumAccount(g_itemsCache.items.stats.attributes) if g_hangarSpace.inited: g_hangarSpace.refreshSpace(premium) else: g_hangarSpace.init(premium) g_currentVehicle.init() g_windowsManager.onAccountShowGUI(g_lobbyContext.getGuiCtx()) yield g_windowsManager.window.tooltipManager.request() g_prbLoader.onAccountShowGUI(g_lobbyContext.getGuiCtx()) SoundGroups.g_instance.enableLobbySounds(True) onCenterIsLongDisconnected(True) Waiting.hide('enter')
def __spaceDone(self): self.__spaceInited = True if self.__spaceDestroyedDuringLoad: self.__spaceDestroyedDuringLoad = False self.destroy() self.onSpaceCreate() Waiting.hide('loadHangarSpace')
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 processLobby(self): yield self.__populateData() self._subscribe() if constants.IS_SHOW_SERVER_STATS: self.__requestServerStats() self.updateAccountInfo() Waiting.hide('enter')
def __prepareAndSendInitData(self): Waiting.show('updatingSkillWindow') items = g_itemsCache.items tankman = items.getTankman(self.__tankManId) if len(tankman.skills) == 0: Waiting.hide('updatingSkillWindow') return rate = items.shop.freeXPToTManXPRate toNextPrcLeft = self.__getCurrentTankmanLevelCost(tankman) toNextPrcLeft = self.__roundByModulo(toNextPrcLeft, rate) needMaxXp = max(1, toNextPrcLeft / rate) nextSkillLevel = tankman.descriptor.lastSkillLevel + 1 freeXp = items.stats.freeXP if freeXp - needMaxXp > 0: while nextSkillLevel < MAX_SKILL_LEVEL: needMaxXp += self.__calcLevelUpCost(tankman, nextSkillLevel, len(tankman.skills)) / rate if freeXp - needMaxXp <= 0: break nextSkillLevel += 1 else: nextSkillLevel -= 1 data = {'tankmanID': self.__tankManId, 'currentSkill': g_itemSerializer.pack(tankman.skills[len(tankman.skills) - 1]), 'lastSkillLevel': tankman.descriptor.lastSkillLevel, 'nextSkillLevel': nextSkillLevel} self.as_setInitDataS(data) Waiting.hide('updatingSkillWindow')
def __ci_onCustomizationDropSuccess(self, message): self.as_onDropSuccessS() Waiting.hide('customizationDrop') self.__lockUpdate = False BigWorld.player().resyncDossiers() self.__refreshData() SystemMessages.pushMessage(message, type=SystemMessages.SM_TYPE.Information)
def _populate(self): battle_selector_items.create() super(LobbyHeader, self)._populate() self.app.containerManager.onViewAddedToContainer += self.__onViewAddedToContainer game_control.g_instance.wallet.onWalletStatusChanged += self.__onWalletChanged game_control.g_instance.gameSession.onPremiumNotify += self.__onPremiumTimeChanged g_currentVehicle.onChanged += self.__onVehicleChanged g_eventsCache.onSyncCompleted += self.__onEventsCacheResync self.addListener(events.FightButtonEvent.FIGHT_BUTTON_UPDATE, self.__handleFightButtonUpdated, scope=EVENT_BUS_SCOPE.LOBBY) self.addListener(events.CoolDownEvent.PREBATTLE, self.__handleSetPrebattleCoolDown, scope=EVENT_BUS_SCOPE.LOBBY) self.addListener(events.BubbleTooltipEvent.SHOW, self.__showBubbleTooltip, scope=EVENT_BUS_SCOPE.LOBBY) self.addListener(events.CloseWindowEvent.GOLD_FISH_CLOSED, self.__onGoldFishWindowClosed, scope=EVENT_BUS_SCOPE.LOBBY) g_clientUpdateManager.addCallbacks({'stats.credits': self.__setCredits, 'stats.gold': self.__setGold, 'stats.freeXP': self.__setFreeXP, 'stats.clanInfo': self.__setClanInfo, 'goodies': self.__updateGoodies, 'account.premiumExpiryTime': self.__onPremiumExpireTimeChanged, 'cache.SPA': self.__onSPAUpdated}) self.as_setFightButtonS(i18n.makeString('#menu:headerButtons/battle')) self.as_setWalletStatusS(game_control.g_instance.wallet.componentsStatuses) self.updateAccountInfo() self.startGlobalListening() self.__updateServerName() if not isTimeToShowGoldFishPromo(): enabledVal = isGoldFishActionActive() tooltip = TOOLTIPS.HEADER_REFILL_ACTION if enabledVal else TOOLTIPS.HEADER_REFILL self.as_setGoldFishEnabledS(enabledVal, False, tooltip, TOOLTIP_TYPES.COMPLEX) Waiting.hide('enter')
def buyAndInstallItem(self, itemCD, state, inInventory = False): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) raise itemTypeID in _RESEARCH_ITEMS or AssertionError oldStyleVehicle = self._data.getInvItem(self._data.getRootCD()) if not oldStyleVehicle is not None: raise AssertionError, 'Vehicle has be in inventory' eqs = functions.findConflictedEquipments(itemCD, itemTypeID, oldStyleVehicle) item = g_itemsCache.items.getItemByCD(itemCD) vehicle = g_itemsCache.items.getItemByCD(self._data.getRootCD()) if not inInventory: Waiting.show('buyItem') buyResult = yield ModuleBuyer(item, count=1, buyForCredits=True, conflictedEqs=eqs, install=True).request() if len(buyResult.userMsg): SystemMessages.g_instance.pushI18nMessage(buyResult.userMsg, type=buyResult.sysMsgType) Waiting.hide('buyItem') else: RequestState.sent(state) item = g_itemsCache.items.getItemByCD(itemCD) if item is not None and item.isInInventory: Waiting.show('applyModule') result = yield getInstallerProcessor(vehicle, item).request() success = result.success if result and result.auxData: for m in result.auxData: SystemMessages.g_instance.pushI18nMessage(m.userMsg, type=m.sysMsgType) if result and len(result.userMsg): SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType) success and itemTypeID in (_GUN, _TURRET) and self.tryLoadShells() Waiting.hide('applyModule') RequestState.received(state) return
def stopProcessing(self, result = False, data = None): if self._callback is not None: self._callback(result, data) self._callback = None if len(self._waitingID): Waiting.hide(self._waitingID) return
def buyAndInstallItem(self, itemCD, state, inInventory = False): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) assert itemTypeID in GUI_ITEM_TYPE.VEHICLE_MODULES vehicle = self._data.getRootItem() assert vehicle.isInInventory, 'Vehicle must be in inventory' item = self._data.getItem(itemCD) conflictedEqs = item.getConflictedEquipments(vehicle) if not inInventory: Waiting.show('buyItem') buyResult = yield ModuleBuyer(item, count=1, buyForCredits=True, conflictedEqs=conflictedEqs, install=True).request() Waiting.hide('buyItem') if len(buyResult.userMsg): SystemMessages.g_instance.pushI18nMessage(buyResult.userMsg, type=buyResult.sysMsgType) if buyResult.success: item = self._data.getItem(itemCD) else: return else: RequestState.sent(state) if item.isInInventory: Waiting.show('applyModule') result = yield getInstallerProcessor(vehicle, item, conflictedEqs=conflictedEqs).request() if result and result.auxData: for m in result.auxData: SystemMessages.g_instance.pushI18nMessage(m.userMsg, type=m.sysMsgType) if result and len(result.userMsg): SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType) if result.success and item.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): vehicle = g_itemsCache.items.getItemByCD(vehicle.intCD) yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('applyModule') RequestState.received(state)
def __handleStartTraining(self, event): if not event.settingsID: LOG_ERROR('Name of tutorial is not defined', event.settingsID) return Waiting.show('tutorial-chapter-loading', isSingle=True) self.startTraining(event.settingsID, event.getState()) Waiting.hide('tutorial-chapter-loading')
def getVehicleInfo(self): Waiting.show('updating') items = yield ItemsRequester().request() vehicle = items.getItemByCD(self.vehicleDescr.type.compactDescr) if vehicle is None: LOG_ERROR('There is error while showing vehicle info window: ', self.vehicleDescr.type.compactDescr) return else: params = vehicle.getParams() tankmenParams = list() for slotIdx, tankman in vehicle.crew: role = vehicle.descriptor.type.crewRoles[slotIdx][0] tankmanLabel = '' if tankman is not None: tankmanLabel = '%s %s (%d%%)' % (tankman.rankUserName, tankman.lastUserName, tankman.roleLevel) tankmenParams.append({'tankmanType': i18n.convert(tankmen.getSkillsConfig()[role].get('userString', '')), 'value': tankmanLabel}) info = {'vehicleName': vehicle.longUserName, 'vehicleDiscription': vehicle.fullDescription, 'vehicleImage': vehicle.icon, 'vehicleLevel': vehicle.level, 'vehicleNation': vehicle.nationID, 'vehicleElite': vehicle.isElite, 'vehicleType': vehicle.type, 'VehicleInfoPropsData': [ {'name': n, 'value': v} for n, v in params['parameters'] ], 'VehicleInfoBaseData': params['base'], 'VehicleInfoCrewData': tankmenParams} self.as_setVehicleInfoS(info) Waiting.hide('updating') return
def __handleConnectionStatus(self, stage, status, serverMsg, isAutoRegister): if self.__onLoggingTryingEndHdlr: self.__onLoggingTryingEndHdlr() STATUS_LOGGED_ON = "LOGGED_ON" LOG_DEBUG("__handleConnectionStatus %s %s %s" % (stage, status, isAutoRegister)) if stage == 1: if status == STATUS_LOGGED_ON: handlerFunc = self.__logOnSuccess[status] elif isAutoRegister: handlerFunc = self.__logAutoRegisterHandlers.get(status, self.__logOnFailedDefaultHandler) if status == "DNS_LOOKUP_FAILED": self.onLoginAppFailed(status, serverMsg) else: handlerFunc = self.__logOnFailedHandlers.get(status, self.__logOnFailedDefaultHandler) if status != "LOGIN_REJECTED_LOGIN_QUEUE": self.__clearAutoLoginTimer() if status != "LOGIN_REJECTED_RATE_LIMITED": self.__resetLgTimeout() self.onCancelQueue(False, False) if status not in ("LOGIN_REJECTED_INVALID_PASSWORD",): g_preDefinedHosts.clearPeripheryTL() try: getattr(self, handlerFunc)(status, serverMsg) except: LOG_ERROR("Handle logon status error: status = %r, message = %r" % (status, serverMsg)) LOG_CURRENT_EXCEPTION() Waiting.hide("login") if connectionManager.isUpdateClientSoftwareNeeded(): self.onHandleUpdateClientSoftwareNeeded() if connectionManager.isConnected(): connectionManager.disconnect() elif status != STATUS_LOGGED_ON: connectionManager.disconnect() elif stage == 6: if not self.__kickedFromServer: self.onCancelQueue(False, False) msg = MENU.LOGIN_STATUS_DISCONNECTED if self.__kickPeripheryID is not None: if self.__kickPeripheryID == -1: msg = MENU.LOGIN_STATUS_ACCOUNTNOTREADY elif self.__kickPeripheryID == -2: msg = "#menu:login/status/centerRestart" elif self.__kickPeripheryID == -3: msg = "#menu:login/status/versionMismatch" elif connectionManager.isVersionsDiffered: msg = "" self.onHandleUpdateClientSoftwareNeeded() localizedMessage = i18n.convert(i18n.makeString(msg)) lastLoginType = Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readString("lastLoginType", "basic") if lastLoginType != "basic" and not Settings.g_instance.userPrefs[Settings.KEY_LOGIN_INFO].readBool( "rememberPwd", False ): from gui.social_network_login import Bridge as socialNetworkLogin localizedMessage = socialNetworkLogin.getLogoutWarning(lastLoginType) self.onSetStatus(localizedMessage, self.ALL_VALID) connectionManager.disconnect() return
def removeVehicle(self): if self.__inited: Waiting.show('loadHangarSpaceVehicle') if self.__space is not None: self.__space.removeVehicle() Waiting.hide('loadHangarSpaceVehicle') self.__lastUpdatedVehicle = None return
def _onKickedWhileLogin(self, peripheryID): Waiting.hide('login') messageType = 'another_periphery' if peripheryID else 'checkout_error' self.as_setErrorMessageS(_ms(SYSTEM_MESSAGES.all(messageType)), INVALID_FIELDS.ALL_VALID) if not self.__loginRetryDialogShown: self.__showLoginRetryDialog({'waitingOpen': WAITING.titles(messageType), 'waitingClose': WAITING.BUTTONS_CEASE, 'message': _ms(WAITING.message(messageType), connectionManager.serverUserName)})
def _populate(self): g_fortSoundController.init() super(FortificationsView, self)._populate() self.addListener(events.FortEvent.VIEW_LOADED, self.__onViewLoaded, scope=EVENT_BUS_SCOPE.FORT) self.addListener(events.FortEvent.REQUEST_TIMEOUT, self.__loadDisconnectedView, scope=EVENT_BUS_SCOPE.FORT) self.startFortListening() Waiting.hide('loadPage') self.loadView()
def handleQueue(self, queueNumber): if not self.__loginQueue: Waiting.hide("enter") self.__loginQueue = True message = i18n.makeString( WAITING.MESSAGE_QUEUE, connectionManager.serverUserName, BigWorld.wg_getIntegralFormat(queueNumber) ) self.onHandleQueue(message)
def onShopResync(): yield g_itemsCache.update() if not g_itemsCache.isSynced(): return Waiting.hide('sinhronize') import time now = time.time() SystemMessages.g_instance.pushI18nMessage(SYSTEM_MESSAGES.SHOP_RESYNC, date=BigWorld.wg_getLongDateFormat(now), time=BigWorld.wg_getShortTimeFormat(now), type=SystemMessages.SM_TYPE.Information)
def _dispose(self): self._statsListener.stopListen() self._invListener.stopListen() g_playerEvents.onShopResync -= self.__shop_onResync g_playerEvents.onCenterIsLongDisconnected -= self.__center_onIsLongDisconnected game_control.g_instance.wallet.onWalletStatusChanged -= self.__setWalletCallback Waiting.hide('draw_research_items') super(Research, self)._dispose()
def __spaceDone(self): self.__spaceInited = True if self.__spaceDestroyedDuringLoad: self.__spaceDestroyedDuringLoad = False self.destroy() self.onSpaceCreate() Waiting.hide('loadHangarSpace') g_statistics.noteHangarLoadingState(HANGAR_LOADING_STATE.FINISH_LOADING_SPACE) g_statistics.noteHangarLoadingState(HANGAR_LOADING_STATE.HANGAR_READY, showSummaryNow=True)
def onShopResync(): yield g_itemsCache.update(CACHE_SYNC_REASON.SHOP_RESYNC) if not g_itemsCache.isSynced(): Waiting.hide('sinhronize') return yield g_eventsCache.update() Waiting.hide('sinhronize') now = time_utils.getCurrentTimestamp() SystemMessages.g_instance.pushI18nMessage(SYSTEM_MESSAGES.SHOP_RESYNC, date=BigWorld.wg_getLongDateFormat(now), time=BigWorld.wg_getShortTimeFormat(now), type=SystemMessages.SM_TYPE.Information)
def _showWindow(self, notification, arenaUniqueID): arenaUniqueID = long(arenaUniqueID) Waiting.show('loadStats') results = yield DeprecatedStatsRequester().getBattleResults(long(arenaUniqueID)) Waiting.hide('loadStats') if results: shared_events.showBattleResultsFromData(results) else: self._updateNotification(notification)
def _populate(self): g_fortSoundController.init() super(FortificationsView, self)._populate() self.addListener(events.FortEvent.VIEW_LOADED, self.__onViewLoaded, scope=EVENT_BUS_SCOPE.FORT) self.addListener(events.FortEvent.REQUEST_TIMEOUT, self.__loadDisconnectedView, scope=EVENT_BUS_SCOPE.FORT) g_clientUpdateManager.addCallbacks({'stats.clanInfo': self.__onClanInfoChanged}) self.startFortListening() Waiting.hide('loadPage') self.loadView()
def updateCaptureDevices(self): Waiting.show('__updateCaptureDevices') devices = yield self.app.voiceChatManager.requestCaptureDevices() currentCaptureDeviceIdx = -1 if VOIP.getVOIPManager().currentCaptureDevice in devices: currentCaptureDeviceIdx = devices.index(VOIP.getVOIPManager().currentCaptureDevice) value = [ d.decode(sys.getfilesystemencoding()).encode('utf-8') for d in devices ] Waiting.hide('__updateCaptureDevices') self.as_setCaptureDevicesS(currentCaptureDeviceIdx, value)
def __updateAll(self): Waiting.show("updateVehicle") self.__updateAmmoPanel() self.__updateState() self.__updateCarousel() self.__updateParams() self.__updateResearchPanel() self.__updateCrew() Waiting.hide("updateVehicle")
def __afterImageReload(self, challenge): Waiting.hide('reloadCaptcha') if challenge is not None: self.__challenge = challenge self.__setCaptchaImageSource() else: SystemMessages.pushI18nMessage('#captcha:error-codes/image-internal-error', type=SystemMessages.SM_TYPE.Error) self.controller.tryBattlesTillCaptchaReset() self._close(False)
def __onCurrentVehicleChanged(self): Waiting.show('updateVehicle') self.__updateState() self.__updateAmmoPanel() self.__updateParams() self.__updateResearchPanel() self.__updateCrew() self.__updateCarouselParams() self.__updateVehIGRStatus() Waiting.hide('updateVehicle')
def installComponent(self, newId): newComponentItem = g_itemsCache.items.getItemByCD(newId) Waiting.show('applyModule') conflictedEqs = newComponentItem.getConflictedEquipments(self.item) result = yield getPreviewInstallerProcessor(self.item, newComponentItem, conflictedEqs).request() processMsg(result) Waiting.hide('applyModule') if result.success: self.refreshModel() self.onComponentInstalled()
def _onLoginRejected(self, loginStatus, responseData): Waiting.hide('login') if loginStatus == LOGIN_STATUS.LOGIN_REJECTED_BAN: self.__loginRejectedBan(responseData) elif loginStatus == LOGIN_STATUS.LOGIN_REJECTED_RATE_LIMITED: self.__loginRejectedRateLimited() elif loginStatus in (LOGIN_STATUS.LOGIN_REJECTED_BAD_DIGEST, LOGIN_STATUS.LOGIN_BAD_PROTOCOL_VERSION): self.__loginRejectedUpdateNeeded() else: self.as_setErrorMessageS(_ms('#menu:login/status/' + loginStatus), _STATUS_TO_INVALID_FIELDS_MAPPING[loginStatus])
def __onServerResponsesReceived(self): self.as_onServerResponsesReceivedS() self.__lockUpdate = False Waiting.hide('customizationApply') for type, message in self.__messages: SystemMessages.pushMessage(message, type=type) self.__messages = [] if self.__returnHangar: self.closeWindow()
def __finishCallback(self, waitingID): LOG_DEBUG('Sending planes to flash finished') if self.__lobby is not None: self.__lobby.call_1('hangar.planesTransferFinished') Waiting.hide(waitingID) return
def _changeDone(self): self._clearChangeCallback() if isPlayerAccount(): self.onChanged() Waiting.hide('updateCurrentVehicle')
def __hideWaiting(self): if self.__currentMessage is not None: Waiting.hide(self.__currentMessage) self.__currentMessage = None return
def __onBootcampBecomePlayer(self): self.__inBootcampAccount = True Waiting.hide('login')
def request(self, callback=None): from gui.Scaleform.Waiting import Waiting Waiting.show('download/inventory') yield self.__stats.request() yield self.__inventory.request() yield self.__vehicleRotation.request() Waiting.hide('download/inventory') Waiting.show('download/shop') yield self.__shop.request() Waiting.hide('download/shop') Waiting.show('download/dossier') yield self.__dossiers.request() Waiting.hide('download/dossier') Waiting.show('download/discounts') yield self.__goodies.request() Waiting.hide('download/discounts') Waiting.show('download/recycleBin') yield self.__recycleBin.request() Waiting.hide('download/recycleBin') Waiting.show('download/ranked') yield self.__ranked.request() Waiting.hide('download/ranked') Waiting.show('download/badges') yield self.__badges.request() Waiting.hide('download/badges') Waiting.show('download/epicMetaGame') yield self.epicMetaGame.request() Waiting.hide('download/epicMetaGame') callback(self)
def __onSpaceCreateHandler(self): Waiting.hide(_WAITING_MESSAGE) self.__ctx.refreshOutfit() self.__updateAnchorPositions()
def _response(self, code, callback, errStr='', ctx=None): super(OptDeviceInstaller, self)._response(code, callback, errStr, ctx) from gui.Scaleform.Waiting import Waiting Waiting.hide('applyModule')
def _response(self, code, callback, ctx=None, errStr=''): super(BuyAndInstallItemProcessor, self)._response(code, callback, errStr, ctx) from gui.Scaleform.Waiting import Waiting Waiting.hide('applyModule')
def __ci_onCustomizationDropFailed(self, message): Waiting.hide('customizationDrop') self.__lockUpdate = False SystemMessages.pushMessage(message, type=SystemMessages.SM_TYPE.Error)
def _clearLoginView(self, *args): Waiting.hide('login') if self.__loginQueueDialogShown: self.__closeLoginQueueDialog() if self.__loginRetryDialogShown: self.__closeLoginRetryDialog()
def _dispose(self): Waiting.hide('updating') super(BCLobbyHeader, self)._dispose()
def hideWaiting(self, messageID=None): if messageID is not None: Waiting.hide('tutorial-{0:>s}'.format(messageID)) else: Waiting.close() return
def _successHandler(self, code, ctx=None): Waiting.hide('loadContent') msg = QuestAchievesFormatter.formatQuestAchieves(ctx or {}, False) if msg is not None: SystemMessages.pushMessage(msg, type=SystemMessages.SM_TYPE.OfferGiftBonuses) return super(ReceiveOfferGiftProcessor, self)._successHandler(code, ctx)
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 _errorHandler(self, code, errStr='', ctx=None): Waiting.hide('loadContent') defaultKey = 'offers/server_error' return makeI18nError('/'.join((defaultKey, errStr)), defaultKey)
def _errorHandler(self, code, errStr='', ctx=None): Waiting.hide('loadContent') return makeI18nError('/'.join((self.ERROR_DEFAULT_KEY, errStr)), self.ERROR_DEFAULT_KEY)