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

allegianceView.py (14202B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation\empireTechnologyViews\allegianceView.py
      2 import carbonui.const as uiconst
      3 from carbonui.primitives.container import Container
      4 from carbonui.primitives.sprite import Sprite
      5 from carbonui.uicore import uicore
      6 from charactercreator.client.empireSelectionData import GetEmpireLogo
      7 from charactercreator.client.scalingUtils import SMALL_SCREEN_HEIGHT, BIG_SCREEN_HEIGHT
      8 from eve.client.script.ui.control.eveLabel import Label
      9 from eve.client.script.ui.login.charcreation.empireTechnologyViews.technologyView import TechnologyView
     10 from eve.client.script.ui.login.charcreation.empireui.empireBanner import MinimalEmpireBanner
     11 from eve.client.script.ui.login.charcreation.technologyViewUtils import LineDecoration, LINE_DECORATION_GRADIENT_HEIGHT
     12 from eve.client.script.ui.util.uix import GetTextHeight
     13 from eve.common.lib.appConst import factionAmarrEmpire, factionCaldariState, factionGallenteFederation, factionMinmatarRepublic, factionTheBloodRaiderCovenant, factionGuristasPirates, factionSerpentis, factionAngelCartel, factionByRace, raceByFaction
     14 from eve.common.script.util.facwarCommon import GetOccupationEnemyFaction
     15 ELEMENTS_PADDING_TOP = -40
     16 LINE_DECORATION_WIDTH = 1000
     17 LINE_DECORATION_HEIGHT = 4
     18 INTERNAL_MARGIN_H = 40
     19 INTERNAL_MARGIN_V = 40
     20 PEOPLE_DESCRIPTION_WIDTH = 450
     21 PEOPLE_DESCRIPTION_FONTSIZE = 16
     22 PEOPLE_DESCRIPTION_PAD_TOP = 60
     23 PORTRAIT_WIDTH = 450
     24 PORTRAIT_HEIGHT = 308
     25 PORTRAIT_PAD_LEFT = 30
     26 POLITICAL_RELATIONSHIP_PAD_TOP = 10
     27 POLITICAL_RELATIONSHIP_PAD_BOT = 10
     28 POLITICAL_RELATIONSHIP_ICON_SIZE = 150
     29 POLITICAL_RELATIONSHIP_TEXT_WIDTH = 320
     30 POLITICAL_RELATIONSHIP_TEXT_FONTSIZE = 16
     31 POLITICAL_RELATIONSHIP_TEXT_PAD_TOP = 10
     32 POLITICAL_RELATIONSHIP_INTERNAL_PAD = 20
     33 POLITICAL_RELATIONSHIP_ICON_TEXT_FONTSIZE = 14
     34 POLITICAL_RELATIONSHIP_FRAME_WIDTH = 128
     35 POLITICAL_RELATIONSHIP_FRAME_HEIGHT = 200
     36 SCALE_FACTOR_AT_SMALL_SCREEN_HEIGHT = 0.71
     37 ICON_COLOR_BY_FACTION = {factionAmarrEmpire: (0.51, 0.44, 0.32),
     38  factionCaldariState: (0.29, 0.43, 0.5),
     39  factionGallenteFederation: (0.21, 0.4, 0.4),
     40  factionMinmatarRepublic: (0.4, 0.22, 0.2),
     41  factionTheBloodRaiderCovenant: (0.43, 0.0, 0.0),
     42  factionGuristasPirates: (0.8, 0.51, 0.0),
     43  factionSerpentis: (0.47, 0.44, 0.29),
     44  factionAngelCartel: (0.36, 0.39, 0.43)}
     45 PIRATE_LOGO_BY_FACTION = {factionTheBloodRaiderCovenant: 'res:/UI/Texture/Classes/EmpireSelection/pirateLogo_Bloodraiders.png',
     46  factionGuristasPirates: 'res:/UI/Texture/Classes/EmpireSelection/pirateLogo_Guristas.png',
     47  factionSerpentis: 'res:/UI/Texture/Classes/EmpireSelection/pirateLogo_Serpentis.png',
     48  factionAngelCartel: 'res:/UI/Texture/Classes/EmpireSelection/pirateLogo_AngelCartel.png'}
     49 LOGO_SIZE = 128
     50 TRADTIONAL_PIRATE_OPPOSITION_BY_RACE = {factionAmarrEmpire: factionTheBloodRaiderCovenant,
     51  factionCaldariState: factionGuristasPirates,
     52  factionGallenteFederation: factionSerpentis,
     53  factionMinmatarRepublic: factionAngelCartel}
     54 
     55 class AllegianceView(TechnologyView):
     56 
     57     def ApplyAttributes(self, attributes):
     58         TechnologyView.ApplyAttributes(self, attributes)
     59         centralContainer = Container(name='centralContainer', parent=self, align=uiconst.ANCH_TOPLEFT, width=self.width, height=self.height)
     60         lineDecorationWidth = self._GetLineDecorationWidth()
     61         portraitWidth, portraitHeight = self._GetPortraitViewSize()
     62         peopleDescriptionText = self.technology.GetMainText(self.raceID)
     63         peopleWidth, peopleHeight = self._GetPeopleDescriptionSize(peopleDescriptionText)
     64         peopleHeight += PEOPLE_DESCRIPTION_PAD_TOP * self._GetScaleFactor()
     65         relationshipFrameWidth, relationshipFrameHeight = self._GetPoliticalRelationshipFrameSize()
     66         pirateEnemyText = self.GetPirateEnemyText()
     67         enemyText = self.GetEnemyText()
     68         relationshipTextWidth = self._GetRelationshipDescriptionWidth()
     69         relationshipTextHeight = self._GetRelationshipDescriptionHeight(relationshipTextWidth, pirateEnemyText, enemyText) + POLITICAL_RELATIONSHIP_TEXT_PAD_TOP
     70         relationshipsVPad = POLITICAL_RELATIONSHIP_PAD_TOP + POLITICAL_RELATIONSHIP_PAD_BOT
     71         relationshipsWidth = relationshipFrameWidth + relationshipTextWidth + POLITICAL_RELATIONSHIP_INTERNAL_PAD
     72         relationshipsHeight = max(relationshipFrameHeight, relationshipTextHeight) + relationshipsVPad
     73         topViewHeight = max(portraitHeight, peopleHeight)
     74         lineViewHeight = 2 * INTERNAL_MARGIN_V + LINE_DECORATION_GRADIENT_HEIGHT
     75         centralViewWidth = lineDecorationWidth
     76         centralViewHeight = topViewHeight + lineViewHeight + relationshipsHeight
     77         centralView = Container(name='centralView', parent=centralContainer, align=uiconst.CENTER, width=centralViewWidth, height=centralViewHeight, top=ELEMENTS_PADDING_TOP * self._GetScaleFactor())
     78         self.BuildTopView(parent=centralView, width=centralViewWidth, height=topViewHeight, portraitWidth=portraitWidth, portraitHeight=portraitHeight, peopleDescriptionText=peopleDescriptionText, peopleWidth=peopleWidth)
     79         self.BuildLineView(parent=centralView, width=centralViewWidth, height=lineViewHeight)
     80         self.BuildBottomView(parent=centralView, width=relationshipsWidth * 2, height=relationshipsHeight, frameWidth=relationshipFrameWidth, frameHeight=relationshipFrameHeight, textWidth=relationshipTextWidth, pirateEnemyText=pirateEnemyText, enemyText=enemyText)
     81 
     82     def BuildTopView(self, parent, width, height, portraitWidth, portraitHeight, peopleDescriptionText, peopleWidth):
     83         self.topView = Container(name='topView', parent=parent, align=uiconst.TOTOP, width=width, height=height, opacity=1.0)
     84         self.AddPeopleDescription(peopleDescriptionText, peopleWidth, height)
     85         self.AddPortraitView(portraitWidth, portraitHeight)
     86 
     87     def AddPeopleDescription(self, text, width, height):
     88         topLeftView = Container(name='topLeftView', parent=self.topView, align=uiconst.TOLEFT, width=self.topView.width / 2, height=self.topView.height)
     89         peopleDescriptionContainer = Container(name='peopleDescriptionContainer', parent=topLeftView, width=width, height=height, align=uiconst.TORIGHT)
     90         Label(name='peopleDescriptionLabel', parent=peopleDescriptionContainer, width=width, height=height, text=text, fontsize=self._GetPeopleDescriptionFontsize(), top=PEOPLE_DESCRIPTION_PAD_TOP * self._GetScaleFactor())
     91 
     92     def AddPortraitView(self, width, height):
     93         topRightView = Container(name='topRightView', parent=self.topView, align=uiconst.TORIGHT, width=self.topView.width / 2, height=self.topView.height)
     94         portraitView = self.technology.GetMainView(self.raceID)
     95         portraitViewContainer = Container(name='portraitViewContainer', parent=topRightView, align=uiconst.TOPLEFT, width=width, height=height, padLeft=PORTRAIT_PAD_LEFT)
     96         Sprite(name='portraitView', parent=portraitViewContainer, align=uiconst.TOTOP, texturePath=portraitView, useSizeFromTexture=False, width=width, height=height)
     97 
     98     def BuildLineView(self, parent, width, height):
     99         lineView = Container(name='lineView', parent=parent, align=uiconst.TOTOP, width=width, height=height)
    100         self.line = LineDecoration(name='lineDecoration', parent=lineView, align=uiconst.TOTOP, width=width, height=LINE_DECORATION_HEIGHT, lineWidth=width, opacity=1.0, padTop=INTERNAL_MARGIN_V)
    101 
    102     def BuildBottomView(self, parent, width, height, frameWidth, frameHeight, textWidth, pirateEnemyText, enemyText):
    103         self.bottomView = Container(name='bottomView', parent=parent, align=uiconst.TOTOP, width=width, height=height, padTop=POLITICAL_RELATIONSHIP_PAD_TOP, padBottom=POLITICAL_RELATIONSHIP_PAD_BOT)
    104         fontsize = self._GetPoliticalRelationshipFontsize()
    105         iconFontsize = self._GetPoliticalRelationshipIconFontsize()
    106         self.AddEnemiesView(frameWidth, frameHeight, height, textWidth, enemyText, fontsize, iconFontsize)
    107         self.AddPirateEnemiesView(frameWidth, frameHeight, height, textWidth, pirateEnemyText, fontsize, iconFontsize)
    108 
    109     def AddEnemiesView(self, frameWidth, frameHeight, height, textWidth, text, fontsize, iconFontsize):
    110         bottomLeftView = Container(name='bottomLeftView', parent=self.bottomView, align=uiconst.TOLEFT, width=self.bottomView.width / 2, height=self.bottomView.height)
    111         factionID = factionByRace[self.raceID]
    112         enemyFactionID = GetOccupationEnemyFaction(factionID)
    113         enemyRaceID = raceByFaction.get(enemyFactionID)
    114         iconColor = ICON_COLOR_BY_FACTION[enemyFactionID]
    115         logo = GetEmpireLogo(enemyRaceID)
    116         logoSize = self._GetLogoSize()
    117         self.enemy = PoliticalRelationshipView(logo=logo, logoSize=logoSize, text=text, iconText=self.GetEnemyTitle(), iconTextFontsize=iconFontsize, iconView=self.GetEnemyIcon(), iconColor=iconColor, frameWidth=frameWidth, frameHeight=frameHeight, textWidth=textWidth, fontsize=fontsize, parent=bottomLeftView, align=uiconst.TOPLEFT, width=frameWidth + textWidth + POLITICAL_RELATIONSHIP_INTERNAL_PAD, height=height, opacity=1.0)
    118 
    119     def AddPirateEnemiesView(self, frameWidth, frameHeight, height, textWidth, text, fontsize, iconFontsize):
    120         bottomRightView = Container(name='bottomRightView', parent=self.bottomView, align=uiconst.TORIGHT, width=self.bottomView.width / 2, height=self.bottomView.height)
    121         factionID = factionByRace[self.raceID]
    122         enemyFactionID = TRADTIONAL_PIRATE_OPPOSITION_BY_RACE[factionID]
    123         iconColor = ICON_COLOR_BY_FACTION[enemyFactionID]
    124         logo = PIRATE_LOGO_BY_FACTION[enemyFactionID]
    125         logoSize = self._GetLogoSize()
    126         self.pirateEnemy = PoliticalRelationshipView(logo=logo, logoSize=logoSize, text=text, iconText=self.GetPirateEnemyTitle(), iconTextFontsize=iconFontsize, iconView=self.GetPirateEnemyIcon(), iconColor=iconColor, frameWidth=frameWidth, frameHeight=frameHeight, textWidth=textWidth, fontsize=fontsize, parent=bottomRightView, align=uiconst.TOPRIGHT, width=frameWidth + textWidth + POLITICAL_RELATIONSHIP_INTERNAL_PAD, height=height, opacity=1.0)
    127 
    128     def GetPirateEnemyText(self):
    129         return self.technology.GetTechExample(2).GetSubtitle(self.raceID)
    130 
    131     def GetEnemyText(self):
    132         return self.technology.GetTechExample(1).GetSubtitle(self.raceID)
    133 
    134     def GetPirateEnemyTitle(self):
    135         return self.technology.GetTechExample(2).GetTitle(self.raceID)
    136 
    137     def GetEnemyTitle(self):
    138         return self.technology.GetTechExample(1).GetTitle(self.raceID)
    139 
    140     def GetPirateEnemyIcon(self):
    141         return self.technology.GetTechExample(2).GetIcon(self.raceID)
    142 
    143     def GetEnemyIcon(self):
    144         return self.technology.GetTechExample(1).GetIcon(self.raceID)
    145 
    146     def _GetLineDecorationWidth(self):
    147         scaleFactor = self._GetScaleFactor()
    148         width = LINE_DECORATION_WIDTH * scaleFactor
    149         return width
    150 
    151     def _GetPortraitViewSize(self):
    152         return self._GetImageSize(PORTRAIT_WIDTH, PORTRAIT_HEIGHT)
    153 
    154     def _GetPoliticalRelationshipFrameSize(self):
    155         return self._GetImageSize(POLITICAL_RELATIONSHIP_FRAME_WIDTH, POLITICAL_RELATIONSHIP_FRAME_HEIGHT)
    156 
    157     def _GetImageSize(self, baseWidth, baseHeight):
    158         scaleFactor = self._GetScaleFactor()
    159         width = baseWidth * scaleFactor
    160         height = baseHeight * scaleFactor
    161         return (width, height)
    162 
    163     def _GetLogoSize(self):
    164         return LOGO_SIZE * self._GetScaleFactor()
    165 
    166     def _GetPeopleDescriptionFontsize(self):
    167         return PEOPLE_DESCRIPTION_FONTSIZE * self._GetScaleFactor()
    168 
    169     def _GetPeopleDescriptionSize(self, text):
    170         width = PEOPLE_DESCRIPTION_WIDTH * self._GetScaleFactor()
    171         height = GetTextHeight(strng=text, width=width, fontsize=self._GetPeopleDescriptionFontsize())
    172         return (width, height)
    173 
    174     def _GetPoliticalRelationshipFontsize(self):
    175         return POLITICAL_RELATIONSHIP_TEXT_FONTSIZE * self._GetScaleFactor()
    176 
    177     def _GetPoliticalRelationshipIconFontsize(self):
    178         return POLITICAL_RELATIONSHIP_ICON_TEXT_FONTSIZE * self._GetScaleFactor()
    179 
    180     def _GetRelationshipDescriptionWidth(self):
    181         return POLITICAL_RELATIONSHIP_TEXT_WIDTH * self._GetScaleFactor()
    182 
    183     def _GetRelationshipDescriptionHeight(self, width, pirateEnemyText, enemyText):
    184         pirateEnemyHeight = GetTextHeight(strng=pirateEnemyText, width=width, fontsize=self._GetPoliticalRelationshipFontsize())
    185         enemyHeight = GetTextHeight(strng=enemyText, width=width, fontsize=self._GetPoliticalRelationshipFontsize())
    186         return max(pirateEnemyHeight, enemyHeight)
    187 
    188     def _GetScaleFactor(self):
    189         desktopHeight = uicore.desktop.height
    190         if desktopHeight > BIG_SCREEN_HEIGHT:
    191             desktopHeight = BIG_SCREEN_HEIGHT
    192         return SCALE_FACTOR_AT_SMALL_SCREEN_HEIGHT * desktopHeight / SMALL_SCREEN_HEIGHT
    193 
    194 
    195 class PoliticalRelationshipView(Container):
    196 
    197     def ApplyAttributes(self, attributes):
    198         Container.ApplyAttributes(self, attributes)
    199         logo = attributes.logo
    200         logoSize = attributes.logoSize
    201         text = attributes.text
    202         iconText = attributes.iconText
    203         iconTextFontsize = attributes.iconTextFontsize
    204         iconView = attributes.iconView
    205         iconColor = attributes.iconColor
    206         frameWidth = attributes.frameWidth
    207         frameHeight = attributes.frameHeight
    208         textWidth = attributes.textWidth
    209         fontsize = attributes.fontsize
    210         bannerContainer = Container(name='relationshipBannerContainer', parent=self, align=uiconst.TOLEFT, width=frameWidth, height=frameHeight, padRight=POLITICAL_RELATIONSHIP_INTERNAL_PAD)
    211         MinimalEmpireBanner(name='relationshipBanner', parent=bannerContainer, width=frameWidth, height=frameHeight, align=uiconst.TOTOP, logo=logo, logoSize=logoSize, iconText=iconText, iconTextFontsize=iconTextFontsize, iconView=iconView, iconColor=iconColor)
    212         descriptionContainer = Container(name='relationshipDescriptionContainer', parent=self, align=uiconst.TOLEFT, width=textWidth, height=self.height, padTop=POLITICAL_RELATIONSHIP_TEXT_PAD_TOP)
    213         Label(name='relationshipDescriptionLabel', parent=descriptionContainer, align=uiconst.TOTOP, width=textWidth, height=self.height - POLITICAL_RELATIONSHIP_TEXT_PAD_TOP, text=text, fontsize=fontsize)