componentLicenseBrowser.py (6328B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\pages\collection\componentLicenseBrowser.py 2 import eveicon 3 from carbonui import Align 4 from carbonui.button.menu import MenuButtonIcon 5 from carbonui.control.contextMenu.menuData import MenuData 6 from carbonui.control.scrollContainer import ScrollContainer 7 from carbonui.primitives.container import Container 8 from carbonui.uianimations import animations 9 from cosmetics.client.ships import ship_skin_signals 10 from cosmetics.client.ships.skins.live_data.section_controller import CollectionNanocoatingComponentsSection, CollectionMetallicComponentsSection, CollectionPatternComponentsSection 11 from cosmetics.common.ships.skins.static_data.component_category import ComponentCategory 12 from cosmetics.common.ships.skins.util import SkinListingOrder, ComponentListingOrder 13 from eve.client.script.ui.cosmetics.ship.controls.baseCardSectionContainer import BaseCardSectionContainer 14 from eve.client.script.ui.cosmetics.ship.pages.cards.componentLicenseCard import ComponentLicenceCard 15 from eve.client.script.ui.cosmetics.ship.pages.collection import collectionSignals, collectionSettings 16 from localization import GetByLabel 17 MAX_NUM_PER_PAGE = 20 18 19 class ComponentLicenseBrowser(ScrollContainer): 20 21 def __init__(self, **kw): 22 super(ComponentLicenseBrowser, self).__init__(**kw) 23 self.is_loaded = False 24 25 def LoadPanel(self, category = None): 26 self.reconstruct_layout() 27 if category == ComponentCategory.PATTERN: 28 self.construct_view_all_section(CollectionPatternComponentsSection(MAX_NUM_PER_PAGE)) 29 elif category == ComponentCategory.MATERIAL: 30 self.construct_view_all_section(CollectionNanocoatingComponentsSection(MAX_NUM_PER_PAGE)) 31 elif category == ComponentCategory.METALLIC: 32 self.construct_view_all_section(CollectionMetallicComponentsSection(MAX_NUM_PER_PAGE)) 33 else: 34 self.construct_landing_page() 35 self.appear() 36 37 def reconstruct_layout(self): 38 self.Flush() 39 40 def construct_landing_page(self): 41 self.Flush() 42 ComponentCollectionSectionContainer(name='materials_section', parent=self, align=Align.TOTOP, section_controller=CollectionNanocoatingComponentsSection(num_per_page=None), single_row=True, padTop=32) 43 ComponentCollectionSectionContainer(name='metallics_section', parent=self, align=Align.TOTOP, section_controller=CollectionMetallicComponentsSection(num_per_page=None), single_row=True, padTop=48) 44 ComponentCollectionSectionContainer(name='pattern_section', parent=self, align=Align.TOTOP, section_controller=CollectionPatternComponentsSection(num_per_page=None), single_row=True, padTop=48) 45 46 def construct_view_all_section(self, section_controller): 47 self.Flush() 48 ComponentCollectionViewAllSectionContainer(name='materials_section', parent=self, align=Align.TOTOP, padTop=32, section_controller=section_controller) 49 50 def appear(self): 51 animations.FadeTo(self, 0.0, 1.0, duration=0.3) 52 53 54 class ComponentCollectionSectionContainer(BaseCardSectionContainer): 55 56 def __init__(self, section_controller, **kw): 57 super(ComponentCollectionSectionContainer, self).__init__(section_controller, **kw) 58 collectionSettings.components_sort_by_setting.on_change.connect(self.on_sort_by_setting) 59 60 def on_sort_by_setting(self, *args): 61 self.reconstruct_cards() 62 63 def connect_signals(self): 64 collectionSignals.on_component_license_selected.connect(self.on_component_license_selected) 65 ship_skin_signals.on_component_license_cache_invalidated.connect(self.on_component_license_cache_invalidated) 66 ship_skin_signals.on_component_license_granted.connect(self.on_component_license_granted) 67 ship_skin_signals.on_skin_sequencing_job_updated.connect(self.on_skin_sequencing_job_updated) 68 self.on_size_changed.connect(self._on_size_changed) 69 70 def disconnect_signals(self): 71 collectionSignals.on_component_license_selected.disconnect(self.on_component_license_selected) 72 ship_skin_signals.on_component_license_cache_invalidated.disconnect(self.on_component_license_cache_invalidated) 73 ship_skin_signals.on_component_license_granted.disconnect(self.on_component_license_granted) 74 ship_skin_signals.on_skin_sequencing_job_updated.disconnect(self.on_skin_sequencing_job_updated) 75 76 def on_component_license_selected(self, component_license): 77 for card in self.cards: 78 if card.component_license != component_license: 79 card.is_selected = False 80 81 def on_component_license_cache_invalidated(self, *args): 82 self.update() 83 84 def on_component_license_granted(self, *args): 85 self.update() 86 87 def on_skin_sequencing_job_updated(self, *args): 88 self.update() 89 90 def construct_card(self, component_license): 91 return ComponentLicenceCard(name='card_{name}'.format(name=component_license.name.encode('utf-8')), parent=self.content, component_license=component_license) 92 93 94 class SortByMenuButtonIcon(MenuButtonIcon): 95 hint = GetByLabel('UI/Common/SortBy') 96 default_texturePath = eveicon.bars_sort_ascending 97 98 def GetMenu(self): 99 m = MenuData() 100 m.AddCaption(self.hint) 101 m.AddRadioButton(GetByLabel('UI/Common/Name'), (SkinListingOrder.NAME, False), collectionSettings.components_sort_by_setting) 102 m.AddRadioButton(GetByLabel('UI/Inventory/NameReversed'), (SkinListingOrder.NAME, True), collectionSettings.components_sort_by_setting) 103 m.AddSeparator() 104 m.AddRadioButton(GetByLabel('UI/Common/ColorShade'), (ComponentListingOrder.COLOR_SHADE, False), collectionSettings.components_sort_by_setting) 105 m.AddRadioButton(GetByLabel('UI/Common/ColorShadeReversed'), (ComponentListingOrder.COLOR_SHADE, True), collectionSettings.components_sort_by_setting) 106 return m 107 108 109 class ComponentCollectionViewAllSectionContainer(ComponentCollectionSectionContainer): 110 111 def construct_filter_and_sorting(self): 112 SortByMenuButtonIcon(parent=self.filter_and_sorting_cont, align=Align.CENTERLEFT) 113 114 def construct_pagination_container(self): 115 self.pagination_container = Container(name='pagination_container', parent=self, align=Align.TOTOP, height=32)