moonscan.py (7385B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\moonscan.py 2 from carbon.common.script.util.linkUtil import GetShowInfoLink 3 from eve.client.script.ui.control.entries.util import GetFromClass 4 from menu import MenuLabel 5 from carbonui.primitives.container import Container 6 from carbonui.util.various_unsorted import SortListOfTuples 7 from eve.client.script.ui.control.baseListEntry import BaseListEntryCustomColumns 8 from eve.client.script.ui.control.eveLabel import Label 9 from eve.client.script.ui.control.eveScroll import Scroll 10 import evetypes 11 import localization 12 from eve.client.script.ui.control.gauge import Gauge 13 from eve.client.script.ui.control.infoIcon import InfoIcon 14 from eve.client.script.ui.control.itemIcon import ItemIcon 15 from eve.client.script.ui.control.listgroup import ListGroup 16 from eve.client.script.ui.control.themeColored import FillThemeColored 17 from eve.client.script.ui.shared.ledger.ledgerUtil import GetColorForBaseTypeID 18 from eveservices.menu import GetMenuService 19 import carbonui.const as uiconst 20 from carbonui.uicore import uicore 21 import mathext 22 from player_messaging.client.ui_message import prompt_player_fsd_dialog 23 24 class MoonScanView(Container): 25 __update_on_reload__ = 1 26 27 def Startup(self): 28 self.sr.scroll = Scroll(parent=self) 29 self.sr.scroll.sr.id = 'moonsurveyscroll' 30 self.sr.scroll.sr.fixedColumns = MoonProductEntry.GetFixedColumns() 31 self.sr.scroll.GetStrengir = self.GetScrollStrengir 32 33 def ClearAll(self, *args): 34 sm.GetService('moonScan').Clear() 35 36 def Clear(self): 37 self.sr.scroll.Clear() 38 39 def SetEntries(self, entries, moonID = None): 40 scrolllist = [] 41 entries = SortListOfTuples([ (celestialID, (celestialID, products)) for celestialID, products in entries.iteritems() ]) 42 for celestialID, products in entries: 43 if celestialID == moonID: 44 blink = True 45 else: 46 blink = False 47 scrolllist.append(GetFromClass(MoonGroup, {'GetSubContent': self.GetSubContent, 48 'MenuFunction': self.GetMenu, 49 'label': cfg.evelocations.Get(celestialID).name, 50 'groupItems': products, 51 'id': ('moon', celestialID), 52 'tabs': [], 53 'state': 'locked', 54 'showlen': 1, 55 'blink': blink})) 56 57 pos = self.sr.scroll.GetScrollProportion() 58 headers = [localization.GetByLabel('UI/Inflight/Scanner/MoonProduct'), localization.GetByLabel('UI/Common/Quantity')] 59 self.sr.scroll.Load(contentList=scrolllist, headers=headers, scrollTo=pos, noContentHint=localization.GetByLabel('UI/Inflight/Scanner/NoScanResult')) 60 61 def GetSubContent(self, data, *args): 62 scrolllist = [] 63 for typeID, quantity in data.groupItems.iteritems(): 64 name = evetypes.GetName(typeID) 65 roundedQty = mathext.clamp(round(quantity, 2), 0, 1.0) 66 scrolllist.append(GetFromClass(MoonProductEntry, {'label': '%s<t>%s' % (name, roundedQty), 67 'typeName': name, 68 'percentage': roundedQty, 69 'typeID': typeID, 70 'GetMenu': self.OnGetEntryMenu, 71 'itemID': None, 72 'getIcon': 1, 73 'sublevel': 1, 74 'gaugeColor': GetOreColor(typeID)[:3] + (0.6,)})) 75 76 return scrolllist 77 78 def GetMenu(self, entry, *args): 79 celestialID = entry.id[1] 80 noteList = [] 81 for typeID, quantity in entry.groupItems.iteritems(): 82 text = '%s [%s]' % (GetShowInfoLink(typeID, evetypes.GetName(typeID)), quantity) 83 noteList.append(text) 84 85 note = '<br>'.join(noteList) 86 celestialMenu = GetMenuService().CelestialMenu(celestialID, hint=note) 87 return celestialMenu + [None] + [(MenuLabel('UI/Common/Delete'), self.ClearEntry, (celestialID,))] 88 89 def ClearEntry(self, celestialID, *args): 90 if prompt_player_fsd_dialog('DeleteScanResult', {}, uiconst.YESNO, suppress=uiconst.ID_YES) == uiconst.ID_YES: 91 sm.GetService('moonScan').ClearEntry(celestialID) 92 93 def OnGetEntryMenu(self, entry, *args): 94 return GetMenuService().GetMenuFromItemIDTypeID(None, entry.sr.node.typeID, includeMarketDetails=True) 95 96 def GetScrollStrengir(self, node, fontsize, letterspace, shift, idx = None): 97 t = node.typeName 98 if node.panel and node.productNameLabel: 99 label = node.productNameLabel 100 fontsize = label.fontsize 101 letterspace = label.letterspace 102 shift = label.left 103 elif node.decoClass == MoonProductEntry: 104 shift = MoonProductEntry.GetShift(node) 105 return (t, 106 fontsize, 107 letterspace, 108 shift, 109 0) 110 111 112 class MoonGroup(ListGroup): 113 __guid__ = 'MoonGroup' 114 115 def Startup(self, *etc): 116 ListGroup.Startup(self, *etc) 117 self.highlightFill = FillThemeColored(parent=self, padding=(1, 0, 1, 1), colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.15) 118 self.highlightFill.display = False 119 120 def Load(self, node): 121 ListGroup.Load(self, node) 122 if node.blink: 123 self.highlightFill.display = True 124 uicore.animations.BlinkIn(self.highlightFill, startVal=0.0, endVal=0.15, duration=0.5, curveType=uiconst.ANIM_WAVE) 125 node.blink = False 126 127 128 class MoonProductEntry(BaseListEntryCustomColumns): 129 default_name = 'MoonProductEntry' 130 default_height = 32 131 info_icon_offset = 4 132 133 def ApplyAttributes(self, attributes): 134 BaseListEntryCustomColumns.ApplyAttributes(self, attributes) 135 self.sr.infoicon = InfoIcon(left=2, parent=self, idx=0, align=uiconst.CENTERLEFT) 136 self.sr.infoicon.OnClick = self.ShowInfo 137 qtyCol = self.AddColumnContainer() 138 self.icon = ItemIcon(parent=qtyCol, pos=(1, 0, 32, 32), align=uiconst.TOPLEFT, idx=0) 139 self.productNameLabel = Label(parent=qtyCol, text='', align=uiconst.CENTERLEFT, left=28) 140 qtyCont = self.AddColumnContainer() 141 self.gauge = Gauge(parent=qtyCont, name='productGauge', value=0.0, color=(1, 1, 1, 0), gaugeHeight=16, align=uiconst.TOALL, pos=(5, 5, 5, 0), state=uiconst.UI_DISABLED, gradientBrightnessFactor=1.5) 142 self.tempQtyLabel = Label(parent=qtyCont, text='', align=uiconst.CENTERLEFT, left=6) 143 144 def Load(self, node): 145 self.sr.node = node 146 self.typeID = node.typeID 147 self.gauge.SetColor((1, 0, 0, 1)) 148 self.icon.SetTypeID(self.typeID) 149 self.icon.left = node.sublevel * 16 + self.info_icon_offset 150 self.productNameLabel.text = node.typeName 151 self.productNameLabel.left = self.icon.left + self.icon.width + self.info_icon_offset 152 value = node.percentage 153 isNew = True 154 self.gauge.SetValue(value, animate=isNew) 155 self.gauge.SetValueText(value) 156 self.gauge.SetColor(node.gaugeColor) 157 if value >= 1: 158 self.gauge.display = False 159 self.tempQtyLabel.text = value 160 161 def ShowInfo(self): 162 sm.GetService('info').ShowInfo(self.typeID) 163 164 @staticmethod 165 def GetFixedColumns(): 166 return {localization.GetByLabel('UI/Inflight/Scanner/Abundance'): 100} 167 168 @staticmethod 169 def GetShift(node): 170 return node.sublevel * 16 + 33 171 172 173 def GetOreColor(typeID): 174 return GetColorForBaseTypeID(typeID)