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 requestBuildingInfo(self, uid): infoData = {} id = self.getBuildingIDbyUID(uid) self.__markAsVisited(id) buildingStatus = self.__getBuildingStatus(id) infoData['buildingName'] = text_styles.highTitle( i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid))) infoData['buildingID'] = uid infoData['longDescr'] = text_styles.standard( i18n.makeString(FORTIFICATIONS.buildingsprocess_longdescr(uid))) buttonLbl = FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBL if buildingStatus == self.BUILDING_STATUS.BUILT: buttonLbl = text_styles.standard( i18n.makeString( FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBLBUILT)) infoData['buttonLabel'] = i18n.makeString(buttonLbl) infoData['orderInfo'] = self.__makeOrderInfoData(uid) isVisibleBtn = True isEnableBtn = True statusMsg = '' statusIconTooltip = None if buildingStatus == self.BUILDING_STATUS.BUILT: statusMsg = ''.join( (icons.checkmark(), text_styles.success( i18n.makeString( FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_BUILT)))) isEnableBtn = False isVisibleBtn = False statusIconTooltip = self.__makeStatusTooltip(True) buttonTooltip = self.__makeButtonTooltip( self.BUILDING_STATUS.BUILT, None) elif buildingStatus == self.BUILDING_STATUS.NOT_AVAILABLE: isEnableBtn = False isVisibleBtn = True statusMsg = text_styles.error( i18n.makeString(FORTIFICATIONS. BUILDINGSPROCESS_BUILDINGINFO_STATUSMESSAGE)) imageSource = icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_REDNOTAVAILABLE, 12, 12, 0, 0) statusMsg = imageSource + ' ' + statusMsg statusIconTooltip = self.__makeStatusTooltip(False) buttonTooltip = self.__makeButtonTooltip( self.BUILDING_STATUS.NOT_AVAILABLE, None) else: buttonTooltip = self.__makeButtonTooltip( self.BUILDING_STATUS.AVAILABLE, i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid))) infoData['isVisibleBtn'] = isVisibleBtn infoData['isEnableBtn'] = isEnableBtn infoData['statusMsg'] = statusMsg infoData['statusIconTooltip'] = statusIconTooltip infoData['buttonTooltip'] = buttonTooltip buildingIcon = FortViewHelper.getPopoverIconSource( uid, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxFortLevel) infoData['buildingIcon'] = buildingIcon self.as_responseBuildingInfoS(infoData) return
def _getBuildingStr(self, order): buildingID = self.getBuildingUIDbyID(order.buildingID) building = i18n.makeString(FORTIFICATIONS.buildings_buildingname(buildingID)) hasBuilding = order.hasBuilding if not hasBuilding: return text_styles.error(building) return building
def _getBuildingStr(self, order): buildingID = self.getBuildingUIDbyID(order.buildingID) building = i18n.makeString(FORTIFICATIONS.buildings_buildingname(buildingID)) hasBuilding = order.hasBuilding if not hasBuilding: return text_styles.error(building) return building
def _getUseBtnTooltip(self, order, buildingDescr, isDisabled): hasBuilding = order.hasBuilding buildingID = self.getBuildingUIDbyID(order.buildingID) buildingStr = i18n.makeString(FORTIFICATIONS.buildings_buildingname(buildingID)) body = None note = None if not isDisabled: header = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_HEADER body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_DESCRIPTION else: header = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_CANTUSE_HEADER fort = self.fortCtrl.getFort() if not order.isSupported: body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_NOTAVAILABLE elif not hasBuilding: body = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_NOBUILDING, building=buildingStr) elif order.inCooldown: body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_WASUSED elif not order.isCompatible and fort.hasActivatedContinualOrders(): body = TOOLTIPS.FORTIFICATION_ORDERSPANEL_CANTUSEORDER elif order.isPermanent and not fort.isDefenceHourEnabled(): body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_DEFENCEHOURDISABLED elif order.count < 1: body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_NOORDERS elif self._isBuildingDamaged(buildingDescr) or self._isBaseBuildingDamaged() or self._isFortFrozen(): body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_CANTUSE_BODY return makeTooltip(header, body, note)
def _packBlocks(self, uid, level): description = _ms(FORTIFICATIONS.buildingsprocess_longdescr(uid)) self._description = _ms(CLANS.SECTION_FORT_BUILDING_TOOLTIP_BODY, level=text_styles.stats(int2roman(level)), description=description) self._title = _ms(FORTIFICATIONS.buildings_buildingname(uid)) items = super(ClanProfileFortBuildingTooltipData, self)._packBlocks() items.append(formatters.packTitleDescBlock(text_styles.highTitle(self._title), desc=text_styles.main(self._description) if self._description else None)) return items
def _updateView(self): buildingName = i18n.makeString(FORTIFICATIONS.buildings_buildingname(self.__uid)) windowTitle = i18n.makeString(FORTIFICATIONS.MODERNIZATION_WINDOWTITLE, buildingName=buildingName) self.as_windowTitleS(windowTitle) self.as_applyButtonLblS(FORTIFICATIONS.MODERNIZATION_APPLYBUTTON_LABEL) self.as_cancelButtonS(FORTIFICATIONS.MODERNIZATION_CANCELBUTTON_LABEL) self.__buildData()
def _buildData(self, buildingID, isRecharged = False): orderID = self.fortCtrl.getFort().getBuildingOrder(buildingID) if orderID is None: return else: orderUID = self.getOrderUIDbyID(orderID) if orderUID == self.FORT_UNKNOWN: return builidngUID = self.getBuildingUIDbyID(buildingID) order = self.fortCtrl.getFort().getOrder(orderID) return {'fortOrderTypeID': order.orderID, 'group': order.group, 'type': order.type, 'enabled': order.hasBuilding, 'id': orderUID, 'icon': order.icon, 'count': order.count, 'level': order.level, 'inProgress': order.inProgress, 'buildingStr': i18n.makeString(FORTIFICATIONS.buildings_buildingname(builidngUID)), 'inCooldown': order.inCooldown, 'cooldownPercent': order.getCooldownAsPercent(), 'leftTime': order.getUsageLeftTime(), 'isPermanent': order.isPermanent, 'isRecharged': isRecharged, 'isDischarging': True}
def _buildData(self, buildingID, isRecharged=False): orderID = self.fortCtrl.getFort().getBuildingOrder(buildingID) if orderID is None: return orderUID = self.getOrderUIDbyID(orderID) if orderUID == self.FORT_UNKNOWN: return builidngUID = self.getBuildingUIDbyID(buildingID) order = self.fortCtrl.getFort().getOrder(orderID) return { "fortOrderTypeID": order.orderID, "group": order.group, "type": order.type, "enabled": order.hasBuilding, "id": orderUID, "icon": order.icon, "count": order.count, "level": order.level, "inProgress": order.inProgress, "buildingStr": i18n.makeString(FORTIFICATIONS.buildings_buildingname(builidngUID)), "inCooldown": order.inCooldown, "cooldownPercent": order.getCooldownAsPercent(), "leftTime": order.getUsageLeftTime(), "isPermanent": order.isPermanent, "isRecharged": isRecharged, "isDischarging": True, }
def _getBuildingStr(self, order): buildingID = self.getBuildingUIDbyID(order.buildingID) building = i18n.makeString(FORTIFICATIONS.buildings_buildingname(buildingID)) hasBuilding = order.hasBuilding if not hasBuilding: return self.app.utilsManager.textManager.getText(TEXT_MANAGER_STYLES.ERROR_TEXT, building) return building
def _getUseBtnTooltip(self, order, buildingDescr, isDisabled): hasBuilding = order.hasBuilding buildingID = self.getBuildingUIDbyID(order.buildingID) buildingStr = i18n.makeString(FORTIFICATIONS.buildings_buildingname(buildingID)) body = None note = None if not isDisabled: header = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_HEADER body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_DESCRIPTION else: header = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_CANTUSE_HEADER fort = self.fortCtrl.getFort() if not order.isSupported: body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_NOTAVAILABLE elif not hasBuilding: body = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_NOBUILDING, building=buildingStr) elif order.inCooldown: body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_WASUSED elif not order.isCompatible and fort.hasActivatedContinualOrders(): body = TOOLTIPS.FORTIFICATION_ORDERSPANEL_CANTUSEORDER elif order.isPermanent and not fort.isDefenceHourEnabled(): body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_DEFENCEHOURDISABLED elif order.count < 1: body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_NOORDERS elif self._isBuildingDamaged(buildingDescr) or self._isBaseBuildingDamaged() or self._isFortFrozen(): body = TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_CANTUSE_BODY return makeTooltip(header, body, note)
def __prepareHeaderData(self): result = {'buildingName': i18n.makeString(FORT.buildings_buildingname(self._buildingUID)), 'buildingIcon': self._buildingUID} buildLevel = self.__convertBuildLevel(self.__buildingLevel) result['buildLevel'] = i18n.makeString(FORT.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=buildLevel) upgradeBtnVisible = False upgradeBtnEnable = False localTooltip = '' if self._canModernization(self.__buildingDescr): upgradeBtnVisible = upgradeBtnEnable = True localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN if upgradeBtnVisible: if not self._isEnableModernizationBtnByDamaged(self.__buildingDescr): upgradeBtnEnable = False localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEBTN_DISABLEDBYDESTROY elif not self._isEnableModernizationBtnByProgress(self.__buildingDescr): upgradeBtnEnable = False localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN_DISABLED result['upgradeButtonToolTip'] = localTooltip result['showUpgradeButton'] = upgradeBtnVisible result['enableUpgradeBtn'] = upgradeBtnEnable isVisibleDemountBtn = self._isVisibleDemountBtn(self.__buildingDescr) result['isVisibleDemountBtn'] = isVisibleDemountBtn if isVisibleDemountBtn: result['enableDemountBtn'] = self._isEnableDemountBtn(self.__buildingDescr) result['demountBtnTooltip'] = TOOLTIPS.FORTIFICATION_POPOVER_DEMOUNTBTN header, body, filterColor = self.__makeHeaderStatusMessage() result['titleStatus'] = header result['bodyStatus'] = body result['glowColor'] = int(filterColor, 16) result['isModernization'] = self.__canUpgrade result['canDeleteBuilding'] = self.fortCtrl.getPermissions().canDeleteBuilding() isDefencePeriodActivated = self.fortCtrl.getFort().isDefenceHourEnabled() if self.__progress is ALIAS.STATE_BUILDING and isDefencePeriodActivated: nextMapTimestamp, nextMapID, curMapID = self.fortCtrl.getFort().getBuildingMaps(self._buildingID) isMapsInfoEnabled = nextMapTimestamp > 0 if self.__buildingLevel < fortified_regions.g_cache.defenceConditions.minRegionLevel: mapIcon = self.app.utilsManager.textManager.getIcon(TextIcons.ALERT_ICON) mapMsg = self.app.utilsManager.textManager.getText(TextType.ALERT_TEXT, i18n.makeString(FORT.BUILDINGPOPOVER_MAPINFO_NOBATTLE)) header = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_HEADER) body = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_BODY) isToolTipSpecial = False elif isMapsInfoEnabled: currentMapUserName = self.__getMapUserName(curMapID) mapIcon = self.app.utilsManager.textManager.getIcon(TextIcons.INFO_ICON) mapMsg = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, currentMapUserName) header = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_HEADER, currentMap=currentMapUserName) body = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_BODY, nextMap=self.__getMapUserName(nextMapID), changeDate=BigWorld.wg_getLongDateFormat(nextMapTimestamp), changeTime=BigWorld.wg_getShortTimeFormat(nextMapTimestamp)) isToolTipSpecial = True else: mapIcon = mapMsg = '' isToolTipSpecial = False mapInfo = i18n.makeString(mapIcon + ' ' + mapMsg) result['mapInfo'] = mapInfo result['isToolTipSpecial'] = isToolTipSpecial result['tooltipData'] = {'mapName': header, 'description': body, 'imageURL': self.__getMapImage(curMapID)} return result
def requestBuildingToolTipData(self, uid, type): fort = self.fortCtrl.getFort() if fort: buildingDescr = fort.getBuilding(self.getBuildingIDbyUID(uid)) header = _ms(FORTIFICATIONS.buildings_buildingname(uid)) self.as_setBuildingToolTipDataS( uid, type, header, self.getCommonBuildTooltipData(buildingDescr))
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 getSlotTooltipBody(self, orderID): header = i18n.makeString( FORTIFICATIONS.orders_orderpopover_ordertype(orderID)) note = None fort = self.fortCtrl.getFort() order = fort.getOrder(self.getOrderIDbyUID(orderID)) buildingDescr = fort.getBuilding(order.buildingID) if order.hasBuilding: description = '' ordersListStr = i18n.makeString( TOOLTIPS.FORTIFICATION_ORDERPOPOVER_CLANPERMISSIONS) if order.inCooldown: description = self._getCooldownInfo(order) elif order.count > 0: if self._isProductionInPause(buildingDescr): description = i18n.makeString( TOOLTIPS.FORTIFICATION_ORDERSPANEL_CANTUSEORDER) description += '\n' + i18n.makeString( TOOLTIPS.FORTIFICATION_ORDERPROCESS_INFO) elif not order.isPermanent and not order.isCompatible and fort.hasActivatedContinualOrders( ): description = i18n.makeString( TOOLTIPS.FORTIFICATION_ORDERSPANEL_CANTUSEORDER) else: description = i18n.makeString( TOOLTIPS.FORTIFICATION_ORDERPOPOVER_ORDERISREADY) if not self._canGiveOrder(): description += '\n' + ordersListStr else: if not order.inProgress: description = i18n.makeString( TOOLTIPS.FORTIFICATION_ORDERPOPOVER_CREATEORDER) if not self._canGiveOrder(): description = i18n.makeString( TOOLTIPS. FORTIFICATION_ORDERPOPOVER_USEORDERBTN_NOORDERS) description += '\n' + ordersListStr if order.inProgress: if self._isProductionInPause(buildingDescr): pauseText = i18n.makeString( TOOLTIPS.FORTIFICATION_ORDERPROCESS_INPAUSE) if len(description) > 0: description += '\n' + pauseText else: description = pauseText description += '\n' + i18n.makeString( TOOLTIPS.FORTIFICATION_ORDERPROCESS_INFO) else: description = self._getProgressInfo(description, order) else: buildingStr = i18n.makeString( FORTIFICATIONS.buildings_buildingname( self.getBuildingUIDbyID(order.buildingID))) description = i18n.makeString( FORTIFICATIONS.ORDERS_ORDERPOPOVER_ORDERNOTREADY, building=buildingStr) return makeTooltip(header, description, note)
def _updateView(self): buildingName = i18n.makeString( FORTIFICATIONS.buildings_buildingname(self.__uid)) windowTitle = i18n.makeString(FORTIFICATIONS.MODERNIZATION_WINDOWTITLE, buildingName=buildingName) self.as_windowTitleS(windowTitle) self.as_applyButtonLblS(FORTIFICATIONS.MODERNIZATION_APPLYBUTTON_LABEL) self.as_cancelButtonS(FORTIFICATIONS.MODERNIZATION_CANCELBUTTON_LABEL) self.__buildData()
def __init__(self, ctx = None): super(FortDemountBuildingWindow, self).__init__() self.__buildingID = ctx.get('data', None) self.__formattedBuildingName = i18n.makeString(ALIAS.buildings_buildingname(self.__buildingID)) self.getBuildingIDbyUID(self.__buildingID) buildingDescr = self.fortCtrl.getFort().getBuilding(self.getBuildingIDbyUID(self.__buildingID)) self.__buildingLevel = buildingDescr.level self.__currHpVal = buildingDescr.hp self.__buildingIntID = buildingDescr.typeID self.__inputChecker = None
def __init__(self, ctx=None): super(FortDemountBuildingWindow, self).__init__() self.__buildingID = ctx.get('data', None) self.__formattedBuildingName = i18n.makeString( ALIAS.buildings_buildingname(self.__buildingID)) self.getBuildingIDbyUID(self.__buildingID) buildingDescr = self.fortCtrl.getFort().getBuilding( self.getBuildingIDbyUID(self.__buildingID)) self.__buildingLevel = buildingDescr.level self.__currHpVal = buildingDescr.hp self.__buildingIntID = buildingDescr.typeID self.__inputChecker = None
def _packBlocks(self, uid, level): description = _ms(FORTIFICATIONS.buildingsprocess_longdescr(uid)) self._description = _ms(CLANS.SECTION_FORT_BUILDING_TOOLTIP_BODY, level=text_styles.stats(int2roman(level)), description=description) self._title = _ms(FORTIFICATIONS.buildings_buildingname(uid)) items = super(ClanProfileFortBuildingTooltipData, self)._packBlocks() items.append( formatters.packTitleDescBlock( text_styles.highTitle(self._title), desc=text_styles.main(self._description) if self._description else None)) return items
def getSlotTooltipBody(self, orderID): header = i18n.makeString(FORTIFICATIONS.orders_orderpopover_ordertype(orderID)) note = None fort = self.fortCtrl.getFort() order = fort.getOrder(self.getOrderIDbyUID(orderID)) buildingDescr = fort.getBuilding(order.buildingID) if order.hasBuilding: description = "" ordersListStr = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_CLANPERMISSIONS) if order.inCooldown: description = self._getCooldownInfo(order) elif order.count > 0: if self._isProductionInPause(buildingDescr): description = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERSPANEL_CANTUSEORDER) description += "\n" + i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPROCESS_INFO) elif not order.isPermanent and not order.isCompatible and fort.hasActivatedContinualOrders(): description = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERSPANEL_CANTUSEORDER) else: description = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_ORDERISREADY) if not self._canGiveOrder(): description += "\n" + ordersListStr else: if not order.inProgress: description = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_CREATEORDER) if not self._canGiveOrder(): description = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPOPOVER_USEORDERBTN_NOORDERS) description += "\n" + ordersListStr if order.inProgress: if self._isProductionInPause(buildingDescr): pauseText = i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPROCESS_INPAUSE) if len(description) > 0: description += "\n" + pauseText else: description = pauseText description += "\n" + i18n.makeString(TOOLTIPS.FORTIFICATION_ORDERPROCESS_INFO) else: description = self._getProgressInfo(description, order) else: buildingStr = i18n.makeString( FORTIFICATIONS.buildings_buildingname(self.getBuildingUIDbyID(order.buildingID)) ) description = i18n.makeString(FORTIFICATIONS.ORDERS_ORDERPOPOVER_ORDERNOTREADY, building=buildingStr) return makeTooltip(header, description, note)
def requestBuildingInfo(self, uid): infoData = {} id = self.getBuildingIDbyUID(uid) self.__markAsVisited(id) buildingStatus = self.__getBuildingStatus(id) infoData['buildingName'] = text_styles.highTitle(i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid))) infoData['buildingID'] = uid infoData['longDescr'] = text_styles.standard(i18n.makeString(FORTIFICATIONS.buildingsprocess_longdescr(uid))) buttonLbl = FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBL if buildingStatus == self.BUILDING_STATUS.BUILT: buttonLbl = text_styles.standard(i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBLBUILT)) infoData['buttonLabel'] = i18n.makeString(buttonLbl) infoData['orderInfo'] = self.__makeOrderInfoData(uid) isVisibleBtn = True isEnableBtn = True statusMsg = '' statusIconTooltip = None if buildingStatus == self.BUILDING_STATUS.BUILT: statusMsg = ''.join((icons.checkmark(), text_styles.success(i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_BUILT)))) isEnableBtn = False isVisibleBtn = False statusIconTooltip = self.__makeStatusTooltip(True) buttonTooltip = self.__makeButtonTooltip(self.BUILDING_STATUS.BUILT, None) elif buildingStatus == self.BUILDING_STATUS.NOT_AVAILABLE: isEnableBtn = False isVisibleBtn = True statusMsg = text_styles.error(i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_BUILDINGINFO_STATUSMESSAGE)) imageSource = icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_REDNOTAVAILABLE, 12, 12, 0, 0) statusMsg = imageSource + ' ' + statusMsg statusIconTooltip = self.__makeStatusTooltip(False) buttonTooltip = self.__makeButtonTooltip(self.BUILDING_STATUS.NOT_AVAILABLE, None) else: buttonTooltip = self.__makeButtonTooltip(self.BUILDING_STATUS.AVAILABLE, i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid))) infoData['isVisibleBtn'] = isVisibleBtn infoData['isEnableBtn'] = isEnableBtn infoData['statusMsg'] = statusMsg infoData['statusIconTooltip'] = statusIconTooltip infoData['buttonTooltip'] = buttonTooltip buildingIcon = FortViewHelper.getPopoverIconSource(uid, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxFortLevel) infoData['buildingIcon'] = buildingIcon self.as_responseBuildingInfoS(infoData) return
def __getStrings(self, value, status): id = value name = text_styles.middleTitle( i18n.makeString(FORTIFICATIONS.buildings_buildingname(id))) shortDescr = text_styles.standard( i18n.makeString(FORTIFICATIONS.buildingsprocess_shortdescr(id))) statusMsg = '' if status == self.BUILDING_STATUS.AVAILABLE: return (id, name, shortDescr, statusMsg, status) if status == self.BUILDING_STATUS.NOT_AVAILABLE: icon = icons.notAvailable() statusMsg = text_styles.standard( i18n.makeString( FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_NOTAVAILABLE)) else: icon = icons.checkmark() statusMsg = text_styles.success( i18n.makeString( FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_BUILT)) statusMsg = ''.join((icon, statusMsg)) return (id, name, shortDescr, statusMsg, status)
def __getStrings(self, value, status): id = value name = text_styles.middleTitle(i18n.makeString(FORTIFICATIONS.buildings_buildingname(id))) shortDescr = text_styles.standard(i18n.makeString(FORTIFICATIONS.buildingsprocess_shortdescr(id))) statusMsg = '' if status == self.BUILDING_STATUS.AVAILABLE: return (id, name, shortDescr, statusMsg, status) if status == self.BUILDING_STATUS.NOT_AVAILABLE: icon = icons.notAvailable() statusMsg = text_styles.standard(i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_NOTAVAILABLE)) else: icon = icons.checkmark() statusMsg = text_styles.success(i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_BUILT)) statusMsg = ''.join((icon, statusMsg)) return (id, name, shortDescr, statusMsg, status)
def __makeData(self): result = {} building = self.fortCtrl.getFort().getBuilding(self.__buildingId) self.__fixedPlayers = building.attachedPlayers self.__oldBuilding = self.getBuildingUIDbyID( self.fortCtrl.getFort().getAssignedBuildingID(BigWorld.player().databaseID) ) self.__isAssigned = self.__buildingUId == self.__oldBuilding self.__limitFixedPlayers = building.typeRef.attachedPlayersLimit isVisible = True isEnabled = True btnTooltipData = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ASSIGNBTNENABLED if self.__isAssigned: isVisible = False result["playerIsAssigned"] = text_styles.neutral( i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_HEADER_ISASSIGNED) ) if isVisible and len(self.__fixedPlayers) == self.__limitFixedPlayers: isEnabled = False btnTooltipData = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ASSIGNBTNDISABLED result["windowTitle"] = i18n.makeString( FORTIFICATIONS.FIXEDPLAYERS_WINDOWTITLE, buildingName=i18n.makeString(FORTIFICATIONS.buildings_buildingname(self.__buildingUId)), ) result["buildingId"] = self.__buildingId result["buttonLbl"] = i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_HEADER_BTNLBL) result["isEnableBtn"] = isEnabled result["isVisibleBtn"] = isVisible generalToolTip = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_GENERALTOOLTIP if len(self.__fixedPlayers) == self.__limitFixedPlayers: generalToolTip = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_GENERALTOOLTIPMAXLIMIT result["generalTooltipData"] = generalToolTip result["btnTooltipData"] = btnTooltipData result["countLabel"] = self.__playersLabel() result["rosters"] = self.__makeRosters() result["tableHeader"] = self._createTableHeader() self.as_setDataS(result)
def __makeData(self): result = {} building = self.fortCtrl.getFort().getBuilding(self.__buildingId) self.__fixedPlayers = building.attachedPlayers self.__oldBuilding = self.getBuildingUIDbyID( self.fortCtrl.getFort().getAssignedBuildingID( BigWorld.player().databaseID)) self.__isAssigned = self.__buildingUId == self.__oldBuilding self.__limitFixedPlayers = building.typeRef.attachedPlayersLimit isVisible = True isEnabled = True btnTooltipData = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ASSIGNBTNENABLED if self.__isAssigned: isVisible = False result['playerIsAssigned'] = text_styles.neutral( i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_HEADER_ISASSIGNED)) if isVisible and len(self.__fixedPlayers) == self.__limitFixedPlayers: isEnabled = False btnTooltipData = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ASSIGNBTNDISABLED result['windowTitle'] = i18n.makeString( FORTIFICATIONS.FIXEDPLAYERS_WINDOWTITLE, buildingName=i18n.makeString( FORTIFICATIONS.buildings_buildingname(self.__buildingUId))) result['buildingId'] = self.__buildingId result['buttonLbl'] = i18n.makeString( FORTIFICATIONS.FIXEDPLAYERS_HEADER_BTNLBL) result['isEnableBtn'] = isEnabled result['isVisibleBtn'] = isVisible generalToolTip = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_GENERALTOOLTIP if len(self.__fixedPlayers) == self.__limitFixedPlayers: generalToolTip = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_GENERALTOOLTIPMAXLIMIT result['generalTooltipData'] = generalToolTip result['btnTooltipData'] = btnTooltipData result['countLabel'] = self.__playersLabel() result['rosters'] = self.__makeRosters() result['tableHeader'] = self._createTableHeader() self.as_setDataS(result)
def __getStrings(self, value, status): id = value name = self.app.utilsManager.textManager.getText(TextType.MIDDLE_TITLE, i18n.makeString(FORTIFICATIONS.buildings_buildingname(id))) shortDescr = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, i18n.makeString(FORTIFICATIONS.buildingsprocess_shortdescr(id))) statusMsg = '' if status == self.BUILDING_STATUS.AVAILABLE: return (id, name, shortDescr, statusMsg, status) iconType = TextIcons.CHECKMARK_ICON textColor = TextType.SUCCESS_TEXT statusType = FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_BUILT if status == self.BUILDING_STATUS.NOT_AVAILABLE: iconType = TextIcons.NOT_AVAILABLE textColor = TextType.STANDARD_TEXT statusType = FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_NOTAVAILABLE statusMsg = self.app.utilsManager.textManager.concatStyles(((iconType,), (textColor, i18n.makeString(statusType)))) return (id, name, shortDescr, statusMsg, status)
def __updateDirections(self): isAttack = not self.__battle.isDefence() (currentBuildingID, _, _), _ = self.__currentBuilding if isAttack: connectionIcon = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_OFFENCE connectionIconTTHeader = i18n.makeString( FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BATTLEICON_OFFENCE_TOOLTIP_HEADER ) connectionIconTTBody = i18n.makeString( FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BATTLEICON_OFFENCE_TOOLTIP_BODY ) buildingIndicatorTTHeader = i18n.makeString( FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BUILDINGINDICATOR_OFFENCE_TOOLTIP_HEADER ) buildingIndicatorTTBody = i18n.makeString( FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BUILDINGINDICATOR_OFFENCE_TOOLTIP_BODY, building=i18n.makeString( FORTIFICATIONS.buildings_buildingname(self.getBuildingUIDbyID(currentBuildingID)) ), ) mineBuildings, mineBaseBuilding = self.__makeBuildingsData( self.__battle.getAttackerBuildList(), self.__battle.getAttackerFullBuildList(), self.__battle.getLootedBuildList(), ) enemyBuildings, enemyBaseBuilding = self.__makeBuildingsData( self.__battle.getDefenderBuildList(), self.__battle.getDefenderFullBuildList(), self.__battle.getLootedBuildList(), False, ) else: connectionIcon = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_DEFENCE connectionIconTTHeader = i18n.makeString( FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BATTLEICON_DEFENCE_TOOLTIP_HEADER ) connectionIconTTBody = i18n.makeString( FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BATTLEICON_DEFENCE_TOOLTIP_BODY ) buildingIndicatorTTHeader = i18n.makeString( FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BUILDINGINDICATOR_DEFENCE_TOOLTIP_HEADER ) buildingIndicatorTTBody = i18n.makeString( FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BUILDINGINDICATOR_DEFENCE_TOOLTIP_BODY, building=i18n.makeString( FORTIFICATIONS.buildings_buildingname(self.getBuildingUIDbyID(currentBuildingID)) ), ) mineBuildings, mineBaseBuilding = self.__makeBuildingsData( self.__battle.getDefenderBuildList(), self.__battle.getDefenderFullBuildList(), self.__battle.getLootedBuildList(), False, ) enemyBuildings, enemyBaseBuilding = self.__makeBuildingsData( self.__battle.getAttackerBuildList(), self.__battle.getAttackerFullBuildList(), self.__battle.getLootedBuildList(), ) _, _, enemyClanDir = self.__battle.getOpponentClanInfo() isReverse = self.__defineArrowDirection() directionsData = { "leftDirection": { "name": i18n.makeString("#fortifications:General/directionName%d" % self.__battle.getDirection()), "isMine": True, "baseBuilding": mineBaseBuilding, "buildings": mineBuildings, "revertArrowDirection": isReverse, "buildingIndicatorTTHeader": buildingIndicatorTTHeader, "buildingIndicatorTTBody": buildingIndicatorTTBody, }, "rightDirection": { "name": i18n.makeString("#fortifications:General/directionName%d" % enemyClanDir), "isMine": False, "baseBuilding": enemyBaseBuilding, "buildings": enemyBuildings, "buildingIndicatorTTHeader": buildingIndicatorTTHeader, "buildingIndicatorTTBody": buildingIndicatorTTBody, "revertArrowDirection": isReverse, }, "connectionIcon": connectionIcon, "connectionIconTTHeader": connectionIconTTHeader, "connectionIconTTBody": connectionIconTTBody, } self.as_updateDirectionsS(directionsData)
def __updateDirections(self): isAttack = not self.__battle.isDefence() (currentBuildingID, _, _), _ = self.__currentBuilding if isAttack: connectionIcon = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_OFFENCE connectionIconTTHeader = i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BATTLEICON_OFFENCE_TOOLTIP_HEADER) connectionIconTTBody = i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BATTLEICON_OFFENCE_TOOLTIP_BODY) buildingIndicatorTTHeader = i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BUILDINGINDICATOR_OFFENCE_TOOLTIP_HEADER) buildingIndicatorTTBody = i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BUILDINGINDICATOR_OFFENCE_TOOLTIP_BODY, building=i18n.makeString(FORTIFICATIONS.buildings_buildingname(self.getBuildingUIDbyID(currentBuildingID)))) mineBuildings, mineBaseBuilding = self.__makeBuildingsData(self.__battle.getAttackerBuildList(), self.__battle.getAttackerFullBuildList(), self.__battle.getLootedBuildList()) enemyBuildings, enemyBaseBuilding = self.__makeBuildingsData(self.__battle.getDefenderBuildList(), self.__battle.getDefenderFullBuildList(), self.__battle.getLootedBuildList(), False) else: connectionIcon = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_DEFENCE connectionIconTTHeader = i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BATTLEICON_DEFENCE_TOOLTIP_HEADER) connectionIconTTBody = i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BATTLEICON_DEFENCE_TOOLTIP_BODY) buildingIndicatorTTHeader = i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BUILDINGINDICATOR_DEFENCE_TOOLTIP_HEADER) buildingIndicatorTTBody = i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_BUILDINGINDICATOR_DEFENCE_TOOLTIP_BODY, building=i18n.makeString(FORTIFICATIONS.buildings_buildingname(self.getBuildingUIDbyID(currentBuildingID)))) mineBuildings, mineBaseBuilding = self.__makeBuildingsData(self.__battle.getDefenderBuildList(), self.__battle.getDefenderFullBuildList(), self.__battle.getLootedBuildList(), False) enemyBuildings, enemyBaseBuilding = self.__makeBuildingsData(self.__battle.getAttackerBuildList(), self.__battle.getAttackerFullBuildList(), self.__battle.getLootedBuildList()) _, _, enemyClanDir = self.__battle.getOpponentClanInfo() isReverse = self.__defineArrowDirection() directionsData = {'leftDirection': {'name': i18n.makeString('#fortifications:General/directionName%d' % self.__battle.getDirection()), 'isMine': True, 'baseBuilding': mineBaseBuilding, 'buildings': mineBuildings, 'revertArrowDirection': isReverse, 'buildingIndicatorTTHeader': buildingIndicatorTTHeader, 'buildingIndicatorTTBody': buildingIndicatorTTBody}, 'rightDirection': {'name': i18n.makeString('#fortifications:General/directionName%d' % enemyClanDir), 'isMine': False, 'baseBuilding': enemyBaseBuilding, 'buildings': enemyBuildings, 'buildingIndicatorTTHeader': buildingIndicatorTTHeader, 'buildingIndicatorTTBody': buildingIndicatorTTBody, 'revertArrowDirection': isReverse}, 'connectionIcon': connectionIcon, 'connectionIconTooltip': makeTooltip(connectionIconTTHeader, connectionIconTTBody)} self.as_updateDirectionsS(directionsData)
def __prepareHeaderData(self): fort = self.fortCtrl.getFort() isDefencePeriodActivated = fort.isDefenceHourEnabled() inProcess, _ = fort.getDefenceHourProcessing() isDefenceOn = isDefencePeriodActivated or inProcess buildingIcon = FortViewHelper.getPopoverIconSource( self._buildingUID, self.__buildingLevel, isDefenceOn=isDefenceOn) result = { 'buildingName': i18n.makeString(FORT.buildings_buildingname(self._buildingUID)), 'buildingIcon': buildingIcon } buildLevel = self.__convertBuildLevel(self.__buildingLevel) result['buildLevel'] = i18n.makeString( FORT.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=buildLevel) upgradeBtnVisible = False upgradeBtnEnable = False localTooltip = '' if self._canModernization(self.__buildingDescr): upgradeBtnVisible = upgradeBtnEnable = True localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN if upgradeBtnVisible: if not self._isEnableModernizationBtnByDamaged( self.__buildingDescr): upgradeBtnEnable = False localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEBTN_DISABLEDBYDESTROY elif not self._isEnableModernizationBtnByProgress( self.__buildingDescr): upgradeBtnEnable = False localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN_DISABLED result['upgradeButtonToolTip'] = localTooltip result['showUpgradeButton'] = upgradeBtnVisible result['enableUpgradeBtn'] = upgradeBtnEnable isVisibleDemountBtn = self._isVisibleDemountBtn(self.__buildingDescr) result['isVisibleDemountBtn'] = isVisibleDemountBtn if isVisibleDemountBtn: result['enableDemountBtn'] = self._isEnableDemountBtn( self.__buildingDescr) result[ 'demountBtnTooltip'] = TOOLTIPS.FORTIFICATION_POPOVER_DEMOUNTBTN header, body, filterColor = self.__makeHeaderStatusMessage() result['titleStatus'] = header result['bodyStatus'] = body result['glowColor'] = int(filterColor, 16) result['isModernization'] = self.__canUpgrade result['canDeleteBuilding'] = self.fortCtrl.getPermissions( ).canDeleteBuilding() if self.__progress is ALIAS.STATE_BUILDING and isDefencePeriodActivated: nextMapTimestamp, nextMapID, curMapID = self.fortCtrl.getFort( ).getBuildingMaps(self._buildingID) isMapsInfoEnabled = nextMapTimestamp > 0 if self.__buildingLevel < fortified_regions.g_cache.defenceConditions.minRegionLevel: mapIcon = icons.alert() mapMsg = text_styles.alert( i18n.makeString(FORT.BUILDINGPOPOVER_MAPINFO_NOBATTLE)) header = i18n.makeString( TOOLTIPS. FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_HEADER ) body = i18n.makeString( TOOLTIPS. FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_BODY ) isToolTipSpecial = False elif isMapsInfoEnabled: currentMapUserName = self.__getMapUserName(curMapID) mapIcon = icons.info() mapMsg = text_styles.main(currentMapUserName) header = i18n.makeString( TOOLTIPS. FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_HEADER, currentMap=currentMapUserName) body = i18n.makeString( TOOLTIPS. FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_BODY, nextMap=self.__getMapUserName(nextMapID), changeDate=BigWorld.wg_getLongDateFormat(nextMapTimestamp), changeTime=BigWorld.wg_getShortTimeFormat( nextMapTimestamp)) isToolTipSpecial = True else: mapIcon = mapMsg = '' isToolTipSpecial = False mapInfo = i18n.makeString(mapIcon + ' ' + mapMsg) result['mapInfo'] = mapInfo result['isToolTipSpecial'] = isToolTipSpecial result['tooltipData'] = { 'mapName': header, 'description': body, 'imageURL': self.__getMapImage(curMapID) } return result
def __makeData(self): result = {} building = self.fortCtrl.getFort().getBuilding(self.__buildingId) self.__fixedPlayers = building.attachedPlayers self.__oldBuilding = self.getBuildingUIDbyID(self.fortCtrl.getFort().getAssignedBuildingID(BigWorld.player().databaseID)) self.__isAssigned = self.__buildingUId == self.__oldBuilding self.__limitFixedPlayers = building.typeRef.attachedPlayersLimit isVisible = True isEnabled = True btnTooltipData = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ASSIGNBTNENABLED if self.__isAssigned: isVisible = False result['playerIsAssigned'] = self.app.utilsManager.textManager.getText(TEXT_MANAGER_STYLES.NEUTRAL_TEXT, i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_HEADER_ISASSIGNED)) if isVisible and len(self.__fixedPlayers) == self.__limitFixedPlayers: isEnabled = False btnTooltipData = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ASSIGNBTNDISABLED result['windowTitle'] = i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_WINDOWTITLE, buildingName=i18n.makeString(FORTIFICATIONS.buildings_buildingname(self.__buildingUId))) result['buildingId'] = self.__buildingId result['buttonLbl'] = i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_HEADER_BTNLBL) result['isEnableBtn'] = isEnabled result['isVisibleBtn'] = isVisible generalToolTip = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_GENERALTOOLTIP if len(self.__fixedPlayers) == self.__limitFixedPlayers: generalToolTip = TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_GENERALTOOLTIPMAXLIMIT result['generalTooltipData'] = generalToolTip result['btnTooltipData'] = btnTooltipData result['countLabel'] = self.__playersLabel() result['rosters'] = self.__makeRosters() self.as_setDataS(result)
def requestBuildingToolTipData(self, uid, type): fort = self.fortCtrl.getFort() if fort: buildingDescr = fort.getBuilding(self.getBuildingIDbyUID(uid)) header = _ms(FORTIFICATIONS.buildings_buildingname(uid)) self.as_setBuildingToolTipDataS(uid, type, header, self.getCommonBuildTooltipData(buildingDescr))
def getDisplayableData(self, buildingUID, isMine): ms = i18n.makeString fort = self.fortCtrl.getFort() battleID = getBattleID() battle = fort.getBattle(battleID) buildingTypeID = self.getBuildingIDbyUID(buildingUID) if battle.isDefence(): isAttack = not isMine else: isAttack = isMine if isAttack: buildingsList = battle.getAttackerBuildList() buildingsFullList = battle.getAttackerFullBuildList() else: buildingsList = battle.getDefenderBuildList() buildingsFullList = battle.getDefenderFullBuildList() buildingFullData = findFirst(lambda x: x[0] == buildingTypeID, buildingsFullList) _, status, buildingLevel, hpVal, defResVal = buildingFullData isReadyForBattle = status == constants.FORT_BUILDING_STATUS.READY_FOR_BATTLE buildingData = None resCount, arenaTypeID = (None, None) if isReadyForBattle: buildingData = findFirst(lambda x: x[0] == buildingTypeID, buildingsList) _, resCount, arenaTypeID = buildingData _, status, buildingLevel, hpVal, defResVal = buildingFullData progress = self._getProgress(buildingTypeID, buildingLevel) normLevel = max(buildingLevel, 1) buildingLevelData = fortified_regions.g_cache.buildings[buildingTypeID].levels[normLevel] hpTotalVal = buildingLevelData.hp maxDefResVal = buildingLevelData.storage buildingName = self.app.utilsManager.textManager.getText(TextType.HIGH_TITLE, ms(FORT.buildings_buildingname(buildingUID))) currentMapTxt = None buildingLevelTxt = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, ms(FORT.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=str(fort_formatters.getTextLevel(buildingLevel)))) descrActionTxt = None statusTxt = None statusLevel = None indicatorsModel = None infoMessage = None if status == constants.FORT_BUILDING_STATUS.LOW_LEVEL: minBuildingLevel = fortified_regions.g_cache.defenceConditions.minRegionLevel minLevel = fort_formatters.getTextLevel(1) maxLevel = fort_formatters.getTextLevel(minBuildingLevel - 1) infoMessage = ms(FORT.TOOLTIPBUILDINGINFO_LOWLEVELMESSAGE, minLevel=minLevel, maxLevel=maxLevel) else: indicatorsModel = makeBuildingIndicatorsVO(buildingLevel, progress, hpVal, hpTotalVal, defResVal, maxDefResVal) if isReadyForBattle: lootedBuildings = battle.getLootedBuildList() battleStatus = self.BATTLE_STATUSES.NO_BATTLE if (buildingData, isAttack) in lootedBuildings: battleStatus = self.BATTLE_STATUSES.LOST if battle.isDefence() and isAttack or not battle.isDefence() and not isAttack: battleStatus = self.BATTLE_STATUSES.WON arenaType = ArenaType.g_cache.get(arenaTypeID) prefix = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, ms(FORT.TOOLTIPBUILDINGINFO_MEP_MAPPREFIX)) mapName = self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, arenaType.name) currentMapTxt = prefix + mapName statusLevel = battleStatus.level statusTxt = ms(battleStatus.msg) defResStatusTxt = self.app.utilsManager.textManager.concatStyles(((battleStatus.color, '%s %s' % (battleStatus.prefix, BigWorld.wg_getIntegralFormat(resCount))), (TextIcons.NUT_ICON,))) descrActionTxt = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, ms(FORT.TOOLTIPBUILDINGINFO_DESCRACTION)) descrActionTxt = descrActionTxt % {'value': defResStatusTxt} else: minResCount = hpTotalVal * 0.2 minResStatusTxt = self.app.utilsManager.textManager.concatStyles(((TextType.NEUTRAL_TEXT, BigWorld.wg_getIntegralFormat(minResCount)), (TextIcons.NUT_ICON,))) infoMessage = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, ms(FORT.TOOLTIPBUILDINGINFO_DESTROYEDMESSAGE)) infoMessage = infoMessage % {'value': minResStatusTxt} result = {'buildingUID': buildingUID, 'buildingName': buildingName, 'currentMap': currentMapTxt, 'buildingLevel': buildingLevelTxt, 'descrAction': descrActionTxt, 'statusMsg': statusTxt, 'statusLevel': statusLevel, 'indicatorModel': indicatorsModel, 'isAvailable': isReadyForBattle, 'infoMessage': infoMessage} return result
def userName(self): from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper return i18n.makeString(FORTIFICATIONS.buildings_buildingname(FortViewHelper.getBuildingUIDbyID(self.typeID)))
def __getDirectionTooltipData(self, dirName, buildings, attackerClanDBID, attackerClanName, attackTime, availableTime): infoMessage = '' bodyParts = [] if self.fortCtrl.getFort().isFrozen() or self.__weAreAtWar: return (None, None, None) else: buildingsMsgs = [] for building in buildings: if building is not None: extraInfo = '' if building['buildingLevel'] < FORTIFICATION_ALIASES.CLAN_BATTLE_BUILDING_MIN_LEVEL: extraInfo = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGLOWLEVEL, minLevel=fort_formatters.getTextLevel(FORTIFICATION_ALIASES.CLAN_BATTLE_BUILDING_MIN_LEVEL)) buildingsMsgs.insert(0, _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGITEM, name=_ms(FORTIFICATIONS.buildings_buildingname(building['uid'])), level=_ms(FORTIFICATIONS.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=str(fort_formatters.getTextLevel(building['buildingLevel']))), extraInfo=extraInfo)) buildingsNames = '\n'.join(buildingsMsgs) if availableTime is not None: infoMessage = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_NOTAVAILABLE, date=BigWorld.wg_getShortDateFormat(availableTime)) bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTAVAILABLE_INFO, date=BigWorld.wg_getShortDateFormat(availableTime))) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTAVAILABLE_HEADER, direction=dirName) elif attackerClanDBID is None: if buildingsNames: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGS, buildings=buildingsNames)) if self.fortCtrl.getPermissions().canPlanAttack(): bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_ATTACKINFO)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_ATTACK, direction=dirName) else: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTCOMMANDERINFO)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTCOMMANDER, direction=dirName) else: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUSY_INFO, date=BigWorld.wg_getShortDateFormat(attackTime), clanName=attackerClanName)) if buildingsNames: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGS, buildings=buildingsNames)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUSY_HEADER, direction=dirName) return (header, '\n'.join(bodyParts), infoMessage)
def userName(self): from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper return i18n.makeString( FORTIFICATIONS.buildings_buildingname( FortViewHelper.getBuildingUIDbyID(self.typeID)))
def __getDirectionTooltipData(self, dirName, buildings, attackerClanDBID, attackerClanName, attackTime, availableTime): infoMessage = '' bodyParts = [] if self.fortCtrl.getFort().isFrozen() or self.__weAreAtWar: return (None, None, None) else: buildingsMsgs = [] for building in buildings: if building is not None: extraInfo = '' if building['buildingLevel'] < FORTIFICATION_ALIASES.CLAN_BATTLE_BUILDING_MIN_LEVEL: extraInfo = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGLOWLEVEL, minLevel=fort_formatters.getTextLevel(FORTIFICATION_ALIASES.CLAN_BATTLE_BUILDING_MIN_LEVEL)) buildingsMsgs.insert(0, _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGITEM, name=_ms(FORTIFICATIONS.buildings_buildingname(building['uid'])), level=_ms(FORTIFICATIONS.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=str(fort_formatters.getTextLevel(building['buildingLevel']))), extraInfo=extraInfo)) buildingsNames = '\n'.join(buildingsMsgs) if availableTime is not None: infoMessage = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_NOTAVAILABLE, date=BigWorld.wg_getShortDateFormat(availableTime)) bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTAVAILABLE_INFO, date=BigWorld.wg_getShortDateFormat(availableTime))) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTAVAILABLE_HEADER, direction=dirName) elif attackerClanDBID is None: if buildingsNames: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGS, buildings=buildingsNames)) if self.fortCtrl.getPermissions().canPlanAttack(): bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_ATTACKINFO)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_ATTACK, direction=dirName) else: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTCOMMANDERINFO)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTCOMMANDER, direction=dirName) else: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUSY_INFO, date=BigWorld.wg_getShortDateFormat(attackTime), clanName=attackerClanName)) if buildingsNames: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGS, buildings=buildingsNames)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUSY_HEADER, direction=dirName) return (header, '\n'.join(bodyParts), infoMessage)
def requestBuildingInfo(self, uid): infoData = {} id = self.getBuildingIDbyUID(uid) buildingStatus = self.__getBuildingStatus(id) infoData['buildingName'] = self.app.utilsManager.textManager.getText(TextType.HIGH_TITLE, i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid))) infoData['buildingID'] = uid infoData['longDescr'] = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, i18n.makeString(FORTIFICATIONS.buildingsprocess_longdescr(uid))) buttonLbl = FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBL if buildingStatus == self.BUILDING_STATUS.BUILT: buttonLbl = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBLBUILT)) infoData['buttonLabel'] = i18n.makeString(buttonLbl) infoData['orderInfo'] = self.__makeOrderInfoData(uid) statusIcon = '' isVisibleBtn = True isEnableBtn = True statusMsg = '' statusIconTooltip = None buttonTooltip = None if buildingStatus == self.BUILDING_STATUS.BUILT: statusMsg = self.app.utilsManager.textManager.concatStyles(((TextIcons.CHECKMARK_ICON,), (TextType.SUCCESS_TEXT, i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_BUILT)))) statusIcon = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_CHECKMARK isEnableBtn = False isVisibleBtn = False statusIconTooltip = self.__makeStatusTooltip(True) buttonTooltip = self.__makeButtonTooltip(self.BUILDING_STATUS.BUILT, None) elif buildingStatus == self.BUILDING_STATUS.NOT_AVAILABLE: isEnableBtn = False isVisibleBtn = True statusMsg = self.app.utilsManager.textManager.getText(TextType.ERROR_TEXT, i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_BUILDINGINFO_STATUSMESSAGE)) imageSource = self.app._utilsMgr.getHtmlIconText(ImageUrlProperties(RES_ICONS.MAPS_ICONS_LIBRARY_REDNOTAVAILABLE, 12, 12, 0, 0)) statusMsg = imageSource + ' ' + statusMsg statusIconTooltip = self.__makeStatusTooltip(False) buttonTooltip = self.__makeButtonTooltip(self.BUILDING_STATUS.NOT_AVAILABLE, None) else: buttonTooltip = self.__makeButtonTooltip(self.BUILDING_STATUS.AVAILABLE, i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid))) infoData['isVisibleBtn'] = isVisibleBtn infoData['isEnableBtn'] = isEnableBtn infoData['statusMsg'] = statusMsg infoData['statusIconTooltip'] = statusIconTooltip infoData['buttonTooltip'] = buttonTooltip self.as_responseBuildingInfoS(infoData) return