implantsBoostersPanel.py (5805B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\charsheet\implantsBoostersPanel.py 2 import dogma.data 3 import evetypes 4 from carbonui.primitives.container import Container 5 from carbonui.util.sortUtil import SortListOfTuples 6 from dogma.const import attributeNonDiminishingSkillInjectorUses 7 from eve.client.script.ui.control.entries.divider import DividerEntry 8 from eve.client.script.ui.control.entries.header import Header 9 from eve.client.script.ui.control.entries.icon import IconEntry 10 from eve.client.script.ui.control.entries.implant import ImplantEntry 11 from eve.client.script.ui.control.entries.util import GetFromClass 12 from eve.client.script.ui.control.eveScroll import Scroll 13 from eve.common.lib import appConst as const 14 from fsdBuiltData.common.iconIDs import GetIconFile 15 from localization import GetByLabel 16 import blue 17 18 class ImplantsBoostersPanel(Container): 19 default_name = 'ImplantsBoostersPanel' 20 __notifyevents__ = ['OnGodmaItemChange', 21 'OnBoosterUpdated', 22 'OnImplantsChanged', 23 'OnNonDiminishingInjectionsChanged'] 24 25 def ApplyAttributes(self, attributes): 26 Container.ApplyAttributes(self, attributes) 27 sm.RegisterNotify(self) 28 self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4)) 29 30 def LoadPanel(self, *args): 31 mygodma = self.GetMyGodmaItem(session.charid) 32 if not mygodma: 33 return 34 implants = mygodma.implants 35 boosters = mygodma.boosters 36 godma = sm.GetService('godma') 37 implants = SortListOfTuples([ (getattr(godma.GetType(implant.typeID), 'implantness', None), implant) for implant in implants ]) 38 boosters = SortListOfTuples([ (getattr(godma.GetType(booster.boosterTypeID), 'boosterness', None), booster) for booster in boosters ]) 39 scrolllist = [] 40 if implants: 41 scrolllist.append(GetFromClass(Header, {'label': GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Augmentations/Implants', implantCount=len(implants))})) 42 for booster in implants: 43 scrolllist.append(GetFromClass(ImplantEntry, {'implant_booster': booster, 44 'label': evetypes.GetName(booster.typeID)})) 45 46 if boosters: 47 scrolllist.append(GetFromClass(DividerEntry)) 48 dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation() 49 staticMgr = dogmaLocation.dogmaStaticMgr 50 if boosters: 51 scrolllist.append(GetFromClass(Header, {'label': GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Augmentations/Boosters', boosterCount=len(boosters))})) 52 for booster in boosters: 53 scrolllist.append(GetFromClass(ImplantEntry, {'implant_booster': booster, 54 'label': evetypes.GetName(booster.boosterTypeID)})) 55 boosterEffects = staticMgr.GetPassiveFilteredEffectsByType(booster.boosterTypeID) 56 for effectID in boosterEffects: 57 eff = dogma.data.get_effect(effectID) 58 chanceAttributeID = staticMgr.effects[effectID].fittingUsageChanceAttributeID 59 if chanceAttributeID and effectID in booster.sideEffectIDs: 60 effectDisplayName = dogma.data.get_effect_display_name(effectID) 61 scrolllist.append(GetFromClass(IconEntry, {'line': 1, 62 'hint': effectDisplayName, 63 'text': None, 64 'label': effectDisplayName, 65 'icon': GetIconFile(eff.iconID), 66 'selectable': 0, 67 'iconoffset': 32, 68 'iconsize': 22, 69 'linecolor': (1.0, 1.0, 1.0, 0.125)})) 70 71 self._AddNonDiminishingSkillInjectorUses(staticMgr, booster, scrolllist) 72 scrolllist.append(GetFromClass(DividerEntry)) 73 74 self.scroll.sr.id = 'charsheet_implantandboosters' 75 self.scroll.Load(fixedEntryHeight=32, contentList=scrolllist, noContentHint=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Augmentations/NoImplantOrBoosterInEffect')) 76 77 def _AddNonDiminishingSkillInjectorUses(self, staticMgr, booster, scrolllist): 78 hasNonDiminishingSkillInjectorUses = staticMgr.GetTypeAttribute(booster.typeID, attributeNonDiminishingSkillInjectorUses, defaultValue=0) 79 if hasNonDiminishingSkillInjectorUses: 80 timesRemaining = sm.GetService('nonDiminishingInjection').GetRemaining() 81 iconID = evetypes.GetIconID(const.typeSkillInjector) 82 scrolllist.append(GetFromClass(IconEntry, {'line': 1, 83 'hint': evetypes.GetName(booster.typeID), 84 'text': None, 85 'label': GetByLabel('UI/Skills/NonDiminishingInjectionsRemainingForBooster', timesRemaining=int(timesRemaining)), 86 'icon': GetIconFile(iconID), 87 'selectable': 0, 88 'iconoffset': 32, 89 'iconsize': 22, 90 'linecolor': (1.0, 1.0, 1.0, 0.125)})) 91 92 def GetMyGodmaItem(self, itemID): 93 ret = sm.GetService('godma').GetItem(itemID) 94 while ret is None and not self.destroyed: 95 blue.pyos.synchro.SleepWallclock(500) 96 ret = sm.GetService('godma').GetItem(itemID) 97 98 return ret 99 100 def OnGodmaItemChange(self, item, change): 101 if const.ixLocationID in change and item.categoryID == const.categoryImplant and item.flagID in [const.flagBooster, const.flagImplant]: 102 self.LoadPanel() 103 104 def OnBoosterUpdated(self): 105 if self.display: 106 self.LoadPanel() 107 108 def OnImplantsChanged(self): 109 if self.display: 110 self.LoadPanel() 111 112 def OnNonDiminishingInjectionsChanged(self): 113 if self.display: 114 self.LoadPanel()