def __makeDefencePeriodData(self): alertMessage = '' blockBtnEnabled = True fort = self.fortCtrl.getFort() inProcess, inCooldown = fort.getDefenceHourProcessing() if self._isFortFrozen(): conditionPostfix = text_styles.standard(fort.getDefencePeriodStr()) else: conditionPostfix = text_styles.neutral(fort.getDefencePeriodStr()) blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEPERIODDESCRIPTION if inProcess: defenceHourChangeDay, nextDefenceHour, _ = fort.events[FORT_EVENT_TYPE.DEFENCE_HOUR_CHANGE] timestampStart = time_utils.getTimeTodayForUTC(nextDefenceHour) value = '%s - %s' % (BigWorld.wg_getShortTimeFormat(timestampStart), BigWorld.wg_getShortTimeFormat(timestampStart + time_utils.ONE_HOUR)) msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_INPROGRESS, value=value, date=BigWorld.wg_getShortDateFormat(defenceHourChangeDay)) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEBTNDISABLED elif inCooldown: msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_RECENTLYSCHEDULED) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEBTNDISABLED conditionPrefix = text_styles.main(i18n.makeString(FORTIFICATIONS.settingswindow_blockcondition('defencePeriodTime'))) blockDescr = text_styles.standard(i18n.makeString(FORTIFICATIONS.settingswindow_blockdescr('defencePeriodTime'))) if alertMessage: alertMessage = icons.alert() + ' ' + alertMessage return {'blockBtnEnabled': blockBtnEnabled, 'blockDescr': blockDescr, 'blockCondition': conditionPrefix + ' ' + conditionPostfix, 'alertMessage': alertMessage, 'blockBtnToolTip': blockBtnToolTip, 'descriptionTooltip': descriptionTooltip}
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 _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 __makeOrderInfoData(self, uid): self._buildingID = self.getBuildingIDbyUID(uid) self._orderID = self.fortCtrl.getFort().getBuildingOrder( self._buildingID) orderTitle = text_styles.middleTitle( i18n.makeString( FORTIFICATIONS.orders_orderpopover_ordertype( self.getOrderUIDbyID(self._orderID)))) descrMSG = i18n.makeString( FORTIFICATIONS.buildings_processorderinfo(uid)) descrMSG = text_styles.main(descrMSG) result = {} result['title'] = orderTitle result['description'] = descrMSG buildingId = self.getBuildingIDbyUID(uid) buildingDescr = self.fortCtrl.getFort().getBuilding( self.getBuildingIDbyUID(uid), BuildingDescr(typeID=buildingId)) order = self.fortCtrl.getFort().getOrder( buildingDescr.typeRef.orderType) result['iconSource'] = order.icon showAlertIcon, alertIconTooltip = self._showOrderAlertIcon(order) result['showAlertIcon'] = showAlertIcon result['alertIconTooltip'] = alertIconTooltip result['iconLevel'] = None return result
def __getBodyStatus(self, status, headerStyle, bodyStyle): headerLbl = headerStyle(i18n.makeString(FORT.buildingpopover_header_titlestatus(status))) if self.__isCommander: bodyLbl = bodyStyle(i18n.makeString(FORT.buildingpopover_commanderstatus_bodystatus(status))) else: bodyLbl = bodyStyle(i18n.makeString(FORT.buildingpopover_soldierstatus_bodystatus(status))) return (headerLbl, bodyLbl)
def __makeDayOfBattle(self, dayOfBattle, timestamp): if dayOfBattle == self.DAY_OF_BATTLE.TODAY: availability = i18n.makeString(FORTIFICATIONS.fortclanbattlelist_renderdayofbattle('today')) elif dayOfBattle == self.DAY_OF_BATTLE.TOMORROW: availability = i18n.makeString(FORTIFICATIONS.fortclanbattlelist_renderdayofbattle('tomorrow')) else: availability = BigWorld.wg_getShortDateFormat(timestamp) return self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, availability)
def __makeDayOfBattle(self, dayOfBattle, timestamp): if dayOfBattle == self.DAY_OF_BATTLE.TODAY: availability = i18n.makeString(I18N_FORTIFICATIONS.fortclanbattlelist_renderdayofbattle('today')) elif dayOfBattle == self.DAY_OF_BATTLE.TOMORROW: availability = i18n.makeString(I18N_FORTIFICATIONS.fortclanbattlelist_renderdayofbattle('tomorrow')) else: availability = BigWorld.wg_getShortDateFormat(timestamp) return text_styles.main(availability)
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 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 __makeVacationData(self): alertMessage = '' blockBtnEnabled = True daysBeforeVacation = -1 fort = self.fortCtrl.getFort() isVacationEnabled = fort.isVacationEnabled() inProcess, inCooldown = fort.getVacationProcessing() _, vacationEnd = fort.getVacationDate() blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONDESCRIPTION conditionPostfix = text_styles.standard( i18n.makeString(FORTIFICATIONS. SETTINGSWINDOW_BLOCKCONDITION_VACATIONNOTPLANNED)) if inProcess or inCooldown: blockBtnEnabled = False if fort.isOnVacation(): blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNDISABLED daysBeforeVacation = -1 elif time_utils.getTimeDeltaFromNow(vacationEnd) != 0: blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNDISABLED else: cooldownEnd = vacationEnd + g_fortCache.vacationCooldownTime daysBeforeVacation = time_utils.getTimeDeltaFromNow( cooldownEnd) / time_utils.ONE_DAY + 1 if daysBeforeVacation == 0: blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNDSBLDLESSADAY daysBeforeVacation = -1 else: blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNDISABLEDNOTPLANNED isVacationEnabled = False if isVacationEnabled: vacation = fort.getVacationDateTimeStr() if not self._isFortFrozen(): if not fort.isOnVacation(): conditionPostfix = text_styles.neutral(vacation) else: conditionPostfix = text_styles.success(vacation) else: conditionPostfix = text_styles.standard(vacation) conditionPrefix = text_styles.main( i18n.makeString( FORTIFICATIONS.settingswindow_blockcondition('vacation'))) blockDescr = text_styles.standard( i18n.makeString( FORTIFICATIONS.settingswindow_blockdescr('vacation'))) if alertMessage: alertMessage = icons.alert() + ' ' + alertMessage return { 'blockBtnEnabled': blockBtnEnabled, 'blockDescr': blockDescr, 'blockCondition': conditionPrefix + ' ' + conditionPostfix, 'alertMessage': alertMessage, 'blockBtnToolTip': blockBtnToolTip, 'daysBeforeVacation': daysBeforeVacation, 'descriptionTooltip': descriptionTooltip }
def __getBodyStatus(self, status, headerStyle, bodyStyle): headerLbl = headerStyle( i18n.makeString(FORT.buildingpopover_header_titlestatus(status))) if self.__isCommander: bodyLbl = bodyStyle( i18n.makeString( FORT.buildingpopover_commanderstatus_bodystatus(status))) else: bodyLbl = bodyStyle( i18n.makeString( FORT.buildingpopover_soldierstatus_bodystatus(status))) return (headerLbl, bodyLbl)
def __makeOffDayData(self): alertMessage = '' blockBtnEnabled = True fort = self.fortCtrl.getFort() inProcess, inCooldown = fort.getOffDayProcessing() dayOff = fort.getOffDayStr() if self._isFortFrozen(): conditionPostfix = text_styles.standard(dayOff) else: conditionPostfix = text_styles.neutral(dayOff) blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DAYOFFDESCRIPTION if inProcess: offDayChangeDate, nextOffDayUTC, _ = fort.events[ FORT_EVENT_TYPE.OFF_DAY_CHANGE] nextOffDayLocal = adjustOffDayToLocal( nextOffDayUTC, self.fortCtrl.getFort().getLocalDefenceHour()[0]) if nextOffDayLocal > NOT_ACTIVATED: value = i18n.makeString( MENU.datetime_weekdays_full(str(nextOffDayLocal + 1))) else: value = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_NOWEEKEND) msgString = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_INPROGRESS, value=value, date=BigWorld.wg_getLongDateFormat(offDayChangeDate)) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED elif inCooldown: msgString = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_RECENTLYSCHEDULED) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED conditionPrefix = text_styles.main( i18n.makeString( FORTIFICATIONS.settingswindow_blockcondition('weekEnd'))) blockDescr = text_styles.standard( i18n.makeString( FORTIFICATIONS.settingswindow_blockdescr('weekEnd'))) if alertMessage: alertMessage = icons.alert() + ' ' + alertMessage return { 'blockBtnEnabled': blockBtnEnabled, 'blockDescr': blockDescr, 'blockCondition': conditionPrefix + ' ' + conditionPostfix, 'alertMessage': alertMessage, 'blockBtnToolTip': blockBtnToolTip, 'descriptionTooltip': descriptionTooltip }
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 __makeVacationData(self): alertMessage = "" blockBtnEnabled = True daysBeforeVacation = -1 fort = self.fortCtrl.getFort() isVacationEnabled = fort.isVacationEnabled() inProcess, inCooldown = fort.getVacationProcessing() _, vacationEnd = fort.getVacationDate() blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONDESCRIPTION conditionPostfix = text_styles.standard( i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_VACATIONNOTPLANNED) ) if inProcess or inCooldown: blockBtnEnabled = False if fort.isOnVacation(): blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNDISABLED daysBeforeVacation = -1 elif time_utils.getTimeDeltaFromNow(vacationEnd) != 0: blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNDISABLED else: cooldownEnd = vacationEnd + g_fortCache.vacationCooldownTime daysBeforeVacation = time_utils.getTimeDeltaFromNow(cooldownEnd) / time_utils.ONE_DAY + 1 if daysBeforeVacation == 0: blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNDSBLDLESSADAY daysBeforeVacation = -1 else: blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_VACATIONBTNDISABLEDNOTPLANNED isVacationEnabled = False if isVacationEnabled: vacation = fort.getVacationDateTimeStr() if not self._isFortFrozen(): if not fort.isOnVacation(): conditionPostfix = text_styles.neutral(vacation) else: conditionPostfix = text_styles.success(vacation) else: conditionPostfix = text_styles.standard(vacation) conditionPrefix = text_styles.main(i18n.makeString(FORTIFICATIONS.settingswindow_blockcondition("vacation"))) blockDescr = text_styles.standard(i18n.makeString(FORTIFICATIONS.settingswindow_blockdescr("vacation"))) if alertMessage: alertMessage = icons.alert() + " " + alertMessage return { "blockBtnEnabled": blockBtnEnabled, "blockDescr": blockDescr, "blockCondition": conditionPrefix + " " + conditionPostfix, "alertMessage": alertMessage, "blockBtnToolTip": blockBtnToolTip, "daysBeforeVacation": daysBeforeVacation, "descriptionTooltip": descriptionTooltip, }
def __prepareDefResInfo(self): result = {} icon = None level = None showAlertIcon = False alertIconTooltip = '' if self._isBaseBuilding: defResTitle = text_styles.middleTitle(i18n.makeString(FORT.BUILDINGPOPOVER_DEFRESINFO_BASEBUILDINGTITLE)) defresDescr = text_styles.main(i18n.makeString(FORT.buildings_defresinfo(self._buildingUID))) else: order = self.fortCtrl.getFort().getOrder(self.__orderID) icon = order.icon level = order.level defResTitle = text_styles.middleTitle(i18n.makeString('#fortifications:General/orderType/%s' % self.getOrderUIDbyID(self.__orderID))) defresDescr = order.description showAlertIcon, alertIconTooltip = self._showOrderAlertIcon(order) result['showAlertIcon'] = showAlertIcon result['alertIconTooltip'] = alertIconTooltip result['title'] = defResTitle result['description'] = defresDescr result['iconSource'] = icon result['iconLevel'] = level if self.__orderID in constants.FORT_ORDER_TYPE.CONSUMABLES: result['orderID'] = self.__orderID return result
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 __prepareDefResInfo(self): result = {} icon = None level = None showAlertIcon = False alertIconTooltip = '' if self._isBaseBuilding: defResTitle = text_styles.middleTitle( i18n.makeString( FORT.BUILDINGPOPOVER_DEFRESINFO_BASEBUILDINGTITLE)) defresDescr = text_styles.main( i18n.makeString(FORT.buildings_defresinfo(self._buildingUID))) else: order = self.fortCtrl.getFort().getOrder(self.__orderID) icon = order.icon level = order.level defResTitle = text_styles.middleTitle( i18n.makeString('#fortifications:General/orderType/%s' % self.getOrderUIDbyID(self.__orderID))) defresDescr = order.description showAlertIcon, alertIconTooltip = self._showOrderAlertIcon(order) result['showAlertIcon'] = showAlertIcon result['alertIconTooltip'] = alertIconTooltip result['title'] = defResTitle result['description'] = defresDescr result['iconSource'] = icon result['iconLevel'] = level if self.__orderID in constants.FORT_ORDER_TYPE.CONSUMABLES: result['orderID'] = self.__orderID return result
def getBonusText(strValue, buildingID, textsStyle=None, ctx=None): ctx = ctx or {} textsStyle = textsStyle or (text_styles.neutral, text_styles.main) descrStr = i18n.makeString(FORTIFICATIONS.buildings_defresinfo(buildingID), **ctx) return ''.join((textsStyle[0](strValue + ' ' if strValue else ''), textsStyle[1](descrStr)))
def buildList(self): self.__list = [{ 'label': I18N_FORTIFICATIONS.sortie_division_name('ALL'), 'data': 0 }] self.__list.extend( makeDivisionData(I18N_FORTIFICATIONS.sortie_division_name))
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 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 text_styles.error(building) return building
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 makeSortieShortVO(unitFunctional, unitIdx=None, app=None): fullData = unitFunctional.getUnitFullData(unitIdx=unitIdx) if fullData is None: title = i18n.makeString(FORTIFICATIONS.SORTIE_LISTVIEW_ALERTTEXT_TITLE) body = i18n.makeString(FORTIFICATIONS.SORTIE_LISTVIEW_ALERTTEXT_BODY) alertView = { 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_ALERTICON, 'titleMsg': text_styles.alert(title), 'bodyMsg': text_styles.main(body), 'buttonLbl': FORTIFICATIONS.SORTIE_LISTVIEW_ENTERBTN } return {'isShowAlertView': True, 'alertView': alertView} unit, unitState, unitStats, pInfo, slotsIter = fullData division = getDivisionNameByType(unit.getRosterTypeID()) divisionTypeStr = i18n.makeString( FORTIFICATIONS.sortie_division_name(division)) unit, unitState, _, pInfo, slotsIter = fullData return { 'isFreezed': unitState.isLocked(), 'hasRestrictions': unit.isRosterSet(ignored=settings.CREATOR_ROSTER_SLOT_INDEXES), 'slots': _getSlotsData(unitIdx, unit, unitState, pInfo, slotsIter, app, unitFunctional.getRosterSettings().getLevelsRange()), 'description': divisionTypeStr if divisionTypeStr else unitFunctional.getCensoredComment(unitIdx=unitIdx) }
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 __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 getBuildingInfoTooltipData(self, buildingDescr): body = None if buildingDescr is not None: uid = self.getBuildingUIDbyID(buildingDescr.typeID) description = i18n.makeString(FORTIFICATIONS.buildingsprocess_longdescr(uid)) level = text_styles.stats(buildingDescr.getUserLevel()) body = i18n.makeString(CLANS.SECTION_FORT_BUILDING_TOOLTIP_BODY, level=level, description=description) return body
def getSlotTooltipBody(self, orderID): if orderID == ORDER_TYPES.EMPTY_ORDER: return makeTooltip( i18n.makeString( FORTIFICATIONS.orders_orderpopover_ordertype(orderID)), i18n.makeString( TOOLTIPS.FORTORDERSPANELCOMPONENT_EMPTYSLOT_BODY), None) return ''
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 __makeOrderInfoData(self, uid): self._buildingID = self.getBuildingIDbyUID(uid) self._orderID = self.fortCtrl.getFort().getBuildingOrder(self._buildingID) orderTitle = text_styles.middleTitle(i18n.makeString(FORTIFICATIONS.orders_orderpopover_ordertype(self.getOrderUIDbyID(self._orderID)))) descrMSG = i18n.makeString(FORTIFICATIONS.buildings_processorderinfo(uid)) descrMSG = text_styles.main(descrMSG) result = {} result['title'] = orderTitle result['description'] = descrMSG buildingId = self.getBuildingIDbyUID(uid) buildingDescr = self.fortCtrl.getFort().getBuilding(self.getBuildingIDbyUID(uid), BuildingDescr(typeID=buildingId)) order = self.fortCtrl.getFort().getOrder(buildingDescr.typeRef.orderType) result['iconSource'] = order.icon showAlertIcon, alertIconTooltip = self._showOrderAlertIcon(order) result['showAlertIcon'] = showAlertIcon result['alertIconTooltip'] = alertIconTooltip result['iconLevel'] = None return result
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 __makeBattleName(self, item, battleType): _, clanAbbrev, _ = item.getOpponentClanInfo() clanName = '[%s]' % clanAbbrev result = i18n.makeString( I18N_FORTIFICATIONS.fortclanbattlelist_renderbattlename( battleType), clanName=clanName) result = text_styles.middleTitle(result) return result
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 __makeOffDayData(self): alertMessage = "" blockBtnEnabled = True fort = self.fortCtrl.getFort() inProcess, inCooldown = fort.getOffDayProcessing() dayOff = fort.getOffDayStr() if self._isFortFrozen(): conditionPostfix = text_styles.standard(dayOff) else: conditionPostfix = text_styles.neutral(dayOff) blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DAYOFFDESCRIPTION if inProcess: offDayChangeDate, nextOffDayUTC, _ = fort.events[FORT_EVENT_TYPE.OFF_DAY_CHANGE] nextOffDayLocal = adjustOffDayToLocal(nextOffDayUTC, self.fortCtrl.getFort().getLocalDefenceHour()[0]) if nextOffDayLocal > NOT_ACTIVATED: value = i18n.makeString(MENU.datetime_weekdays_full(str(nextOffDayLocal + 1))) else: value = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_NOWEEKEND) msgString = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_INPROGRESS, value=value, date=BigWorld.wg_getLongDateFormat(offDayChangeDate), ) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED elif inCooldown: msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_RECENTLYSCHEDULED) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED conditionPrefix = text_styles.main(i18n.makeString(FORTIFICATIONS.settingswindow_blockcondition("weekEnd"))) blockDescr = text_styles.standard(i18n.makeString(FORTIFICATIONS.settingswindow_blockdescr("weekEnd"))) if alertMessage: alertMessage = icons.alert() + " " + alertMessage return { "blockBtnEnabled": blockBtnEnabled, "blockDescr": blockDescr, "blockCondition": conditionPrefix + " " + conditionPostfix, "alertMessage": alertMessage, "blockBtnToolTip": blockBtnToolTip, "descriptionTooltip": descriptionTooltip, }
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 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 description(self): from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper if self.isSpecialMission: awardText = i18n.makeString(FORTIFICATIONS.ORDERS_SPECIALMISSION_POSSIBLEAWARD) + ' ' bonusDescr = i18n.makeString(FORTIFICATIONS.orders_specialmission_possibleaward_description_level(self.level)) return self.app.utilsManager.textManager.concatStyles(((TEXT_MANAGER_STYLES.NEUTRAL_TEXT, awardText), (TEXT_MANAGER_STYLES.MAIN_TEXT, bonusDescr))) elif self.isConsumable: return fort_formatters.getBonusText('', FortViewHelper.getBuildingUIDbyID(self.buildingID), ctx=dict(self.getParams())) else: effectValueStr = '+' + str(abs(self.effectValue)) return fort_formatters.getBonusText('%s%%' % effectValueStr, FortViewHelper.getBuildingUIDbyID(self.buildingID))
def description(self): from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper if self.isSpecialMission: awardText = i18n.makeString(FORTIFICATIONS.ORDERS_SPECIALMISSION_POSSIBLEAWARD) + ' ' bonusDescr = i18n.makeString(FORTIFICATIONS.orders_specialmission_possibleaward_description_level(self.level)) return ''.join((text_styles.neutral(awardText), text_styles.main(bonusDescr))) elif self.isConsumable: return fort_formatters.getBonusText('', FortViewHelper.getBuildingUIDbyID(self.buildingID), ctx=dict(self.getParams())) else: effectValueStr = '+' + str(abs(self.effectValue)) return fort_formatters.getBonusText('%s%%' % effectValueStr, FortViewHelper.getBuildingUIDbyID(self.buildingID))
def makeSortieShortVO(unitEntity, unitIdx = None, app = None): fullData = unitEntity.getUnitFullData(unitIdx=unitIdx) division = getDivisionNameByType(fullData.unit.getRosterTypeID()) divisionTypeStr = i18n.makeString(FORTIFICATIONS.sortie_division_name(division)) if divisionTypeStr: description = divisionTypeStr else: description = unitEntity.getCensoredComment(unitIdx=unitIdx) return {'isFreezed': fullData.flags.isLocked(), 'hasRestrictions': fullData.unit.isRosterSet(ignored=settings.CREATOR_ROSTER_SLOT_INDEXES), 'slots': _getSlotsData(unitIdx, fullData, app, unitEntity.getRosterSettings().getLevelsRange()), 'description': description}
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 __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 __prepareOrderInfo(self, increment = False, orderCount = 0, orderLevel = 1): result = {} if self.intBuildingID == FORT_BUILDING_TYPE.MILITARY_BASE: if increment: building_bonus = i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=fort_formatters.getTextLevel(min(self.__baseBuildingLevel + 1, MAX_FORTIFICATION_LEVEL))) defresDescr = self.app.utilsManager.textManager.concatStyles(((TEXT_MANAGER_STYLES.NEUTRAL_TEXT, building_bonus + ' '), (TEXT_MANAGER_STYLES.MAIN_TEXT, i18n.makeString(FORTIFICATIONS.BUILDINGS_MODERNIZATIONDESCR_BASE_BUILDING)))) else: building_bonus = i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=fort_formatters.getTextLevel(self.__baseBuildingLevel)) defresDescr = self.app.utilsManager.textManager.concatStyles(((TEXT_MANAGER_STYLES.STANDARD_TEXT, building_bonus + ' '), (TEXT_MANAGER_STYLES.STANDARD_TEXT, i18n.makeString(FORTIFICATIONS.BUILDINGS_MODERNIZATIONDESCR_BASE_BUILDING)))) else: orderTypeID = self.fortCtrl.getFort().getBuildingOrder(self.intBuildingID) _, _, foundedLevel, orderData = self.fortCtrl.getFort().getOrderData(orderTypeID) if increment: bodyTextColor = TEXT_MANAGER_STYLES.MAIN_TEXT bonusTextColor = TEXT_MANAGER_STYLES.NEUTRAL_TEXT foundedLevel += 1 _, _, _, orderData = self.fortCtrl.getFort().getOrderData(orderTypeID, foundedLevel) textPadding = ' ' else: bodyTextColor = TEXT_MANAGER_STYLES.STANDARD_TEXT bonusTextColor = TEXT_MANAGER_STYLES.STANDARD_TEXT textPadding = '' if orderTypeID == FORT_ORDER_TYPE.SPECIAL_MISSION: awardText = textPadding + i18n.makeString(FORTIFICATIONS.ORDERS_SPECIALMISSION_POSSIBLEAWARD) + ' ' bonusDescr = i18n.makeString(FORTIFICATIONS.orders_specialmission_possibleaward_description_level(foundedLevel)) defresDescr = self.app.utilsManager.textManager.concatStyles(((bonusTextColor, awardText), (bodyTextColor, bonusDescr))) elif orderTypeID in FORT_ORDER_TYPE.CONSUMABLES: colorStyle = (bonusTextColor, bodyTextColor) battleOrder = FortOrder(orderTypeID, level=orderLevel) defresDescr = fort_formatters.getBonusText(textPadding, self.__uid, ctx=dict(battleOrder.getParams()), textsStyle=colorStyle) else: colorStyle = (bonusTextColor, bodyTextColor) bonus = str(abs(orderData.effectValue)) defresDescr = fort_formatters.getBonusText('%s+%s%%' % (textPadding, bonus), self.__uid, colorStyle) result['ordersCount'] = orderCount result['description'] = defresDescr result['buildingType'] = self.__uid result['showAlertIcon'] = False isCombatOrderBuilding = self.__uid in [FORTIFICATION_ALIASES.FORT_ARTILLERY_SHOP_BUILDING, FORTIFICATION_ALIASES.FORT_BOMBER_SHOP_BUILDING] result['descriptionLink'] = increment and isCombatOrderBuilding if self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: order = self.fortCtrl.getFort().getOrder(self._buildingDescr.typeRef.orderType) result['iconSource'] = order.icon result['iconLevel'] = order.level if not increment else order.level + 1 if increment and self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: result['infoIconSource'] = RES_ICONS.MAPS_ICONS_LIBRARY_INFORMATIONICON toolTipData = {} toolTipData['header'] = i18n.makeString(TOOLTIPS.FORTIFICATION_DEFRESICONINFO_HEADER) toolTipData['body'] = i18n.makeString(TOOLTIPS.FORTIFICATION_DEFRESICONINFO_BODY, testData='test py var') result['infoIconToolTipData'] = toolTipData return result
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 makeDivisionData(nameGenerator = None): result = [] for name, divisionID, rosterTypeID in getDivisionsOrderData(): settings = getDivisionSettings(name) if settings: profit = settings.resourceBonus else: profit = 0 result.append({'profit': profit, 'level': divisionID, 'label': nameGenerator or I18N_FORTIFICATIONS.sortie_division_name(name), 'data': rosterTypeID, 'vehLvls': MIN_MAX_VEH_LVLS_MAPPING[divisionID].DEFAULT_LEVELS}) return result
def __prepareOrderInfo(self, increment = False, orderCount = 0, orderLevel = 1): result = {} if self.intBuildingID == FORT_BUILDING_TYPE.MILITARY_BASE: if increment: building_bonus = i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=fort_formatters.getTextLevel(min(self.__baseBuildingLevel + 1, MAX_FORTIFICATION_LEVEL))) defresDescr = ''.join((text_styles.neutral(building_bonus + ' '), text_styles.main(i18n.makeString(FORTIFICATIONS.BUILDINGS_MODERNIZATIONDESCR_BASE_BUILDING)))) else: building_bonus = i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=fort_formatters.getTextLevel(self.__baseBuildingLevel)) defresDescr = ''.join((text_styles.standard(building_bonus + ' '), text_styles.standard(i18n.makeString(FORTIFICATIONS.BUILDINGS_MODERNIZATIONDESCR_BASE_BUILDING)))) else: orderTypeID = self.fortCtrl.getFort().getBuildingOrder(self.intBuildingID) _, _, foundedLevel, orderData = self.fortCtrl.getFort().getOrderData(orderTypeID) if increment: bodyStyle = text_styles.main bonusStyle = text_styles.neutral foundedLevel += 1 _, _, _, orderData = self.fortCtrl.getFort().getOrderData(orderTypeID, foundedLevel) textPadding = ' ' else: bodyStyle = text_styles.standard bonusStyle = text_styles.standard textPadding = '' if orderTypeID == FORT_ORDER_TYPE.SPECIAL_MISSION: awardText = textPadding + i18n.makeString(FORTIFICATIONS.ORDERS_SPECIALMISSION_POSSIBLEAWARD) + ' ' bonusDescr = i18n.makeString(FORTIFICATIONS.orders_specialmission_possibleaward_description_level(foundedLevel)) defresDescr = ''.join((bonusStyle(awardText), bodyStyle(bonusDescr))) elif orderTypeID in FORT_ORDER_TYPE.CONSUMABLES: battleOrder = FortOrder(orderTypeID, level=orderLevel) defresDescr = fort_formatters.getBonusText(textPadding, self.__uid, ctx=dict(battleOrder.getParams()), textsStyle=(bonusStyle, bodyStyle)) else: colorStyle = (bonusStyle, bodyStyle) bonus = str(abs(orderData.effectValue)) defresDescr = fort_formatters.getBonusText('%s+%s%%' % (textPadding, bonus), self.__uid, colorStyle) result['ordersCount'] = orderCount result['description'] = defresDescr result['buildingType'] = self.__uid result['showAlertIcon'] = False isCombatOrderBuilding = self.__uid in [FORTIFICATION_ALIASES.FORT_ARTILLERY_SHOP_BUILDING, FORTIFICATION_ALIASES.FORT_BOMBER_SHOP_BUILDING] result['descriptionLink'] = increment and isCombatOrderBuilding if self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: order = self.fortCtrl.getFort().getOrder(self._buildingDescr.typeRef.orderType) result['iconSource'] = order.icon result['iconLevel'] = order.level if not increment else order.level + 1 if increment and self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: result['infoIconSource'] = RES_ICONS.MAPS_ICONS_LIBRARY_INFORMATIONICON result['infoIconToolTip'] = makeTooltip(TOOLTIPS.FORTIFICATION_DEFRESICONINFO_HEADER, TOOLTIPS.FORTIFICATION_DEFRESICONINFO_BODY) return result
def _prepareAndSendData(self): resultData = {} if self._orderID: orderTitle = i18n.makeString(FORTIFICATIONS.orders_orderpopover_ordertype(self._orderID)) order = self.fortCtrl.getFort().getOrder(self.getOrderIDbyUID(self._orderID)) building = self.fortCtrl.getFort().getBuilding(order.buildingID) defRes = building.storage maxPurchase = int(defRes / order.productionCost) resultData = {'orderIcon': order.icon, 'name': orderTitle, 'description': order.description, 'productionTime': order.productionTotalTime, 'productionCost': order.productionCost, 'level': order.level, 'defaultValue': -1, 'maxAvailableCount': min(order.maxCount - order.count, maxPurchase)} self.as_setDataS(resultData)
def __makeOrderInfoData(self, uid): self._buildingID = self.getBuildingIDbyUID(uid) self._orderID = self.fortCtrl.getFort().getBuildingOrder(self._buildingID) orderTitle = self.app.utilsManager.textManager.getText(TEXT_MANAGER_STYLES.MIDDLE_TITLE, i18n.makeString(FORTIFICATIONS.orders_orderpopover_ordertype(self.getOrderUIDbyID(self._orderID)))) descrMSG = i18n.makeString(FORTIFICATIONS.buildings_processorderinfo(uid)) descrMSG = self.app.utilsManager.textManager.getText(TEXT_MANAGER_STYLES.MAIN_TEXT, descrMSG) result = {} result['title'] = orderTitle result['description'] = descrMSG buildingId = self.getBuildingIDbyUID(uid) buildingDescr = self.fortCtrl.getFort().getBuilding(self.getBuildingIDbyUID(uid), BuildingDescr(typeID=buildingId)) order = self.fortCtrl.getFort().getOrder(buildingDescr.typeRef.orderType) result['iconSource'] = order.icon showAlertIcon, alertIconTooltip = self._showOrderAlertIcon(order) result['showAlertIcon'] = showAlertIcon result['alertIconTooltip'] = alertIconTooltip result['iconLevel'] = None return result
def makeSortieShortVO(unitFunctional, unitIdx = None, app = None): fullData = unitFunctional.getUnitFullData(unitIdx=unitIdx) if fullData is None: title = i18n.makeString(FORTIFICATIONS.SORTIE_LISTVIEW_ALERTTEXT_TITLE) body = i18n.makeString(FORTIFICATIONS.SORTIE_LISTVIEW_ALERTTEXT_BODY) alertView = {'icon': RES_ICONS.MAPS_ICONS_LIBRARY_ALERTICON, 'titleMsg': text_styles.alert(title), 'bodyMsg': text_styles.main(body), 'buttonLbl': FORTIFICATIONS.SORTIE_LISTVIEW_ENTERBTN} return {'isShowAlertView': True, 'alertView': alertView} unit, unitState, unitStats, pInfo, slotsIter = fullData division = getDivisionNameByType(unit.getRosterTypeID()) divisionTypeStr = i18n.makeString(FORTIFICATIONS.sortie_division_name(division)) unit, unitState, _, pInfo, slotsIter = fullData return {'isFreezed': unitState.isLocked(), 'hasRestrictions': unit.isRosterSet(ignored=settings.CREATOR_ROSTER_SLOT_INDEXES), 'slots': _getSlotsData(unitIdx, unit, unitState, pInfo, slotsIter, app, unitFunctional.getRosterSettings().getLevelsRange()), 'description': divisionTypeStr if divisionTypeStr else unitFunctional.getCensoredComment(unitIdx=unitIdx)}
def makeSortieVO(unitFunctional, unitIdx=None, app=None): fullData = unitFunctional.getUnitFullData(unitIdx=unitIdx) if fullData is None: return else: unit, unitState, unitStats, pInfo, slotsIter = fullData division = getDivisionNameByType(unit.getRosterTypeID()) divisionTypeStr = i18n.makeString( FORTIFICATIONS.sortie_division_name(division)) divisionStr = i18n.makeString(FORTIFICATIONS.SORTIE_ROOM_DIVISION) divisionLbl = ''.join((text_styles.standard(divisionStr), text_styles.main(divisionTypeStr))) isPlayerCreator = pInfo.isCreator() canDoAction, restriction = unitFunctional.validateLevels( stats=unitStats) sumLevelsStr = makeTotalLevelLabel(unitStats, restriction) return { 'isCommander': isPlayerCreator, 'isFreezed': unitState.isLocked(), 'hasRestrictions': unit.isRosterSet(ignored=settings.CREATOR_ROSTER_SLOT_INDEXES), 'statusLbl': makeUnitStateLabel(unitState), 'statusValue': unitState.isOpened(), 'sumLevelsInt': unitStats.curTotalLevel, 'sumLevels': sumLevelsStr, 'sumLevelsError': canDoAction, 'slots': _getSlotsData(unitIdx, unit, unitState, pInfo, slotsIter, app, unitFunctional.getRosterSettings().getLevelsRange()), 'description': unitFunctional.getCensoredComment(unitIdx=unitIdx), 'divisionLbl': divisionLbl }
def _makeVO(self, index, item): isInBattle = item.getFlags() & UNIT_FLAGS.IN_ARENA > 0 or item.getFlags() & UNIT_FLAGS.IN_QUEUE > 0 or item.getFlags() & UNIT_FLAGS.IN_SEARCH > 0 user = self.usersStorage.getUser(item.getCommanderDatabaseID()) scheme = g_settings.getColorScheme('rosters') if user: colors = scheme.getColors(user.getGuiType()) color = colors[0] if user.isOnline() else colors[1] else: colors = scheme.getColors(USER_GUI_TYPE.OTHER) color = colors[1] return {'sortieID': item.getID(), 'creatorName': item.getCommanderFullName(), 'divisionName': I18N_FORTIFICATIONS.sortie_division_name(item.getDivisionName()), 'description': text_styles.standard(item.getDescription()), 'descriptionForTT': item.getDescription(), 'isInBattle': isInBattle, 'division': item.getDivision(), 'playersCount': item.itemData.count, 'commandSize': item.itemData.maxCount, 'rallyIndex': index, 'igrType': item.getIgrType(), 'color': color}
def _prepareAndSendData(self): resultData = {} if self._orderID: orderTitle = i18n.makeString( FORTIFICATIONS.orders_orderpopover_ordertype(self._orderID)) order = self.fortCtrl.getFort().getOrder( self.getOrderIDbyUID(self._orderID)) building = self.fortCtrl.getFort().getBuilding(order.buildingID) defRes = building.storage maxPurchase = int(defRes / order.productionCost) maxAvailableCount = min(order.maxCount - order.count, maxPurchase, 100) resultData = { 'orderIcon': order.icon, 'name': orderTitle, 'description': order.description, 'productionTime': order.productionTotalTime, 'productionCost': order.productionCost, 'level': order.level, 'defaultValue': -1, 'maxAvailableCount': maxAvailableCount } self.as_setDataS(resultData)