icon.py (5156B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\entries\icon.py 2 from carbon.client.script.environment.AudioUtil import PlaySound 3 from carbonui import uiconst 4 from carbonui.control.scrollentries import SE_BaseClassCore 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.fill import Fill 7 from carbonui.primitives.sprite import Sprite 8 from eve.client.script.ui.control.eveLabel import EveLabelMedium 9 from eve.client.script.ui.control.glowSprite import GlowSprite 10 from player_messaging.client.ui_message import prompt_player_fsd_dialog 11 12 class IconEntry(SE_BaseClassCore): 13 __guid__ = 'listentry.IconEntry' 14 __params__ = ['label'] 15 16 def Startup(self, *etc): 17 self.labelleft = 32 18 self.ConstructLabel() 19 self.ConstructIcon() 20 21 def ConstructLabel(self): 22 self.sr.label = EveLabelMedium(text='', parent=self, left=self.labelleft, top=0, width=512, state=uiconst.UI_DISABLED, align=uiconst.CENTERLEFT) 23 24 def ConstructIcon(self): 25 self.icon = GlowSprite(icon='ui_5_64_10', parent=self, pos=(0, 0, 0, 0), align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED) 26 27 def Load(self, node): 28 self.sr.node = node 29 data = node 30 self.sr.label.width = data.Get('maxLabelWidth', 512) 31 self.sr.label.text = data.label 32 if data.Get('icon', None) is not None: 33 self.icon.LoadIcon(data.icon, ignoreSize=True) 34 iconoffset = node.Get('iconoffset', 0) 35 self.icon.left = iconoffset 36 iconsize = node.Get('iconsize', 32) 37 labeloffset = node.Get('labeloffset', 0) 38 self.icon.width = self.icon.height = iconsize 39 self.sr.label.left = iconsize + iconoffset + labeloffset 40 if node.Get('selectable', 1) and node.Get('selected', 0): 41 self.Select() 42 else: 43 self.Deselect() 44 if node.Get('hint', None): 45 self.hint = data.hint 46 47 def OnClick(self, *args): 48 if self.sr.node and self.sr.node.Get('selectable', 1): 49 self.BlinkOff() 50 self.sr.node.scroll.SelectNode(self.sr.node) 51 prompt_player_fsd_dialog('ListEntryClick') 52 if self.sr.node.Get('OnClick', None): 53 self.sr.node.OnClick(self) 54 55 def GetHeight(self, *args): 56 node, width = args 57 iconsize = node.Get('height', node.Get('iconsize', 32)) 58 node.height = iconsize 59 return node.height 60 61 def Blink(self, hint = None, force = 1, blinkcount = 3, frequency = 750, bright = 0): 62 blink = self.GetBlink() 63 blink.state = uiconst.UI_DISABLED 64 sm.GetService('ui').BlinkSpriteRGB(blink, min(1.0, self.r * (1.0 + bright * 0.25)), min(1.0, self.g * (1.0 + bright * 0.25)), min(1.0, self.b * (1.0 + bright * 0.25)), frequency, blinkcount, passColor=1) 65 66 def BlinkOff(self): 67 if self.sr.Get('blink', None) is not None: 68 self.sr.blink.state = uiconst.UI_HIDDEN 69 70 def GetBlink(self): 71 if self.sr.Get('blink', None): 72 return self.sr.blink 73 blink = Fill(bgParent=self, name='hiliteFrame', state=uiconst.UI_HIDDEN, color=(0.28, 0.3, 0.35, 1.0), align=uiconst.TOALL) 74 self.sr.blink = blink 75 self.r = 0.28 76 self.g = 0.3 77 self.b = 0.35 78 return self.sr.blink 79 80 @classmethod 81 def GetCopyData(cls, node): 82 return node.label 83 84 def OnMouseEnter(self, *args): 85 super(IconEntry, self).OnMouseExit(*args) 86 self.icon.OnMouseEnter() 87 88 def OnMouseExit(self, *args): 89 super(IconEntry, self).OnMouseExit(*args) 90 self.icon.OnMouseExit() 91 92 93 class Icons(SE_BaseClassCore): 94 __guid__ = 'listentry.Icons' 95 __params__ = ['icons'] 96 default_showHilite = False 97 98 def Load(self, node): 99 i = 0 100 for each in node.icons: 101 icon, color, identifier, click = each 102 if i >= len(self.children): 103 newicon = Container(parent=self, pos=(0, 104 0, 105 self.height, 106 self.height), name='glassicon', state=uiconst.UI_NORMAL, align=uiconst.RELATIVE) 107 newicon.sr.icon = Sprite(parent=newicon, name='picture', state=uiconst.UI_NORMAL, align=uiconst.TOALL) 108 newicon.sr.color = Fill(parent=newicon, name='color', state=uiconst.UI_DISABLED, color=(0.45, 0.5, 1.0, 1.0)) 109 newicon.left = i * self.height 110 else: 111 newicon = self.children[i] 112 if icon: 113 newicon.sr.icon.LoadTexture(icon) 114 newicon.sr.icon.state = uiconst.UI_DISABLED 115 else: 116 newicon.sr.icon.state = uiconst.UI_HIDDEN 117 if color: 118 newicon.sr.color.SetRGBA(*color) 119 newicon.sr.color.state = uiconst.UI_DISABLED 120 else: 121 newicon.sr.color.state = uiconst.UI_HIDDEN 122 newicon.OnClick = (click, newicon) 123 newicon.OnMouseEnter = self.OnIconMouseEnter 124 newicon.sr.identifier = identifier 125 i += 1 126 127 def OnIconMouseEnter(self, *args): 128 PlaySound(uiconst.SOUND_BUTTON_HOVER)