panelIndustry.py (11302B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\shipInfoPanels\panelIndustry.py 2 import eveicon 3 import trinity 4 import eveui 5 import evetypes 6 import localization 7 import uthread2 8 from carbonui import Align, Density, TextColor, uiconst 9 from carbonui.text.styles import TextBody, TextDetail 10 from carbonui.primitives.collapsibleContainer import CollapsibleContainer 11 from carbonui.primitives.container import Container 12 from carbonui.primitives.containerAutoSize import ContainerAutoSize 13 from carbonui.primitives.flowcontainer import FlowContainer 14 from carbonui.primitives.line import Line 15 from carbonui.primitives.sprite import Sprite 16 from eve.client.script.ui.control.infoIcon import InfoIcon 17 from eve.client.script.ui.control.itemIcon import ItemIcon 18 from eve.client.script.ui.control.eveIcon import OwnerIcon 19 from eve.client.script.ui.shared.info.shipInfoConst import TOP_DOWN_NOSE_DOWN, TAB_INDUSTRY, CONTENT_PADDING, EXPANDED 20 from evetypes import TypeNotFoundException 21 from inventorycommon.const import typeCorporation 22 from npcs.npccorporations import get_npc_corporation_name, get_designer_description 23 from typematerials.data import get_type_materials_by_id 24 from eve.client.script.ui.shared.info.shipInfoPanels.panelBase import PanelBase 25 from eve.client.script.ui.shared.info.collapseGroup import CollapseGroup 26 from eve.client.script.ui.shared.info.auraHintSection import AuraHintSection 27 from eve.client.script.ui.shared.info.shipInfoListEntries import ListEntryEveType 28 DESIGNER_DESCRIPTION_MOCK = 'This Corp Excels as a ship manufacturer, integrating cutting-edge secret technology and precision engineering to craft superior spacecraft' 29 30 class BluePrintSection(eveui.ContainerAutoSize): 31 default_icon_size = 64 32 default_padBottom = 4 33 default_align = Align.TOTOP 34 default_height = 96 35 icon_size = None 36 37 def __init__(self, type_id, icon_size = None, show_background_graphic = True, *args, **kwargs): 38 super(BluePrintSection, self).__init__(*args, **kwargs) 39 self.type_id = type_id 40 self.icon_size = icon_size if icon_size else self.default_icon_size 41 self.show_background_graphic = show_background_graphic 42 self._construct_content() 43 44 def on_click_market_details(self, _object): 45 sm.StartService('marketutils').ShowMarketDetails(self.type_id, None) 46 47 def on_click_view_contract(self, _object): 48 sm.GetService('contracts').FindRelated(self.type_id, None, None, None, None, None) 49 50 def _get_product_name(self): 51 product_type_id = sm.GetService('blueprintSvc').GetBlueprintType(self.type_id).productTypeID 52 return evetypes.GetName(product_type_id or self.type_id) 53 54 def _construct_item_icon(self): 55 item_icon_cont = eveui.Container(parent=self.container, align=Align.TOLEFT, width=self.icon_size * 1.5 if self.show_background_graphic else self.icon_size, padRight=8, padLeft=0 if self.show_background_graphic else 8) 56 ItemIcon(parent=item_icon_cont, align=Align.CENTER, typeID=self.type_id, width=self.icon_size, height=self.icon_size) 57 if self.show_background_graphic: 58 Sprite(parent=item_icon_cont, align=Align.CENTER, width=self.icon_size * 1.5, height=self.icon_size * 1.5, texturePath='res:/UI/Texture/classes/ShipInfo/frame_small.png') 59 60 def _construct_top_container(self): 61 top_container = eveui.Container(parent=self.container, align=Align.TOTOP, height=20) 62 icon_container = eveui.Container(parent=top_container, align=Align.TORIGHT, width=16, padRight=8) 63 InfoIcon(parent=icon_container, texturePath=eveicon.info, typeID=self.type_id, color=TextColor.SECONDARY) 64 text_container = eveui.Container(parent=top_container, align=Align.TOALL, padRight=4) 65 TextBody(parent=text_container, align=Align.TOLEFT, text=self._get_product_name(), autoFadeSides=16) 66 67 def _construct_bottom_container(self): 68 bottom_container = eveui.Container(parent=self.container, align=Align.TOALL) 69 top = eveui.Container(parent=bottom_container, align=Align.TOTOP_PROP, height=0.5, padBottom=4) 70 bot = eveui.Container(parent=bottom_container, align=Align.TOALL, padTop=4) 71 eveui.Button(parent=bot, align=Align.TOPLEFT, label=localization.GetByLabel('UI/InfoWindow/ShowContracts'), func=self.on_click_view_contract, density=Density.COMPACT) 72 eveui.Button(parent=top, align=Align.BOTTOMLEFT, label=localization.GetByLabel('UI/VirtualGoodsStore/Buttons/ViewInMarket'), func=self.on_click_market_details, density=Density.COMPACT) 73 74 def _construct_content(self): 75 self.container = eveui.Container(parent=self, align=Align.TOTOP, height=self.height, padTop=4, padBottom=4) 76 self._construct_item_icon() 77 self._construct_top_container() 78 self._construct_bottom_container() 79 80 81 class PanelIndustry(PanelBase): 82 is_minimized_constructed = False 83 84 def _construct_content(self): 85 uthread2.Yield() 86 bottom_cont = eveui.Container(parent=self.rightCont, align=Align.TOBOTTOM, height=32) 87 blueprint = sm.GetService('blueprintSvc').GetBlueprintByProduct(self.typeID) 88 if blueprint: 89 AuraHintSection(parent=bottom_cont, text=localization.GetByLabel('UI/InfoWindow/ViewBlueprint'), align=Align.TOBOTTOM) 90 self.infoScroll = eveui.ScrollContainer(parent=self.rightCont, name='industry_scroll', align=Align.TOALL, padBottom=20) 91 self._add_blueprint_section() 92 self._add_materials_section() 93 self._add_required_for_section() 94 self._add_designer_section() 95 Sprite(parent=self.leftCont, align=Align.CENTER_PRESERVE_ASPECT, aspectRatio=1, texturePath='res:/UI/Texture/classes/ShipInfo/square_flair.png', state=uiconst.UI_DISABLED, blendMode=trinity.TR2_SBM_ADD, padLeft=-CONTENT_PADDING[EXPANDED]) 96 97 def _add_blueprint_section(self, parent = None, is_minimized = False): 98 blueprint = sm.GetService('blueprintSvc').GetBlueprintByProduct(self.typeID) 99 if blueprint: 100 collapse_group = CollapseGroup(parent=parent if parent else self.infoScroll, icon=eveicon.production, text=localization.GetByLabel('UI/Industry/Blueprint')) 101 BluePrintSection(parent=collapse_group.mainCont, ship_name=evetypes.GetName(self.typeID), type_id=blueprint.blueprintTypeID, show_background_graphic=False if is_minimized else True) 102 103 def _has_any_published(self, blueprint_id_list): 104 for blueprint_id in blueprint_id_list: 105 if evetypes.IsPublished(blueprint_id): 106 return True 107 108 return False 109 110 def _add_required_for_section(self, parent = None, is_minimized = False): 111 blueprint_ids = cfg.blueprintsByMaterialTypeIDs.get(self.typeID, None) 112 if blueprint_ids and self._has_any_published(blueprint_ids): 113 collapse_group = CollapseGroup(parent=parent if parent else self.infoScroll, icon=eveicon.production, text=localization.GetByLabel('UI/InfoWindow/TabNames/RequiredFor')) 114 for blueprint_id in blueprint_ids: 115 try: 116 if not evetypes.IsPublished(blueprint_id): 117 continue 118 except TypeNotFoundException: 119 continue 120 121 BluePrintSection(parent=collapse_group.mainCont, type_id=blueprint_id, show_background_graphic=False if is_minimized else True) 122 123 def _add_materials_section(self, parent = None): 124 materials = get_type_materials_by_id(self.typeID) 125 if materials: 126 collapse_group = CollapseGroup(parent=parent if parent else self.infoScroll, icon=eveicon.resource_processing, text=localization.GetByLabel('UI/Reprocessing/ReprocessedMaterials'), padBottom=4, padTop=4) 127 for material in materials: 128 ListEntryEveType(parent=collapse_group.mainCont, align=Align.TOTOP, typeID=material.materialTypeID, text=localization.GetByLabel('UI/InfoWindow/TypeNameWithNumUnits', invType=material.materialTypeID, qty=material.quantity)) 129 130 def _add_designer_section(self): 131 bottomCont = ContainerAutoSize(name='bottomCont', parent=self.leftCont, align=Align.TOBOTTOM, padBottom=20, padLeft=25, padRight=15) 132 designerIDs = evetypes.GetDesigners(self.typeID) 133 if designerIDs is None or len(designerIDs) == 0: 134 bottomCont.Hide() 135 return 136 designerDescription = '' 137 if designerDescription: 138 cont = Container(name='bottomCont', parent=bottomCont, align=Align.TOBOTTOM, height=78) 139 self._add_designer_icon(designerIDs[0], cont, align=Align.CENTERLEFT) 140 descriptionCont = ContainerAutoSize(name='descCont', parent=cont, align=Align.TOBOTTOM, padding=(88, 0, 8, 0)) 141 self.descCont = CollapsibleContainer(parent=descriptionCont, align=Align.TOBOTTOM, minHeight=74, collapsedHeight=48, maxFadeHeight=0, textClass=TextDetail, backgroundColor=(0, 0, 0, 0.4), topSpacing=8) 142 self.descriptionSeparator = Line(name='line_separator', parent=descriptionCont, align=Align.TOBOTTOM, weight=1) 143 self.descCont.set_text(designerDescription) 144 else: 145 flowCont = FlowContainer(name='designerFlowCont', parent=bottomCont, align=Align.TOBOTTOM, contentSpacing=(8, 8)) 146 for designerID in designerIDs: 147 self._add_designer_icon(designerID, flowCont, align=Align.NOALIGN) 148 149 def _add_designer_icon(self, designerID, parent, align): 150 designerLogoCont = Container(name=get_npc_corporation_name(designerID), parent=parent, align=align, width=64, height=64) 151 Sprite(bgParent=designerLogoCont, state=uiconst.UI_DISABLED, align=uiconst.CENTER, texturePath='res:/UI/Texture/classes/ShipInfo/logo_frame.png', color=(1, 1, 1, 0.05)) 152 OwnerIcon(ownerID=designerID, parent=designerLogoCont, state=uiconst.UI_NORMAL, align=uiconst.CENTER, width=60, height=60) 153 154 def _enable_minimized_view(self): 155 if self.is_minimized_constructed: 156 return 157 self.minimized_footer.height = 32 158 self.minimized_footer.display = True 159 blueprint = sm.GetService('blueprintSvc').GetBlueprintByProduct(self.typeID) 160 if blueprint: 161 AuraHintSection(parent=self.minimized_footer, text=localization.GetByLabel('UI/InfoWindow/ViewBlueprint'), align=Align.TOBOTTOM) 162 self._add_blueprint_section(parent=self.content_scroll_minimized, is_minimized=True) 163 self._add_materials_section(parent=self.content_scroll_minimized) 164 self._add_required_for_section(parent=self.content_scroll_minimized, is_minimized=True) 165 self.is_minimized_constructed = True 166 167 @classmethod 168 def get_name(cls): 169 return localization.GetByLabel('UI/InfoWindow/TabNames/Industry') 170 171 @classmethod 172 def get_icon(cls): 173 return eveicon.production 174 175 def get_camera_position(self): 176 return TOP_DOWN_NOSE_DOWN 177 178 def get_tab_type(self): 179 return TAB_INDUSTRY 180 181 @classmethod 182 def is_visible(cls, typeID, itemID = None, rec = None): 183 if sm.GetService('blueprintSvc').GetBlueprintByProduct(typeID): 184 return True 185 elif get_type_materials_by_id(typeID): 186 return True 187 elif cfg.blueprintsByMaterialTypeIDs.get(typeID, None): 188 return True 189 else: 190 return False