skillHistoryPanel.py (5073B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\charsheet\skillHistoryPanel.py 2 import characterskills as charskills 3 import evetypes 4 from carbon.common.script.util.format import FmtDate 5 from carbonui.primitives.container import Container 6 from eve.client.script.ui.control.entries.generic import Generic 7 from eve.client.script.ui.control.entries.util import GetFromClass 8 from eve.client.script.ui.control.eveScroll import Scroll 9 from eve.common.lib import appConst 10 from localization import GetByLabel 11 from localization.formatters.numericFormatters import FormatNumeric 12 from utillib import KeyVal 13 import blue 14 ACTIONS = {appConst.skillEventClonePenalty: GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillClonePenalty'), 15 appConst.skillEventTrainingStarted: GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillTrainingStarted'), 16 appConst.skillEventTrainingComplete: GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillTrainingComplete'), 17 appConst.skillEventTrainingCancelled: GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillTrainingCanceled'), 18 appConst.skillEventGMGive: GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/GMGiveSkill'), 19 appConst.skillEventQueueTrainingCompleted: GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillTrainingComplete'), 20 appConst.skillEventFreeSkillPointsUsed: GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillPointsApplied'), 21 appConst.skillEventSkillExtracted: GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillLevelExtracted'), 22 appConst.skillEventGift: GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SkillGift')} 23 ENTRYHEIGHT = 40 24 25 class SkillHistoryPanel(Container): 26 default_name = 'SkillHistoryPanel' 27 __notifyevents__ = ['OnHighlightSkillHistorySkills'] 28 29 def ApplyAttributes(self, attributes): 30 Container.ApplyAttributes(self, attributes) 31 sm.RegisterNotify(self) 32 self.scroll = Scroll(parent=self, padding=(0, 4, 0, 4)) 33 self.scroll.sr.id = 'charsheet_skillhistory' 34 35 def LoadPanel(self): 36 scrolllist = self.GetHistoryScrollList() 37 self.scroll.Load(contentList=scrolllist, headers=[GetByLabel('UI/Common/Date'), 38 GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/Skill'), 39 GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/Action'), 40 GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/Level')], noContentHint=GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/NoRecordsFound'), reversesort=True) 41 42 def GetHistoryScrollList(self): 43 44 def GetPts(lvl): 45 return charskills.GetSPForLevelRaw(stc, lvl) 46 47 rs = sm.GetService('skills').GetSkillHistory() 48 scrolllist = [] 49 for r in rs: 50 skill = sm.GetService('skills').GetSkill(r.skillTypeID) 51 if skill: 52 stc = skill.skillRank 53 levels = [0, 54 GetPts(1), 55 GetPts(2), 56 GetPts(3), 57 GetPts(4), 58 GetPts(5)] 59 level = 5 60 for i in range(len(levels)): 61 if levels[i] > r.absolutePoints: 62 level = i - 1 63 break 64 65 data = KeyVal() 66 data.label = FmtDate(r.logDate, 'ls') + '<t>' 67 data.label += evetypes.GetName(r.skillTypeID) + '<t>' 68 data.label += ACTIONS.get(r.eventTypeID, GetByLabel('UI/Generic/Unknown')) + '<t>' 69 data.label += FormatNumeric(level) 70 data.Set('sort_%s' % GetByLabel('UI/Common/Date'), r.logDate) 71 data.id = r.skillTypeID 72 data.level = level 73 data.GetMenu = self.GetEntryMenu 74 data.MenuFunction = self.GetEntryMenu 75 data.OnDblClick = (self.OnEntryDblClick, data) 76 addItem = GetFromClass(Generic, data=data) 77 scrolllist.append(addItem) 78 79 return scrolllist 80 81 def GetEntryMenu(self, entry, *args): 82 return [(GetByLabel('UI/Common/ShowInfo'), self.ShowInfo, (entry.sr.node.id, 1))] 83 84 def ShowInfo(self, *args): 85 skillID = args[0] 86 sm.GetService('info').ShowInfo(skillID, None) 87 88 def OnEntryDblClick(self, otherSelf, nodeData): 89 skillTypeID = getattr(nodeData, 'id', None) 90 if skillTypeID is not None: 91 self.ShowInfo(skillTypeID) 92 93 def OnHighlightSkillHistorySkills(self, skillTypeIds): 94 self.DeselectAllNodes() 95 blue.pyos.synchro.SleepWallclock(500) 96 skillTypeIds = skillTypeIds[:] 97 for node in self.scroll.GetNodes(): 98 recordKey = (node.id, node.level) 99 if recordKey in skillTypeIds: 100 self.scroll._SelectNode(node) 101 skillTypeIds.remove(recordKey) 102 103 def DeselectAllNodes(self): 104 for node in self.scroll.GetNodes(): 105 self.scroll._DeselectNode(node)