characterInfo.py (6703B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\controls\characterInfo.py 2 from carbonui import Align, TextColor, uiconst 3 from carbonui.text.styles import TextHeader, TextDetail 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.containerAutoSize import ContainerAutoSize 6 from carbonui.primitives.sprite import Sprite 7 from cosmetics.client.ships import ship_skin_signals 8 from cosmetics.client.ships.skins.live_data import current_skin_design, current_skin_design_signals 9 from eve.client.script.ui import eveColor 10 from eve.client.script.ui.cosmetics.ship import charUtil 11 from eveui import CharacterPortrait 12 from localization import GetByLabel 13 14 class CharacterInfo(Container): 15 default_display = False 16 default_width = 200 17 default_height = 64 18 19 def __init__(self, *args, **kwargs): 20 super(CharacterInfo, self).__init__(*args, **kwargs) 21 self._character_id = None 22 self._compact_mode = False 23 self.construct_layout() 24 25 def construct_layout(self): 26 icon_container = Container(name='icon_container', parent=self, align=Align.TOLEFT, pos=(0, 0, 64, 64)) 27 Sprite(name='ring', parent=icon_container, align=Align.CENTER, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Cosmetics/Ship/circle_frame.png', color=eveColor.GUNMETAL_GREY, pos=(0, 0, 64, 64)) 28 self.icon = CharacterInfoPortrait(name='icon', parent=icon_container, align=Align.CENTER, textureSecondaryPath='res:/UI/Texture/circle_full.png', spriteEffect=uiconst.SpriteEffect.MODULATE, pos=(0, 0, 64, 64)) 29 self.text_container = ContainerAutoSize(name='text_container', parent=self, align=Align.CENTERLEFT, width=128, left=72, padTop=16) 30 self.description_label = TextDetail(name='description_label', parent=self.text_container, align=Align.TOTOP, top=-16, text=self.description_text, color=TextColor.SECONDARY) 31 self.name_label = TextHeader(name='name_label', parent=self.text_container, align=Align.TOTOP, state=uiconst.UI_NORMAL, maxLines=3, autoFadeSides=16, bold=True) 32 33 def update_icon(self): 34 if self.character_id: 35 self.icon.character_id = self.character_id 36 37 def update_name(self): 38 if self.character_id: 39 self.name_label.text = charUtil.get_name_link(self.character_id) 40 41 def update_compact_mode(self): 42 self.text_container.display = not self.compact_mode 43 self.width = 64 if self.compact_mode else self.default_width 44 self.icon.description = self.description_text if self.compact_mode else None 45 46 @property 47 def description_text(self): 48 return None 49 50 @property 51 def character_id(self): 52 return self._character_id 53 54 @character_id.setter 55 def character_id(self, value): 56 if self._character_id == value: 57 return 58 self._character_id = value 59 self.display = value is not None 60 self.update_icon() 61 self.update_name() 62 63 @property 64 def compact_mode(self): 65 return self._compact_mode 66 67 @compact_mode.setter 68 def compact_mode(self, value): 69 if self._compact_mode == value: 70 return 71 self._compact_mode = value 72 self.update_compact_mode() 73 74 75 class MadeByCharacterInfo(CharacterInfo): 76 77 @property 78 def description_text(self): 79 return GetByLabel('UI/Personalization/ShipSkins/SKINR/MadeBy') 80 81 82 class ListedByCharacterInfo(CharacterInfo): 83 84 @property 85 def description_text(self): 86 return GetByLabel('UI/Personalization/ShipSkins/SKINR/ListedBy') 87 88 89 class TargetedAtCharacterInfo(CharacterInfo): 90 91 @property 92 def description_text(self): 93 return GetByLabel('UI/Personalization/ShipSkins/SKINR/TargetedAt') 94 95 96 class DesignOwnerCharacterInfo(CharacterInfo): 97 98 def __init__(self, *args, **kwargs): 99 self._has_changes = False 100 super(DesignOwnerCharacterInfo, self).__init__(*args, **kwargs) 101 self.connect_signals() 102 103 def Close(self): 104 try: 105 self.disconnect_signals() 106 finally: 107 super(DesignOwnerCharacterInfo, self).Close() 108 109 def connect_signals(self): 110 current_skin_design_signals.on_name_changed.connect(self.update) 111 current_skin_design_signals.on_line_name_changed.connect(self.update) 112 current_skin_design_signals.on_ship_type_id_changed.connect(self.update) 113 current_skin_design_signals.on_slot_fitting_changed.connect(self.update) 114 current_skin_design_signals.on_snapshot_changed.connect(self.update) 115 ship_skin_signals.on_skin_design_saved.connect(self.update) 116 117 def disconnect_signals(self): 118 current_skin_design_signals.on_name_changed.disconnect(self.update) 119 current_skin_design_signals.on_line_name_changed.disconnect(self.update) 120 current_skin_design_signals.on_ship_type_id_changed.disconnect(self.update) 121 current_skin_design_signals.on_slot_fitting_changed.disconnect(self.update) 122 current_skin_design_signals.on_snapshot_changed.disconnect(self.update) 123 ship_skin_signals.on_skin_design_saved.disconnect(self.update) 124 125 @property 126 def description_text(self): 127 if self._has_changes: 128 return GetByLabel('UI/Personalization/ShipSkins/SKINR/BasedOnDesignBy') 129 else: 130 return GetByLabel('UI/Personalization/ShipSkins/SKINR/DesignedBy') 131 132 def update(self, *args): 133 if current_skin_design.get().creator_character_id == session.charid: 134 self.display = False 135 else: 136 self._has_changes = current_skin_design.has_changes_from_snapshot() 137 self.description_label.text = self.description_text 138 self.display = True 139 140 141 class CharacterInfoPortrait(CharacterPortrait): 142 143 def __init__(self, size = 64, character_id = None, **kwargs): 144 kwargs.setdefault('height', size) 145 kwargs.setdefault('width', size) 146 super(CharacterInfoPortrait, self).__init__(**kwargs) 147 self._character_id = None 148 self._description = None 149 self.character_id = character_id 150 151 def _update_hint(self): 152 if self.character_id is None: 153 self.SetHint(None) 154 return 155 character_info = cfg.eveowners.Get(self._character_id) 156 if self.description: 157 self.SetHint(u'%s\n%s' % (self.description, character_info.name)) 158 else: 159 self.SetHint(character_info.name) 160 161 @property 162 def description(self): 163 return self._description 164 165 @description.setter 166 def description(self, value): 167 if self._description == value: 168 return 169 self._description = value 170 self._update_hint()