NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

skinLicenseBrowser.py (8741B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\ship\pages\collection\skinLicenseBrowser.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 CollectionAllActivatedSkinsSection, CollectionAllUnactivatedSkinsSection
     11 from cosmetics.client.ships.skins.static_data.collection_section import CollectionSection
     12 from cosmetics.common.ships.skins.util import SkinListingOrder
     13 from eve.client.script.ui.cosmetics.ship.controls.baseCardSectionContainer import BaseCardSectionContainer
     14 from eve.client.script.ui.cosmetics.ship.controls.shipFilterMenuButton import ShipFilterMenuButton
     15 from eve.client.script.ui.cosmetics.ship.pages.cards.skinLicenseCard import ActivatedSkinLicenseCard, UnactivatedSkinLicenseCard
     16 from eve.client.script.ui.cosmetics.ship.pages.collection import collectionSignals, collectionSettings
     17 from localization import GetByLabel
     18 MAX_NUM_PER_PAGE = 10
     19 
     20 class SkinLicenseBrowser(ScrollContainer):
     21 
     22     def __init__(self, **kw):
     23         super(SkinLicenseBrowser, self).__init__(**kw)
     24         self.is_loaded = False
     25 
     26     def LoadPanel(self, section_id = None):
     27         self.reconstruct_layout()
     28         if section_id == CollectionSection.SKINS_3RD_PARTY_ACTIVATED:
     29             self.construct_view_all_activated_section()
     30         elif section_id == CollectionSection.SKINS_3RD_PARTY_UNACTIVATED:
     31             self.construct_view_all_unactivated_section()
     32         else:
     33             self.construct_landing_page()
     34         self.appear()
     35 
     36     def construct_view_all_unactivated_section(self):
     37         self.Flush()
     38         ViewAllUnactivatedSkinsSectionContainer(parent=self, align=Align.TOTOP, padTop=32, section_controller=CollectionAllUnactivatedSkinsSection(num_per_page=MAX_NUM_PER_PAGE))
     39 
     40     def construct_view_all_activated_section(self):
     41         self.Flush()
     42         ViewAllActivatedSkinsSectionContainer(parent=self, align=Align.TOTOP, padTop=32, section_controller=CollectionAllActivatedSkinsSection(num_per_page=MAX_NUM_PER_PAGE))
     43 
     44     def reconstruct_layout(self):
     45         self.Flush()
     46 
     47     def construct_landing_page(self):
     48         self.Flush()
     49         ActivatedSkinsSectionContainer(parent=self, align=Align.TOTOP, section_controller=CollectionAllActivatedSkinsSection(num_per_page=None, apply_filtering=False), single_row=True, padTop=32)
     50         UnactivatedSkinsSectionContainer(parent=self, align=Align.TOTOP, section_controller=CollectionAllUnactivatedSkinsSection(num_per_page=None, apply_filtering=False), single_row=True, padTop=32)
     51 
     52     def appear(self):
     53         animations.FadeTo(self, 0.0, 1.0, duration=0.3)
     54 
     55 
     56 class BaseSkinsSectionContainer(BaseCardSectionContainer):
     57 
     58     def on_sort_by_setting(self, *args):
     59         self.update()
     60 
     61     def connect_signals(self):
     62         super(BaseSkinsSectionContainer, self).connect_signals()
     63         collectionSettings.skins_sort_by_setting.on_change.connect(self.on_sort_by_setting)
     64         collectionSignals.on_activated_skin_license_selected.connect(self.on_activated_skin_license_selected)
     65         collectionSignals.on_unactivated_skin_license_selected.connect(self.on_unactivated_skin_license_selected)
     66         ship_skin_signals.on_skin_license_added.connect(self.on_skin_license_added)
     67         ship_skin_signals.on_skin_license_deleted.connect(self.on_skin_license_deleted)
     68         ship_skin_signals.on_skin_license_updated.connect(self.on_skin_license_updated)
     69 
     70     def disconnect_signals(self):
     71         super(BaseSkinsSectionContainer, self).disconnect_signals()
     72         collectionSettings.skins_sort_by_setting.on_change.disconnect(self.on_sort_by_setting)
     73         collectionSignals.on_activated_skin_license_selected.connect(self.on_activated_skin_license_selected)
     74         collectionSignals.on_unactivated_skin_license_selected.connect(self.on_unactivated_skin_license_selected)
     75         ship_skin_signals.on_skin_license_added.disconnect(self.on_skin_license_added)
     76         ship_skin_signals.on_skin_license_deleted.disconnect(self.on_skin_license_deleted)
     77         ship_skin_signals.on_skin_license_updated.disconnect(self.on_skin_license_updated)
     78 
     79     def on_skin_license_added(self, *args):
     80         self.update()
     81 
     82     def on_skin_license_deleted(self, *args):
     83         self.update()
     84 
     85     def on_skin_license_updated(self, *args):
     86         self.update()
     87 
     88     def on_unactivated_skin_license_selected(self, skin_license):
     89         pass
     90 
     91     def on_activated_skin_license_selected(self, skin_license):
     92         pass
     93 
     94     def set_selected_license(self, skin_license):
     95         for card in self.cards:
     96             if card.skin_license != skin_license:
     97                 card.is_selected = False
     98 
     99 
    100 class ActivatedSkinsSectionContainer(BaseSkinsSectionContainer):
    101 
    102     def construct_card(self, skin_license):
    103         return ActivatedSkinLicenseCard(name='card_{name}'.format(name=skin_license.skin_hex), parent=self.content, skin_license=skin_license)
    104 
    105     def on_unactivated_skin_license_selected(self, skin_license):
    106         self.set_selected_license(None)
    107 
    108     def on_activated_skin_license_selected(self, skin_license):
    109         self.set_selected_license(skin_license)
    110 
    111 
    112 class UnactivatedSkinsSectionContainer(BaseSkinsSectionContainer):
    113 
    114     def construct_card(self, skin_license):
    115         return UnactivatedSkinLicenseCard(name='card_{name}'.format(name=skin_license.skin_hex), parent=self.content, skin_license=skin_license)
    116 
    117     def on_unactivated_skin_license_selected(self, skin_license):
    118         self.set_selected_license(skin_license)
    119 
    120     def on_activated_skin_license_selected(self, skin_license):
    121         self.set_selected_license(None)
    122 
    123 
    124 class SortByMenuButtonIcon(MenuButtonIcon):
    125     hint = GetByLabel('UI/Common/SortBy')
    126     default_texturePath = eveicon.bars_sort_ascending
    127 
    128     def GetMenu(self):
    129         m = MenuData()
    130         m.AddCaption(self.hint)
    131         m.AddRadioButton(GetByLabel('UI/Common/Name'), (SkinListingOrder.NAME, False), collectionSettings.skins_sort_by_setting)
    132         m.AddRadioButton(GetByLabel('UI/Inventory/NameReversed'), (SkinListingOrder.NAME, True), collectionSettings.skins_sort_by_setting)
    133         return m
    134 
    135 
    136 class BaseViewAllSkinsSectionContainer(BaseSkinsSectionContainer):
    137 
    138     def __init__(self, section_controller, max_entries = None, **kw):
    139         super(BaseViewAllSkinsSectionContainer, self).__init__(section_controller, max_entries, **kw)
    140         collectionSettings.skins_hull_type_filter_setting.set(None)
    141 
    142     def connect_signals(self):
    143         super(BaseViewAllSkinsSectionContainer, self).connect_signals()
    144         collectionSettings.skins_hull_type_filter_setting.on_change.connect(self.skins_hull_type_filter_setting)
    145 
    146     def disconnect_signals(self):
    147         super(BaseViewAllSkinsSectionContainer, self).disconnect_signals()
    148         collectionSettings.skins_hull_type_filter_setting.on_change.disconnect(self.skins_hull_type_filter_setting)
    149 
    150     def skins_hull_type_filter_setting(self, type_id):
    151         self.update()
    152 
    153     def construct_filter_and_sorting(self):
    154         ShipFilterMenuButton(parent=self.filter_and_sorting_cont, align=Align.CENTERLEFT, left=20, hull_type_setting=collectionSettings.skins_hull_type_filter_setting)
    155         SortByMenuButtonIcon(parent=self.filter_and_sorting_cont, align=Align.CENTERLEFT)
    156 
    157     def construct_pagination_container(self):
    158         self.pagination_container = Container(name='pagination_container', parent=self, align=Align.TOTOP, height=32)
    159 
    160 
    161 class ViewAllActivatedSkinsSectionContainer(BaseViewAllSkinsSectionContainer):
    162 
    163     def construct_card(self, skin_license):
    164         return ActivatedSkinLicenseCard(name='card_{name}'.format(name=skin_license.skin_hex), parent=self.content, skin_license=skin_license)
    165 
    166     def on_unactivated_skin_license_selected(self, skin_license):
    167         self.set_selected_license(None)
    168 
    169     def on_activated_skin_license_selected(self, skin_license):
    170         self.set_selected_license(skin_license)
    171 
    172 
    173 class ViewAllUnactivatedSkinsSectionContainer(BaseViewAllSkinsSectionContainer):
    174 
    175     def construct_card(self, skin_license):
    176         return UnactivatedSkinLicenseCard(name='card_{name}'.format(name=skin_license.skin_hex), parent=self.content, skin_license=skin_license)
    177 
    178     def on_unactivated_skin_license_selected(self, skin_license):
    179         self.set_selected_license(skin_license)
    180 
    181     def on_activated_skin_license_selected(self, skin_license):
    182         self.set_selected_license(None)