requiredComponentTooltipPanel.py (4006B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\pages\studio\requiredComponentTooltipPanel.py 2 import eveicon 3 from carbonui import PickState, Align, ButtonVariant 4 from carbonui.button.group import ButtonGroup, ButtonSizeMode 5 from carbonui.control.button import Button 6 from cosmetics.client.shipSkinComponentTradingSvc import get_ship_skin_component_trading_svc 7 from cosmetics.client.shipSkinSequencingSvc import get_ship_skin_sequencing_svc 8 from cosmetics.client.ships.skins.live_data import current_skin_design 9 from cosmetics.common.ships.skins.live_data.component_license_type import ComponentLicenseType 10 from eve.client.script.ui import eveColor 11 from eve.client.script.ui.control.tooltips import TooltipPanel 12 from eve.client.script.ui.cosmetics.ship.pages.store.buyComponentDialogue import BuyComponentDialogue 13 from localization import GetByLabel 14 15 class RequiredComponentTooltipPanel(TooltipPanel): 16 default_columns = 1 17 18 def __init__(self, component_instance, title = None, text = None, show_warning = False, **kw): 19 super(RequiredComponentTooltipPanel, self).__init__(**kw) 20 self.component_instance = component_instance 21 self.LoadStandardSpacing() 22 self.AddMediumHeader(text=title) 23 if text: 24 self.AddLabelMedium(text=text, wrapWidth=300) 25 if show_warning and self.component_instance: 26 warning_text = self.get_warning_text() 27 if warning_text: 28 self.AddLabelMedium(text=warning_text, wrapWidth=300, color=eveColor.DANGER_RED, padTop=8) 29 if self.component_instance and show_warning: 30 self.pickState = PickState.ON 31 self.construct_buy_buttons() 32 33 def construct_buy_buttons(self): 34 listings = get_ship_skin_component_trading_svc().get_component_listings(self.component_instance.component_id) 35 if listings: 36 button_group = ButtonGroup(parent=self, align=Align.TOTOP, button_size_mode=ButtonSizeMode.DYNAMIC, padTop=8) 37 Button(parent=button_group, hint=GetByLabel('UI/Inventory/ItemActions/ViewTypesMarketDetails'), func=self.on_view_on_market_button, texturePath=eveicon.market_details, variant=ButtonVariant.GHOST) 38 Button(parent=button_group, label=GetByLabel('UI/Personalization/ShipSkins/SKINR/Studio/BuyElement'), func=lambda *args: self.on_buy_component_button(listings[0]), variant=ButtonVariant.PRIMARY) 39 else: 40 Button(parent=self, align=Align.CENTERBOTTOM, label=GetByLabel('UI/Inventory/ItemActions/ViewTypesMarketDetails'), func=self.on_view_on_market_button, texturePath=eveicon.market_details, variant=ButtonVariant.GHOST, padTop=8) 41 42 def get_warning_text(self): 43 component_data = self.component_instance.get_component_data() 44 if component_data.get_item_type(ComponentLicenseType.LIMITED): 45 layout = current_skin_design.get().slot_layout 46 number_of_runs = get_ship_skin_sequencing_svc().get_num_runs() 47 num_required = number_of_runs * layout.get_amount_of_components_with_license_type(self.component_instance.component_id) 48 return GetByLabel('UI/Personalization/ShipSkins/SKINR/Studio/NotEnoughLimitedDesignElements', num_required=num_required) 49 if component_data.get_item_type(ComponentLicenseType.UNLIMITED): 50 return GetByLabel('UI/Personalization/ShipSkins/SKINR/Studio/NotEnoughUnlimitedDesignElements') 51 52 def on_view_on_market_button(self, *args): 53 component_data = self.component_instance.get_component_data() 54 item_type_id = component_data.get_item_type(ComponentLicenseType.LIMITED) 55 if not item_type_id: 56 item_type_id = component_data.get_item_type(ComponentLicenseType.UNLIMITED) 57 if item_type_id: 58 sm.GetService('marketutils').ShowMarketDetails(item_type_id) 59 60 def on_buy_component_button(self, listing): 61 dialogue = BuyComponentDialogue(listing=listing) 62 dialogue.ShowModal()