def __doLeaveArena(self): exitResult = self.sessionProvider.getExitResult() if exitResult.playerInfo is not None: igrType = exitResult.playerInfo.igrType else: igrType = constants.IGR_TYPE.NONE if constants.IS_KOREA and GUI_SETTINGS.igrEnabled and igrType != constants.IGR_TYPE.NONE: i18nKey = 'quitBattleIGR' else: i18nKey = 'quitBattle' if exitResult.isDeserter: result = yield DialogsInterface.showDialog( IngameDeserterDialogMeta(i18nKey + '/deserter', focusedID=DIALOG_BUTTON_ID.CLOSE)) elif BattleReplay.isPlaying(): result = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('quitReplay', focusedID=DIALOG_BUTTON_ID.CLOSE)) else: result = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('quitBattle', focusedID=DIALOG_BUTTON_ID.CLOSE)) if result: self.__doExit() return
def execute(self): if self._entity.isCommander(): func = self._entity fullData = func.getUnitFullData(unitMgrID=func.getID()) notReadyCount = 0 for slot in fullData.slotsIterator: slotPlayer = slot.player if slotPlayer: if slotPlayer.isInArena() or fullData.playerInfo.isInSearch() or fullData.playerInfo.isInQueue(): DialogsInterface.showI18nInfoDialog('squadHavePlayersInBattle', lambda result: None) return True if not slotPlayer.isReady: notReadyCount += 1 if not fullData.playerInfo.isReady: notReadyCount -= 1 if fullData.stats.occupiedSlotsCount == 1: DialogsInterface.showDialog(I18nConfirmDialogMeta('squadHaveNoPlayers'), self._confirmCallback) return True if notReadyCount > 0: if notReadyCount == 1: DialogsInterface.showDialog(I18nConfirmDialogMeta('squadHaveNotReadyPlayer'), self._confirmCallback) return True DialogsInterface.showDialog(I18nConfirmDialogMeta('squadHaveNotReadyPlayers'), self._confirmCallback) return True self._setCreatorReady() else: self._entity.togglePlayerReadyAction(True) return True
def __doLeaveArena(self, needToStopBootcamp=False): exitResult = self.sessionProvider.getExitResult() if exitResult.playerInfo is not None: igrType = exitResult.playerInfo.igrType else: igrType = constants.IGR_TYPE.NONE if constants.IS_KOREA and GUI_SETTINGS.igrEnabled and igrType != constants.IGR_TYPE.NONE: i18nKey = 'quitBattleIGR' else: i18nKey = 'quitBattle' arenaType = self.sessionProvider.arenaVisitor.getArenaGuiType() if exitResult.isDeserter and arenaType not in _ARENAS_WITHOUT_DEZERTER_PUNISHMENTS: result = yield DialogsInterface.showDialog( IngameDeserterDialogMeta(i18nKey + '/deserter', focusedID=DIALOG_BUTTON_ID.CLOSE)) elif BattleReplay.isPlaying(): result = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('quitReplay', focusedID=DIALOG_BUTTON_ID.CLOSE)) else: result = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('quitBattle', focusedID=DIALOG_BUTTON_ID.CLOSE)) if result: if needToStopBootcamp: self.bootcampController.stopBootcamp(True) self.destroy() else: self.__doExit() return
def execute(self): if self._entity.isCommander(): func = self._entity fullData = func.getUnitFullData(unitMgrID=func.getID()) notReadyCount = 0 for slot in fullData.slotsIterator: slotPlayer = slot.player if slotPlayer: if slotPlayer.isInArena( ) or fullData.playerInfo.isInSearch( ) or fullData.playerInfo.isInQueue(): DialogsInterface.showI18nInfoDialog( 'squadHavePlayersInBattle', lambda result: None) return True if not slotPlayer.isReady: notReadyCount += 1 if not fullData.playerInfo.isReady: notReadyCount -= 1 if fullData.stats.occupiedSlotsCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNoPlayers'), self._confirmCallback) return True if notReadyCount > 0: if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayer'), self._confirmCallback) return True DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayers'), self._confirmCallback) return True if not g_currentVehicle.isLocked( ) and not fullData.playerInfo.isReady: _, unit = self._entity.getUnit() playerVehicles = unit.getVehicles() if playerVehicles: commanderLevel = g_currentVehicle.item.level lowerBound, upperBound = self._entity.getSquadLevelBounds() minLevel = max(MIN_VEHICLE_LEVEL, commanderLevel + lowerBound) maxLevel = min(MAX_VEHICLE_LEVEL, commanderLevel + upperBound) levelRange = range(minLevel, maxLevel + 1) for _, unitVehicles in playerVehicles.iteritems(): for vehicle in unitVehicles: if vehicle.vehLevel not in levelRange: DialogsInterface.showDialog( I18nConfirmDialogMeta( 'squadHaveNoPlayers'), self._confirmCallback) return True self._setCreatorReady() else: self._entity.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 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 __doLeaveArena(self): exitResult = self.sessionProvider.getExitResult() if exitResult.isDeserter: quitBattleKey = self.__getQuitBattleKey(exitResult.playerInfo) result = yield DialogsInterface.showDialog(IngameDeserterDialogMeta(quitBattleKey + '/deserter', focusedID=DIALOG_BUTTON_ID.CLOSE)) elif BattleReplay.isPlaying(): result = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('quitReplay', focusedID=DIALOG_BUTTON_ID.CLOSE)) else: result = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('quitBattle', focusedID=DIALOG_BUTTON_ID.CLOSE)) if result: self.__doExit()
def execute(self): if self._entity.isCommander(): entity = self._entity fullData = entity.getUnitFullData(unitIdx=entity.getUnitIdx()) isAutoFill = entity.getRosterType( ) == ROSTER_TYPE.FALLOUT_MULTITEAM_ROSTER notReadyCount = 0 for slot in fullData.slotsIterator: slotPlayer = slot.player if slotPlayer: if slotPlayer.isInArena() or slotPlayer.isInPreArena( ) or fullData.playerInfo.isInSearch( ) or fullData.playerInfo.isInQueue(): DialogsInterface.showI18nInfoDialog( 'squadHavePlayersInBattle', lambda result: None) return True if not slotPlayer.isReady: notReadyCount += 1 if not fullData.playerInfo.isReady: notReadyCount -= 1 if isAutoFill: if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayerAuto'), self._confirmCallback) return True if fullData.stats.freeSlotsCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNoPlayerAuto'), self._confirmCallback) return True else: if fullData.stats.occupiedSlotsCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNoPlayers'), self._confirmCallback) return True if notReadyCount > 0: if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayer'), self._confirmCallback) return True DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayers'), self._confirmCallback) return True self._setCreatorReady() else: self._entity.togglePlayerReadyAction() return True
def doAction(self, action=None, dispatcher=None): if self.isCreator(): if self.getRosterKey() != PREBATTLE_ROSTER.ASSIGNED_IN_TEAM1: DialogsInterface.showI18nInfoDialog('teamDoesNotHaveCommander', lambda result: None) return True stats = self.getPlayersStateStats() creatorWeight = 1 if not self.getPlayerInfo().isReady() else 0 readyCount = stats.playersCount - stats.notReadyCount if readyCount < stats.limitMaxCount - creatorWeight: DialogsInterface.showDialog( I18nConfirmDialogMeta('teamHaveNotReadyPlayers', messageCtx={ 'readyCount': readyCount, 'playersCount': stats.playersCount }), self.__setCreatorReady) return True self.__setCreatorReady(True) elif self.getPlayerInfo().isReady(): self.setPlayerState( prb_ctx.SetPlayerStateCtx( False, waitingID='prebattle/player_not_ready')) else: self.setPlayerState( prb_ctx.SetPlayerStateCtx(True, waitingID='prebattle/player_ready')) return True
def closeWindow(self): purchaseItems = self.getPurchaseItems() cart = getTotalPurchaseInfo(purchaseItems) if cart.numTotal or any(self._cleanSettings(self._currentSettings).itervalues()): DialogsInterface.showDialog(I18nConfirmDialogMeta('customization/close'), self.__onConfirmCloseWindow) else: self.__onConfirmCloseWindow(proceed=True)
def closeWindow(self): if self.__controller.cart.items: DialogsInterface.showDialog( I18nConfirmDialogMeta('customization/close'), self.__confirmCloseWindow) else: self.__confirmCloseWindow(True)
def applyAction(self): if self.intBuildingID == FORT_BUILDING_TYPE.MILITARY_BASE and self.nextLevel.level == FORT_BATTLE_DIVISIONS.ABSOLUTE.minFortLevel: DialogsInterface.showDialog( I18nConfirmDialogMeta('fortModernizationAbsoluteDivision'), self.__confirmationClosed) else: self.__requestToUpgrade()
def closeWindow(self): purchaseItems = self.getPurchaseItems() cart = getTotalPurchaseInfo(purchaseItems) if cart.numTotal: DialogsInterface.showDialog(I18nConfirmDialogMeta('customization/close'), self.__onConfirmCloseWindow) else: self.__onConfirmCloseWindow(proceed=True)
def __showDialog(self): isOk = yield DialogsInterface.showDialog( I18nConfirmDialogMeta( 'fortificationFixedPlayers', messageCtx={ 'oldBuilding': i18n.makeString( FORTIFICATIONS.buildings_buildingname( self.__oldBuilding)), 'newBuilding': i18n.makeString( FORTIFICATIONS.buildings_buildingname( self.__buildingUId)) }, scope=FortifiedWindowScopes.ASSIGN_BUILD_DLG_SCOPE)) if isOk: result = yield self.fortProvider.sendRequest( AttachCtx(self.__buildingId, waitingID='fort/building/attach')) if result: g_fortSoundController.playAttachedToBuilding() building = self.fortCtrl.getFort().getBuilding( self.__buildingId) SystemMessages.g_instance.pushI18nMessage( SYSTEM_MESSAGES.FORTIFICATION_FIXEDPLAYERTOBUILDING, buildingName=building.userName, type=SystemMessages.SM_TYPE.Warning)
def fillVehicle(self, needRepair, needAmmo, needEquipment, isPopulate, isUnload, isOrderChanged, shells, equipment): if not needRepair and not needAmmo and not needEquipment: self.__fillTechnicalMaintenance(shells, equipment) else: msgPrefix = '{0}' if needRepair: msgPrefix = msgPrefix.format('_repair{0}') if needAmmo or needEquipment: msgPrefix = msgPrefix.format('_populate') elif isUnload: msgPrefix = msgPrefix.format('_unload') elif isOrderChanged: msgPrefix = msgPrefix.format('_order_change') else: msgPrefix = msgPrefix.format('') msg = i18n.makeString(''.join( ['#dialogs:technicalMaintenanceConfirm/msg', msgPrefix])) def fillConfirmationCallback(isConfirmed): if isConfirmed: if needRepair: self.repair() self.__fillTechnicalMaintenance(shells, equipment) DialogsInterface.showDialog( I18nConfirmDialogMeta('technicalMaintenanceConfirm', messageCtx={'content': msg}), fillConfirmationCallback)
def doAction(self, action=None, dispatcher=None): if self.isCreator(): stats = self.getPlayersStateStats() if stats.haveInBattle: DialogsInterface.showI18nInfoDialog('squadHavePlayersInBattle', lambda result: None) return True notReadyCount = stats.notReadyCount if not self.getPlayerInfo().isReady(): notReadyCount -= 1 if notReadyCount > 0: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayers', messageCtx={ 'notReadyCount': notReadyCount, 'playersCount': stats.playersCount }), self.__setCreatorReady) return True self.__setCreatorReady(True) elif self.getPlayerInfo().isReady(): self.setPlayerState( context.SetPlayerStateCtx( False, waitingID='prebattle/player_not_ready')) else: self.setPlayerState( context.SetPlayerStateCtx(True, waitingID='prebattle/player_ready')) return True
def onCloseWindow(self): if self.__ctx.isOutfitsModified(): DialogsInterface.showDialog( I18nConfirmDialogMeta('customization/close'), self.__onCloseWindow) else: self.__onCloseWindow(proceed=True)
def _disbandClub(self, club): if len(club.getMembers()) > 1: i18nKey = 'discontinuingFormationConfirmation' else: i18nKey = 'discontinuingEmptyFormationConfirmation' sysMsg = club_fmts.getDestroyClubSysMsg(self.clubsCtrl.getClub(self._clubDbID)) self._doExitAction(DestroyClubCtx(self._clubDbID), I18nConfirmDialogMeta('staticFormation/staffView/%s' % i18nKey, focusedID=DIALOG_BUTTON_ID.CLOSE), WAITING.CLUBS_DESTROYCLUB, sysMsg)
def __onRepairBtnClicked(self): msg = backport.text( R.strings.dialogs.technicalMaintenanceConfirm.msg_repair()) isConfirmed = yield DialogsInterface.showDialog( I18nConfirmDialogMeta('technicalMaintenanceConfirm', messageCtx={'content': msg})) if isConfirmed and g_currentVehicle.item.isBroken: self.__repair()
def execute(self, customData): if self._functional.isCreator(): fullData = self._functional.getUnitFullData( unitIdx=self._functional.getUnitIdx()) if fullData is None: return {} _, _, _, pInfo, slotsIter = fullData playerIsIdle = False playersCount = 0 notReadyCount = 0 for slot in slotsIter: slotPlayer = slot.player if slotPlayer: if not playerIsIdle: playerIsIdle = slotPlayer.isInArena( ) or slotPlayer.isInPreArena() or pInfo.isInSearch( ) or pInfo.isInQueue() playersCount += 1 if not slotPlayer.isReady: notReadyCount += 1 if playerIsIdle: DialogsInterface.showI18nInfoDialog('squadHavePlayersInBattle', lambda result: None) return True if playersCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNoPlayers'), self.__setCreatorReady) return True if not pInfo.isReady: notReadyCount -= 1 if notReadyCount == 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayer'), self.__setCreatorReady) return True if notReadyCount > 1: DialogsInterface.showDialog( I18nConfirmDialogMeta('squadHaveNotReadyPlayers'), self.__setCreatorReady) return True self.__setCreatorReady(True) else: self._functional.togglePlayerReadyAction(True) return True
def _buyRequestConfirmation(productName, priceStr, key='buyConfirmation'): return DialogsInterface.showDialog( meta=I18nConfirmDialogMeta(key=key, messageCtx={ 'product': productName, 'price': priceStr }, focusedID=DIALOG_BUTTON_ID.SUBMIT))
def _makeMeta(self): return I18nConfirmDialogMeta(self.localeKey, self.ctx, self.ctx, meta=HtmlMessageDialogMeta( self.metaPath, self.metaKey, self.ctx), focusedID=DIALOG_BUTTON_ID.SUBMIT)
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 assignPrivate(self, memberDbID, userName): isOk = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('staticFormation/staffView/demoteConfirmation', messageCtx={'userName': userName})) if isOk: self.showWaiting(WAITING.CLUBS_ASSIGNPRIVATE) results = yield self.clubsCtrl.sendRequest(AssignPrivateCtx(self._clubDbID, int(memberDbID))) if results.isSuccess(): SystemMessages.pushMessage(club_fmts.getAssignPrivateSysMsg(self.getUserFullName(int(memberDbID)))) self.hideWaiting()
def showI18nConfirmDialog(i18nKey, callback, meta = None, focusedID = None): if g_sessionProvider.isBattleUILoaded(): customMsg = None if meta is not None: customMsg.getMessage() showConfirmDialog(i18nKey, callback, customMessage=customMsg, ns='battle') else: showDialog(I18nConfirmDialogMeta(i18nKey, meta=meta, focusedID=focusedID), callback)
def __requestConfirmation(self): return DialogsInterface.showDialog(meta=I18nConfirmDialogMeta( key='buyConfirmation', messageCtx={ 'product': self.__packTitle or '"This Pack"', 'price': formatPrice( self.__packPrice, reverse=True, useIcon=True) }, focusedID=DIALOG_BUTTON_ID.SUBMIT))
def _leaveClub(self): sysMsg = club_fmts.getLeaveClubSysMsg( self.clubsCtrl.getClub(self._clubDbID)) self._doExitAction( LeaveClubCtx(self._clubDbID), I18nConfirmDialogMeta( 'staticFormation/staffView/leaveClubConfirmation', focusedID=DIALOG_BUTTON_ID.CLOSE), WAITING.CLUBS_LEAVECLUB, sysMsg)
def _kickMember(self, memberDbID, memberUserName): sysMsg = club_fmts.getKickMemberSysMsg(memberUserName) self._doExitAction( KickMemberCtx(self._clubDbID, memberDbID), I18nConfirmDialogMeta( 'staticFormation/staffView/removeMemberConfirmation', messageCtx={'userName': memberUserName}, focusedID=DIALOG_BUTTON_ID.CLOSE), WAITING.CLUBS_CLUBKICKMEMBER, sysMsg)
def __canActivate(self, newBoosterDescription): return DialogsInterface.showDialog( I18nConfirmDialogMeta( BC.BOOSTER_ACTIVATION_CONFORMATION_TEXT_KEY, messageCtx={ 'newBoosterName': text_styles.middleTitle(newBoosterDescription) }, focusedID=DIALOG_BUTTON_ID.CLOSE))
def getDialogReplaceElements(elementGroups): elementsCount = sum([ len(x) for x in elementGroups ]) if elementsCount > 1: deleteStr = text_styles.error(VEHICLE_CUSTOMIZATION.DIALOG_REMOVE_ELEMENTS_DELETE) description = text_styles.main(_ms(VEHICLE_CUSTOMIZATION.DIALOG_REPLACE_ELEMENTS_DESCRIPTION, elementsName=__formatReplaceElements(elementGroups), delete=deleteStr)) return I18nConfirmDialogMeta('customization/replace_elements', messageCtx={'description': description}, focusedID=DIALOG_BUTTON_ID.CLOSE) for elements, cType in zip(elementGroups, CUSTOMIZATION_TYPE.ALL): if elements: return getDialogReplaceElement(elements[0], cType)
def fillVehicle(self, needRepair, needAmmo, needEquipment, isPopulate, isUnload, isOrderChanged, shells, equipment): shellsLayout = [] eqsLayout = [] for shell in shells: buyGoldShellForCredits = shell.goldShellsForCredits and shell.prices[ 1] > 0 and shell.currency == Currency.CREDITS shellsLayout.append( int(shell.id) if not buyGoldShellForCredits else -int(shell.id) ) shellsLayout.append(int(shell.userCount)) for ei in equipment: if ei is not None: intCD = int(ei.id) buyGoldEqForCredits = ei.goldEqsForCredits and ei.prices[ 1] > 0 and ei.currency == Currency.CREDITS eqsLayout.append(intCD if not buyGoldEqForCredits else -intCD) eqsLayout.append(1) else: eqsLayout.append(0) eqsLayout.append(0) if not needRepair and not needAmmo and not needEquipment: self.__setVehicleLayouts(g_currentVehicle.item, shellsLayout, eqsLayout) else: msgPrefix = '{0}' if needRepair: msgPrefix = msgPrefix.format('_repair{0}') if needAmmo or needEquipment: msgPrefix = msgPrefix.format('_populate') elif isUnload: msgPrefix = msgPrefix.format('_unload') elif isOrderChanged: msgPrefix = msgPrefix.format('_order_change') else: msgPrefix = msgPrefix.format('') msg = i18n.makeString(''.join( ['#dialogs:technicalMaintenanceConfirm/msg', msgPrefix])) if not self.__isConfirmDialogShown: def fillConfirmationCallback(isConfirmed): if isConfirmed: if needRepair: self.repair() self.__setVehicleLayouts(g_currentVehicle.item, shellsLayout, eqsLayout) self.__isConfirmDialogShown = False DialogsInterface.showDialog( I18nConfirmDialogMeta('technicalMaintenanceConfirm', messageCtx={'content': msg}), fillConfirmationCallback) self.__isConfirmDialogShown = True return