personalPlansPanel.py (6413B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\skillPlan\browser\personalPlansPanel.py 2 import uthread2 3 from carbonui import TextAlign, uiconst 4 from carbonui.control.button import Button 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.containerAutoSize import ContainerAutoSize 7 from eve.client.script.ui import eveColor 8 from eve.client.script.ui.control.eveLabel import EveCaptionLarge 9 from eve.client.script.ui.control.eveLoadingWheel import LoadingWheel 10 from eve.client.script.ui.skillPlan import skillPlanUISignals, skillPlanUtil 11 from eve.client.script.ui.skillPlan.browser.noContentHintContainer import NoContentHintContainer 12 from eve.client.script.ui.skillPlan.browser.skillPlanScroll import SkillPlanScroll 13 from eve.client.script.ui.skillPlan.skillPlanConst import BUTTON_GROUP_ID_SKILL_PLANS, BUTTON_GROUP_ID_TOP_LEVEL, PANEL_CERTIFIED, PANEL_SKILLS_CATALOGUE 14 from localization import GetByLabel 15 from skills.skillplan import skillPlanSignals, skillPlanConst 16 from skills.skillplan.errors import SkillPlanConnectionError 17 from skills.skillplan.skillPlanConst import MAX_PERSONAL_PLANS 18 from skills.skillplan.skillPlanService import GetSkillPlanSvc 19 CREATE_BUTTON_WIDTH = 200 20 CREATE_BUTTON_HEIGHT = 70 21 CREATE_BUTTON_FONT_SIZE = 16 22 23 def CreateNew(*args): 24 skillPlanUISignals.on_create_new_personal_button() 25 26 27 class CreatePersonalPlanButton(Button): 28 default_minWidth = 200 29 default_width = 200 30 default_height = 70 31 default_label = GetByLabel('UI/SkillPlan/CreateNewSkillPlan') 32 default_func = CreateNew 33 34 def ApplyAttributes(self, attributes): 35 super(CreatePersonalPlanButton, self).ApplyAttributes(attributes) 36 self.numPlans = None 37 38 def LoadTooltipPanel(self, tooltipPanel, owner): 39 tooltipPanel.LoadStandardSpacing() 40 tooltipPanel.columns = 1 41 tooltipPanel.AddMediumHeader(text=GetByLabel('UI/SkillPlan/CreatePersonalSkillPlan')) 42 tooltipPanel.AddLabelMedium(text=GetByLabel('UI/SkillPlan/PlansInTotal', numPlans=self.numPlans, numTotal=skillPlanConst.MAX_PERSONAL_PLANS)) 43 warningText = self._GetWarningText() 44 if warningText: 45 tooltipPanel.AddLabelMedium(text=warningText, color=eveColor.WARNING_ORANGE, wrapWidth=200) 46 47 def _GetWarningText(self): 48 if self.numPlans >= skillPlanConst.MAX_PERSONAL_PLANS: 49 warningText = GetByLabel('UI/SkillPlan/MaximumSkillPlanReached', numPlans=skillPlanConst.MAX_PERSONAL_PLANS) 50 else: 51 warningText = '' 52 return warningText 53 54 def UpdateState(self, numPlans): 55 self.numPlans = numPlans 56 57 58 class PersonalPlansPanel(Container): 59 60 def ApplyAttributes(self, attributes): 61 super(PersonalPlansPanel, self).ApplyAttributes(attributes) 62 skillPlanSignals.on_deleted.connect(self.OnSkillPlanDeleted) 63 skillPlanSignals.on_created.connect(self.OnSkillPlanCreated) 64 skillPlanSignals.on_saved.connect(self.OnSkillPlanSaved) 65 self.ConstructLayout() 66 67 def Show(self, *args): 68 super(PersonalPlansPanel, self).Show(*args) 69 uthread2.start_tasklet(self.PopulateScroll) 70 71 def ConstructLayout(self): 72 self.noContentHint = NoContentHintContainer(parent=self, align=uiconst.VERTICALLY_CENTERED, state=uiconst.UI_HIDDEN, btnClass=CreatePersonalPlanButton) 73 self.buttonCont = ContainerAutoSize(name='buttonCont', parent=self, align=uiconst.TOBOTTOM, state=uiconst.UI_HIDDEN, padTop=10) 74 self.createBtn = CreatePersonalPlanButton(name='createBtn', parent=self.buttonCont, align=uiconst.CENTER) 75 self.loadingWheel = LoadingWheel(parent=self, align=uiconst.CENTER, state=uiconst.UI_HIDDEN, idx=0) 76 self.scroll = SkillPlanScroll(parent=self, padTop=20) 77 self.scroll.onSizeChangeSignal.connect(self.OnScrollSizeChanged) 78 79 def OnScrollSizeChanged(self, width, height): 80 uthread2.start_tasklet(self.PositionButtonCont) 81 82 def PositionButtonCont(self): 83 if self.destroyed: 84 return 85 if not self.scroll.display: 86 self.buttonCont.SetAlign(uiconst.CENTER) 87 self.buttonCont.SetParent(self, 0) 88 elif not self.scroll.IsVerticalScrollBarVisible(): 89 self.buttonCont.SetAlign(uiconst.TOTOP) 90 self.buttonCont.SetParent(self.scroll) 91 else: 92 self.buttonCont.SetAlign(uiconst.TOBOTTOM) 93 self.buttonCont.SetParent(self, 0) 94 numPlans = len(GetSkillPlanSvc().GetAllPersonal()) 95 if numPlans >= MAX_PERSONAL_PLANS: 96 self.createBtn.Disable() 97 self.createBtn.hint = GetByLabel('UI/SkillPlan/MaximumSkillPlanReached', numPlans=numPlans) 98 else: 99 self.createBtn.Enable() 100 self.createBtn.hint = '' 101 102 def PopulateScroll(self): 103 if self.destroyed: 104 return 105 skillPlans, noContentHint = self._GetSkillPlans() 106 if skillPlans: 107 self.scroll.Show() 108 self.buttonCont.Show() 109 self.buttonCont.SetParent(self, 0) 110 self.noContentHint.Hide() 111 self.scroll.ConstructSkillPlanEntries(skillPlans) 112 else: 113 self.scroll.Hide() 114 self.buttonCont.Hide() 115 self.noContentHint.SetText(noContentHint) 116 self.noContentHint.state = uiconst.UI_PICKCHILDREN 117 self.createBtn.UpdateState(len(skillPlans or [])) 118 self.PositionButtonCont() 119 120 def _GetSkillPlans(self): 121 self.loadingWheel.Show() 122 self.buttonCont.Hide() 123 try: 124 skillPlans = GetSkillPlanSvc().GetAllPersonal().values() 125 except SkillPlanConnectionError: 126 skillPlans = None 127 noContentHint = GetByLabel('UI/SkillPlan/ConnectionError') 128 skillPlanUtil.SetPersistedPanelID(BUTTON_GROUP_ID_TOP_LEVEL, PANEL_SKILLS_CATALOGUE) 129 skillPlanUtil.SetPersistedPanelID(BUTTON_GROUP_ID_SKILL_PLANS, PANEL_CERTIFIED) 130 else: 131 noContentHint = GetByLabel('UI/SkillPlan/NoPersonalSkillPlans') 132 self.buttonCont.Show() 133 finally: 134 self.loadingWheel.Hide() 135 136 return (skillPlans, noContentHint) 137 138 def OnSkillPlanDeleted(self, skillPlanID): 139 self.PopulateScroll() 140 141 def OnSkillPlanCreated(self, skillPlanID): 142 self.PopulateScroll() 143 144 def OnSkillPlanSaved(self, skillPlan): 145 return self.PopulateScroll()