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

designApplicationPage.py (5505B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\cosmetics\structure\pages\designApplicationPage.py
      2 from carbonui import const as uiconst
      3 from carbonui.control.button import Button
      4 from carbonui.primitives.container import Container
      5 from carbonui.util.dpi import ReverseScaleDpi
      6 from eve.client.script.ui.control.loadingContainer import LoadingSpriteSize, LoadingContainer
      7 from eve.client.script.ui.cosmetics.structure import const as paintToolConst, paintToolUtils
      8 from eve.client.script.ui.cosmetics.structure import paintToolSelections
      9 from eve.client.script.ui.cosmetics.structure import paintToolSignals
     10 from eve.client.script.ui.cosmetics.structure.components.corpStructureSelector import CorpStructureSelector
     11 from eve.client.script.ui.cosmetics.structure.components.durationSelector import DurationSelector
     12 from eve.client.script.ui.cosmetics.structure.components.navigationButtons import BackButton
     13 from eve.client.script.ui.cosmetics.structure.confirmApplyWnd import ConfirmApplyWnd
     14 from eve.client.script.ui.cosmetics.structure.pages.basePage import BasePage
     15 from localization import GetByLabel
     16 
     17 class DesignApplicationPage(BasePage):
     18 
     19     def __init__(self, **kw):
     20         paintToolSelections.clear_all_selected_structures()
     21         paintToolSignals.on_structure_selection_changed.connect(self._on_structure_selection_changed)
     22         paintToolSignals.on_duration_selection_changed.connect(self._on_duration_selection_changed)
     23         self._panel_container = None
     24         super(DesignApplicationPage, self).__init__(**kw)
     25         self._content.LoadContent(loadCallback=self._load_catalogue_callback)
     26 
     27     def Close(self):
     28         paintToolSignals.on_structure_selection_changed.disconnect(self._on_structure_selection_changed)
     29         paintToolSignals.on_duration_selection_changed.disconnect(self._on_duration_selection_changed)
     30         super(DesignApplicationPage, self).Close()
     31 
     32     def _OnResize(self, *args):
     33         super(DesignApplicationPage, self)._OnResize(*args)
     34         self._set_panel_container_size()
     35 
     36     def _open_page(self):
     37         super(DesignApplicationPage, self)._open_page()
     38         self._corp_structure_selector.update()
     39 
     40     def _construct_layout(self):
     41         self._content = LoadingContainer(parent=self, name='contentCont', align=uiconst.TOALL, loadingSpriteSize=LoadingSpriteSize.LARGE, failureStateMessage=GetByLabel('UI/Personalization/PaintTool/CatalogueLoadingErrorTitle'), failureStateSubtext=GetByLabel('UI/Personalization/PaintTool/CatalogueLoadingErrorDescription'), retryBtnLabel=GetByLabel('UI/Personalization/PaintTool/ErrorRetry'), padTop=40, failedCallback=self._on_loading_failed)
     42         self._panel_container = Container(name='panel_container', parent=self._content, align=uiconst.CENTERTOP)
     43         self._set_panel_container_size()
     44         self._create_navigation_button()
     45         self._create_duration_selection()
     46         self._create_apply_button()
     47         self._create_structure_list()
     48         self.UpdateAlignment()
     49 
     50     def _set_panel_container_size(self):
     51         if self._panel_container:
     52             self._panel_container.width = paintToolConst.get_design_application_page_width()
     53             self._panel_container.height = ReverseScaleDpi(self.displayHeight)
     54 
     55     def _on_loading_failed(self, exception):
     56         raise exception
     57 
     58     def _create_navigation_button(self):
     59         BackButton(name='back_button', parent=self, align=uiconst.TOPLEFT, left=23, top=23, onClick=self._on_back_clicked)
     60 
     61     def _create_duration_selection(self):
     62         self._duration_selector = DurationSelector(parent=self._panel_container, name='durationSelector', align=uiconst.TOTOP)
     63 
     64     def _create_apply_button(self):
     65         apply_button_cont = Container(parent=self._panel_container, name='applyButtonCont', align=uiconst.TOBOTTOM, height=98)
     66         self._apply_button = Button(parent=apply_button_cont, align=uiconst.CENTERTOP, label=GetByLabel('UI/Personalization/PaintTool/BuyLicense'), enabled=self._is_apply_enabled(), func=self._on_apply_clicked)
     67 
     68     def _create_structure_list(self):
     69         self._corp_structure_selector = CorpStructureSelector(parent=self._panel_container, name='corpStructureSelector', align=uiconst.TOALL)
     70 
     71     def _load_catalogue_callback(self):
     72         catalogue = sm.GetService('cosmeticsLicenseSvc').get_structure_paintwork_licenses_catalogue()
     73         self._duration_selector.set_durations(catalogue.get_available_durations_sorted())
     74         self._corp_structure_selector.set_prices(catalogue)
     75 
     76     @staticmethod
     77     def _is_apply_enabled():
     78         return len(paintToolSelections.SELECTED_STRUCTURES) > 0 and paintToolUtils.has_sufficient_funds()
     79 
     80     @staticmethod
     81     def _on_back_clicked():
     82         paintToolSelections.SELECTED_PAGE.set(paintToolConst.DESIGN_CREATION_PAGE_ID)
     83 
     84     @staticmethod
     85     def _on_apply_clicked(_button):
     86         popup = ConfirmApplyWnd(paintwork=paintToolSelections.SELECTED_PAINTWORK, structure_ids=paintToolSelections.SELECTED_STRUCTURES.keys(), duration_days=paintToolSelections.SELECTED_DURATION / 86400, total_em_cost=paintToolUtils.get_total_price())
     87         result = popup.ShowModal()
     88         if result == uiconst.ID_OK:
     89             paintToolSelections.SELECTED_PAGE.set(paintToolConst.SUMMARY_PAGE_ID)
     90 
     91     def _on_structure_selection_changed(self, *_args):
     92         self._apply_button.enabled = self._is_apply_enabled()
     93 
     94     def _on_duration_selection_changed(self):
     95         self._apply_button.enabled = self._is_apply_enabled()