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

attributesPanel.py (3539B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\charsheet\attributesPanel.py
      2 from carbonui.primitives.container import Container
      3 from dogma.attributes.format import GetFormattedAttributeAndValue
      4 from eve.client.script.ui.control.entries.label_text import LabelTextSidesAttributes
      5 from eve.client.script.ui.control.entries.util import GetFromClass
      6 from eve.client.script.ui.control.eveScroll import Scroll
      7 from eve.client.script.ui.shared.neocom.attributes import AttributeRespecEntry
      8 from eve.common.lib import appConst as const
      9 from eve.common.script.sys.dbrow import LookupConstValue
     10 from localization import GetByLabel
     11 
     12 class AttributesPanel(Container):
     13     default_name = 'AttributesPanel'
     14     __notifyevents__ = ['OnAttribute', 'OnAttributes', 'OnRespecInfoUpdated']
     15 
     16     def ApplyAttributes(self, attributes):
     17         Container.ApplyAttributes(self, attributes)
     18         sm.RegisterNotify(self)
     19         self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4))
     20         self.scroll.sr.id = 'charsheet_myattributes'
     21 
     22     def LoadPanel(self, *args):
     23         self.scroll.Load(fixedEntryHeight=32, contentList=self.GetScrollList(), noContentHint=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Attributes/NoAttributesFound'))
     24 
     25     def GetScrollList(self):
     26         attributeIDs = (const.attributePerception,
     27          const.attributeMemory,
     28          const.attributeWillpower,
     29          const.attributeIntelligence,
     30          const.attributeCharisma)
     31         scrollList = [ self.GetEntry(attributeID) for attributeID in attributeIDs ]
     32         respecInfo = sm.GetService('skills').GetRespecInfo()
     33         self.respecEntry = GetFromClass(AttributeRespecEntry, {'nextTimedRespec': respecInfo['nextTimedRespec'],
     34          'freeRespecs': respecInfo['freeRespecs']})
     35         scrollList.append(self.respecEntry)
     36         return scrollList
     37 
     38     def GetEntry(self, attributeID):
     39         value = sm.GetService('skills').GetCharacterAttributes()[attributeID]
     40         formatInfo = GetFormattedAttributeAndValue(attributeID, value)
     41         if not formatInfo:
     42             return None
     43         return GetFromClass(LabelTextSidesAttributes, {'attributeID': attributeID,
     44          'label': formatInfo.displayName,
     45          'text': formatInfo.value,
     46          'iconID': formatInfo.iconID,
     47          'typeID': formatInfo.infoTypeID,
     48          'itemID': session.charid,
     49          'OnClick': lambda : sm.GetService('info').OnAttributeClick(attributeID, session.charid)})
     50 
     51     def UpdateInline(self, attributeID):
     52         for entry in self.scroll.GetNodes():
     53             if entry.attributeID == attributeID:
     54                 value = sm.GetService('skills').GetCharacterAttributes()[attributeID]
     55                 entry.text = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Attributes/Points', skillPoints=int(value))
     56                 if entry.panel:
     57                     entry.panel.sr.text.text = entry.text
     58                     entry.panel.hint = entry.text.replace('<t>', '  ')
     59 
     60     def OnAttribute(self, attributeName, item, value):
     61         if not self.display:
     62             return
     63         if attributeName in ('memory', 'intelligence', 'willpower', 'perception', 'charisma'):
     64             self.UpdateInline(LookupConstValue('attribute%s' % attributeName.capitalize(), 0))
     65 
     66     def OnAttributes(self, changes):
     67         for attributeName, item, value in changes:
     68             self.OnAttribute(attributeName, item, value)
     69 
     70     def OnRespecInfoUpdated(self):
     71         if self.display:
     72             self.LoadPanel()