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

enlistmentUtil.py (9525B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\factionalWarfare\enlistmentFlow\enlistmentUtil.py
      2 import appConst
      3 from factionwarfare.client.enrollmentConst import warningByWarningID
      4 from fwwarzone.client.dashboard.const import FACTION_ID_TO_COLOR, FACTION_ID_TO_FLAT_ICON
      5 from localization import GetByLabel
      6 import carbonui.const as uiconst
      7 from player_messaging.client.ui_message import prompt_player_fsd_dialog
      8 ANIM_DURATION = 0.75
      9 BG_MAP_OPACITY = 0.3
     10 mottoPathByFactionID = {appConst.factionAmarrEmpire: 'UI/FactionWarfare/Enlistment/MottoAmarr',
     11  appConst.factionCaldariState: 'UI/FactionWarfare/Enlistment/MottoCaldari',
     12  appConst.factionGallenteFederation: 'UI/FactionWarfare/Enlistment/MottoGallente',
     13  appConst.factionMinmatarRepublic: 'UI/FactionWarfare/Enlistment/MottoMinmatar',
     14  appConst.factionAngelCartel: 'UI/FactionWarfare/Enlistment/MottoAngels',
     15  appConst.factionGuristasPirates: 'UI/FactionWarfare/Enlistment/MottoGuristas'}
     16 
     17 def GetFactionColor(factionID):
     18     return FACTION_ID_TO_COLOR.get(factionID, None)
     19 
     20 
     21 _FACTION_ID_TO_FLAT_ICON = {appConst.factionAmarrEmpire: 'res:/UI/Texture/Classes/Enlistment/logos/amarr.png',
     22  appConst.factionCaldariState: 'res:/UI/Texture/Classes/Enlistment/logos/caldari.png',
     23  appConst.factionGallenteFederation: 'res:/UI/Texture/Classes/Enlistment/logos/gallente.png',
     24  appConst.factionMinmatarRepublic: 'res:/UI/Texture/Classes/Enlistment/logos/minmatar.png',
     25  appConst.factionAngelCartel: 'res:/UI/Texture/Classes/Enlistment/logos/angels.png',
     26  appConst.factionGuristasPirates: 'res:/UI/Texture/Classes/Enlistment/logos/guristas.png'}
     27 
     28 def GetFactionIcon(factionID):
     29     return _FACTION_ID_TO_FLAT_ICON.get(factionID, '')
     30 
     31 
     32 def GetFactionIconSmall(factionID):
     33     return FACTION_ID_TO_FLAT_ICON.get(factionID, '')
     34 
     35 
     36 INFO_1 = 'INFO_1'
     37 INFO_2 = 'INFO_2'
     38 INFO_3 = 'INFO_3'
     39 INFO_4 = 'INFO_4'
     40 INFO_ICONS = [(INFO_1, 'res:/UI/Texture/Classes/Enlistment/infoIcons/CallToArms.png', 'UI/FactionWarfare/Enlistment/CallToArms'),
     41  (INFO_2, 'res:/UI/Texture/Classes/Enlistment/infoIcons/Warning.png', 'UI/FactionWarfare/Enlistment/Warnings'),
     42  (INFO_3, 'res:/UI/Texture/Classes/Enlistment/infoIcons/Benefits.png', 'UI/FactionWarfare/Enlistment/Benefits'),
     43  (INFO_4, 'res:/UI/Texture/Classes/Enlistment/infoIcons/AtWar.png', 'UI/FactionWarfare/Enlistment/Conflict')]
     44 INFO_BY_FACTION_ID = {appConst.factionAmarrEmpire: {INFO_1: 'UI/FactionWarfare/Enlistment/DetailsAmarrInfo1',
     45                                INFO_2: 'UI/FactionWarfare/Enlistment/DetailsAmarrInfo2',
     46                                INFO_3: 'UI/FactionWarfare/Enlistment/DetailsAmarrInfo3',
     47                                INFO_4: 'UI/FactionWarfare/Enlistment/DetailsAmarrInfo4'},
     48  appConst.factionCaldariState: {INFO_1: 'UI/FactionWarfare/Enlistment/DetailsCaldariInfo1',
     49                                 INFO_2: 'UI/FactionWarfare/Enlistment/DetailsCaldariInfo2',
     50                                 INFO_3: 'UI/FactionWarfare/Enlistment/DetailsCaldariInfo3',
     51                                 INFO_4: 'UI/FactionWarfare/Enlistment/DetailsCaldariInfo4'},
     52  appConst.factionGallenteFederation: {INFO_1: 'UI/FactionWarfare/Enlistment/DetailsGallenteInfo1',
     53                                       INFO_2: 'UI/FactionWarfare/Enlistment/DetailsGallenteInfo2',
     54                                       INFO_3: 'UI/FactionWarfare/Enlistment/DetailsGallenteInfo3',
     55                                       INFO_4: 'UI/FactionWarfare/Enlistment/DetailsGallenteInfo4'},
     56  appConst.factionMinmatarRepublic: {INFO_1: 'UI/FactionWarfare/Enlistment/DetailsMinmatarInfo1',
     57                                     INFO_2: 'UI/FactionWarfare/Enlistment/DetailsMinmatarInfo2',
     58                                     INFO_3: 'UI/FactionWarfare/Enlistment/DetailsMinmatarInfo3',
     59                                     INFO_4: 'UI/FactionWarfare/Enlistment/DetailsMinmatarInfo4'},
     60  appConst.factionAngelCartel: {INFO_1: 'UI/FactionWarfare/Enlistment/DetailsAngelsInfo1',
     61                                INFO_2: 'UI/FactionWarfare/Enlistment/DetailsAngelsInfo2',
     62                                INFO_3: 'UI/FactionWarfare/Enlistment/DetailsAngelsInfo3',
     63                                INFO_4: 'UI/FactionWarfare/Enlistment/DetailsAngelsInfo4'},
     64  appConst.factionGuristasPirates: {INFO_1: 'UI/FactionWarfare/Enlistment/DetailsGuristasInfo1',
     65                                    INFO_2: 'UI/FactionWarfare/Enlistment/DetailsGuristasInfo2',
     66                                    INFO_3: 'UI/FactionWarfare/Enlistment/DetailsGuristasInfo3',
     67                                    INFO_4: 'UI/FactionWarfare/Enlistment/DetailsGuristasInfo4'}}
     68 
     69 def GetInfoLabelPath(factionID, infoConst):
     70     infoLabels = INFO_BY_FACTION_ID.get(factionID, None)
     71     if not infoLabels:
     72         return ''
     73     return infoLabels.get(infoConst, None)
     74 
     75 
     76 _BG_BY_FACTIONID = {appConst.factionAmarrEmpire: 'res:/UI/Texture/Classes/Enlistment/backgrounds/Amarr.png',
     77  appConst.factionCaldariState: 'res:/UI/Texture/Classes/Enlistment/backgrounds/Caldari.png',
     78  appConst.factionGallenteFederation: 'res:/UI/Texture/Classes/Enlistment/backgrounds/Gallente.png',
     79  appConst.factionMinmatarRepublic: 'res:/UI/Texture/Classes/Enlistment/backgrounds/Minmatar.png',
     80  appConst.factionAngelCartel: 'res:/UI/Texture/Classes/Enlistment/backgrounds/Angels.png',
     81  appConst.factionGuristasPirates: 'res:/UI/Texture/Classes/Enlistment/backgrounds/Guristas.png'}
     82 
     83 def GetBgTexturePath(factionID):
     84     return _BG_BY_FACTIONID.get(factionID, None)
     85 
     86 
     87 _MAP_BG_BY_FACTIONID = {appConst.factionAmarrEmpire: 'res:/UI/Texture/Classes/Enlistment/backgrounds/amarrMap.png',
     88  appConst.factionCaldariState: 'res:/UI/Texture/Classes/Enlistment/backgrounds/caldariMap.png',
     89  appConst.factionGallenteFederation: 'res:/UI/Texture/Classes/Enlistment/backgrounds/gallenteMap.png',
     90  appConst.factionMinmatarRepublic: 'res:/UI/Texture/Classes/Enlistment/backgrounds/minmatarMap.png',
     91  appConst.factionAngelCartel: 'res:/UI/Texture/Classes/Enlistment/backgrounds/angelsMap.png',
     92  appConst.factionGuristasPirates: 'res:/UI/Texture/Classes/Enlistment/backgrounds/guristasMap.png'}
     93 
     94 def GetMapBgTexturePath(factionID):
     95     return _MAP_BG_BY_FACTIONID.get(factionID, None)
     96 
     97 
     98 JOB_PROVIDER = 'factional_warfare_enlistment'
     99 
    100 def RetireAlliance(*args):
    101     factionID = sm.GetService('facwar').GetCorpFactionalWarStatus().factionID
    102     ret = prompt_player_fsd_dialog('CustomQuestion', {'header': GetByLabel('UI/FactionWarfare/ConfirmRetireHeader'),
    103      'question': GetByLabel('UI/FactionWarfare/ConfirmRetire', factionName=cfg.eveowners.Get(factionID).name)}, uiconst.YESNO)
    104     if ret == uiconst.ID_YES:
    105         sm.GetService('facwar').LeaveFactionAsAlliance(factionID)
    106 
    107 
    108 def RetireCorp(*args):
    109     factionID = sm.GetService('facwar').GetCorpFactionalWarStatus().factionID
    110     ret = prompt_player_fsd_dialog('CustomQuestion', {'header': GetByLabel('UI/FactionWarfare/ConfirmRetireHeader'),
    111      'question': GetByLabel('UI/FactionWarfare/ConfirmRetire', factionName=cfg.eveowners.Get(factionID).name)}, uiconst.YESNO)
    112     if ret == uiconst.ID_YES:
    113         sm.GetService('facwar').LeaveFactionAsCorporation(factionID)
    114 
    115 
    116 def Retire(*args):
    117     if ConfirmCharacterRetire():
    118         corp = sm.GetService('corp')
    119         corp.KickOut(session.charid, confirm=False)
    120         sm.GetService('objectCaching').InvalidateCachedMethodCall('corporationSvc', 'GetEmploymentRecord', session.charid)
    121 
    122 
    123 def RemoveDirectEnlistment(*args):
    124     if ConfirmCharacterRetire():
    125         sm.GetService('fwEnlistmentSvc').RemoveMyDirectEnlistment()
    126 
    127 
    128 def CancelRetirement(*args):
    129     factionID = sm.GetService('facwar').GetCorpFactionalWarStatus().factionID
    130     ret = prompt_player_fsd_dialog('CustomQuestion', {'header': GetByLabel('UI/FactionWarfare/ConfirmCancelRetirementHeader'),
    131      'question': GetByLabel('UI/FactionWarfare/ConfirmCancelRetirementHeader', factionName=cfg.eveowners.Get(factionID).name)}, uiconst.YESNO)
    132     if ret == uiconst.ID_YES:
    133         if session.allianceid:
    134             sm.GetService('facwar').WithdrawLeaveFactionAsAlliance(factionID)
    135         else:
    136             sm.GetService('facwar').WithdrawLeaveFactionAsCorporation(factionID)
    137 
    138 
    139 def ConfirmCharacterRetire():
    140     factionID = session.warfactionid
    141     ret = prompt_player_fsd_dialog('CustomQuestion', {'header': GetByLabel('UI/FactionWarfare/ConfirmRetireHeader'),
    142      'question': GetByLabel('UI/FactionWarfare/ConfirmRetire', factionName=cfg.eveowners.Get(factionID).name)}, uiconst.YESNO)
    143     return ret == uiconst.ID_YES
    144 
    145 
    146 def CancelApplication(*args):
    147     factionID = sm.GetService('facwar').GetCorpFactionalWarStatus().factionID
    148     msgArgs = {'header': GetByLabel('UI/FactionWarfare/ConfirmCancelApplicationHeader'),
    149      'question': GetByLabel('UI/FactionWarfare/ConfirmCancelApplicationAlliance', factionName=cfg.eveowners.Get(factionID).name)}
    150     ret = prompt_player_fsd_dialog('CustomQuestion', msgArgs, uiconst.YESNO)
    151     if ret == uiconst.ID_YES:
    152         if session.allianceid:
    153             sm.GetService('facwar').WithdrawJoinFactionAsAlliance(factionID)
    154         else:
    155             sm.GetService('facwar').WithdrawJoinFactionAsCorporation(factionID)
    156 
    157 
    158 def GetTextForWarning(warningValue):
    159     labelPath, _ = warningByWarningID.get(warningValue, ('', ''))
    160     text = ''
    161     if labelPath:
    162         text = GetByLabel(labelPath)
    163     return text
    164 
    165 
    166 def GetHintForWarning(warningValue):
    167     _, hintPath = warningByWarningID.get(warningValue, ('', ''))
    168     hint = ''
    169     if hintPath:
    170         hint = GetByLabel(hintPath)
    171     return hint