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

panelMastery.py (6989B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\panels\panelMastery.py
      2 import evetypes
      3 import localization
      4 from carbonui import uiconst
      5 from carbonui.primitives.container import Container
      6 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      7 from carbonui.util.color import Color
      8 from carbonui.util.various_unsorted import SortListOfTuples
      9 from carbon.common.script.util.format import IntToRoman
     10 from eve.client.script.ui.control.entries.certificate import CertEntry
     11 from eve.client.script.ui.control.entries.util import GetFromClass
     12 from eve.client.script.ui.control.toggleButtonGroup import ToggleButtonGroup
     13 from eve.client.script.ui.control.eveScroll import Scroll
     14 from eve.client.script.ui.control.toggleButtonGroupButton import ToggleButtonGroupButtonIcon
     15 from eve.client.script.ui.control.utilMenu import UtilMenu
     16 from eve.client.script.ui.shared.shipTree import shipTreeConst
     17 from eve.client.script.ui.shared.tooltip.itemObject import ItemObject
     18 from eve.client.script.ui.shared.tooltip.skillBtns import SkillActionContainer
     19 from eve.client.script.ui.shared.tooltip.skill_requirement import OmegaTrainingTimeContainer, AlphaTrainingTimeContainer
     20 from eve.common.lib import appConst as const
     21 from omega.client.clone_grade_svc import get_clone_grade_svc
     22 BUTTONS = ((1, 'res:/UI/Texture/classes/Mastery/MasterySmall1.png'),
     23  (2, 'res:/UI/Texture/classes/Mastery/MasterySmall2.png'),
     24  (3, 'res:/UI/Texture/classes/Mastery/MasterySmall3.png'),
     25  (4, 'res:/UI/Texture/classes/Mastery/MasterySmall4.png'),
     26  (5, 'res:/UI/Texture/classes/Mastery/MasterySmall5.png'))
     27 
     28 class PanelMastery(Container):
     29     __notifyevents__ = ['OnSkillsChanged']
     30 
     31     def ApplyAttributes(self, attributes):
     32         Container.ApplyAttributes(self, attributes)
     33         self.typeID = attributes.typeID
     34         self.masteryLevel = 0
     35         sm.RegisterNotify(self)
     36 
     37     def Load(self):
     38         self.Flush()
     39         toggleButtonCont = Container(name='btnGroupCont', parent=self, align=uiconst.TOTOP, height=45)
     40         btnGroup = ToggleButtonGroup(parent=toggleButtonCont, align=uiconst.CENTER, height=toggleButtonCont.height, width=330, padding=(10, 4, 10, 3), callback=self.LoadMasteryLevel, btnClass=ToggleButtonGroupButtonIcon)
     41         for level, iconPath in BUTTONS:
     42             hint = localization.GetByLabel('UI/InfoWindow/MasteryLevelButtonHint', level=level)
     43             if level == 5:
     44                 color = Color(*shipTreeConst.COLOR_MASTERED).SetBrightness(0.2).GetRGBA()
     45             else:
     46                 color = Color(*shipTreeConst.COLOR_BG).SetBrightness(0.35).GetRGBA()
     47             btnGroup.AddButton(btnID=level, iconPath=iconPath, iconSize=45, hint=hint, colorSelected=color)
     48 
     49         self.settingsMenu = UtilMenu(menuAlign=uiconst.TOPLEFT, parent=toggleButtonCont, align=uiconst.BOTTOMLEFT, top=4, left=4, GetUtilMenu=self.GetSettingsMenu, texturePath='res:/UI/Texture/SettingsCogwheel.png', width=16, height=16, iconSize=18)
     50         self.bottomContainer = ContainerAutoSize(parent=self, align=uiconst.TOBOTTOM, padding=const.defaultPadding)
     51         self.masteryScroll = Scroll(name='masteryScroll', parent=self, padding=const.defaultPadding)
     52         level = sm.GetService('certificates').GetCurrCharMasteryLevel(self.typeID)
     53         level = max(level, 1)
     54         btnGroup.SelectByID(level)
     55 
     56     def LoadMasteryLevel(self, btnID, *args):
     57         if getattr(self, 'masteryScroll', None) is None:
     58             return
     59         if btnID is None:
     60             return
     61         self.masteryLevel = btnID
     62         entries = self.GetMasteryScrollEntries(btnID)
     63         self.masteryScroll.Load(contentList=entries)
     64         self.UpdateTrainingTime(btnID)
     65 
     66     def GetMasteryScrollEntries(self, level):
     67         certificates = sm.GetService('certificates').GetCertificatesForShipByMasteryLevel(self.typeID, level)
     68         scrolllist = []
     69         for cert in certificates:
     70             data = sm.GetService('info').GetCertEntry(cert, level)
     71             scrolllist.append((data.get('label', ''), GetFromClass(CertEntry, data)))
     72 
     73         return SortListOfTuples(scrolllist)
     74 
     75     def UpdateTrainingTime(self, masteryLevel):
     76         certSvc = sm.GetService('certificates')
     77         trainingTime = certSvc.GetShipTrainingTimeForMasteryLevel(self.typeID, masteryLevel)
     78         skillSvc = sm.GetService('skills')
     79         isOmegaRestricted = False
     80         requiredSkillsList = []
     81         for skillID, skillLevel in certSvc.GetSkillsRequiredForMasteryLevel(self.typeID, masteryLevel).iteritems():
     82             skill = skillSvc.GetSkill(skillID)
     83             if not isOmegaRestricted:
     84                 isOmegaRestricted = get_clone_grade_svc().is_requirements_restricted(skillID)
     85                 if not isOmegaRestricted:
     86                     isOmegaRestricted = get_clone_grade_svc().is_skill_level_restricted(skillID, skillLevel)
     87             if not skill or skill.trainedSkillLevel < skillLevel:
     88                 requiredSkillsList.append((skillID, skillLevel))
     89 
     90         if not isOmegaRestricted:
     91             isOmegaRestricted = ItemObject(self.typeID).NeedsOmegaUpgrade()
     92         requiredSkillsList = list(set(requiredSkillsList))
     93         requiredSkillsList = skillSvc.GetSkillsMissingToUseAllSkillsFromListRecursiveAsList(requiredSkillsList)
     94         missingSkills = sm.GetService('skills').GetMissingSkillBooksFromList(requiredSkillsList)
     95         self.bottomContainer.Flush()
     96         if len(requiredSkillsList) > 0:
     97             if get_clone_grade_svc().is_omega_with_grace_period():
     98                 OmegaTrainingTimeContainer(parent=self.bottomContainer, omegaTime=long(trainingTime), padBottom=8)
     99             else:
    100                 omegaTime = long(trainingTime) / 2
    101                 AlphaTrainingTimeContainer(parent=self.bottomContainer, isOmegaRestricted=isOmegaRestricted, alphaTime=long(trainingTime), omegaTime=omegaTime, activityText=localization.GetByLabel('Tooltips/SkillPlanner/ActivityTrainMasteryLevel'), padBottom=8, clipChildren=True)
    102             if not isOmegaRestricted:
    103                 typeName = evetypes.GetName(self.typeID)
    104                 level = IntToRoman(self.masteryLevel)
    105                 skillPlanName = localization.GetByLabel('UI/SkillPlan/CreateMasterySkillPlanName', typeName=typeName, level=level)
    106                 SkillActionContainer(parent=self.bottomContainer, align=uiconst.TOTOP, requiredSkills=requiredSkillsList, missingSkills=missingSkills, skillPlanName=skillPlanName)
    107 
    108     def GetSettingsMenu(self, parent):
    109         parent.AddCheckBox(text=localization.GetByLabel('UI/InfoWindow/MasteryFilterAcquired'), checked=bool(settings.user.ui.Get('masteries_filter_acquired', False)), callback=self.ToggleFilterAcquired)
    110 
    111     def ToggleFilterAcquired(self, *args):
    112         settings.user.ui.Set('masteries_filter_acquired', not settings.user.ui.Get('masteries_filter_acquired', False))
    113         self.LoadMasteryLevel(self.masteryLevel)
    114 
    115     def OnSkillsChanged(self, *args):
    116         self.LoadMasteryLevel(self.masteryLevel)