epicArcChapterCont.py (6485B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\epicArcs\epicArcChapterCont.py 2 import carbonui.text.styles 3 import random 4 import carbonui 5 from carbonui.control.section import COLOR_HEADER 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from carbonui.primitives.stretchspritevertical import StretchSpriteVertical 9 from carbonui.primitives.sprite import Sprite 10 from eve.client.script.ui.shared.agencyNew.ui.contentCards.epicArcAgentContentCard import EpicArcAgentContentCard 11 from eve.client.script.ui.shared.epicArcs.epicArcMissionCont import EpicArcMissionCont 12 from eve.client.script.ui.shared.epicArcs.epicArcUIUtil import GetLineColor 13 from eve.client.script.ui import eveColor 14 import eveicon 15 import eveui 16 from localization import GetByMessageID, GetByLabel 17 ICONSIZE_LARGE = 34 18 ICONSIZE_SMALL = 28 19 20 class EpicArcChapters(ContainerAutoSize): 21 default_align = carbonui.Align.TOTOP 22 23 def __init__(self, contentPiece, *args, **kwargs): 24 super(EpicArcChapters, self).__init__(*args, **kwargs) 25 self._contentPiece = contentPiece 26 self._epicArc = contentPiece.epicArc 27 self._chapterIDs = self._epicArc.GetChapterIDs() 28 self._chapterContainers = {} 29 self._currentChapterID = self._epicArc.GetCurrentChapterID() 30 self._expandedChapterID = self._currentChapterID 31 for index, chapterID in enumerate(self._chapterIDs): 32 self._ConstructChapter(chapterID, index) 33 34 @eveui.skip_if_destroyed 35 def GetCurrentChapterPosFraction(self): 36 y = self._chapterContainers[self._currentChapterID].parent.GetAbsoluteTop() - self.GetAbsoluteTop() 37 _, h = self.GetAbsoluteSize() 38 return y / float(h) 39 40 def _ConstructChapter(self, chapterID, index): 41 container = ContainerAutoSize(name='EpicArcChapter_{}'.format(chapterID), parent=self, align=carbonui.Align.TOTOP, padTop=8 if index else 0) 42 missionNodes = self._epicArc.GetChapterMissions(chapterID) 43 isChapterCompleted = True 44 for missionNode in missionNodes: 45 if not missionNode.IsComplete(): 46 isChapterCompleted = False 47 break 48 49 header = Container(parent=container, align=carbonui.Align.TOTOP, state=carbonui.uiconst.UI_NORMAL, height=30, bgColor=COLOR_HEADER, padding=(0, 0, 4, 6)) 50 header.OnClick = lambda *args, **kwargs: self._ToggleExpand(chapterID) 51 if chapterID == self._currentChapterID: 52 icon = eveicon.polestar 53 color = carbonui.TextColor.NORMAL 54 elif isChapterCompleted: 55 icon = eveicon.checkmark 56 color = carbonui.TextColor.SUCCESS 57 else: 58 icon = None 59 color = carbonui.TextColor.SECONDARY 60 Sprite(parent=header, align=carbonui.Align.CENTERLEFT, width=16, height=16, left=8, texturePath=icon, color=color) 61 carbonui.text.styles.TextBody(parent=header, align=carbonui.Align.CENTERLEFT, left=32, text=GetByLabel('UI/Agency/EpicArcChapter', chapterNum=index + 1, numChapters=len(self._chapterIDs), chapterName=GetByMessageID(chapterID))) 62 self._chapterContainers[chapterID] = contentContainer = ContainerAutoSize(parent=container, align=carbonui.Align.TOTOP, clipChildren=True) 63 if chapterID != self._currentChapterID: 64 contentContainer.CollapseHeight() 65 self._ConstructMissionNodes(contentContainer, missionNodes) 66 67 def _ConstructMissionNodes(self, parent, missionNodes): 68 activeMission = self._epicArc.GetActiveMission() 69 for missionNode in missionNodes: 70 EpicArcMissionEntry(parent=parent, align=carbonui.Align.TOTOP, missionNode=missionNode) 71 if missionNode == activeMission: 72 agentCard = EpicArcAgentContentCard(parent=parent, align=carbonui.Align.TOTOP, contentPiece=self._contentPiece.GetActiveAgentContentPiece(), padding=(40, 0, 40, 0)) 73 agentCard.AnimEnter() 74 75 def _ToggleExpand(self, chapterID): 76 if self._expandedChapterID and chapterID != self._expandedChapterID: 77 self._chapterContainers[self._expandedChapterID].CollapseHeight() 78 self._expandedChapterID = chapterID if self._expandedChapterID != chapterID else None 79 container = self._chapterContainers[chapterID] 80 if container.isCollapsed: 81 container.ExpandHeight() 82 else: 83 container.CollapseHeight() 84 85 86 class EpicArcMissionEntry(Container): 87 default_name = 'EpicArcMissionEntry' 88 default_height = 34 89 default_state = carbonui.uiconst.UI_NORMAL 90 91 def ApplyAttributes(self, attributes): 92 super(EpicArcMissionEntry, self).ApplyAttributes(attributes) 93 self.missionNode = attributes.missionNode 94 iconSize = self.GetIconSize() 95 EpicArcMissionCont(parent=self, missionNode=self.missionNode, align=carbonui.Align.CENTERLEFT, state=carbonui.uiconst.UI_DISABLED, left=17 - iconSize / 2, width=iconSize, height=iconSize, iconSize=iconSize) 96 opacity = 0.3 if not self.missionNode.IsOffered() else 1.0 97 carbonui.text.styles.TextBody(parent=self, align=carbonui.Align.CENTERLEFT, text=self.GetMissionText(), color=self.missionNode.GetStateColor(), opacity=opacity, left=40) 98 if not self.missionNode.IsFirstInChapter(): 99 height = 8 100 StretchSpriteVertical(parent=self, align=carbonui.Align.TOPLEFT, texturePath='res:/UI/Texture/Classes/EpicArcBar/lineVertical.png', topEdgeSize=4, bottomEdgeSize=4, pos=(14, 101 -height / 2, 102 6, 103 height), color=GetLineColor(self.missionNode.IsComplete())) 104 105 def GetMissionText(self): 106 if not self.missionNode.IsOffered(): 107 return '%s %s %s %s' % (self._GetHex(), 108 self._GetHex(), 109 self._GetHex(), 110 self._GetHex()) 111 else: 112 return self.missionNode.GetName() 113 114 def _GetHex(self): 115 return str(hex(random.randint(0, 500))).upper() 116 117 def GetIconSize(self): 118 if self.missionNode.IsActive() or self.missionNode.IsLastInChapter(): 119 return ICONSIZE_LARGE 120 else: 121 return ICONSIZE_SMALL 122 123 def LoadTooltipPanel(self, tooltipPanel, *args): 124 tooltipPanel.LoadGeneric1ColumnTemplate() 125 tooltipPanel.AddLabelMedium(text=self.missionNode.GetHint(), wrapWidth=200) 126 127 def GetTooltipPointer(self): 128 return carbonui.uiconst.POINT_RIGHT_2