NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

agentDialogueUtil.py (34595B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\station\agents\agentDialogueUtil.py
      2 import localization
      3 from carbon.common.script.util.commonutils import StripTags
      4 from carbonui.util.color import Color
      5 from eve.common.lib import appConst
      6 from eve.common.script.sys import idCheckers
      7 from eve.common.script.util.eveFormat import FmtISK
      8 from evedungeons.client.data import GetDungeon
      9 from eveformat.client.location import get_security_status
     10 from eveuniverse.security import is_high_sec_or_higher, is_low_sec_or_lower
     11 from fsdBuiltData.common.iconIDs import GetIconFile
     12 from npcs.divisions import get_division_name
     13 from security.client.securityColor import get_security_status_color
     14 from eveuniverse.security import get_solar_system_security_class, securityClassSafeSec
     15 from security.common.const import AGENT_MISSION_SECURITY_TAX_RATE
     16 from eve.client.script.ui.eveColor import SMOKE_BLUE_HEX, PLATINUM_GREY_HEX
     17 CHECK_ICON = '<img src=icon:38_193 size=16>'
     18 CROSS_ICON = '<img src=icon:38_194 size=16>'
     19 CIRCLE_ICON = '<img src=icon:38_195 size=16>'
     20 HIGH_SEC_COLOR = (0, 255, 255)
     21 MEDIUM_HIGH_SEC_COLOR = (0, 255, 0)
     22 MEDIUM_SEC_COLOR = (255, 255, 0)
     23 LOW_SEC_COLOR = (255, 0, 0)
     24 
     25 def _ProcessObjectiveEntry(objType, objData):
     26     html = ''
     27     if objType == 'agent':
     28         agentID, agentLocation = objData
     29         agentInfoIcon = '<a href=showinfo:%d//%d><img src=icon:38_208 size=16 alt="%s"></a>' % (cfg.eveowners.Get(agentID).typeID, agentID, StripTags(localization.GetByLabel('UI/Commands/ShowInfo')))
     30         html = '\n            <span id=caption>%(speakWithString)s %(agentInfoIcon)s</span><br>\n            <table>\n                <tr valign=middle>\n                    <td width=64>%(agentGraphic)s</td>\n                    <td>%(agentLocationHeader)s</td>\n                    <td>%(dropoffLocation)s</td>\n                </tr>\n            </table>\n            <br>\n        ' % {'speakWithString': localization.GetByLabel('UI/Agents/StandardMission/ObjectiveReportToAgent', agentID=agentID),
     31          'agentInfoIcon': agentInfoIcon,
     32          'agentGraphic': '<img src="portrait:%d" size=64 hspace=2 vspace=2>' % agentID,
     33          'dropoffLocation': LocationWrapper(agentLocation, 'agenthomebase'),
     34          'agentLocationHeader': localization.GetByLabel('UI/Agents/StandardMission/AgentLocation')}
     35     elif objType == 'transport':
     36         pickupOwnerID, pickupLocation, dropoffOwnerID, dropoffLocation, cargo = objData
     37         cargoObjectiveIcon = CHECK_ICON if cargo['hasCargo'] else CIRCLE_ICON
     38         isAtPickupLocation = pickupLocation['locationID'] == session.locationid
     39         if isAtPickupLocation or cargo['hasCargo']:
     40             pickupObjectiveIcon = CHECK_ICON
     41         else:
     42             pickupObjectiveIcon = CIRCLE_ICON
     43         pickupGraphic = _OwnerWrap(pickupOwnerID)
     44         isAtDropoffLocation = dropoffLocation['locationID'] == session.locationid
     45         if isAtDropoffLocation and (isAtPickupLocation or cargo['hasCargo']):
     46             dropoffObjectiveIcon = CHECK_ICON
     47         else:
     48             dropoffObjectiveIcon = CIRCLE_ICON
     49         dropoffGraphic = _OwnerWrap(dropoffOwnerID)
     50         cargoText = localization.GetByLabel('UI/Common/QuantityAndItem', quantity=cargo['quantity'], item=cargo['typeID'])
     51         if cargo['volume'] > 0:
     52             cargoText = localization.GetByLabel('UI/Agents/StandardMission/CargoDescriptionWithSize', cargoDescription=cargoText, size=cargo['volume'])
     53         cargoGraphic = _IconWrap(cargo['typeID'])
     54         html = '\n            <span id=caption>%(transportHeader)s</span><br>\n            <div id=basetext>%(transportBlurb)s\n            <br>\n            <table>\n                <tr valign=middle>\n                    <td>%(pickupObjectiveIcon)s</td>                \n                    <td width=32>%(pickupGraphic)s</td>\n                    <td>%(transportPickup)s</td>\n                    <td>%(pickupLocation)s</td>\n                </tr>\n                <tr valign=middle>\n                    <td>%(dropoffObjectiveIcon)s</td>                \n                    <td width=32>%(dropoffGraphic)s</td>\n                    <td>%(transportDropOff)s</td>\n                    <td>%(dropoffLocation)s</td>\n                </tr>\n                <tr valign=middle>\n                    <td>%(cargoObjectiveIcon)s</td>\n                    <td width=32>%(cargoGraphic)s</td>\n                    <td>%(transportCargo)s</td>\n                    <td>%(cargo)s</td>\n                </tr>\n            </table></div>\n            <br>\n        ' % {'transportHeader': localization.GetByLabel('UI/Agents/StandardMission/TransportObjectiveHeader'),
     55          'transportBlurb': localization.GetByLabel('UI/Agents/StandardMission/TransportBlurb'),
     56          'pickupObjectiveIcon': pickupObjectiveIcon,
     57          'pickupGraphic': pickupGraphic,
     58          'transportPickup': localization.GetByLabel('UI/Agents/StandardMission/TransportPickupLocation'),
     59          'pickupLocation': LocationWrapper(pickupLocation),
     60          'dropoffObjectiveIcon': dropoffObjectiveIcon,
     61          'dropoffGraphic': dropoffGraphic,
     62          'transportDropOff': localization.GetByLabel('UI/Agents/StandardMission/TransportDropOffLocation'),
     63          'dropoffLocation': LocationWrapper(dropoffLocation),
     64          'cargoObjectiveIcon': cargoObjectiveIcon,
     65          'cargoGraphic': cargoGraphic,
     66          'transportCargo': localization.GetByLabel('UI/Agents/StandardMission/TransportCargo'),
     67          'cargo': cargoText}
     68     elif objType == 'fetch':
     69         dropoffOwnerID, dropoffLocation, cargo = objData
     70         isAtDropoffLocation = dropoffLocation is not None and dropoffLocation['locationID'] == session.locationid
     71         dropoffObjectiveIcon = CHECK_ICON if isAtDropoffLocation else CIRCLE_ICON
     72         dropoffGraphic = _OwnerWrap(dropoffOwnerID)
     73         if dropoffLocation is not None:
     74             dropoffLocationText = LocationWrapper(dropoffLocation)
     75         else:
     76             dropoffLocationText = _OwnerWrap(dropoffOwnerID)
     77         cargoObjectiveIcon = CHECK_ICON if cargo['hasCargo'] else CIRCLE_ICON
     78         cargoGraphic = _IconWrap(cargo['typeID'])
     79         cargoText = localization.GetByLabel('UI/Common/QuantityAndItem', quantity=cargo['quantity'], item=cargo['typeID'])
     80         if cargo['volume'] > 0:
     81             cargoText = localization.GetByLabel('UI/Agents/StandardMission/CargoDescriptionWithSize', cargoDescription=cargoText, size=cargo['volume'])
     82         html = '\n            <span id=caption>%(fetchHeader)s</span><br>\n            <div id=basetext>%(fetchBlurb)s<br><br>\n            <table>\n                <tr valign=middle>\n                    <td>%(dropoffObjectiveIcon)s</td>\n                    <td width=32>%(dropoffGraphic)s</td>\n                    <td>%(fetchDropOff)s</td>\n                    <td>%(dropoffLocation)s</td>\n                </tr>\n                <tr valign=middle>\n                    <td>%(cargoObjectiveIcon)s</td>\n                    <td width=32>%(cargoGraphic)s</td>\n                    <td>%(fetchItem)s</td>\n                    <td>%(cargo)s</td>\n                </tr>\n            </table>\n            </div>\n            <br>\n        ' % {'fetchHeader': localization.GetByLabel('UI/Agents/StandardMission/FetchObjectiveHeader'),
     83          'fetchBlurb': localization.GetByLabel('UI/Agents/StandardMission/FetchObjectiveBlurb'),
     84          'dropoffObjectiveIcon': dropoffObjectiveIcon,
     85          'dropoffGraphic': dropoffGraphic,
     86          'fetchDropOff': localization.GetByLabel('UI/Agents/StandardMission/FetchObjectiveDropOffLocation'),
     87          'dropoffLocation': dropoffLocationText,
     88          'cargoObjectiveIcon': cargoObjectiveIcon,
     89          'cargoGraphic': cargoGraphic,
     90          'fetchItem': localization.GetByLabel('UI/Agents/StandardMission/FetchObjectiveItem'),
     91          'cargo': cargoText}
     92     return html
     93 
     94 
     95 def _ProcessDungeonData(dunData, agentID):
     96     s1, s2 = ('', '')
     97     if 'completionStatus' in dunData:
     98         lbl = ['UI/Agents/StandardMission/DungeonObjectiveFailed', 'UI/Agents/StandardMission/DungeonObjectiveCompleted'][dunData['completionStatus']]
     99         s1 = '<strike>'
    100         s2 = '</strike> %s' % localization.GetByLabel(lbl)
    101     if dunData['optional']:
    102         objectiveTextTitle = localization.GetByLabel('UI/Agents/StandardMission/OptionalObjectiveHeader')
    103         objectiveTextBody = localization.GetByLabel('UI/Agents/StandardMission/OptionalObjectiveBody')
    104     else:
    105         objectiveTextTitle = localization.GetByLabel('UI/Agents/StandardMission/ObjectiveHeader')
    106         objectiveTextBody = localization.GetByLabel('UI/Agents/StandardMission/DungeonObjectiveBody')
    107     if 'briefingMessage' in dunData:
    108         objectiveTextBody = sm.GetService('agents').ProcessMessage(dunData['briefingMessage'], agentID)
    109     if dunData['objectiveCompleted'] is not None:
    110         objectiveIcon = [CROSS_ICON, CHECK_ICON][dunData['objectiveCompleted']]
    111     else:
    112         objectiveIcon = CIRCLE_ICON
    113     if 'ownerID' in dunData:
    114         dungeonGraphic = _OwnerWrap(dunData['ownerID'])
    115     else:
    116         dungeonGraphic = ''
    117     html = '\n        <span id=caption>%(objectiveTextTitle)s</span><br>\n        <div id=basetext> %(s1)s%(objectiveTextBody)s%(s2)s<br>\n        <table>\n            <tr valign=middle>\n                <td>%(objectiveIcon)s</td>\n                <td width=32>%(dungeonGraphic)s</td>\n                <td width=50>%(locationHeader)s</td>\n                <td width=200>%(dungeonLocation)s</td>\n            </tr>\n        </table></div>\n    ' % {'objectiveTextTitle': objectiveTextTitle,
    118      'objectiveTextBody': objectiveTextBody,
    119      'objectiveIcon': objectiveIcon,
    120      's1': s1,
    121      's2': s2,
    122      'locationHeader': localization.GetByLabel('UI/Agents/StandardMission/ObjectiveLocation'),
    123      'dungeonGraphic': dungeonGraphic,
    124      'dungeonLocation': LocationWrapper(dunData['location'])}
    125     if 'shipRestrictions' in dunData:
    126         lbl = ['UI/Agents/StandardMission/DungeonObjectiveNormalRestrictions', 'UI/Agents/StandardMission/DungeonObjectiveSpecialRestrictions'][dunData['shipRestrictions']]
    127         httpLink = '<a href=localsvc:method=PopupDungeonShipRestrictionList&agentID=%d&charID=%d&dungeonID=%d>' % (agentID, session.charid, dunData['dungeonID'])
    128         if dunData['shipRestrictions'] == 1:
    129             html += '<font color=#E3170D>'
    130         html += localization.GetByLabel(lbl, startHttpLink=httpLink, endHttpLink='</a>')
    131         if dunData['shipRestrictions'] == 1:
    132             html += '</font>'
    133         html += '<br>'
    134     dungeonData = GetDungeon(dunData['dungeonID'])
    135     if dungeonData.connections:
    136         for connection in dungeonData.connections:
    137             if connection.disallowedFittedTypesList:
    138                 httpLink = '<a href=localsvc:method=PopupDungeonFittedTypesRestrictionList&dungeonID=%d>' % dunData['dungeonID']
    139                 html += '<font color=#E3170D>'
    140                 html += localization.GetByLabel('UI/Agents/StandardMission/DungeonObjectiveSpecialFittingRestrictions', startHttpLink=httpLink, endHttpLink='</a>')
    141                 html += '</font>'
    142                 break
    143 
    144     return html
    145 
    146 
    147 def _GetSecurityModifierIcon(solarSystemID):
    148     res = sm.GetService('securitySvc').get_security_modifier_icon_res_path(solarSystemID)
    149     if res:
    150         return '<a href=showinfo:{typeSolarSystem}//{solarSystemID}><img src="{resPath}" width=12 height=10 hspace=2 vspace=2></a>'.format(typeSolarSystem=appConst.typeSolarSystem, solarSystemID=solarSystemID, resPath=res)
    151     return ''
    152 
    153 
    154 def LocationWrapper(location, locationType = None):
    155     if locationType is None and 'locationType' in location:
    156         locationType = location['locationType']
    157     solarSystemID = location['solarsystemID']
    158     securityStatus = get_security_status(solarSystemID)
    159     secColor = get_security_status_color(securityStatus)
    160     secColorAsHtml = Color.RGBtoHex(*secColor)
    161     secWarning = '<font color=#E3170D>'
    162     secClass = sm.GetService('securitySvc').get_modified_security_class(solarSystemID)
    163     if is_low_sec_or_lower(secClass):
    164         secWarning += localization.GetByLabel('UI/Agents/LowSecWarning')
    165     elif sm.GetService('crimewatchSvc').GetMySecurityStatus() <= -5:
    166         secWarning += localization.GetByLabel('UI/Agents/HighSecWarning')
    167     secWarning += '</font>'
    168     if 'coords' in location:
    169         x, y, z = location['coords']
    170         refAgentString = str(location['agentID'])
    171         if 'referringAgentID' in location:
    172             refAgentString += ',' + str(location['referringAgentID'])
    173         infoLinkData = ['showinfo',
    174          location['typeID'],
    175          location['locationID'],
    176          x,
    177          y,
    178          z,
    179          refAgentString,
    180          0,
    181          locationType]
    182     else:
    183         infoLinkData = ['showinfo', location['typeID'], location['locationID']]
    184     spacePigShipType = location.get('shipTypeID', None)
    185     if spacePigShipType is not None:
    186         locationName = localization.GetByLabel('UI/Agents/Items/ItemLocation', typeID=spacePigShipType, locationID=location['locationID'])
    187     else:
    188         locationName = cfg.evelocations.Get(location['locationID']).locationName
    189     image = _GetSecurityModifierIcon(solarSystemID)
    190     return localization.GetByLabel('UI/Agents/LocationWrapper', startFontTag='<font color=%s>' % secColorAsHtml, endFontTag='</font>', image=image, securityRating=securityStatus, locationName=locationName, linkdata=infoLinkData, securityWarning=secWarning)
    191 
    192 
    193 def _OwnerWrap(ownerID, typeID = None):
    194     if ownerID is None:
    195         return ''
    196     elif idCheckers.IsFaction(ownerID):
    197         return '<a href=showinfo:%d//%d><img src="factionlogo:%d" width=32 height=32 hspace=2 vspace=2></a>' % (appConst.typeFaction, ownerID, ownerID)
    198     elif idCheckers.IsCorporation(ownerID):
    199         return '<a href=showinfo:%d//%d><img src="corplogo:%d" width=32 height=32 hspace=2 vspace=2></a>' % (appConst.typeCorporation, ownerID, ownerID)
    200     else:
    201         if not typeID:
    202             typeID = cfg.eveowners.Get(ownerID).typeID
    203         return '<a href=showinfo:%d//%d><img src="portrait:%d" width=32 height=32 hspace=2 vspace=2></a>' % (typeID, ownerID, ownerID)
    204 
    205 
    206 def _IconWrap(typeID, extra = None):
    207     if typeID is None:
    208         return ''
    209     elif typeID == appConst.typeCredits:
    210         return '<img style:vertical-align:bottom src="icon:06_03" size="32">'
    211     elif extra and 'blueprintInfo' in extra:
    212         bpInfo = extra['blueprintInfo']
    213         return '<a href=showinfo:%d//0//%d//%d//%d//%d><img src="typeicon:%d" width=32 height=32 align=left iscopy=1></a>' % (typeID,
    214          bpInfo.get('licensedProductionRunsRemaining', 0),
    215          bpInfo.get('copy', 1),
    216          bpInfo.get('productivityLevel', 0),
    217          bpInfo.get('materialLevel', 0),
    218          typeID)
    219     else:
    220         return '<a href=showinfo:%d><img src="typeicon:%d" width=32 height=32 align=left></a>' % (typeID, typeID)
    221 
    222 
    223 def _ProcessTypeAndQuantity(typeID, quantity, extra = None):
    224     if typeID == appConst.typeCredits:
    225         return FmtISK(quantity)
    226     elif extra is None:
    227         return cfg.FormatConvert(appConst.UE_TYPEIDANDQUANTITY, typeID, quantity)
    228     else:
    229         specificItemID = extra.get('specificItemID', 0)
    230         blueprintInfo = extra.get('blueprintInfo', None)
    231         if blueprintInfo is None:
    232             if specificItemID:
    233                 props = [localization.GetByLabel('UI/Agents/Items/SpecificItems')]
    234             else:
    235                 return cfg.FormatConvert(appConst.UE_TYPEIDANDQUANTITY, typeID, quantity)
    236         else:
    237             props = []
    238             if specificItemID:
    239                 props.append(localization.GetByLabel('UI/Agents/Items/SpecificItems'))
    240             if blueprintInfo.get('licensedProductionRunsRemaining', 0) > 1:
    241                 runsRemaining = blueprintInfo.get('licensedProductionRunsRemaining', 0)
    242                 props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoMultirun', runsRemaining=runsRemaining))
    243             elif blueprintInfo.get('licensedProductionRunsRemaining', 0) == 1:
    244                 props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoSingleRun'))
    245             if blueprintInfo.get('copy', 0):
    246                 props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoCopy'))
    247             else:
    248                 props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoOriginal'))
    249             if blueprintInfo.get('materialLevel', 0):
    250                 props.append(localization.GetByLabel('UI/Agents/Items/BlueprintInfoMaterialLevel', materialLevel=blueprintInfo.get('materialLevel', 0)))
    251             if blueprintInfo.get('productivityLevel', 0):
    252                 props.append(localization.GetByLabel('UI/Agents/Items/ProductivityLevel', productivityLevel=blueprintInfo.get('productivityLevel', 0)))
    253         return localization.GetByLabel('UI/Agents/Items/NumItemsAndProperties', itemAndQuantity=cfg.FormatConvert(appConst.UE_TYPEIDANDQUANTITY, typeID, quantity), propertyList=localization.formatters.FormatGenericList(props))
    254 
    255 
    256 def GetMissionObjectiveHTML(agentID, objectiveData):
    257     html = ''
    258     if objectiveData.get('importantStandings', 0):
    259         html += '<span id=ip>%s</span><br><br>' % localization.GetByLabel('UI/Agents/StandardMission/ImportantStandingsWarning')
    260     cmpStatus = objectiveData['completionStatus']
    261     if isinstance(objectiveData['missionTitleID'], basestring):
    262         missionName = objectiveData['missionTitleID']
    263     else:
    264         missionName = localization.GetByMessageID(objectiveData['missionTitleID'])
    265     isMissionFinished = cmpStatus > 0
    266     isMissionFailed = objectiveData['missionState'] == appConst.agentMissionStateFailed
    267     isMissionCheatCompleted = cmpStatus == 2
    268     if isMissionFailed:
    269         missionHeaderColor = '<font color=#E3170D>'
    270         missionHeader = localization.GetByLabel('UI/Agents/StandardMission/MissionObjectivesFailed', missionName=missionName)
    271     elif isMissionFinished:
    272         missionHeaderColor = '<font color=#5ABA56>'
    273         missionHeader = localization.GetByLabel('UI/Agents/StandardMission/MissionObjectivesComplete', missionName=missionName)
    274     else:
    275         missionHeaderColor = '<font>'
    276         missionHeader = localization.GetByLabel('UI/Agents/StandardMission/MissionObjectives', missionName=missionName)
    277     if isMissionCheatCompleted:
    278         gmStatusHeader = '<font color=#00FF00>Debug Mode: Cheat Complete Enabled</div></font>'
    279     else:
    280         gmStatusHeader = ''
    281     objectives = ''
    282     for objType, objData in objectiveData['objectives']:
    283         objectives += _ProcessObjectiveEntry(objType, objData)
    284 
    285     for dunData in objectiveData['dungeons']:
    286         if isMissionFailed:
    287             dunData['completionStatus'] = 0
    288             dunData['objectiveCompleted'] = 0
    289         objectives += _ProcessDungeonData(dunData, agentID)
    290 
    291     html += '\n        %(GMStatusHeader)s\n        <span id=subheader>%(missionHeaderColor)s%(missionHeader)s</font></span><br>\n        <div id=basetext>%(objectivesHeader)s<br>\n        <br>\n        <span id=basetext>\n        %(objectives)s\n        </span>\n        <br>\n    ' % {'GMStatusHeader': gmStatusHeader,
    292      'missionHeader': missionHeader,
    293      'missionHeaderColor': missionHeaderColor,
    294      'objectivesHeader': localization.GetByLabel('UI/Agents/StandardMission/OverviewAndObjectivesBlurb'),
    295      'objectives': objectives}
    296     secWarning = GetSecurityWarning(objectiveData['locations'])
    297     if secWarning:
    298         html += '<font color=red>%s</font><br><br>' % secWarning
    299 
    300     def ProcessEntry(typeID, quantity, extra):
    301         if idCheckers.IsCharacter(typeID):
    302             iconWrap = _OwnerWrap(typeID)
    303             description = localization.GetByLabel('UI/Agents/StandardMission/MissionReferral', agentID=typeID)
    304         else:
    305             iconWrap = _IconWrap(typeID, extra)
    306             description = _ProcessTypeAndQuantity(typeID, quantity, extra)
    307         return (iconWrap, description)
    308 
    309     grantedItems = [ (typeID, quantity, extra) for typeID, quantity, extra in objectiveData['agentGift'] if quantity > 0 ]
    310     if len(grantedItems) > 0:
    311         if objectiveData['missionState'] in (appConst.agentMissionStateAccepted, appConst.agentMissionStateFailed):
    312             grantedItemsDetail = localization.GetByLabel('UI/Agents/StandardMission/AcceptedGrantedItemDetail')
    313         else:
    314             grantedItemsDetail = localization.GetByLabel('UI/Agents/StandardMission/GrantedItemDetail')
    315         html += '<br>\n            <span id=subheader>%s</span>\n            <div id=basetext>%s</div>\n            <div><table>\n        ' % (localization.GetByLabel('UI/Agents/StandardMission/GrantedItems'), grantedItemsDetail)
    316         for typeID, quantity, extra in grantedItems:
    317             icon, text = ProcessEntry(typeID, quantity, extra)
    318             html += '\n                <tr valign=middle>\n                    <td width=36>%s</td>\n                    <td width=352>%s</td>\n                </tr>\n                ' % (icon, text)
    319 
    320         html += '</table></div><br>'
    321     normalRewards = [ (typeID, quantity, extra) for typeID, quantity, extra in objectiveData['normalRewards'] if quantity > 0 ]
    322     loyaltyPoints = objectiveData['loyaltyPoints']
    323     researchPoints = objectiveData['researchPoints']
    324     if len(normalRewards) or loyaltyPoints > 0 or researchPoints > 0:
    325         html += '\n            <span id=subheader>%s</span>\n            <div id=basetext>%s</div>\n            <div><table>\n        ' % (localization.GetByLabel('UI/Agents/StandardMission/RewardsTitle'), localization.GetByLabel('UI/Agents/StandardMission/RewardsHeader'))
    326         for reward in normalRewards:
    327             typeID, quantity, extra = reward
    328             icon, text = ProcessEntry(typeID, quantity, extra)
    329             html += '\n                <tr valign=middle>\n                    <td width=36>%s</td>\n                    <td width=352>%s</td>\n                </tr>\n            ' % (icon, text)
    330 
    331         if loyaltyPoints > 0:
    332             icon, text = _GetLoyaltyPointsDisplay(agentID, loyaltyPoints)
    333             html += '\n                <tr valign=middle>\n                    <td width=36>%s</td>\n                    <td width=352>%s</td>\n                </tr>\n            ' % (icon, text)
    334         if objectiveData['researchPoints'] > 0:
    335             icon = _IconWrap(appConst.typeResearch)
    336             quantity = round(researchPoints, 0)
    337             text = localization.GetByLabel('UI/Agents/StandardMission/NumResearchPoints', rpAmount=quantity)
    338             html += '\n                <tr valign=middle>\n                    <td width=36>%s</td>\n                    <td width=352>%s</td>\n                </tr>\n            ' % (icon, text)
    339         html += '</table></div><br>'
    340     bonusRewards = [ (timeRemaining,
    341      typeID,
    342      quantity,
    343      extra,
    344      timeBonusIntervalMin) for timeRemaining, typeID, quantity, extra, timeBonusIntervalMin in objectiveData['bonusRewards'] if quantity > 0 ]
    345     if len(bonusRewards) > 0:
    346         html += '<span id=subheader>%s</span><br>' % localization.GetByLabel('UI/Agents/StandardMission/BonusRewardsTitle')
    347         for timeRemaining, typeID, quantity, extra, timeBonusIntervalMin in bonusRewards:
    348             if timeRemaining > 0:
    349                 header = localization.GetByLabel('UI/Agents/StandardMission/BonusRewardsHeader', timeRemaining=timeRemaining)
    350             else:
    351                 header = localization.GetByLabel('UI/Agents/StandardMission/BonusTimePassed')
    352             icon, text = ProcessEntry(typeID, quantity, extra)
    353             html += '\n                <div id=basetext>%s<br>\n                <div><table>\n                    <tr valign=middle>\n                        <td width=36>%s</TD>\n                        <td width=352>%s</TD>\n                    </tr>\n                </table></div>\n            ' % (header, icon, text)
    354 
    355         html += '<br>'
    356     agentInfo = sm.GetService('agents').GetAgentByID(agentID)
    357     if agentInfo and agentInfo.agentTypeID != appConst.agentTypeCareerAgent:
    358         solarSystemID = agentInfo.solarsystemID
    359         if solarSystemID and get_solar_system_security_class(solarSystemID) == securityClassSafeSec:
    360             hasIskReward = any((typeID == appConst.typeCredits and qty > 0 for typeID, qty, extra in objectiveData.get('normalRewards', [])))
    361             hasIskBonus = any((typeID == appConst.typeCredits and qty > 0 for timeRemaining, typeID, qty, extra, timeBonusIntervalMin in objectiveData.get('bonusRewards', [])))
    362             if hasIskReward or hasIskBonus:
    363                 taxPercent = int(round(AGENT_MISSION_SECURITY_TAX_RATE * 100))
    364                 bannerTitleText = localization.GetByLabel('UI/Agents/StandardMission/ReducedPayoutsBannerTitle')
    365                 bannerText = localization.GetByLabel('UI/Agents/StandardMission/ReducedPayoutsBanner', taxPercent=taxPercent)
    366                 BODY_COLOR = PLATINUM_GREY_HEX
    367                 ICON_PATH = GetIconFile(27413)
    368                 html += '\n                    <table width=372 cellpadding=0 cellspacing=0>\n                        <tr>\n                            <td width=1></td>\n                            <td>\n                                <table width=360 cellpadding=0 cellspacing=0>\n                                    <tr height=10>\n                                        <td></td>\n                                    </tr>\n\n                                    <tr>\n                                        <td>\n                                            <span id=subheader>%%s</span>\n                                        </td>\n                                    </tr>\n\n                                    <tr height=4>\n                                        <td></td>\n                                    </tr>\n\n                                    <tr>\n                                        <td>\n                                            <table width=360 cellpadding=0 cellspacing=0>\n                                                <tr valign=top>\n                                                    <td width=16 valign=top>\n                                                        <img src="%(icon)s" width=16 height=16>\n                                                    </td>\n                                                    <td width=6></td>\n                                                    <td valign=top>\n                                                        <color=%(body_color)s>%%s</color>\n                                                    </td>\n                                                </tr>\n                                            </table>\n                                        </td>\n                                    </tr>\n\n                                    <tr height=8>\n                                        <td></td>\n                                    </tr>\n                                </table>\n                            </td>\n                            <td></td>\n                        </tr>\n                    </table>\n                    <br>\n                ' % {'body_color': BODY_COLOR,
    369                  'icon': ICON_PATH} % (bannerTitleText, bannerText)
    370     collateral = [ (typeID, quantity, extra) for typeID, quantity, extra in objectiveData['collateral'] if quantity > 0 ]
    371     if len(collateral) > 0:
    372         html += '\n            <span id=subheader>%s</span>\n            <div id=basetext>%s</div><br>\n            <div><table>\n        ' % (localization.GetByLabel('UI/Agents/StandardMission/CollateralTitle'), localization.GetByLabel('UI/Agents/StandardMission/CollateralHeader'))
    373         for typeID, quantity, extra in collateral:
    374             icon = _IconWrap(typeID, extra)
    375             text = _ProcessTypeAndQuantity(typeID, quantity, extra)
    376             html += '\n                <tr valign=middle>\n                    <td width=36>%s</td>\n                    <td width=352>%s</td>\n                </tr>\n            ' % (icon, text)
    377 
    378         html += '</table></div><br>'
    379     if 'missionExtra' in objectiveData:
    380         headerID, bodyID = objectiveData['missionExtra']
    381         html += '\n            <span id=subheader>%s</span>\n            <div id=basetext>%s</div>\n        ' % (sm.GetService('agents').ProcessMessage((headerID, objectiveData['contentID']), agentID), sm.GetService('agents').ProcessMessage((bodyID, objectiveData['contentID']), agentID))
    382     return html
    383 
    384 
    385 def _GetLoyaltyPointsDisplay(agentID, loyaltyPoints):
    386     agent = sm.GetService('agents').GetAgentByID(agentID)
    387     if agent and agent.divisionID == appConst.corpDivisionHeraldry:
    388         typeID = appConst.typeLoyaltyPointsHeraldry
    389         icon = _IconWrap(typeID)
    390         text = localization.GetByLabel('UI/Common/QuantityAndItem', quantity=loyaltyPoints, item=typeID)
    391         return (icon, text)
    392     icon = _IconWrap(appConst.typeLoyaltyPoints)
    393     text = localization.GetByLabel('UI/Agents/StandardMission/NumLoyaltyPoints', lpAmount=loyaltyPoints)
    394     return (icon, text)
    395 
    396 
    397 def GetSecurityWarning(locations):
    398     routeStart = session.solarsystemid2
    399     charSecStatus = sm.GetService('crimewatchSvc').GetMySecurityStatus()
    400     secWarning = ''
    401     for each in locations:
    402         if len(secWarning) > 0:
    403             break
    404         if routeStart == session.solarsystemid2 and each == session.solarsystemid2:
    405             continue
    406         else:
    407             route = sm.GetService('clientPathfinderService').GetAutopilotPathBetween(routeStart, each)
    408         if route is None:
    409             secWarning = localization.GetByLabel('UI/Agents/Dialogue/AutopilotRouteNotFound')
    410             break
    411         elif len(route) > 0:
    412             routeStart = route[len(route) - 1]
    413             for solarsystem in route:
    414                 if charSecStatus > -5.0 and is_low_sec_or_lower(sm.GetService('securitySvc').get_modified_security_class(solarsystem)):
    415                     secWarning = localization.GetByLabel('UI/Agents/Dialogue/AutopilotRouteLowSecWarning')
    416                     break
    417                 elif charSecStatus < -5.0 and is_high_sec_or_higher(sm.GetService('securitySvc').get_modified_security_class(solarsystem)):
    418                     secWarning = localization.GetByLabel('UI/Agents/Dialogue/AutopilotRouteHighSecWarning')
    419                     break
    420 
    421     return secWarning
    422 
    423 
    424 def GetMissionDetailsWindowHTML(missionInfo, agentID):
    425     missionName = sm.GetService('agents').ProcessMessage((missionInfo['missionNameID'], missionInfo['contentID']), agentID)
    426     missionBriefing = sm.GetService('agents').ProcessMessage((missionInfo['briefingTextID'], missionInfo['contentID']), agentID)
    427     html = '\n        <html>\n        <head>\n            <LINK REL="stylesheet" TYPE="text/css" HREF="res:/ui/css/missionjournal.css">\n        </head>\n        <body>\n    '
    428     if 'iconID' in missionInfo:
    429         missionGraphic = GetIconFile(missionInfo['iconID'])
    430         if missionGraphic:
    431             html += '<p><img src="icon:%s" width=64 height=64 align=left hspace=4 vspace=4><br>' % missionGraphic
    432     html += '\n        <span id=mainheader>%(missionName)s</span><br>\n        <hr>\n        <center><span id=ip>%(missionImage)s</span></center><br>\n        </p>\n        <span id=subheader>%(briefingTitle)s</span>\n        <div id=basetext>%(missionBriefing)s</div>\n        <br>\n    ' % {'missionName': missionName,
    433      'missionImage': missionInfo['missionImage'],
    434      'briefingTitle': localization.GetByLabel('UI/Agents/StandardMission/MissionBriefing'),
    435      'missionBriefing': missionBriefing}
    436     expirationTime = missionInfo['expirationTime']
    437     if expirationTime is not None:
    438         if missionInfo['missionState'] in (appConst.agentMissionStateAllocated, appConst.agentMissionStateOffered):
    439             expirationMessage = localization.GetByLabel('UI/Agents/Dialogue/ThisOfferExpiresAt', expireTime=expirationTime)
    440         else:
    441             expirationMessage = localization.GetByLabel('UI/Agents/Dialogue/ThisMissionExpiresAt', expireTime=expirationTime)
    442         html += '<span id=ip>%s</span><br><br>' % expirationMessage
    443     html += GetMissionObjectiveHTML(agentID, missionInfo['objectives'])
    444     html += '</body></html>'
    445     return html
    446 
    447 
    448 def GetAgentNameAndLevel(agentID, level):
    449     return localization.GetByLabel('UI/Agents/AgentEntryNameAndLevel', ownerID=agentID, level=level)
    450 
    451 
    452 def GetAgentLocationHeader(agentInfo, agentLocation, loyaltyPoints = None):
    453     cfgAgent = cfg.eveowners.Get(agentInfo.agentID)
    454     agentInfoIcon = '<a href=showinfo:%d//%d><img src=icon:38_208 size=16 alt="%s"></a>' % (cfgAgent.typeID, agentInfo.agentID, StripTags(localization.GetByLabel('UI/Commands/ShowInfo'), stripOnly=['localized']))
    455     blurbDivision = localization.GetByLabel('UI/Agents/Dialogue/Division', divisionName=get_division_name(agentInfo.divisionID))
    456     s = [sm.GetService('standing').GetStandingWithSkillBonus(agentInfo.factionID, session.charid), sm.GetService('standing').GetStandingWithSkillBonus(agentInfo.corporationID, session.charid), sm.GetService('standing').GetStandingWithSkillBonus(agentInfo.agentID, session.charid)]
    457     if min(*s) <= -2.0:
    458         es = min(*s)
    459         blurbEffectiveStanding = localization.GetByLabel('UI/Agents/Dialogue/EffectiveStandingLow', effectiveStanding=es)
    460     else:
    461         es = max(*s) or 0.0
    462         blurbEffectiveStanding = localization.GetByLabel('UI/Agents/Dialogue/EffectiveStanding', effectiveStanding=es)
    463     if loyaltyPoints:
    464         loyaltyPointsBlurb = localization.GetByLabel('UI/Agents/Dialogue/LoyaltyPointsTableRow', loyaltyPoints=loyaltyPoints)
    465     else:
    466         loyaltyPointsBlurb = ''
    467     return '\n        <table border=0 cellpadding=0 cellspacing=0>\n            <tr>\n                <td valign=top width=140>\n                    <img src="portrait:%(agentID)d" width=128 height=128 size=256 style=margin-right:10>\n                </td>\n                <td valign=top>\n                    <font size=18>%(agentName)s</font> %(showInfoLink)s\n                    <br>\n                    %(blurbDivision)s\n                    <br><br>\n                    %(agentLocation)s\n                    <br>\n                    <br>\n                    %(blurbEffectiveStanding)s\n                    <br>\n                    %(loyaltyPoints)s\n                </td>\n            </tr>\n        </table>\n    ' % {'agentID': agentInfo.agentID,
    468      'agentName': cfgAgent.name,
    469      'showInfoLink': agentInfoIcon,
    470      'blurbDivision': blurbDivision,
    471      'agentLocation': LocationWrapper(agentLocation),
    472      'blurbEffectiveStanding': blurbEffectiveStanding,
    473      'loyaltyPoints': loyaltyPointsBlurb}