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

skillPlanPanel.py (11293B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\skillPlan\skillPlanPanel.py
      2 import uthread2
      3 from carbon.client.script.environment.AudioUtil import PlaySound
      4 from carbonui import uiconst
      5 from carbonui.primitives.container import Container
      6 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      7 from carbonui.uianimations import animations
      8 from eve.client.script.ui.control.floatingToggleButtonGroup import FloatingToggleButtonGroup
      9 from eve.client.script.ui.shared.monetization.events import LogMultiPilotTrainingBannerImpression
     10 from eve.client.script.ui.shared.monetization.multiTrainingOverlay import MultiTrainingOverlay
     11 from eve.client.script.ui.shared.pointerTool.pointerToolConst import UNIQUE_NAME_SKILL_PLANS_TAB, UNIQUE_NAME_SKILL_CATALOGUE_TAB
     12 from eve.client.script.ui.skillPlan import skillPlanUISignals, skillPlanUtil
     13 from eve.client.script.ui.skillPlan.browser.skillPlansBrowserPanel import SkillPlansBrowserPanel
     14 from eve.client.script.ui.skillPlan.selectedPlan.selectedSkillPlanContainer import SelectedSkillPlanContainer
     15 from eve.client.script.ui.skillPlan.skillPlanConst import BUTTON_GROUP_ID_TOP_LEVEL, PANEL_SKILLS_CATALOGUE, PANEL_SKILL_PLANS
     16 from eve.client.script.ui.skillPlan.skillPlanEditor.skillPlanEditorPanel import SkillPlanEditorPanel
     17 from eve.client.script.ui.skillPlan.skillPlanUtil import IsExternalServicePanelSelected
     18 from eve.client.script.ui.skillPlan.skillsCatalogue.skillsCataloguePanel import SkillsCataloguePanel
     19 from eve.client.script.ui.skillPlan.trainingOverviewPanel.trainingOverviewPanel import TrainingOverviewPanel
     20 from eve.client.script.ui.skilltrading.dailyAlphaInjectorOverlay import DailyAlphaInjectorOverlay
     21 from localization import GetByLabel
     22 from skills.skillplan import skillPlanSignals
     23 from skills.skillplan.skillPlanService import GetSkillPlanSvc
     24 from skills.skillplan.skillPlanTemplate import SkillPlanTemplate
     25 
     26 class SkillPlanPanel(Container):
     27 
     28     def ApplyAttributes(self, attributes):
     29         super(SkillPlanPanel, self).ApplyAttributes(attributes)
     30         PlaySound('skills_planner_window_open_play')
     31         PlaySound('skills_planner_background_loop_play')
     32         self.selectedSkillPlan = None
     33         self.skillPlanEditor = None
     34         self.multiTrainingOverlay = None
     35         self.dailyAlphaInjectorOverlay = None
     36         self.skillPlanBrowser = None
     37         skillPlanSignals.on_created.connect(self.OnSkillPlanCreated)
     38         skillPlanSignals.on_saved.connect(self.OnSkillPlanSaved)
     39         skillPlanSignals.on_deleted.connect(self.OnSkillPlanDeleted)
     40         skillPlanUISignals.on_create_new_personal_button.connect(self.OnCreateNewPersonalSkillPlanButton)
     41         skillPlanUISignals.on_create_new_corp_button.connect(self.OnCreateNewCorpSkillPlanButton)
     42         skillPlanUISignals.on_edit_button.connect(self.OnEditSkillPlanButton)
     43         skillPlanUISignals.on_delete_button.connect(self.OnDeleteSkillPlanButton)
     44         skillPlanUISignals.on_close_new_button.connect(self.OnCloseNewSkillPlanButton)
     45         skillPlanUISignals.on_selected.connect(self.OnSkillPlanSelected)
     46         skillPlanUISignals.on_close_button.connect(self.OnSkillPlanCloseButton)
     47         skillPlanUISignals.on_show_multi_training_msg.connect(self.OnShowMultiTrainingMessage)
     48         skillPlanUISignals.on_show_alpha_training_msg.connect(self.OnShowAlphaTrainingMessage)
     49         self.overlayCont = Container(name='overlayCont', parent=self, state=uiconst.UI_HIDDEN)
     50         self.rightCont = Container(name='rightCont', parent=self, align=uiconst.TORIGHT_PROP, width=1.0 - 1.0 / uiconst.GOLDEN_RATIO, padLeft=32)
     51         self.leftCont = Container(name='leftCont', parent=self)
     52         self._ConstructLeft()
     53         self._ConstructRight()
     54         uthread2.start_tasklet(self.AutoSelectTab)
     55         self.skillPlanTemplate = attributes.get('skillPlanTemplate', None)
     56         if self.skillPlanTemplate:
     57             self.OnCreateNewPersonalSkillPlanWithTemplate(self.skillPlanTemplate)
     58 
     59     def _ConstructLeft(self):
     60         self.leftOverlayCont = Container(parent=self.leftCont, name='leftOverlayCont', state=uiconst.UI_HIDDEN)
     61         self.leftTabContentsCont = Container(name='leftTabContents', parent=self.leftCont, state=uiconst.UI_PICKCHILDREN)
     62         tabcont = ContainerAutoSize(name='tabCont', parent=self.leftTabContentsCont, align=uiconst.TOTOP, padBottom=16)
     63         self.topLevelToggleButtonGroup = FloatingToggleButtonGroup(parent=tabcont, align=uiconst.CENTERTOP, fontsize=16, width=400, callback=self.OnTopLevelToggleButtonGroup)
     64         self.skillPlanBrowser = SkillPlansBrowserPanel(parent=self.leftTabContentsCont, state=uiconst.UI_HIDDEN)
     65         skillsCataloguePanel = SkillsCataloguePanel(parent=self.leftTabContentsCont, state=uiconst.UI_HIDDEN)
     66         self.topLevelToggleButtonGroup.AddButton(btnID=PANEL_SKILL_PLANS, label=GetByLabel('UI/SkillPlan/SkillPlans'), panel=self.skillPlanBrowser, hint=GetByLabel('UI/SkillPlan/SkillPlansHoverTooltip'), analyticID='TopLevelTabs_SkillPlans', uniqueUiName=UNIQUE_NAME_SKILL_PLANS_TAB)
     67         self.topLevelToggleButtonGroup.AddButton(btnID=PANEL_SKILLS_CATALOGUE, label=GetByLabel('UI/SkillPlan/SkillCatalogue'), panel=skillsCataloguePanel, hint=GetByLabel('UI/SkillPlan/SkillsCatalogueHoverTooltip'), analyticID='TopLevelTabs_SkillCatalogue', uniqueUiName=UNIQUE_NAME_SKILL_CATALOGUE_TAB)
     68 
     69     def AutoSelectTab(self):
     70         if IsExternalServicePanelSelected() and not sm.GetService('publicGatewaySvc').is_available():
     71             panelID = PANEL_SKILLS_CATALOGUE
     72         else:
     73             panelID = skillPlanUtil.GetPersistedPanelID(BUTTON_GROUP_ID_TOP_LEVEL)
     74         self.topLevelToggleButtonGroup.SelectByID(panelID)
     75 
     76     def OnTopLevelToggleButtonGroup(self, btnID, oldBtnID):
     77         skillPlanUtil.SetPersistedPanelID(BUTTON_GROUP_ID_TOP_LEVEL, btnID)
     78 
     79     def _ConstructRight(self):
     80         self.rightMainCont = Container(name='rightMainCont', parent=self.rightCont, padTop=16)
     81         self.trainingOverviewPanel = TrainingOverviewPanel(parent=self.rightMainCont, align=uiconst.TOALL)
     82 
     83     def _ConstructMultiTrainingOverlay(self):
     84         if self.multiTrainingOverlay is None or self.multiTrainingOverlay.destroyed:
     85             self.multiTrainingOverlay = MultiTrainingOverlay(parent=self, padding=(-2, 0, -2, 2), idx=0)
     86 
     87     def _ConstructAlphaOverlay(self):
     88         if self.dailyAlphaInjectorOverlay is None or self.dailyAlphaInjectorOverlay.destroyed:
     89             self.dailyAlphaInjectorOverlay = DailyAlphaInjectorOverlay(parent=self, padding=(-2, 0, -2, 2), idx=0)
     90 
     91     def ShowCertifiedPlans(self, careerID):
     92         self.topLevelToggleButtonGroup.SelectByID(PANEL_SKILL_PLANS)
     93         self.skillPlanBrowser.ShowCertifiedPlans(careerID)
     94 
     95     def OnSkillPlanCloseButton(self):
     96         self._HideAllOverlays()
     97 
     98     def OnCloseNewSkillPlanButton(self):
     99         self._HideAllOverlays()
    100 
    101     def OnSkillPlanCreated(self, skillPlanID):
    102         self._HideAllOverlays()
    103 
    104     def OnSkillPlanSaved(self, skillPlan):
    105         self._HideAllOverlays()
    106 
    107     def OnSkillPlanDeleted(self, skillPlanID):
    108         if self.selectedSkillPlan and skillPlanID == self.selectedSkillPlan.GetID():
    109             self._HideAllOverlays()
    110 
    111     def _HideAllOverlays(self):
    112         self._DisableLeftOverlay()
    113         self._DisableOverlay()
    114         self.trainingOverviewPanel.Show()
    115         self.skillPlanEditor = None
    116 
    117     def OnCreateNewPersonalSkillPlanButton(self):
    118         skillPlan = GetSkillPlanSvc().GetNewUnsavedPersonal()
    119         self._ShowSkillPlanEditor(skillPlan)
    120 
    121     def OnCreateNewCorpSkillPlanButton(self):
    122         skillPlan = GetSkillPlanSvc().GetNewUnsavedCorp()
    123         self._ShowSkillPlanEditor(skillPlan)
    124 
    125     def OnEditSkillPlanButton(self, skillPlan):
    126         self._HideAllOverlays()
    127         newSkillPlan = skillPlan.GetCopy()
    128         self._ShowSkillPlanEditor(newSkillPlan)
    129 
    130     def OnCreateNewPersonalSkillPlanWithTemplate(self, skillPlanTemplate):
    131         skillPlan = GetSkillPlanSvc().GetNewUnsavedPersonal()
    132         skillPlanTemplate.Apply(skillPlan)
    133         self._ShowSkillPlanEditor(skillPlan)
    134 
    135     def OnDeleteSkillPlanButton(self, skillPlan):
    136         GetSkillPlanSvc().Delete(skillPlan)
    137 
    138     def _ShowSkillPlanEditor(self, skillPlan):
    139         self._EnableOverlay()
    140         self.trainingOverviewPanel.Hide()
    141         if not skillPlan:
    142             return
    143         self.skillPlanEditor = SkillPlanEditorPanel(parent=self.overlayCont, skillPlan=skillPlan, padTop=16)
    144 
    145     def OnSkillPlanSelected(self, skillPlan):
    146         if self.destroyed:
    147             return
    148         if skillPlan == self.selectedSkillPlan:
    149             return
    150         self._EnableLeftOverlay()
    151         self.leftOverlayCont.Flush()
    152         self.selectedSkillPlanContainer = SelectedSkillPlanContainer(parent=self.leftOverlayCont, skillPlan=skillPlan, padTop=45)
    153         self._SelectSkillPlan(skillPlan)
    154 
    155     def _SelectSkillPlan(self, skillPlan):
    156         if self.selectedSkillPlan != skillPlan:
    157             self.selectedSkillPlan = skillPlan
    158             sm.ScatterEvent('OnSelectedSkillPlanChanged')
    159 
    160     def _DeselectSkillPlan(self):
    161         if self.selectedSkillPlan:
    162             self.selectedSkillPlan = None
    163             sm.ScatterEvent('OnSelectedSkillPlanChanged')
    164 
    165     def IsSkillPlanContainerShown(self, skillPlanID):
    166         return self.selectedSkillPlan == skillPlanID
    167 
    168     def OnBack(self, *args):
    169         self._HideAllOverlays()
    170 
    171     def _EnableOverlay(self):
    172         duration = 0.3
    173         animations.FadeTo(self.leftTabContentsCont, self.leftTabContentsCont.opacity, 0.0, duration=duration)
    174         self.leftTabContentsCont.Disable()
    175         self.overlayCont.Show()
    176         animations.FadeTo(self.overlayCont, 0.0, 1.0, duration=duration)
    177 
    178     def _DisableOverlay(self):
    179         if not self.overlayCont.display:
    180             return
    181         self.overlayCont.Hide()
    182         self.overlayCont.Flush()
    183         animations.FadeTo(self.leftTabContentsCont, self.leftTabContentsCont.opacity, 1.0, duration=uiconst.TIME_EXIT)
    184         self.leftTabContentsCont.Enable()
    185 
    186     def _EnableLeftOverlay(self):
    187         duration = 0.3
    188         animations.FadeTo(self.leftTabContentsCont, self.leftTabContentsCont.opacity, 0.2, duration=duration)
    189         self.leftTabContentsCont.Disable()
    190         self.leftOverlayCont.Show()
    191         animations.FadeTo(self.leftOverlayCont, 0.0, 1.0, duration=duration)
    192         animations.MorphScalar(self.leftOverlayCont, 'left', -0.01, 0, duration=duration)
    193 
    194     def _DisableLeftOverlay(self):
    195         if not self.leftOverlayCont.display:
    196             return
    197         self.leftOverlayCont.Hide()
    198         self.leftOverlayCont.Flush()
    199         animations.FadeTo(self.leftTabContentsCont, self.leftTabContentsCont.opacity, 1.0, duration=uiconst.TIME_EXIT)
    200         self.leftTabContentsCont.Enable()
    201         self._DeselectSkillPlan()
    202 
    203     def OnShowMultiTrainingMessage(self):
    204         self._ConstructMultiTrainingOverlay()
    205         uthread2.start_tasklet(self.multiTrainingOverlay.Display)
    206         LogMultiPilotTrainingBannerImpression()
    207 
    208     def OnShowAlphaTrainingMessage(self, message):
    209         self._ConstructAlphaOverlay()
    210         uthread2.start_tasklet(self.dailyAlphaInjectorOverlay.Display, message)
    211 
    212     def Close(self):
    213         super(SkillPlanPanel, self).Close()
    214         PlaySound('skills_planner_background_loop_stop')