objectivestep.py (5483B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\agentinteraction\objectivestep.py 2 import carbonui 3 import carbonui.text.styles 4 import eveicon 5 from carbonui import const as uiconst 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from carbonui.primitives.fill import Fill 9 from carbonui.primitives.frame import Frame 10 from carbonui.primitives.sprite import Sprite 11 from carbonui.util.color import Color 12 from eve.client.script.ui.control.eveIcon import OwnerIcon 13 from evemissions.client.objectives import ObjectiveState, CargoObjective 14 import trinity 15 ICON_SIZE = 32 16 STATE_ICON_SIZE = 16 17 IMAGE_SIZE = 64 18 19 class ObjectiveStep(ContainerAutoSize): 20 default_alignMode = uiconst.TOTOP 21 22 def ApplyAttributes(self, attributes): 23 self.step_info_container = None 24 super(ObjectiveStep, self).ApplyAttributes(attributes) 25 self.title_left = attributes.title_left 26 self.title_right = attributes.title_right 27 self.text = attributes.text 28 self.step_state = attributes.step_state 29 self.owner_id = attributes.get('owner_id', None) 30 self.step = attributes.step 31 content_padding_bottom = attributes.content_padding_bottom 32 content_padding_top = attributes.content_padding_top 33 self._build_objective_image() 34 self.content = ContainerAutoSize(name='content', parent=self, align=uiconst.TOTOP, padBottom=content_padding_bottom, padTop=content_padding_top) 35 self._build_title_container() 36 self._build_step_container() 37 38 def _build_objective_image(self): 39 self.objective_image_container = Container(name='objective_image_container', parent=self, align=uiconst.TOLEFT, width=IMAGE_SIZE, padRight=15) 40 if self.owner_id: 41 OwnerIcon(name='objective_icon', parent=self.objective_image_container, align=uiconst.CENTER, width=IMAGE_SIZE, height=IMAGE_SIZE, ownerID=self.owner_id, spriteEffect=trinity.TR2_SFX_MASK, textureSecondaryPath='res:/UI/Texture/Classes/AgentInteraction/AgentCircle.png') 42 Sprite(name='objective_icon_frame', parent=self.objective_image_container, texturePath='res:/UI/Texture/Classes/AgentInteraction/AgentCircleFrame.png', state=uiconst.UI_DISABLED, align=uiconst.CENTER, height=IMAGE_SIZE, width=IMAGE_SIZE, color=Color.WHITE) 43 else: 44 self.objective_image_container.Hide() 45 46 def _build_title_container(self): 47 self.title_container = Container(name='title_container', parent=self.content, align=uiconst.TOTOP, padBottom=3, height=20) 48 self._build_title_left() 49 self._build_title_right() 50 51 def _build_title_left(self): 52 carbonui.text.styles.TextBody(name='title_left', parent=self.title_container, align=uiconst.TOLEFT, text=self.title_left, color=carbonui.TextColor.SECONDARY) 53 54 def _build_title_right(self): 55 carbonui.text.styles.TextBody(name='title_right', parent=self.title_container, align=uiconst.TOLEFT, text=self.title_right, color=carbonui.TextColor.HIGHLIGHT, padLeft=8) 56 57 def _build_step_container(self): 58 self.step_container = ContainerAutoSize(name='step_container', parent=self.content, align=uiconst.TOTOP, height=ICON_SIZE, alignMode=uiconst.TOTOP) 59 self._build_sprite() 60 self._build_step_info() 61 62 def _build_sprite(self): 63 sprite_container = Container(name='sprite_container', parent=self.step_container, align=uiconst.TOLEFT, width=ICON_SIZE, padRight=4) 64 state_icon_container = Container(name='state_icon_container', parent=sprite_container) 65 Sprite(name='state_icon', parent=state_icon_container, align=uiconst.CENTER, width=STATE_ICON_SIZE, height=STATE_ICON_SIZE, texturePath=self._get_icon(), color=carbonui.TextColor.NORMAL) 66 Frame(name='sprite_background', parent=sprite_container, color=self._get_state_color(), cornerSize=6, texturePath='res:/UI/Texture/Classes/AgentInteraction/ObjectiveStep_IconBackground.png') 67 68 def _build_step_info(self): 69 self.step_info_container = ContainerAutoSize(name='step_info_container', parent=self.step_container, align=uiconst.TOTOP, alignMode=uiconst.TOTOP) 70 self.text_label = self._get_step_label(self.step_info_container, uiconst.TOTOP_NOPUSH) 71 label_bg_cont = ContainerAutoSize(name='label_bg_cont', parent=self.step_info_container, align=uiconst.TOTOP, alignMode=uiconst.TOTOP) 72 self.bg_fill = Fill(parent=label_bg_cont, align=uiconst.TOLEFT_NOPUSH, opacity=0.1) 73 c = ContainerAutoSize(name='c', parent=label_bg_cont, align=uiconst.TOTOP, opacity=0.0) 74 self._get_step_label(c, uiconst.TOTOP) 75 text_width, _ = self.text_label.MeasureTextSize(self.text_label.text, maxLines=1) 76 self.bg_fill.width = text_width + 2 * self.text_label.padLeft 77 78 def _get_step_label(self, parent, alignment): 79 return carbonui.text.styles.TextBody(name='text', parent=parent, align=alignment, text=self.text, state=uiconst.UI_NORMAL, padding=(7, 8, 7, 8), color=carbonui.TextColor.HIGHLIGHT) 80 81 def _get_state_color(self): 82 if self.step_state == ObjectiveState.COMPLETED: 83 return carbonui.TextColor.SUCCESS 84 if self.step_state == ObjectiveState.FAILED: 85 return carbonui.TextColor.DANGER 86 return (1.0, 1.0, 1.0, 0.05) 87 88 def _get_icon(self): 89 if self.step_state == ObjectiveState.COMPLETED: 90 return eveicon.checkmark 91 return self.step.get_icon()