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 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 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 removeVehicle(self): if self.__inited: Waiting.show('loadHangarSpaceVehicle') if self.__space is not None: self.__space.removeVehicle() self.__changeDone() self.__lastUpdatedVehicle = None
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 cancelQueue(self, showWaiting = True, logged = False): if self.__onLoginQueue: if showWaiting: Waiting.show('enter') self.__setLoginQueue(False) self.fireEvent(LoginEvent(LoginEvent.CANCEL_LGN_QUEUE, View.alias)) self.as_cancelLoginQueueS()
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 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 onLogin(self, user, password, host, hdlr, isSocialToken2Login = False): self.__onLoggingTryingEndHdlr = hdlr self.__kickedFromServer = False self.__kickPeripheryID = None if self.__closeCallbackId: BigWorld.cancelCallback(self.__closeCallbackId) self.__closeCallbackId = None if not isSocialToken2Login: if not self.__validateCredentials(user.lower().strip(), password.strip()): self.__onLoggingTryingEndHdlr() return Waiting.show('login') self.__loginDataLoader.host = host self.__loginDataLoader.user = user self.__loginDataLoader.passLength = len(password) self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host) password = pwd_token.generate(password) if len(self.__loginDataLoader.token2): password = '' token2 = self.__loginDataLoader.token2 if AUTO_LOGIN_QUERY_URL == host: g_preDefinedHosts.autoLoginQuery(lambda host: connectionManager.connect(getHostURL(host, token2), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)) return else: host = g_preDefinedHosts.byUrl(host) connectionManager.connect(getHostURL(host, token2, True), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd) return
def updateVehicle(self, vehicle): if self.__inited: Waiting.show('loadHangarSpaceVehicle', True) igrRoomType = game_control.g_instance.igr.getRoomType() igrLayout = g_itemsCache.items.inventory.getIgrCustomizationsLayout() updatedVehCompactDescr = getCustomizedVehCompDescr(igrLayout, vehicle.invID, igrRoomType, vehicle.descriptor.makeCompactDescr()) self.__space.recreateVehicle(self._stripVehCompDescrIfRoaming(updatedVehCompactDescr), vehicle.modelState, self.__changeDone) self.__lastUpdatedVehicle = vehicle
def onLogin(self, userName, password, serverName, isSocialToken2Login): self._autoSearchVisited = serverName == AUTO_LOGIN_QUERY_URL result = self.__validateCredentials(userName.lower().strip(), password.strip(), bool(g_loginManager.getPreference('token2'))) if result.isValid: Waiting.show('login') g_loginManager.initiateLogin(userName, password, serverName, isSocialToken2Login, isSocialToken2Login or self._rememberUser) else: self.as_setErrorMessageS(result.errorMessage, result.invalidFields)
def __onDataServerReceivedData(self, token, spaID, socialNetwork): Waiting.show('login') BigWorld.callback(0.1, BigWorld.wg_bringWindowToForeground) self.__loginParams['token'] = token self.__loginParams['account_id'] = spaID from Manager import SOCIAL_NETWORKS self.__preferences['login_type'] = socialNetwork or SOCIAL_NETWORKS.WGNI connectionManager.initiateConnection(self.__loginParams, '', self.__preferences['server_name'])
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 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 _selectVehicle(self, vehInvID): if vehInvID == self.__vehInvID: return Waiting.show('updateCurrentVehicle', isSingle=True) self.onChangeStarted() self.__vehInvID = vehInvID AccountSettings.setFavorites(CURRENT_VEHICLE, vehInvID) self.refreshModel() self._setChangeCallback()
def _selectVehicle(self, vehicleCD): if self.isPresent() and self.item.intCD == vehicleCD: return Waiting.show('updateCurrentVehicle', isSingle=True) self.onChangeStarted() self.__defaultItem = self.__getPreviewVehicle(vehicleCD) self.__item = self.__getPreviewVehicle(vehicleCD) self.refreshModel() self._setChangeCallback()
def __updateAll(self): Waiting.show("updateVehicle") self.__updateAmmoPanel() self.__updateState() self.__updateCarousel() self.__updateParams() self.__updateResearchPanel() self.__updateCrew() Waiting.hide("updateVehicle")
def onLogin(self, user, password, host, hdlr): self.__onLoggingTryingEndHdlr = hdlr self.__kickedFromServer = False if self.__closeCallbackId: BigWorld.cancelCallback(self.__closeCallbackId) self.__closeCallbackId = None if g_steamAccount.isValid: user, password = g_steamAccount.getCredentials() else: user = user.lower().strip() if len(user) < _LOGIN_NAME_MIN_LENGTH: self.onSetStatus( i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN_LENGTH) % {"count": _LOGIN_NAME_MIN_LENGTH}, self.LOGIN_INVALID, ) return if not isAccountLoginValid(user) and not constants.IS_DEVELOPMENT: self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN), self.LOGIN_INVALID) return password = password.strip() if ( not isPasswordValid(password) and not constants.IS_DEVELOPMENT and not len(self.__loginDataLoader.token2) ): self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_PASSWORD), self.LOGIN_PWD_INVALID) return Waiting.show("login") self.__loginDataLoader.host = host self.__loginDataLoader.user = user self.__loginDataLoader.passLength = len(password) if constants.IS_VIETNAM: self.__pass = password self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host) password = pwd_token.generate(password) if len(self.__loginDataLoader.token2): password = "" if AUTO_LOGIN_QUERY_URL == host: g_preDefinedHosts.autoLoginQuery( lambda host: connectionManager.connect( host.url, user, password, host.keyPath, nickName=None, token2=self.__loginDataLoader.token2 ) ) return else: host = g_preDefinedHosts.byUrl(host) urls = host.urlIterator if urls is not None: if urls.end(): urls.cursor = 0 host = urls.next() LOG_DEBUG("Gets next LoginApp url:", host) connectionManager.connect( host.url, user, password, host.keyPath, nickName=None, token2=self.__loginDataLoader.token2 ) return
def init(self, isPremium): if not self.__spaceInited: LOG_DEBUG('_HangarSpace::init') Waiting.show('loadHangarSpace') self.__inited = True self.__isSpacePremium = isPremium self.__space.create(isPremium, self.__spaceDone) if self.__lastUpdatedVehicle is not None: self.updateVehicle(self.__lastUpdatedVehicle) return
def __selectVehicle(self, vehInvID): if vehInvID == self.__vehInvID: return Waiting.show("updateCurrentVehicle", isSingle=True) self.onChangeStarted() self.__vehInvID = vehInvID AccountSettings.setFavorites(CURRENT_VEHICLE, vehInvID) self.refreshModel() if not self.__changeCallbackID: self.__changeCallbackID = BigWorld.callback(0.1, self.__changeDone)
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 __onCurrentVehicleChanged(self): Waiting.show('updateVehicle') self.__updateState() self.__updateAmmoPanel() self.__updateParams() self.__updateResearchPanel() self.__updateCrew() self.__updateCarouselParams() self.__updateVehIGRStatus() Waiting.hide('updateVehicle')
def doAction(self): vehicle = None if self.__vehInvID > 0: vehicle = g_itemsCache.items.getVehicle(self.__vehInvID) if vehicle is None: return else: isUseGold = self.__isRemove and self.__oldItemCD is not None newComponentItem = g_itemsCache.items.getItemByCD(int(self.__newItemCD)) if newComponentItem is None: return oldComponentItem = None if self.__oldItemCD: oldComponentItem = g_itemsCache.items.getItemByCD(int(self.__oldItemCD)) if not self.__isRemove and oldComponentItem and oldComponentItem.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE: result = yield getInstallerProcessor(vehicle, oldComponentItem, self.__slotIdx, False, True).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 not result.success: return conflictedEqs = newComponentItem.getConflictedEquipments(vehicle) if not newComponentItem.isInInventory and not self.__isRemove: if not self._canBuy(newComponentItem) and self._canBuyWithExchange(newComponentItem): isOk, args = yield DialogsInterface.showDialog(ExchangeCreditsMeta(newComponentItem.intCD)) if not isOk: return if self._canBuy(newComponentItem): Waiting.show('buyItem') buyResult = yield ModuleBuyer(newComponentItem, 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: newComponentItem = g_itemsCache.items.getItemByCD(int(self.__newItemCD)) else: return else: return Waiting.show('applyModule') result = yield getInstallerProcessor(vehicle, newComponentItem, self.__slotIdx, not self.__isRemove, isUseGold, 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 newComponentItem.itemTypeID in (GUI_ITEM_TYPE.TURRET, GUI_ITEM_TYPE.GUN): vehicle = g_itemsCache.items.getItemByCD(vehicle.intCD) yield tryToLoadDefaultShellsLayout(vehicle) Waiting.hide('applyModule') return
def updateVehicleTypeDropdown(self, nationID, vclass): Waiting.show("updating") modulesAll = g_itemsCache.items.getVehicles(self.__getVehicleTypeCriteria(nationID, vclass)).values() data = [{"id": None, "label": DIALOGS.RECRUITWINDOW_MENUEMPTYROW}] modulesAll.sort() for module in modulesAll: data.append({"id": module.innationID, "label": module.shortUserName}) self.flashObject.as_setVehicleTypeDropdown(data) Waiting.hide("updating") return
def updateVehicle(self, vehicle, historicalBattle = None): if self.__inited: Waiting.show('loadHangarSpaceVehicle', True) historicalBattleDef = None if historicalBattle is not None and historicalBattle.canParticipateWith(vehicle.intCD): historicalBattleDef = historicalBattle.getData() igrRoomType = game_control.g_instance.igr.getRoomType() igrLayout = g_itemsCache.items.inventory.getIgrCustomizationsLayout() updatedVehCompactDescr = getCustomizedVehCompDescr(igrLayout, vehicle.invID, igrRoomType, vehicle.descriptor.makeCompactDescr(), historicalBattleDef) self.__space.recreateVehicle(self._stripVehCompDescrIfRoaming(updatedVehCompactDescr), vehicle.modelState, self.__changeDone) self.__lastUpdatedVehicle = vehicle
def __updateAll(self): Waiting.show('updateVehicle') self.__switchCarousels() self.__updateState() self.__updateAmmoPanel() self.__updateCarouselVehicles() self.__updateCarouselParams() self.__updateParams() self.__updateResearchPanel() self.__updateCrew() Waiting.hide('updateVehicle')
def __onConnected(self): Waiting.hide('login') g_preDefinedHosts.resetQueryResult() self.__loginQueue = False LOG_DEBUG('onConnected') def iCallback(): self.app.logoff(True) Waiting.close() Waiting.show('enter', interruptCallback=iCallback)
def onLogin(self, userName, password, serverName, isSocialToken2Login): g_statistics.noteHangarLoadingState(HANGAR_LOADING_STATE.LOGIN, True) self._autoSearchVisited = serverName == AUTO_LOGIN_QUERY_URL self.__customLoginStatus = None result = self.__validateCredentials(userName.lower().strip(), password.strip(), bool(g_loginManager.getPreference('token2'))) if result.isValid: Waiting.show('login') g_loginManager.initiateLogin(userName, password, serverName, isSocialToken2Login, isSocialToken2Login or self._rememberUser) else: self.as_setErrorMessageS(result.errorMessage, result.invalidFields) return
def __onConnected(self): Waiting.hide('login') g_preDefinedHosts.resetQueryResult() self.__loginQueue = False LOG_DEBUG('onConnected') def iCallback(): g_appLoader.goToLoginByRQ() Waiting.close() Waiting.show('enter', interruptCallback=iCallback)
def requestClanFortInfo(self, index): vo = self._searchDP.getVO(index) if vo is not None: cache = self.fortCtrl.getPublicInfoCache() if cache is not None and not cache.isRequestInProcess: if not cache.setSelectedID(vo['clanID']): cache.clearSelectedID() self._searchDP.refresh() else: Waiting.show('fort/card/get') self._searchDP.setSelectedID(vo['clanID'])
def login(self, selectedServer): self.__selectedServer = selectedServer self.__lobbyContext.setAccountComplete(WGC.isAccountComplete()) WGC.prepareToken() Waiting.show('login') self.__wgcCheck()
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 __onSpaceRefreshHandler(self): Waiting.show(_WAITING_MESSAGE)
def changeNation(self, nationIndex): self.__nation = nationIndex Waiting.show('sinhronize') self.__account.base.changeBootcampLessonBonus(nationIndex) g_playerEvents.onClientUpdated += self.onNationChanged
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 _populate(self): super(CaptchaDialog, self)._populate() Waiting.show('requestCaptcha') CaptchaImageWorker(self, '_CaptchaDialog__afterImageCreate').start()
def showWaiting(self, messageID, isSingle = False): Waiting.show('tutorial-{0:>s}'.format(messageID), isSingle=isSingle)
def updateVehicle(self, vehicle): if self.__inited: Waiting.show('loadHangarSpaceVehicle', True) self.statsCollector.noteHangarLoadingState(HANGAR_LOADING_STATE.START_LOADING_VEHICLE) self.__space.recreateVehicle(vehicle.descriptor, vehicle.modelState, self.__changeDone) self.__lastUpdatedVehicle = vehicle
def updateVehicles(self, resetPos = False): Waiting.show('updateMyVehicles') filterCriteria = REQ_CRITERIA.INVENTORY if self.vehiclesFilter['nation'] != -1: filterCriteria |= REQ_CRITERIA.NATIONS([self.vehiclesFilter['nation']]) if self.vehiclesFilter['tankType'] != 'none': filterCriteria |= REQ_CRITERIA.VEHICLE.CLASSES([self.vehiclesFilter['tankType']]) if self.vehiclesFilter['ready']: filterCriteria |= REQ_CRITERIA.VEHICLE.FAVORITE items = g_itemsCache.items newVehs = items.getVehicles(REQ_CRITERIA.INVENTORY) filteredVehs = items.getVehicles(filterCriteria) vehsData = [] def sorting(v1, v2): if v1.isFavorite and not v2.isFavorite: return -1 if not v1.isFavorite and v2.isFavorite: return 1 return v1.__cmp__(v2) for vehicle in sorted(filteredVehs.itervalues(), sorting): try: vState, vStateLvl = vehicle.getState() v = {'id': vehicle.invID, 'inventoryId': vehicle.invID, 'label': vehicle.userName, 'image': vehicle.icon, 'nation': vehicle.nationID, 'level': vehicle.level, 'stat': vState, 'stateLevel': vStateLvl, 'doubleXPReceived': vehicle.dailyXPFactor, 'compactDescr': vehicle.intCD, 'favorite': vehicle.isFavorite, 'canSell': vehicle.canSell, 'clanLock': vehicle.clanLock, 'elite': vehicle.isElite, 'premium': vehicle.isPremium, 'tankType': vehicle.type, 'exp': vehicle.xp, 'current': 0, 'enabled': True} except Exception: LOG_ERROR("Exception while '%s' vehicle processing" % vehicle.descriptor.type.name) LOG_CURRENT_EXCEPTION() continue vehsData.append(v) self.as_vehiclesResponseS({'slotPrice': items.shop.getVehicleSlotsPrice(items.stats.vehicleSlots), 'availableSlotsForBuy': items.stats.vehicleSlots - len(newVehs), 'allTanksCount': len(newVehs), 'selectedTankID': g_currentVehicle.invID, 'slots': vehsData}) isVehTypeLock = sum((len(v) for v in items.stats.vehicleTypeLocks.itervalues())) isGlobalVehLock = sum((len(v) for v in items.stats.globalVehicleLocks.itervalues())) if self.__updateVehiclesTimerId is None and (isVehTypeLock or isGlobalVehLock): self.__updateVehiclesTimerId = BigWorld.callback(self.UPDATE_LOCKS_PERIOD, self.updateLockTimers) LOG_DEBUG('Lock timer updated') Waiting.hide('updateMyVehicles') return
def updateTankmen(self, diff=None): Waiting.show('updateTankmen') if g_currentVehicle.isPresent(): vehicle = g_currentVehicle.item allTankmen = self.itemsCache.items.getTankmen() commander_bonus = vehicle.bonuses['commander'] roles = [] lessMastered = 0 tankmenDescrs = dict(vehicle.crew) skillsConfig = getSkillsConfig() for slotIdx, tman in vehicle.crew: if slotIdx > 0 and tman is not None and ( tankmenDescrs[lessMastered] is None or compareMastery(tankmenDescrs[lessMastered].descriptor, tman.descriptor) > 0): lessMastered = slotIdx role = vehicle.descriptor.type.crewRoles[slotIdx][0] roles.append({ 'tankmanID': tman.invID if tman is not None else None, 'roleType': role, 'role': convert(skillsConfig.getSkill(role).userString), 'roleIcon': Tankman.getRoleBigIconPath(role), 'nationID': vehicle.nationID, 'typeID': vehicle.innationID, 'slot': slotIdx, 'vehicleType': vehicle.shortUserName, 'tankType': vehicle.type, 'vehicleElite': vehicle.isPremium or vehicle.isPremiumIGR, 'roles': list(vehicle.descriptor.type.crewRoles[slotIdx]) }) tankmenData = [] for tankman in allTankmen.itervalues(): if tankman.isInTank and tankman.vehicleInvID != vehicle.invID: continue tankmanVehicle = self.itemsCache.items.getItemByCD( tankman.vehicleNativeDescr.type.compactDescr) bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0 skills_count = skillsConfig.getNumberOfActiveSkills() skillsList = [] for skill in tankman.skills: skillsList.append({ 'tankmanID': tankman.invID, 'id': str(tankman.skills.index(skill)), 'name': skill.userName, 'desc': skill.description, 'icon': skill.icon, 'level': skill.level, 'active': skill.isEnable and skill.isActive }) newSkillsCount, lastNewSkillLvl = tankman.newSkillCount if newSkillsCount > 0: skillsList.append({ 'buy': True, 'buyCount': newSkillsCount - 1, 'tankmanID': tankman.invID, 'level': lastNewSkillLvl }) tankmanData = { 'fullName': tankman.fullUserName, 'lastName': tankman.lastUserName or tankman.firstUserName, 'rank': tankman.rankUserName, 'specializationLevel': tankman.realRoleLevel[0], 'role': tankman.roleUserName, 'vehicleType': tankmanVehicle.shortUserName, 'iconFile': tankman.icon, 'rankIconFile': tankman.iconRank, 'roleIconFile': Tankman.getRoleBigIconPath(tankman.descriptor.role), 'contourIconFile': tankmanVehicle.iconContour, 'tankmanID': tankman.invID, 'nationID': tankman.nationID, 'typeID': tankmanVehicle.innationID, 'inTank': tankman.isInTank, 'roleType': tankman.descriptor.role, 'tankType': tankmanVehicle.type, 'efficiencyLevel': tankman.efficiencyRoleLevel, 'bonus': bonus_role_level, 'lastSkillLevel': tankman.descriptor.lastSkillLevel, 'isLessMastered': vehicle.crewIndices.get(tankman.invID) == lessMastered and vehicle.isXPToTman, 'compact': tankman.strCD, 'availableSkillsCount': skills_count, 'skills': skillsList } self.__updateTankmanDataByCrewSkin(tankman, tankmanData) tankmenData.append(tankmanData) self.as_tankmenResponseS({ 'showRecruit': self._showRecruit, 'roles': roles, 'tankmen': tankmenData }) dogName = '' if 'dog' in self.itemsCache.items.getItemByCD( g_currentVehicle.item.intCD).tags: dogName = backport.text( R.strings.menu.hangar.crew.rody.dog.dyn( vehicle.nationName).name()) self.as_dogResponseS(dogName) tooltipId = TOOLTIPS.HANGAR_CREW_RUDY_DOG + vehicle.nationName self.as_setDogTooltipS(tooltipId) Waiting.hide('updateTankmen') return
def __nextWaiting(self): if len(self.__messages2Show): self.__hideWaiting() self.__currentMessage = self.__messages2Show.pop(0) Waiting.show(self.__currentMessage)
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 onShopResyncStarted(): Waiting.show('sinhronize')
def finishBootcamp(self): Waiting.show('login') g_bootcampEvents.onGarageLessonFinished(self.getLessonNum()) g_bootcampEvents.onRequestBootcampFinish()
def changeNation(self, nationIndex, removedCallback): self.__nation = nationIndex self.__nationWindowRemovedCallback = removedCallback Waiting.show('sinhronize') self.__account.base.changeBootcampLessonBonus(nationIndex) g_playerEvents.onClientUpdated += self.onNationChanged
def _request(self, callback): _logger.debug('Make server request to receive offers gifts. Choices: %s', self.__chosenGifts) Waiting.show('loadContent') choices = cPickle.dumps(self.__chosenGifts) BigWorld.player().receiveMultipleOfferGifts(choices, lambda requestID, resultID, errStr, ext=None: self._response(resultID, callback, ctx=ext, errStr=errStr)) return
def finishBootcamp(self): Waiting.show('login') self.clear() g_bootcampEvents.onGarageLessonFinished(self.__lessonId) self.toDefaultAccount()
def login(self, selectedServer): self.__selectedServer = selectedServer BigWorld.WGC_prepareToken() Waiting.show('login') self.__wgcCheck()
def start(flagCode = None, waitingMsg = 'LOBBY_LOAD_HANGAR_SPACE_VEHICLE', showWaiting = True): if showWaiting and not SyncOperationKeeper.getFlagStatus(flagCode): waitingID = Waiting.show(waitingMsg) SyncOperationKeeper.__WAITING_IDS[flagCode] = waitingID for flag in SyncOperationKeeper.__getProcessedFlags(flagCode): SyncOperationKeeper.__FLAGS_STATUS[flag] += 1
def updatePreviewVehicle(self, vehicle): if self.__inited: Waiting.show('loadHangarSpaceVehicle', True) self.__space.recreateVehicle(vehicle.descriptor, vehicle.modelState, self.__changeDone) self.__lastUpdatedVehicle = vehicle
def reload(self): Waiting.show('reloadCaptcha') CaptchaImageWorker(self, '_CaptchaDialog__afterImageReload').start()
def globalWaitingToggle(self, cmd): if cmd.show: Waiting.show(cmd.messageID) else: Waiting.hide(cmd.messageID)
def startToUpdateVehicle(self, vehicle): Waiting.show('loadHangarSpaceVehicle', isSingle=True, overlapsUI=False) self.updateVehicle(vehicle)
def load(self, url=None, title=None, showActionBtn=True, showWaiting=True, browserID=None, isAsync=False, browserSize=None, isDefault=True, callback=None, showCloseBtn=False, useBrowserWindow=True, isModal=False, showCreateWaiting=False, handlers=None, showBrowserCallback=None, isSolidBorder=False): if showCreateWaiting: Waiting.show('browser/init') url = yield self.__urlMacros.parse(url or GUI_SETTINGS.browser.url) suffix = yield self.__urlMacros.parse(GUI_SETTINGS.browser.params) concatenator = '&' if '?' in url else '?' if suffix not in url: url = concatenator.join([url, suffix]) size = browserSize or BROWSER.SIZE webBrowserID = browserID if browserID is None: browserID = self.__browserIDGenerator.next() webBrowserID = browserID elif type(browserID) is not int: webBrowserID = self.__browserIDGenerator.next() ctx = { 'url': url, 'title': title, 'showActionBtn': showActionBtn, 'showWaiting': showWaiting, 'browserID': browserID, 'size': size, 'isAsync': isAsync, 'showCloseBtn': showCloseBtn, 'showWindow': useBrowserWindow, 'alias': VIEW_ALIAS.BROWSER_WINDOW_MODAL if isModal else VIEW_ALIAS.BROWSER_WINDOW, 'showCreateWaiting': showCreateWaiting, 'handlers': handlers, 'showBrowserCallback': showBrowserCallback, 'isSolidBorder': isSolidBorder } if browserID not in self.__browsers and browserID not in self.__pendingBrowsers: texture = self._BROWSER_TEXTURE app = g_appLoader.getApp() if app is None: raise SoftException('Application can not be None') browser = WebBrowser(webBrowserID, app, texture, size, url, handlers=self.__filters) self.__browsers[browserID] = browser if self.__isCreatingBrowser(): LOG_BROWSER('CTRL: Queueing a browser creation: ', browserID, url) self.__pendingBrowsers[browserID] = ctx else: self.__createBrowser(ctx) elif browserID in self.__pendingBrowsers: LOG_BROWSER('CTRL: Re-queuing a browser creation, overriding: ', browserID, url) self.__pendingBrowsers[browserID] = ctx elif browserID in self.__browsers: LOG_BROWSER('CTRL: Re-navigating an existing browser: ', browserID, url) browser = self.__browsers[browserID] browser.navigate(url) browser.changeTitle(title) callback(browserID) return
def updateTankmen(self): Waiting.show('updateTankmen') if g_currentVehicle.isPresent(): tankmen = g_itemsCache.items.getTankmen() vehicle = g_currentVehicle.item commander_bonus = vehicle.bonuses['commander'] roles = [] lessMastered = 0 tankmenDescrs = dict(vehicle.crew) for slotIdx, tman in vehicle.crew: if slotIdx > 0 and tman is not None and ( tankmenDescrs[lessMastered] is None or compareMastery(tankmenDescrs[lessMastered].descriptor, tman.descriptor) > 0): lessMastered = slotIdx role = vehicle.descriptor.type.crewRoles[slotIdx][0] roles.append({ 'tankmanID': tman.invID if tman is not None else None, 'roleType': role, 'role': convert(getSkillsConfig()[role]['userString']), 'roleIcon': Tankman.getRoleBigIconPath(role), 'nationID': vehicle.nationID, 'typeID': vehicle.innationID, 'slot': slotIdx, 'vehicleType': vehicle.shortUserName, 'tankType': vehicle.type, 'vehicleElite': vehicle.isPremium or vehicle.isPremiumIGR, 'roles': list(vehicle.descriptor.type.crewRoles[slotIdx]) }) tankmenData = [] for tankman in tankmen.itervalues(): if tankman.isInTank and tankman.vehicleInvID != vehicle.invID: continue tankmanVehicle = g_itemsCache.items.getItemByCD( tankman.vehicleNativeDescr.type.compactDescr) bonus_role_level = commander_bonus if tankman.descriptor.role != 'commander' else 0.0 skills_count = len(list(ACTIVE_SKILLS)) skillsList = [] for skill in tankman.skills: skillsList.append({ 'tankmanID': tankman.invID, 'id': str(tankman.skills.index(skill)), 'name': skill.userName, 'desc': skill.description, 'icon': skill.icon, 'level': skill.level, 'active': skill.isEnable and skill.isActive }) newSkillsCount, lastNewSkillLvl = tankman.newSkillCount if newSkillsCount > 0: skillsList.append({ 'buy': True, 'tankmanID': tankman.invID, 'level': lastNewSkillLvl }) tankmanData = { 'firstName': tankman.firstUserName, 'lastName': tankman.lastUserName, 'rank': tankman.rankUserName, 'specializationLevel': tankman.realRoleLevel[0], 'role': tankman.roleUserName, 'vehicleType': tankmanVehicle.shortUserName, 'iconFile': tankman.icon, 'rankIconFile': tankman.iconRank, 'roleIconFile': Tankman.getRoleBigIconPath(tankman.descriptor.role), 'contourIconFile': tankmanVehicle.iconContour, 'tankmanID': tankman.invID, 'nationID': tankman.nationID, 'typeID': tankmanVehicle.innationID, 'inTank': tankman.isInTank, 'roleType': tankman.descriptor.role, 'tankType': tankmanVehicle.type, 'efficiencyLevel': tankman.efficiencyRoleLevel, 'bonus': bonus_role_level, 'lastSkillLevel': tankman.descriptor.lastSkillLevel, 'isLessMastered': vehicle.crewIndices.get(tankman.invID) == lessMastered and vehicle.isXPToTman, 'compact': tankman.strCD, 'availableSkillsCount': skills_count, 'skills': skillsList } tankmenData.append(tankmanData) self.as_tankmenResponseS({'roles': roles, 'tankmen': tankmenData}) dogName = '' if 'dog' in g_itemsCache.items.getItemByCD( g_currentVehicle.item.intCD).tags: dogName = MENU.HANGAR_CREW_RODY_DOG_NAME self.as_dogResponseS(dogName) Waiting.hide('updateTankmen') return
def requestTableData(self, nation, type, filter): Waiting.show('updateInventory') AccountSettings.setFilter('inventory_current', (nation, type)) AccountSettings.setFilter('inventory_' + type, filter) self._setTableData(filter, nation, type) Waiting.hide('updateInventory')
def showActionWaitWindow(self): if not self.__showingWaitingActionWindow: self.__showingWaitingActionWindow = True Waiting.show('sinhronize')
def _request(self, callback): _logger.debug('Make server request to receive offer gift. offerID=%s, giftID=%s', self.__offerID, self.__giftID) Waiting.show('loadContent') BigWorld.player().receiveOfferGift(self.__offerID, self.__giftID, lambda requestID, resultID, errStr, ext=None: self._response(resultID, callback, ctx=ext, errStr=errStr)) return