standingEntry.py (5777B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\standings\standingEntry.py 2 import math 3 import localization 4 import evetypes 5 import inventorycommon.const as invconst 6 from carbon.client.script.environment.AudioUtil import PlaySound 7 from carbonui import const as uiconst 8 from carbonui.control.scrollentries import SE_BaseClassCore 9 from carbonui.primitives.container import Container 10 from carbonui.primitives.containerAutoSize import ContainerAutoSize 11 from carbonui.primitives.sprite import Sprite 12 from carbonui.uianimations import animations 13 from eve.client.script.ui.control import eveIcon, eveLabel 14 from eve.client.script.ui.shared.standings.standingsBonusTooltip import StandingBonusTooltip 15 POSITIVE_CHANGE_ICON = 'res:/UI/Texture/classes/Standings/positiveStandingChange.png' 16 NEGATIVE_CHANGE_ICON = 'res:/UI/Texture/classes/Standings/negativeStandingChange.png' 17 18 class StandingEntry(SE_BaseClassCore): 19 __guid__ = 'listentry.StandingEntry' 20 __notifyevents__ = ['OnStandingNotificationClicked', 'OnNPCStandingChange'] 21 22 def ApplyAttributes(self, attributes): 23 SE_BaseClassCore.ApplyAttributes(self, attributes) 24 self.standingSvc = sm.GetService('standing') 25 self.isRead = True 26 self.ConstructLayout() 27 sm.RegisterNotify(self) 28 29 def ConstructLayout(self): 30 self.label = eveLabel.EveLabelMedium(name='ownerNameLabel', text='', parent=self, left=36, top=0, state=uiconst.UI_DISABLED, opacity=1.0, maxLines=1, align=uiconst.CENTERLEFT) 31 iconCont = ContainerAutoSize(name='IconContainer', parent=self, align=uiconst.TORIGHT, left=5) 32 unreadIconCont = ContainerAutoSize(name='unreadIconCont', parent=iconCont, align=uiconst.TORIGHT, left=5) 33 self.unreadIcon = Sprite(name='unreadIcon', parent=unreadIconCont, align=uiconst.CENTER, width=8, height=8, rotation=math.pi, hint=localization.GetByLabel('UI/Standings/Common/UnreadStandingsHint'), state=uiconst.UI_DISABLED, opacity=0) 34 self.unreadIcon.OnClick = self.OnClick 35 self.ownerIconContainer = Container(name='iconParent', parent=self, left=1, top=0, width=32, height=32, align=uiconst.TOPLEFT, state=uiconst.UI_PICKCHILDREN) 36 37 def Load(self, node): 38 self.sr.node = node 39 self.standingData = node.standingData 40 self.tooltipPanelClassInfo = StandingBonusTooltip(self.standingData) 41 self.MarkUnreadEntries() 42 text = "%s <color='0x88ffffff'>%s</color>" % (self.standingData.GetStanding2To1Formatted(), self.standingData.GetOwner2Name()) 43 self.label.text = text 44 self.UpdateIcon(node) 45 if node.selected: 46 self.Select() 47 else: 48 self.Deselect() 49 50 def UpdateIcon(self, node): 51 standingData = node.standingData 52 typeID = standingData.GetOwner2TypeID() 53 groupID = evetypes.GetGroupID(typeID) 54 ownerID = standingData.GetOwnerID2() 55 self.ownerIconContainer.Flush() 56 iconParams = {'parent': self.ownerIconContainer, 57 'align': uiconst.TOALL, 58 'state': uiconst.UI_DISABLED, 59 'idx': 0} 60 if groupID in (invconst.groupCorporation, invconst.groupFaction, invconst.groupAlliance): 61 eveIcon.GetLogoIcon(itemID=ownerID, **iconParams) 62 elif groupID == invconst.groupCharacter: 63 logo = eveIcon.Icon(icon=None, **iconParams) 64 sm.GetService('photo').GetPortrait(ownerID, 64, logo) 65 66 def OnDblClick(self, *args): 67 self.ShowInfo() 68 69 def OnClick(self, *args): 70 SE_BaseClassCore.OnClick(self) 71 PlaySound(uiconst.SOUND_ENTRY_SELECT) 72 self.sr.node.scroll.SelectNode(self.sr.node) 73 self.SetAsRead() 74 if self.sr.node.Get('OnClick', None): 75 self.sr.node.OnClick(self) 76 77 def ShowInfo(self, node = None, *args): 78 standingData = self.standingData 79 typeID = standingData.GetOwner2TypeID() 80 ownerID = standingData.GetOwnerID2() 81 sm.GetService('info').ShowInfo(typeID, ownerID) 82 83 def GetMenu(self): 84 standingData = self.standingData 85 return sm.GetService('menu').GetMenuForOwner(standingData.GetOwnerID2()) 86 87 def GetHeight(self, *args): 88 node, width = args 89 node.height = 32 90 return node.height 91 92 def SetAsUnread(self, isPositive): 93 self.isRead = False 94 iconPath = POSITIVE_CHANGE_ICON if isPositive else NEGATIVE_CHANGE_ICON 95 self.unreadIcon.SetTexturePath(iconPath) 96 self.ShowHilite(animate=True) 97 animations.FadeTo(self.unreadIcon, startVal=0, duration=1.0, curveType=uiconst.ANIM_OVERSHOT3, callback=lambda : self.unreadIcon.SetState(uiconst.UI_NORMAL)) 98 99 def SetAsRead(self): 100 self.isRead = True 101 self.standingSvc.RemoveFromUnreadEntries(self.standingData.GetOwnerID2()) 102 self.unreadIcon.SetTexturePath(None) 103 self.HideHilite(animate=True) 104 animations.FadeOut(self.unreadIcon, callback=self.unreadIcon.SetState(uiconst.UI_DISABLED)) 105 106 def OnStandingNotificationClicked(self, entryToOpen): 107 self.MarkUnreadEntries() 108 109 def OnNPCStandingChange(self, fromID, newStanding, oldStanding): 110 self.MarkUnreadEntries() 111 112 def MarkUnreadEntries(self): 113 unreadEntries = self.standingSvc.GetUnreadEntries() 114 if self.standingData.GetOwnerID2() in unreadEntries: 115 self.SetAsUnread(unreadEntries[self.standingData.GetOwnerID2()] > 0) 116 117 def OnMouseExit(self, *args): 118 if not self.unreadIcon.texturePath: 119 super(StandingEntry, self).OnMouseExit(*args) 120 121 @classmethod 122 def GetCopyData(cls, node): 123 textList = [node.standingData.GetStanding2To1Formatted(), node.standingData.GetOwner2Name()] 124 return '\t'.join([ unicode(x) for x in textList ])