sequenceBinderEntries.py (13977B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\pages\sequence\sequenceBinderEntries.py 2 import carbonui 3 import carbonui.text.styles 4 import eveformat 5 import eveicon 6 import evetypes 7 from carbonui import Align, TextColor, PickState, uiconst, ButtonVariant 8 from carbonui.text.styles import TextBody 9 from carbonui.button.group import ButtonGroup, ButtonSizeMode 10 from carbonui.control.button import Button 11 from carbonui.primitives.container import Container 12 from carbonui.primitives.containerAutoSize import ContainerAutoSize 13 from carbonui.primitives.sprite import Sprite 14 from carbonui.uiconst import OutputMode 15 from cosmetics.client.ships.skins.live_data import current_skin_design 16 from cosmetics.client.shipSkinSequencingSvc import get_ship_skin_sequencing_svc 17 from cosmetics.common.ships.skins.live_data.component_license_type import ComponentLicenseType 18 from eve.client.script.ui import eveColor 19 from eve.client.script.ui.control.warningIcon import WarningIcon 20 from eve.client.script.ui.cosmetics.ship.const import PANEL_BG_COLOR, PANEL_BG_OPACITY, SEQUENCE_BINDER_ICONS_BY_MATERIAL_TYPE, SEQUENCE_BINDER_NAMES_BY_MATERIAL_TYPE 21 from eve.client.script.ui.cosmetics.ship.pages.studio.requiredComponentTooltipPanel import RequiredComponentTooltipPanel 22 from eveservices.menu import GetMenuService 23 from localization import GetByLabel 24 25 class SequenceBinderCostEntry(Container): 26 default_height = 32 27 28 def __init__(self, type_id, **kw): 29 super(SequenceBinderCostEntry, self).__init__(**kw) 30 self.type_id = type_id 31 self.is_lacking = False 32 self.construct_layout() 33 self.update() 34 35 def construct_layout(self): 36 self.icon = Sprite(parent=self, texturePath=SEQUENCE_BINDER_ICONS_BY_MATERIAL_TYPE[self.type_id], align=Align.CENTERLEFT, pos=(0, 0, 16, 16), color=TextColor.NORMAL, pickState=PickState.OFF) 37 self.label = carbonui.text.styles.TextBody(name='name_label', parent=self, align=Align.CENTERLEFT, left=24, text=evetypes.GetName(self.type_id)) 38 self.warning_icon = WarningIcon(parent=self, align=Align.CENTERLEFT, left=self.label.left + self.label.width + 4, top=2, display=False) 39 self.amount_label = carbonui.text.styles.TextBody(name='amount_label', parent=self, align=Align.CENTERRIGHT, color=TextColor.HIGHLIGHT, bold=True) 40 41 def update(self): 42 num_runs = get_ship_skin_sequencing_svc().get_num_runs() 43 amount_required_by_type = current_skin_design.get().get_sequence_binder_amounts_required(num_runs) 44 amount_available_by_type = get_ship_skin_sequencing_svc().get_available_at_active_location(amount_required_by_type) 45 required_amount = amount_required_by_type[self.type_id] 46 available_amount = amount_available_by_type[self.type_id] 47 self.amount_label.text = eveformat.number(required_amount) 48 self.is_lacking = required_amount > available_amount 49 text_color = eveColor.DANGER_RED if self.is_lacking else TextColor.NORMAL 50 self.amount_label.rgba = self.label.rgba = text_color 51 self.warning_icon.display = self.is_lacking 52 if self.is_lacking: 53 self.hint = GetByLabel('UI/Personalization/ShipSkins/SKINR/Studio/InsufficientSequenceBinderAmount', type_id=self.type_id, available_amount=available_amount) 54 else: 55 self.hint = None 56 57 def GetMenu(self): 58 return GetMenuService().GetMenuFromItemIDTypeID(itemID=None, typeID=self.type_id, includeMarketDetails=True) 59 60 def OnClick(self, *args): 61 sm.GetService('info').ShowInfo(self.type_id) 62 63 def LoadTooltipPanel(self, tooltipPanel, *args): 64 if not self.hint: 65 return 66 tooltipPanel.columns = 1 67 tooltipPanel.LoadStandardSpacing() 68 tooltipPanel.pickState = PickState.ON 69 tooltipPanel.AddLabelMedium(text=self.hint, wrapWidth=300, color=eveColor.DANGER_RED) 70 button_group = ButtonGroup(parent=tooltipPanel, align=Align.TOTOP, button_size_mode=ButtonSizeMode.DYNAMIC, padTop=8) 71 Button(parent=button_group, label=GetByLabel('UI/Inventory/ItemActions/ViewTypesMarketDetails'), func=self.on_view_on_market_button, texturePath=eveicon.market_details, variant=ButtonVariant.GHOST) 72 73 def GetTooltipPointer(self): 74 return uiconst.POINT_RIGHT_2 75 76 def on_view_on_market_button(self, *args): 77 sm.GetService('marketutils').ShowMarketDetails(self.type_id) 78 79 80 class SequenceBinderCostEntryCompact(Container): 81 default_width = 60 82 default_height = 68 83 84 def __init__(self, type_id, **kw): 85 super(SequenceBinderCostEntryCompact, self).__init__(**kw) 86 self.type_id = type_id 87 cont = ContainerAutoSize(parent=self, align=Align.VERTICALLY_CENTERED) 88 self.icon = Sprite(parent=cont, texturePath=SEQUENCE_BINDER_ICONS_BY_MATERIAL_TYPE[self.type_id], align=Align.CENTERTOP, pos=(0, 0, 16, 16), color=TextColor.SECONDARY, pickState=PickState.OFF) 89 self.amount_label = carbonui.text.styles.TextHeader(name='amount_label', parent=cont, align=Align.CENTERTOP, top=18, color=TextColor.HIGHLIGHT) 90 carbonui.text.styles.TextBody(name='name_label', parent=self, align=Align.CENTERBOTTOM, top=-20, text=GetByLabel(SEQUENCE_BINDER_NAMES_BY_MATERIAL_TYPE[self.type_id]), color=TextColor.NORMAL) 91 self.frame = Sprite(name='frame_bg', bgParent=self, opacity=0.2, texturePath='res:/UI/Texture/classes/Cosmetics/Ship/sequencing/hex_frame.png', outputMode=OutputMode.COLOR_AND_GLOW, glowBrightness=0.0) 92 Sprite(name='bg', bgParent=self, color=PANEL_BG_COLOR, opacity=PANEL_BG_OPACITY, texturePath='res:/UI/Texture/classes/Cosmetics/Ship/sequencing/hex_bg.png') 93 94 def update_frame(self, required_amount): 95 if required_amount: 96 self.frame.rgba = TextColor.NORMAL 97 self.frame.glowBrightness = 0.5 98 else: 99 self.frame.rgba = TextColor.DISABLED 100 self.frame.glowBrightness = 0.0 101 102 def update(self, required_amount): 103 self.amount_label.text = eveformat.number_readable_short(required_amount) 104 self.update_frame(required_amount) 105 106 def GetMenu(self): 107 return GetMenuService().GetMenuFromItemIDTypeID(itemID=None, typeID=self.type_id, includeMarketDetails=True) 108 109 def OnClick(self, *args): 110 sm.GetService('info').ShowInfo(self.type_id) 111 112 113 class UnlimitedComponentLicenseEntry(Container): 114 default_height = 28 115 ITEM_ICON_SIZE = 28 116 TYPE_ICON_SIZE = 16 117 118 def __init__(self, type_id, component, *args, **kwargs): 119 super(UnlimitedComponentLicenseEntry, self).__init__(*args, **kwargs) 120 self.type_id = type_id 121 self.component = component 122 self.construct_layout() 123 self.update() 124 125 def construct_layout(self): 126 self.sequence_binder_name = SequenceBinderName(parent=self, align=Align.TOLEFT, component=self.component, license_type=ComponentLicenseType.UNLIMITED, height=self.default_height, padLeft=32) 127 warning_icon_container = Container(parent=self, align=Align.TOLEFT, width=16, top=2, padLeft=4) 128 self.warning_icon = WarningIcon(parent=warning_icon_container, align=Align.CENTER, display=False) 129 SequenceBinderAmount(parent=self, align=Align.TORIGHT, type_id=self.type_id, component_data=self.component.get_component_data(), height=self.default_height) 130 131 def update(self): 132 license = self.component.get_component_license() 133 self.show_warning = license is None 134 self.sequence_binder_name.show_warning = self.show_warning 135 self.warning_icon.display = self.show_warning 136 137 138 class LimitedComponentLicenseEntry(Container): 139 default_height = 28 140 ITEM_ICON_SIZE = 28 141 142 def __init__(self, component, *args, **kwargs): 143 super(LimitedComponentLicenseEntry, self).__init__(*args, **kwargs) 144 self.component = component 145 self.show_warning = False 146 self.construct_layout() 147 self.update() 148 149 def construct_layout(self): 150 self.sequence_binder_name = SequenceBinderName(parent=self, align=Align.TOLEFT, component=self.component, license_type=ComponentLicenseType.LIMITED, height=self.default_height) 151 warning_icon_container = Container(parent=self, align=Align.TOLEFT, width=16, top=2, padLeft=4) 152 self.warning_icon = WarningIcon(parent=warning_icon_container, align=Align.CENTER, display=False) 153 label_container = ContainerAutoSize(parent=self, align=Align.TORIGHT, height=self.default_height) 154 self.label = TextBody(parent=label_container, align=Align.CENTERRIGHT) 155 156 def update(self): 157 license = self.component.get_component_license() 158 if license is None: 159 self.show_warning = True 160 elif license.license_type == ComponentLicenseType.LIMITED: 161 self.show_warning = not license.has_enough_remaining_uses(self.component_amount) 162 else: 163 self.show_warning = False 164 self.label.text = eveformat.number(self.component_amount) 165 self.label.rgba = eveColor.DANGER_RED if self.show_warning else TextColor.NORMAL 166 self.sequence_binder_name.show_warning = self.show_warning 167 self.warning_icon.display = self.show_warning 168 self.sequence_binder_name.state = uiconst.UI_PICKCHILDREN if self.show_warning else uiconst.UI_NORMAL 169 self.state = uiconst.UI_NORMAL if self.show_warning else uiconst.UI_PICKCHILDREN 170 171 @property 172 def item_type_id(self): 173 return self.sequence_binder_name.item_type_id 174 175 @property 176 def component_amount(self): 177 slot_layout = current_skin_design.get().slot_layout 178 num_runs = get_ship_skin_sequencing_svc().get_num_runs() 179 return num_runs * slot_layout.get_amount_of_components_with_license_type(component_id=self.component.component_id, license_type=ComponentLicenseType.LIMITED) 180 181 def GetMenu(self): 182 if not self.item_type_id: 183 return None 184 return GetMenuService().GetMenuFromItemIDTypeID(itemID=None, typeID=self.item_type_id, includeMarketDetails=True) 185 186 def ConstructTooltipPanel(self): 187 if not self.show_warning: 188 return None 189 return RequiredComponentTooltipPanel(component_instance=self.component, title=self.component.get_component_data().name, show_warning=self.show_warning) 190 191 def GetTooltipPointer(self): 192 return uiconst.POINT_RIGHT_2 193 194 def OnClick(self, *args): 195 if self.item_type_id: 196 sm.GetService('info').ShowInfo(self.item_type_id) 197 198 199 class SequenceBinderName(ContainerAutoSize): 200 default_state = uiconst.UI_NORMAL 201 202 def __init__(self, component, license_type, *args, **kwargs): 203 super(SequenceBinderName, self).__init__(*args, **kwargs) 204 self.component = component 205 self.license_type = license_type 206 self._show_warning = False 207 self.construct_layout() 208 209 def construct_layout(self): 210 icon_container = Container(parent=self, align=Align.TOLEFT, width=self.height) 211 Sprite(parent=icon_container, align=Align.CENTER, state=uiconst.UI_DISABLED, texturePath=self.component.get_component_data().icon_file_path, textureSecondaryPath='res:/UI/Texture/circle_full.png', spriteEffect=uiconst.SpriteEffect.MODULATE, pos=(0, 212 0, 213 self.height, 214 self.height)) 215 label_container = ContainerAutoSize(parent=self, align=Align.TOLEFT, height=self.default_height, padLeft=8) 216 self.label = TextBody(parent=label_container, align=Align.CENTERLEFT, text=self.component.get_component_data().name, color=TextColor.SECONDARY) 217 218 def update(self): 219 self.label.rgba = eveColor.DANGER_RED if self.show_warning else TextColor.NORMAL 220 221 @property 222 def show_warning(self): 223 return self._show_warning 224 225 @show_warning.setter 226 def show_warning(self, value): 227 if self._show_warning == value: 228 return 229 self._show_warning = value 230 self.update() 231 232 @property 233 def item_type_id(self): 234 return self.component.get_component_data().get_item_type(self.license_type) 235 236 def GetMenu(self): 237 if not self.item_type_id: 238 return None 239 return GetMenuService().GetMenuFromItemIDTypeID(itemID=None, typeID=self.item_type_id, includeMarketDetails=True) 240 241 def OnClick(self, *args): 242 if self.item_type_id: 243 sm.GetService('info').ShowInfo(self.item_type_id) 244 245 def ConstructTooltipPanel(self): 246 if not self.show_warning: 247 return None 248 return RequiredComponentTooltipPanel(component_instance=self.component, title=self.component.get_component_data().name, show_warning=self.show_warning) 249 250 251 class SequenceBinderAmount(ContainerAutoSize): 252 default_state = uiconst.UI_NORMAL 253 254 def __init__(self, type_id, component_data, *args, **kwargs): 255 super(SequenceBinderAmount, self).__init__(*args, **kwargs) 256 self.type_id = type_id 257 self.component_data = component_data 258 self.construct_layout() 259 260 def construct_layout(self): 261 text_container = ContainerAutoSize(parent=self, align=Align.TORIGHT, height=self.default_height) 262 required_amount = self.component_data.sequence_binder_required_amount 263 num_runs = get_ship_skin_sequencing_svc().get_num_runs() 264 TextBody(parent=text_container, align=Align.CENTERRIGHT, text=eveformat.number(required_amount * num_runs), color=TextColor.SECONDARY) 265 icon_container = Container(parent=self, align=Align.TORIGHT, opacity=0.75, width=16, padRight=8) 266 Sprite(parent=icon_container, align=Align.CENTER, state=uiconst.UI_DISABLED, texturePath=SEQUENCE_BINDER_ICONS_BY_MATERIAL_TYPE[self.type_id], textureSecondaryPath='res:/UI/Texture/circle_full.png', spriteEffect=uiconst.SpriteEffect.MODULATE, pos=(0, 0, 16, 16), color=TextColor.SECONDARY) 267 268 def GetMenu(self): 269 return GetMenuService().GetMenuFromItemIDTypeID(itemID=None, typeID=self.type_id, includeMarketDetails=True) 270 271 def OnClick(self, *args): 272 sm.GetService('info').ShowInfo(self.type_id)