class UITree(Window): default_windowID = 'uitree' default_caption = 'UI Roots' default_width = 300 default_height = 400 default_minSize = (default_width, default_height) default_left = '__center__' default_top = '__center__' filterString = None def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) mainArea = self.GetMainArea() mainArea.padding = 6 self._selectedObject = None self.SetTopparentHeight(0) self._infoContainer = Container(parent=mainArea, align=uiconst.TOTOP, height=72) self.searchInput = SinglelineEdit(parent=self._infoContainer, align=uiconst.BOTTOMRIGHT, left=4, top=8, width=100, OnChange=self.OnSearchInputChange, hinttext='Search') self.searchInput.SetHistoryVisibility(False) self.searchInput.ShowClearButton() m = UtilMenu(menuAlign=uiconst.TOPRIGHT, parent=self._infoContainer, align=uiconst.TOPRIGHT, GetUtilMenu=self.SettingMenu) self._infoLabel = Label(parent=self._infoContainer, state=uiconst.UI_DISABLED, color=(1.0, 1.0, 1.0, 0.75), left=2) self.searchResultParent = ContainerAutoSize(parent=mainArea, align=uiconst.TOTOP_NOPUSH, padding=(26, -6, 4, 0), bgColor=(0.5, 0.5, 0.5, 1)) self.attributeScroll = Scroll(parent=mainArea, align=uiconst.TOBOTTOM, name='attributeScroll') self.attributeScroll.height = min( self.height / 2, max(72, settings.user.ui.Get('uitree_attributeScroll_height', 200))) settings.user.ui.Set('uitree_attributeScroll_height', self.attributeScroll.height) self.divider = Divider(align=uiconst.TOBOTTOM, parent=mainArea, height=11, state=uiconst.UI_NORMAL) self.divider.OnChange_ = self.OnDividerMove self.divider.OnChangeStart_ = self.OnDividerMoveStart Fill(parent=self.divider, align=uiconst.CENTER, pos=(0, 0, 20, 1)) self.scroll = Scroll(parent=mainArea, name='treeScroll') self._hiliteFrame = Fill(parent=uicore.desktop, align=uiconst.ABSOLUTE, color=(0, 1, 0, 0.3), idx=0, state=uiconst.UI_DISABLED) self._selectedFrame = Frame(parent=uicore.desktop, align=uiconst.ABSOLUTE, color=(0, 1, 0, 0.3), idx=0, state=uiconst.UI_DISABLED) self.ReloadUIRoots() uthread.new(self.UpdateInfo) self._keyDownCookie = uicore.uilib.RegisterForTriuiEvents( [uiconst.UI_KEYDOWN], self.OnGlobalKeyDown) def OnSearchInputChange(self, *args): self.searchThread = base.AutoTimer(250, self.SearchTree) def SearchTree(self): self.searchThread = None self.filterString = self.searchInput.GetValue() if not self.filterString: self.searchResultParent.Hide() self.searchResultParent.Flush() return self.searchResultParent.Flush() res = [] searchFor = self.filterString.lower() def Crawl(obj, path): if obj is self: return if searchFor in obj.name.lower(): if path: res.append((obj, path + '/ <b>' + obj.name + '</b>')) else: res.append((obj, '<b>' + obj.name + '</b>')) if hasattr(obj, 'children'): for each in obj.children: if path: Crawl(each, path + '/' + obj.name) else: Crawl(each, obj.name) for root in uicore.uilib.rootObjects: Crawl(root, '') if res: for obj, path in res[:20]: label = Label(parent=self.searchResultParent, align=uiconst.TOTOP, text=path, state=uiconst.UI_NORMAL, padding=(10, 2, 10, 2)) label._searchObj = obj label.hint = path label.OnClick = (self.OnSearchResultClick, obj) if len(res) > 20: Label(parent=self.searchResultParent, align=uiconst.TOTOP, text='and even more... (%s found)' % len(res), padding=(10, 2, 10, 2)) else: Label(parent=self.searchResultParent, align=uiconst.TOTOP, text='No Match!', padding=(10, 3, 10, 3)) self.searchResultParent.Show() def OnSearchResultClick(self, obj): self.searchResultParent.Hide() self.ShowUIObject(obj) def _OnSizeChange_NoBlock(self, *args, **kwds): Window._OnSizeChange_NoBlock(self, *args, **kwds) self.attributeScroll.height = min( self.height / 2, max(72, settings.user.ui.Get('uitree_attributeScroll_height', 200))) settings.user.ui.Set('uitree_attributeScroll_height', self.attributeScroll.height) def OnDividerMove(self, divider, dx, dy): self.attributeScroll.height = min( self.height / 2, max(72, self._initAttributeScrollHeight - dy)) settings.user.ui.Set('uitree_attributeScroll_height', self.attributeScroll.height) def OnDividerMoveStart(self, *args): self._initAttributeScrollHeight = self.attributeScroll.height def SettingMenu(self, menuParent, *args): checked = settings.user.ui.Get('uitreeShowPickHilite', True) menuParent.AddCheckBox(text='Show pick hilite', checked=checked, callback=(self.ToggleCheckboxSetting, 'ShowPickHilite')) checked = settings.user.ui.Get('uitreeIgnoreFullScreenPick', False) menuParent.AddCheckBox(text='Ignore fullscreen hilite', checked=checked, callback=(self.ToggleCheckboxSetting, 'IgnoreFullScreenPick')) menuParent.AddIconEntry(icon=None, text='Move To Desktop', callback=self.MoveToDesktop) menuParent.AddIconEntry(icon=None, text='Reload Textures', callback=self.ReloadTextures) def ReloadTextures(self): import blue for resPath in blue.motherLode.GetNonCachedKeys( ) + blue.motherLode.GetCachedKeys(): if resPath.lower().startswith('res:/ui'): res = blue.motherLode.Lookup(resPath) if res: if hasattr(res, 'Reload'): res.Reload() def MoveToDesktop(self): self.SetParent(uicore.desktop, idx=0) def ToggleCheckboxSetting(self, settingName, *args): checked = settings.user.ui.Get('uitree' + settingName, True) settings.user.ui.Set('uitree' + settingName, not checked) def Close(self, *args, **kwds): frame = getattr(self, '_hiliteFrame', None) if frame: frame.Close() if getattr(self, '_selectedFrame', None): self._selectedFrame.Close() Window.Close(self, *args, **kwds) def OnGlobalKeyDown(self, *args, **kwds): if self.destroyed: return False ctrl = uicore.uilib.Key(uiconst.VK_CONTROL) alt = uicore.uilib.Key(uiconst.VK_MENU) if ctrl and not (IsUnder(uicore.uilib.mouseOver, self) or uicore.uilib.mouseOver is self): self.ShowUIObject(uicore.uilib.mouseOver) return True def UpdateInfo(self): while not self.destroyed: mo = uicore.uilib.mouseOver if mo: infoText = 'MouseOver: %s' % mo.name else: infoText = 'MouseOver: None' active = uicore.registry.GetActive() if active: infoText += '<br>Active: %s' % active.name else: infoText += '<br>Active: None' focus = uicore.registry.GetFocus() if focus: infoText += '<br>Focus: %s' % (focus.name or focus.__guid__) else: infoText += '<br>Focus: None' capture = uicore.uilib.GetMouseCapture() if capture: infoText += '<br>Capture: %s' % (capture.name or capture.__guid__) else: infoText += '<br>Capture: None' infoText += '<br>MouseX/Y: %s, %s' % (uicore.uilib.x, uicore.uilib.y) showHilite = settings.user.ui.Get('uitreeShowPickHilite', True) ignoreFullScreenPick = settings.user.ui.Get( 'uitreeIgnoreFullScreenPick', False) hiliteUIObject = None if showHilite: if IsUnder(mo, self): if IsUnder(mo, self.scroll): uiObjectGetAbs = GetAttrs(mo, 'sr', 'node', 'uiObject', 'GetAbsolute') if uiObjectGetAbs: hiliteUIObject = GetAttrs(mo, 'sr', 'node', 'uiObject') elif mo is not uicore.desktop and mo is not self and not IsUnder( mo, self) and self.state == uiconst.UI_NORMAL: hiliteUIObject = mo if hiliteUIObject and ignoreFullScreenPick and isinstance( hiliteUIObject, (LayerCore, UIRoot)): hiliteUIObject = None self.ShowHilitedObjectInUI(hiliteUIObject) selectedObject = None if self._selectedObject: selectedObject = self._selectedObject() if getattr(selectedObject, 'destroyed', False): selectedObject = None for node in self.scroll.sr.nodes: if node.panel: node.panel.UpdateSelected(selectedObject) node.panel.UpdatePickHilite(hiliteUIObject) if getattr(node.uiObject, 'destroyed', False): node.panel.CheckDestroyed() self.ShowSelectedObjectInUI(selectedObject) self._infoLabel.text = infoText self._infoContainer.height = self._infoLabel.textheight + 5 blue.pyos.synchro.SleepWallclock(100) def ShowSelectedObjectInUI(self, uiObject): if uiObject and hasattr(uiObject, 'GetAbsolute'): self._selectedFrame.pos = uiObject.GetAbsolute() self._selectedFrame.display = True else: self._selectedFrame.display = False def ShowHilitedObjectInUI(self, uiObject): if self.destroyed: return if uiObject: self._hiliteFrame.pos = uiObject.GetAbsolute() self._hiliteFrame.display = True else: self._hiliteFrame.display = False def ReloadUIRoots(self, *args): startRoot = uicore.uilib.rootObjects scrollNodes = [] for root in startRoot: self._CrawlUIObject(root, scrollNodes, 0) self.scroll.LoadContent(contentList=scrollNodes) def _AddUIObject(self, uiObject, scrollList, lvl, isExpanded=False, objectLabel=None, isExpandable=False): if len(scrollList) > 1 and lvl: for i in xrange(1, len(scrollList) - 1): last = scrollList[-i] if last.level < lvl: break if lvl not in last.connectLevels: last.connectLevels.append(lvl) node = ScrollEntryNode(decoClass=UITreeEntry, uiObject=uiObject, level=lvl, isExpanded=isExpanded, objectLabel=objectLabel, isExpandable=isExpandable, connectLevels=[lvl]) scrollList.append(node) def IsExpanded(self, uiObject): desktopObjectID = id(uicore.desktop) allPrefs = settings.user.ui.Get('UITreeExpandedObjects', {}) if desktopObjectID not in allPrefs: return False uiObjectID = id(uiObject) if getattr(uiObject, 'parent', None): uiObjectID = (id(uiObject.parent), uiObjectID) return uiObjectID in allPrefs[desktopObjectID] def ExpandUIObject(self, uiObject): uiObjectID = id(uiObject) if getattr(uiObject, 'parent', None): uiObjectID = (id(uiObject.parent), uiObjectID) desktopObjectID = id(uicore.desktop) allPrefs = settings.user.ui.Get('UITreeExpandedObjects', {}) if desktopObjectID not in allPrefs: allPrefs[desktopObjectID] = [] if uiObjectID not in allPrefs[desktopObjectID]: allPrefs[desktopObjectID].append(uiObjectID) settings.user.ui.Set('UITreeExpandedObjects', allPrefs) def ToggleExpandedObject(self, uiObject): uiObjectID = id(uiObject) if getattr(uiObject, 'parent', None): uiObjectID = (id(uiObject.parent), uiObjectID) desktopObjectID = id(uicore.desktop) allPrefs = settings.user.ui.Get('UITreeExpandedObjects', {}) if desktopObjectID not in allPrefs: allPrefs[desktopObjectID] = [] if uiObjectID in allPrefs[desktopObjectID]: allPrefs[desktopObjectID].remove(uiObjectID) else: allPrefs[desktopObjectID].append(uiObjectID) settings.user.ui.Set('UITreeExpandedObjects', allPrefs) self.ReloadUIRoots() def _CrawlUIObject(self, uiObject, scrollNodes, lvl, objectLabel=None): """Defines what to show in the tree""" isExpandable = UITree._IsExpandable(uiObject) if isExpandable: isExpanded = self.IsExpanded(uiObject) else: isExpanded = False self._AddUIObject(uiObject, scrollNodes, lvl, isExpanded, objectLabel=objectLabel, isExpandable=isExpandable) if isExpanded: if isinstance(uiObject, Base): allPy = dir(uiObject) for propertyName in allPy: if propertyName.startswith( '_') or propertyName in IGNORE_PROPERTIES: continue try: prop = getattr(uiObject, propertyName, None) except: print 'Failed on property', propertyName continue try: if getattr(prop, 'TypeInfo', None): self._CrawlUIObject(prop, scrollNodes, lvl + 1, objectLabel=propertyName) except (KeyError, RuntimeError): pass for dictName in PYOBJECT_SUBDICTS: dct = getattr(uiObject, dictName, {}) if dct: for k, v in dct.iteritems(): self._CrawlUIObject(v, scrollNodes, lvl + 1, objectLabel='%s: %s' % (dictName.lstrip('_'), k)) for listName in PYOBJECT_SUBLISTS: lst = getattr(uiObject, listName, []) if lst: for objChild in lst: if listName == 'background': self._CrawlUIObject(objChild, scrollNodes, lvl + 1, objectLabel=listName) else: self._CrawlUIObject(objChild, scrollNodes, lvl + 1) else: allC = dir(uiObject) for propertyName in allC: if propertyName.startswith('_'): continue prop = getattr(uiObject, propertyName, None) if callable(prop): continue if getattr(prop, '__bluetype__', None) == 'blue.List': isExpanded = self.IsExpanded(prop) self._AddUIObject(prop, scrollNodes, lvl + 1, isExpanded, isExpandable=True, objectLabel='%s (%s)' % (propertyName, len(prop))) if isExpanded: for each in prop: self._CrawlUIObject(each, scrollNodes, lvl + 2) continue elif getattr(prop, '__bluetype__', None) == 'blue.Dict': isExpanded = self.IsExpanded(prop) self._AddUIObject(prop, scrollNodes, lvl + 1, isExpanded, isExpandable=True, objectLabel=propertyName) if isExpanded: for k, v in prop.items(): self._CrawlUIObject(v, scrollNodes, lvl + 2, objectLabel=k) continue elif hasattr(prop, 'TypeInfo'): self._CrawlUIObject(prop, scrollNodes, lvl + 1, objectLabel=propertyName) @classmethod def _IsExpandable(cls, uiObject): if isinstance(uiObject, Base): return True allC = dir(uiObject) for propertyName in allC: if propertyName.startswith('_'): continue prop = getattr(uiObject, propertyName, None) if getattr(prop, '__bluetype__', None) in ('blue.List', 'blue.Dict'): return True if hasattr(prop, 'TypeInfo'): return True return False def ShowUIObject(self, uiObject): traceUp = [uiObject] parent = uiObject.parent while parent: traceUp.insert(0, parent) parent = parent.parent for each in traceUp: self.ExpandUIObject(each) self.ShowPropertiesForObject(uiObject) for node in self.scroll.sr.nodes: if node.uiObject is uiObject: self.scroll.ShowNodeIdx(node.idx) break def ShowPropertiesForObject(self, uiObject): if uiObject is None: return try: len(uiObject) self.attributeScroll.LoadContent(contentList=[]) return except: pass self._selectedObject = weakref.ref(uiObject) level = 0 newNodes = [] if isinstance(uiObject, Base): combined = [] if hasattr(uiObject, 'color'): combined.append( ('color', ('color.r', 'color.g', 'color.b', 'color.a'))) for propertyName, subs in combined: propertyNode = ScrollEntryNode(decoClass=UITreePropertyEntry, uiObject=uiObject, level=level, propertyName=propertyName, combineProperties=subs) newNodes.append(propertyNode) basics = [ 'name', 'pos', 'opacity', 'padding', 'displayRect', 'display', 'pickState', 'align', 'clipChildren', 'pickRadius', 'absoluteCoordinates', 'cacheContents', 'text', 'blendMode', 'spriteEffect', 'effectAmount', 'effectAmount2', 'glowColor', 'glowFactor', 'glowExpand', 'useSizeFromTexture', 'rotation', 'rotationCenter', 'scale', 'scalingCenter', 'scalingRotation', '', '__guid__', '__class__' ] for propertyName in basics: prop = getattr(uiObject, propertyName, '_!_') if prop == '_!_': continue propertyNode = ScrollEntryNode(decoClass=UITreePropertyEntry, uiObject=uiObject, level=level, propertyName=propertyName) newNodes.append(propertyNode) else: for attr in dir(uiObject): if attr[0] == attr[0].upper(): continue if attr[0] == '_': continue if attr in ('children', 'background'): continue propertyNode = ScrollEntryNode(decoClass=UITreePropertyEntry, uiObject=uiObject, level=level, propertyName=attr) newNodes.append((attr, propertyNode)) newNodes = SortListOfTuples(newNodes) self.ReloadUIRoots() self.attributeScroll.LoadContent(contentList=newNodes)
class InfoBubbleRace(Container): default_name = 'InfoBubbleRace' default_alignMode = uiconst.TOTOP __notifyevents__ = ('OnShipTreeFactionButtonEnter', 'OnShipTreeFactionButtonExit', 'OnShipTreeFactionSelected') def ApplyAttributes(self, attributes): super(InfoBubbleRace, self).ApplyAttributes(attributes) sm.RegisterNotify(self) self.factionID = attributes.factionID self.mainCont = Container(name='mainCont', parent=self) self.content = ContainerAutoSize(name='mainCont', parent=self.mainCont, align=uiconst.TOTOP, callback=self.OnMainContResize) self.bgFrame = Container(name='bgFrame', parent=self, state=uiconst.UI_DISABLED) self.frameTop = StretchSpriteHorizontal( name='frameTop', parent=self.bgFrame, align=uiconst.TOTOP, texturePath= 'res:/UI/Texture/classes/ShipTree/InfoBubble/frameUpper.png', height=36) self.frameBottom = StretchSpriteHorizontal( name='frameBottom', parent=self.bgFrame, align=uiconst.TOBOTTOM, texturePath= 'res:/UI/Texture/classes/ShipTree/InfoBubble/frameLower.png', height=36) self.bgFill = Container(name='bgFill', parent=self, state=uiconst.UI_DISABLED) StretchSpriteHorizontal( parent=self.bgFill, align=uiconst.TOTOP, texturePath= 'res:/UI/Texture/classes/ShipTree/InfoBubble/backTopExtender.png', height=1) StretchSpriteHorizontal( parent=self.bgFill, align=uiconst.TOBOTTOM, texturePath= 'res:/UI/Texture/classes/ShipTree/InfoBubble/backBottom.png', height=6) Sprite(parent=self.bgFill, align=uiconst.TOALL, texturePath= 'res:/UI/Texture/classes/ShipTree/InfoBubble/backMiddle.png') topCont = ContainerAutoSize(name='topContainer', parent=self.content, align=uiconst.TOTOP, padding=(10, 10, 10, 0), height=50) topRightCont = ContainerAutoSize(parent=topCont, align=uiconst.TOPLEFT, left=64, width=190) self.icon = Sprite(name='icon', parent=topCont, pos=(0, 0, 64, 64), align=uiconst.TOPLEFT) self.caption = EveCaptionSmall(parent=topRightCont, align=uiconst.TOTOP) self.attributeCont = ContainerAutoSize(name='attributeCont', parent=topRightCont, align=uiconst.TOTOP, height=30, padTop=5) self.descriptionLabel = Label(name='descriptionLabel', parent=self.content, align=uiconst.TOTOP, padding=(10, 6, 10, 10)) self.ShowFaction(self.factionID) def OnMainContResize(self): self.height = self.content.height def UpdateFaction(self, factionID): self.factionID = factionID self.ShowFaction(factionID) def ShowFaction(self, factionID, animate=True): self.icon.texturePath = ICON_BY_FACTIONID.get(factionID) self.caption.text = cfg.factions.Get(factionID).factionName factionData = cfg.infoBubbleFactions[factionID] self.attributeCont.Flush() for _, attributeID in factionData['elements'].iteritems(): InfoBubbleAttributeIcon(parent=self.attributeCont, align=uiconst.TOLEFT, attributeID=attributeID, opacity=1.0, width=self.attributeCont.height) self.descriptionLabel.text = localization.GetByMessageID( factionData['descriptionID']) def OnShipTreeFactionButtonEnter(self, factionID): self.ShowFaction(factionID, animate=False) def OnShipTreeFactionButtonExit(self, factionID): self.ShowFaction(self.factionID, animate=False)
class CharacterSheetWindow(uicontrols.Window): __guid__ = 'form.CharacterSheet' default_width = 497 default_height = 456 default_minSize = (497, 456) default_left = 0 default_top = 32 default_windowID = 'charactersheet' default_captionLabelPath = 'UI/CharacterSheet/CharacterSheetWindow/CharacterSheetCaption' default_descriptionLabelPath = 'Tooltips/Neocom/CharacterSheet_description' default_iconNum = 'res:/ui/Texture/WindowIcons/charactersheet.png' default_scope = 'station_inflight' default_topParentHeight = 0 __notifyevents__ = ['OnGodmaItemChange', 'OnSkillsChanged'] def OnUIRefresh(self): pass @telemetry.ZONE_METHOD def ApplyAttributes(self, attributes): uicontrols.Window.ApplyAttributes(self, attributes) panelID = attributes.panelID self.loadingHeader = False self.loading = False self.currPanel = None self.topCont = ContainerAutoSize(name='topCont', parent=self.sr.main, align=uiconst.TOTOP, alignMode=uiconst.TOPLEFT, clipChildren=True, padRight=3) self.leftCont = Container(name='leftSide', parent=self.sr.main, align=uiconst.TOLEFT, left=const.defaultPadding, width=settings.user.ui.Get( 'charsheetleftwidth', 200)) self.panelSelectScroll = uicontrols.Scroll(name='panelSelectScroll', parent=self.leftCont, padding=(0, 4, 0, 4), multiSelect=False) self.panelSelectScroll.OnSelectionChange = self.OnSelectEntry self.mainCont = Container(name='mainCont', parent=self.sr.main, align=uiconst.TOALL, padRight=4) self.ConstructDivider() self.panelCont = Container(name='panelCont', parent=self.mainCont) self.employmentHistoryPanel = EmploymentHistoryPanel( parent=self.panelCont, state=uiconst.UI_HIDDEN) self.jumpClonesPanel = JumpClonesPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN) self.killRightsPanel = KillRightsPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN) self.attributesPanel = AttributesPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN) self.decorationsPanel = DecorationsPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN) self.plexPanel = PLEXPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN) self.skinsPanel = SkinsPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN, padding=(0, 4, 0, 4)) self.bioPanel = BioPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN) self.implantsBoostersPanel = ImplantsBoostersPanel( parent=self.panelCont, state=uiconst.UI_HIDDEN) self.standingsPanel = StandingsPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN) self.securityStatusPanel = SecurityStatusPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN) self.skillsPanel = SkillsPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN, padTop=2) self.combatLogPanel = CombatLogPanel(parent=self.panelCont, state=uiconst.UI_HIDDEN) self.ConstructHeader() self.ConstructPanelSelectScroll() if panelID: self.LoadPanel(panelID) else: self.LoadDefaultPanel() self._CheckShowT3ShipLossMessage() def LoadDefaultPanel(self): self.panelSelectScroll.SetSelected( min( len(TABS) - 1, settings.char.ui.Get('charactersheetselection', 0))) def ConstructDivider(self): divider = Divider(name='divider', align=uiconst.TOLEFT, width=const.defaultPadding - 1, parent=self.mainCont, state=uiconst.UI_NORMAL) divider.Startup(self.leftCont, 'width', 'x', 84, 220) self.sr.divider = divider def ConstructHeader(self): if self.loadingHeader: return self.loadingHeader = True self.topCont.Flush() characterName = cfg.eveowners.Get(session.charid).name if not getattr(self, 'charMgr', None): self.charMgr = sm.RemoteSvc('charMgr') if not getattr(self, 'cc', None): self.charsvc = sm.GetService('cc') self.sr.charinfo = charinfo = self.charMgr.GetPublicInfo( session.charid) if settings.user.ui.Get('charsheetExpanded', 1): parent = self.topCont self.sr.picParent = Container(name='picpar', parent=parent, align=uiconst.TOPLEFT, width=200, height=200, left=const.defaultPadding, top=16) self.sr.pic = Sprite(parent=self.sr.picParent, align=uiconst.TOALL, left=1, top=1, height=1, width=1) self.sr.pic.OnClick = self.OpenPortraitWnd self.sr.pic.cursor = uiconst.UICURSOR_MAGNIFIER uicontrols.Frame(parent=self.sr.picParent, opacity=0.2) sm.GetService('photo').GetPortrait(session.charid, 256, self.sr.pic) infoTextPadding = self.sr.picParent.width + const.defaultPadding * 4 characterLink = GetByLabel( 'UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=characterName, info=('showinfo', const.typeCharacterAmarr, session.charid)) self.sr.nameText = uicontrols.EveCaptionMedium( text=characterLink, parent=self.topCont, left=infoTextPadding, top=12, state=uiconst.UI_NORMAL) self.sr.raceinfo = raceinfo = cfg.races.Get(charinfo.raceID) self.sr.bloodlineinfo = bloodlineinfo = cfg.bloodlines.Get( charinfo.bloodlineID) self.sr.schoolinfo = schoolinfo = self.charsvc.GetData( 'schools', ['schoolID', charinfo.schoolID]) self.sr.ancestryinfo = ancestryinfo = self.charsvc.GetData( 'ancestries', ['ancestryID', charinfo.ancestryID]) if self.destroyed: self.loadingHeader = False return securityStatus = sm.GetService( 'crimewatchSvc').GetMySecurityStatus() roundedSecurityStatus = localization.formatters.FormatNumeric( securityStatus, decimalPlaces=1) cloneLocationRow = sm.RemoteSvc('charMgr').GetHomeStationRow() if cloneLocationRow: stationID = cloneLocationRow.stationID cloneLocationSystemID = cloneLocationRow.solarSystemID if cloneLocationSystemID: labelPath = 'UI/CharacterSheet/CharacterSheetWindow/CloneLocationHint' cloneLocationHint = GetByLabel( labelPath, locationId=stationID, systemId=cloneLocationSystemID) cloneLocation = cfg.evelocations.Get( cloneLocationSystemID).name else: cloneLocationHint = cfg.evelocations.Get(stationID).name cloneLocation = GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/UnknownSystem') else: cloneLocation = GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/UnknownSystem') cloneLocationHint = '' alliance = '' if session.allianceid: cfg.eveowners.Prime([session.allianceid]) alliance = (GetByLabel('UI/Common/Alliance'), cfg.eveowners.Get(session.allianceid).name, '') faction = '' if session.warfactionid: fac = sm.StartService('facwar').GetFactionalWarStatus() faction = (GetByLabel('UI/Common/Militia'), cfg.eveowners.Get(fac.factionID).name, '') bounty = '' bountyOwnerIDs = (session.charid, session.corpid, session.allianceid) bountyAmount = sm.GetService('bountySvc').GetBounty( *bountyOwnerIDs) bountyAmounts = sm.GetService('bountySvc').GetBounties( *bountyOwnerIDs) charBounty = 0 corpBounty = 0 allianceBounty = 0 if len(bountyAmounts): for ownerID, value in bountyAmounts.iteritems(): if util.IsCharacter(ownerID): charBounty = value elif util.IsCorporation(ownerID): corpBounty = value elif util.IsAlliance(ownerID): allianceBounty = value bountyHint = GetByLabel('UI/Station/BountyOffice/BountyHint', charBounty=util.FmtISK(charBounty, 0), corpBounty=util.FmtISK(corpBounty, 0), allianceBounty=util.FmtISK( allianceBounty, 0)) bounty = (GetByLabel('UI/Station/BountyOffice/Bounty'), util.FmtISK(bountyAmount, 0), bountyHint) skillPoints = int(sm.GetService('skills').GetSkillPoints()) textList = [ (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/SkillPoints'), localization.formatters.FormatNumeric(skillPoints, useGrouping=True), ''), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/HomeSystem'), cloneLocation, cloneLocationHint), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/CharacterBackground' ), GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/CharacterBackgroundInformation', raceName=localization.GetByMessageID(raceinfo.raceNameID), bloodlineName=localization.GetByMessageID( bloodlineinfo.bloodlineNameID), ancestryName=localization.GetByMessageID( ancestryinfo.ancestryNameID)), GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/CharacterBackgroundHint' )), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DateOfBirth'), localization.formatters.FormatDateTime( charinfo.createDateTime, dateFormat='long', timeFormat='long'), ''), (GetByLabel('UI/CharacterSheet/CharacterSheetWindow/School'), localization.GetByMessageID(schoolinfo.schoolNameID), ''), (GetByLabel('UI/Common/Corporation'), cfg.eveowners.Get(session.corpid).name, ''), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/SecurityStatus'), roundedSecurityStatus, localization.formatters.FormatNumeric(securityStatus, decimalPlaces=4)) ] if faction: textList.insert(len(textList) - 1, faction) if alliance: textList.insert(len(textList) - 1, alliance) if bounty: textList.insert(len(textList), bounty) numLines = len(textList) + 2 mtext = 'Xg<br>' * numLines mtext = mtext[:-4] th = GetTextHeight(mtext) topParentHeight = max(220, th + const.defaultPadding * 2 + 2) top = max(34, self.sr.nameText.top + self.sr.nameText.height) leftContainer = Container(parent=self.topCont, left=infoTextPadding, top=top, align=uiconst.TOPLEFT) rightContainer = Container(parent=self.topCont, top=top, align=uiconst.TOPLEFT) subTop = 0 for label, value, hint in textList: label = uicontrols.EveLabelMedium(text=label, parent=leftContainer, idx=0, state=uiconst.UI_NORMAL, align=uiconst.TOPLEFT, top=subTop) label.hint = hint label._tabMargin = 0 display = uicontrols.EveLabelMedium(text=value, parent=rightContainer, idx=0, state=uiconst.UI_NORMAL, align=uiconst.TOPLEFT, top=subTop) display.hint = hint display._tabMargin = 0 subTop += label.height leftContainer.AutoFitToContent() rightContainer.left = leftContainer.left + leftContainer.width + 20 rightContainer.AutoFitToContent() self.topCont.EnableAutoSize() else: self.topCont.DisableAutoSize() self.topCont.height = 18 charsheetExpanded = settings.user.ui.Get('charsheetExpanded', 1) if not charsheetExpanded: uicontrols.EveLabelMedium(text=characterName, parent=self.topCont, left=8, top=1, state=uiconst.UI_DISABLED) expandOptions = [ GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Expand'), GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Collapse') ] a = uicontrols.EveLabelSmall(text=expandOptions[charsheetExpanded], parent=self.topCont, left=15, top=3, state=uiconst.UI_NORMAL, align=uiconst.TOPRIGHT, bold=True) a.OnClick = self.ToggleGeneral expander = Sprite(parent=self.topCont, pos=(3, 2, 11, 11), name='expandericon', state=uiconst.UI_NORMAL, texturePath=[ 'res:/UI/Texture/Shared/expanderDown.png', 'res:/UI/Texture/Shared/expanderUp.png' ][charsheetExpanded], align=uiconst.TOPRIGHT) expander.OnClick = self.ToggleGeneral self.loadingHeader = False def LoadPanel(self, panelID): for entry in self.panelSelectScroll.GetNodes(): if entry.key == panelID: self.panelSelectScroll.SelectNode(entry) return def OnSelectEntry(self, node): if node != []: self._LoadPanel(node[0].key) settings.char.ui.Set('charactersheetselection', node[0].idx) def _LoadPanel(self, panelID, subPanelID=None): if self.loading or self.GetPanelByID(panelID) == self.currPanel: return self.loading = True try: if self.currPanel: self.currPanel.Hide() if hasattr(self.currPanel, 'UnloadPanel'): self.currPanel.UnloadPanel() self.currPanel = self.GetPanelByID(panelID) self.currPanel.state = uiconst.UI_PICKCHILDREN self.currPanel.LoadPanel() finally: self.loading = False def GetPanelByID(self, panelID): if panelID == PANEL_STANDINGS: return self.standingsPanel if panelID == PANEL_SKILLS: return self.skillsPanel if panelID == PANEL_DECORATIONS: return self.decorationsPanel if panelID == PANEL_COMBATLOG: return self.combatLogPanel if panelID == PANEL_ATTRIBUTES: return self.attributesPanel if panelID == PANEL_IMPLANTSBOOTERS: return self.implantsBoostersPanel if panelID == PANEL_BIO: return self.bioPanel if panelID == PANEL_SECURITYSTATUS: return self.securityStatusPanel if panelID == PANEL_KILLRIGHTS: return self.killRightsPanel if panelID == PANEL_JUMPCLONES: return self.jumpClonesPanel if panelID == PANEL_EMPLOYMENT: return self.employmentHistoryPanel if panelID == PANEL_PLEX: return self.plexPanel if panelID == PANEL_SHIPSKINS: return self.skinsPanel def GetActivePanel(self): return self.currPanel def HideAllPanels(self): for panel in self.panelCont.children: panel.Hide() def OpenPortraitWnd(self, *args): PortraitWindow.CloseIfOpen() PortraitWindow.Open(charID=session.charid) def ToggleGeneral(self, *args): charsheetExpanded = not settings.user.ui.Get('charsheetExpanded', 1) settings.user.ui.Set('charsheetExpanded', charsheetExpanded) self.ConstructHeader() def ConstructPanelSelectScroll(self): scrolllist = [] for label, icon, key, UIName, descriptionLabelPath in TABS: data = util.KeyVal() label = GetByLabel(label) data.text = label data.label = label data.icon = icon data.key = key data.hint = label data.name = UIName data.line = False data.labeloffset = 4 data.tooltipPanelClassInfo = TooltipHeaderDescriptionWrapper( header=label, description=GetByLabel(descriptionLabelPath), tooltipPointer=uiconst.POINT_RIGHT_2) scrolllist.append(listentry.Get('IconEntry', data=data)) self.panelSelectScroll.Load(contentList=scrolllist) def GetSelected(self): return self.panelSelectScroll.GetSelected() def DeselectAll(self): self.panelSelectScroll.DeselectAll() def SetSelected(self, idx): self.panelSelectScroll.SetSelected(idx) @telemetry.ZONE_METHOD def _CheckShowT3ShipLossMessage(self): lossMessages = sm.StartService('skills').GetRecentLossMessages() for messageTuple in lossMessages: messageType, messageDict = messageTuple uicore.Message(messageType, messageDict) if len(lossMessages): sm.GetService('skills').ResetSkillHistory() def Close(self, *args, **kwds): settings.user.ui.Set('charsheetleftwidth', self.leftCont.width) uicontrols.Window.Close(self, *args, **kwds) def OnGodmaItemChange(self, item, change): self.ConstructHeader() def OnSkillsChanged(self, *args): self.ConstructHeader() @classmethod def OpenCertificates(cls): panelID = PANEL_SKILLS_CERTIFICATES wnd = cls._OpenSkillSubPanel(panelID) return wnd @classmethod def _OpenSkillSubPanel(cls, panelID): wnd = cls.GetIfOpen() if wnd: wnd.LoadPanel(PANEL_SKILLS) else: wnd = cls.Open(panelID=PANEL_SKILLS) uthread.new(wnd.GetPanelByID(PANEL_SKILLS).SelectTab, panelID) return wnd @classmethod def OpenSkills(cls): panelID = PANEL_SKILLS_SKILLS wnd = cls._OpenSkillSubPanel(panelID) return wnd @classmethod def OpenSkillHistory(cls): panelID = PANEL_SKILLS_HISTORY wnd = cls._OpenSkillSubPanel(panelID) return wnd @classmethod def OpenSkillHistoryHilightSkills(cls, skillIDs): uthread.new(cls._HighlightSkillHistorySkills, skillTypeIds=skillIDs) @classmethod def _HighlightSkillHistorySkills(cls, skillTypeIds): wnd = cls.OpenSkillHistory() wnd.GetPanelByID(PANEL_SKILLS).HighlightSkillHistorySkills( skillTypeIds) def DeselectAllNodes(self, wnd): for node in wnd.sr.scroll.GetNodes(): wnd.sr.scroll._DeselectNode(node)
class AchievementAuraWindow(Window): default_captionLabelPath = 'UI/Achievements/OpportunitiesHint' default_windowID = 'AchievementAuraWindow' default_width = WINDOW_WIDTH default_fixedWidth = default_width default_height = 160 default_fixedHeight = default_height default_left = 370 default_top = '__center__' default_topParentHeight = 0 default_isCollapseable = False aura = None activeStep = None animHeight = 0 transitionBox = None fadeoutState = None def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.MakeUnMinimizable() self.MakeUnpinable() self.MakeUnstackable() mainArea = self.GetMainArea() mainArea.clipChildren = True self.isFadingOut = False leftSide = Container(parent=mainArea, align=uiconst.TOLEFT, width=AURA_SIZE * 0.8) auraSprite = Sprite( parent=leftSide, texturePath='res:/UI/Texture/classes/achievements/auraAlpha.png', pos=(0, -4, AURA_SIZE, AURA_SIZE), align=uiconst.CENTERTOP) self.mainContent = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(0, 6, 10, 10)) self.opacity = 0.0 self.fadeoutState = FADE_STATE_OUT self.sizeTimer = AutoTimer(10, self.UpdateWindowSize) if not settings.char.ui.Get('opportunities_aura_introduced', False): settings.char.ui.Set('opportunities_aura_introduced', True) self.Step_Intro() elif attributes.loadAchievementTask: self.Step_TaskInfo_Manual(attributes.loadAchievementTask, attributes.loadAchievementGroup) else: self.UpdateOpportunityState() def AddCustomHeaderButtons(self, container): settingControl = OpportunitiesSettingsMenu(parent=container, align=uiconst.TORIGHT, width=16, top=1) def OpenOpportunitiesTree(self, *args): from achievements.client.achievementTreeWindow import AchievementTreeWindow AchievementTreeWindow.Open() sm.GetService('experimentClientSvc').LogWindowOpenedActions( 'OpportunityWindowAuraWindow') self.FadeOutTransitionAndClose() def Prepare_HeaderButtons_(self, *args, **kwds): Window.Prepare_HeaderButtons_(self, *args, **kwds) def UpdateWindowSize(self): if self.destroyed: self.sizeTimer = None return headerHeight = self.GetCollapsedHeight() newheight = max( WINDOW_MIN_HEIGHT, headerHeight + self.mainContent.height + self.mainContent.padTop + self.mainContent.padBottom) if newheight != self.height: self.height = newheight self.SetFixedHeight(self.height) if self.transitionBox and not self.transitionBox.destroyed: self.transitionBox.height = newheight def CloseByUser(self, *args, **kwds): Window.CloseByUser(self, *args, **kwds) if self.activeStep == STEP_TASK_INFO: settings.char.ui.Set('opportunities_suppress_taskinfo', True) return self.ResetActiveAchievementGroup(self.activeStep) def Close(self, setClosed=False, *args, **kwds): if not self.isFadingOut: self.FadeOutTransitionAndClose(args, kwds) else: Window.Close(self, setClosed, args, kwds) def FadeOutTransitionAndClose(self, *args, **kwds): self.isFadingOut = True self.FadeOutTransition() activeStep = self.activeStep self.Close() self.ResetActiveAchievementGroup(activeStep) self.isFadingOut = False def ResetActiveAchievementGroup(self, activeStep): if activeStep in (STEP_INTRO, STEP_INTRO2, STEP_COMPLETED_NEXT, STEP_PRESENT_OPPORTUNITY): sm.GetService('achievementSvc').SetActiveAchievementGroupID(None) def FadeOutTransition(self): if not self.opacity or self.fadeoutState == FADE_STATE_OUT: return self.fadeoutState = FADE_STATE_OUT timeScale = 1.0 wasCacheContent = self.cacheContents self.cacheContents = False l, t, w, h = self.GetAbsolute() transform = Transform( parent=self.parent, state=uiconst.UI_DISABLED, align=uiconst.TOALL, scalingCenter=(float(l + w / 2) / uicore.desktop.width, float(t + h / 2) / uicore.desktop.height), scaling=(1.0, 1.0), idx=self.parent.children.index(self)) self.SetParent(transform) self.transitionBox = WindowTransition(parent=transform, pos=self.pos) uicore.animations.BlinkOut(self.transitionBox.cornerPoints, loops=5, duration=0.3 * timeScale) uicore.animations.FadeOut(self, duration=0.2 * timeScale, sleep=True) uicore.animations.FadeTo(self.transitionBox.whiteFill, startVal=0.2, endVal=0.05, duration=0.1 * timeScale, sleep=True) uicore.animations.SpColorMorphTo(self.transitionBox.whiteFill, startColor=(0, 0, 0, 0.1), endColor=(1, 1, 1, 0.1), duration=0.1 * timeScale) uicore.animations.Tr2DScaleTo(transform, startScale=(1.0, 1.0), endScale=(1.0, 0.0), duration=0.3 * timeScale, sleep=True) if not self.destroyed: self.SetParent(uicore.layer.main, idx=0) self.cacheContents = wasCacheContent transform.Close() def FadeInTransition(self): if self.fadeoutState == FADE_STATE_IN: return self.fadeoutState = FADE_STATE_IN uthread.new(self._FadeInTransition) def _FadeInTransition(self): timeScale = 1.0 wasCacheContent = self.cacheContents self.cacheContents = False self.opacity = 0.0 l, t, w, h = self.GetAbsolute() transform = Transform( parent=self.parent, state=uiconst.UI_DISABLED, align=uiconst.TOALL, scalingCenter=(float(l + w / 2) / uicore.desktop.width, float(t + h / 2) / uicore.desktop.height), scaling=(1.0, 0.0), idx=self.parent.children.index(self)) self.SetParent(transform) self.transitionBox = WindowTransition(parent=transform, pos=self.pos) uicore.animations.Tr2DScaleTo(transform, startScale=(1.0, 0.0), endScale=(1.0, 1.0), duration=0.2 * timeScale) uicore.animations.FadeTo(self.transitionBox.whiteFill, startVal=0.2, endVal=0.5, sleep=True, duration=0.1 * timeScale) uicore.animations.SpColorMorphTo(self.transitionBox.whiteFill, startColor=(1, 1, 1, 0.125), endColor=(0, 0, 0, 0.25), sleep=True, duration=0.1 * timeScale) uicore.animations.BlinkIn(self.transitionBox.cornerPoints, loops=5, duration=0.3 * timeScale) uicore.animations.FadeIn(self, duration=0.3 * timeScale, sleep=True) if not self.destroyed: self.SetParent(uicore.layer.main, idx=0) self.cacheContents = wasCacheContent transform.Close() def TriggerForcedGroup(self, forcedGroup): activeGroup = GetActiveAchievementGroup() if activeGroup != forcedGroup: self.Step_PresentOpportunity(groupToPresent=forcedGroup) def Step_Intro(self): self.FadeOutTransition() self.mainContent.Flush() self.LoadMediumText(GetByLabel('Achievements/AuraText/intro'), padRight=8) self._LoadDismissAcceptButtons() self.LoadTreeLink() self.SetOrder(0) self.activeStep = STEP_INTRO settings.char.ui.Set('opportunities_suppress_taskinfo', False) self.FadeInTransition() def Step_AskStart(self): self.FadeOutTransition() self.mainContent.Flush() self.LoadLargeText( GetByLabel('Achievements/AuraText/IntroAfterDismissHeader')) self.LoadMediumText( GetByLabel('Achievements/AuraText/IntroAfterDismissText')) self._LoadDismissAcceptButtons() self.LoadTreeLink() self.SetCaption(GetByLabel('UI/Achievements/OpportunitiesHint')) self.SetOrder(0) self.activeStep = STEP_INTRO2 self.FadeInTransition() def Step_ActiveCompleted(self): self.FadeOutTransition() self.mainContent.Flush() self.LoadLargeText( GetByLabel('Achievements/AuraText/CompletedReactivatedHeader')) self.LoadMediumText( GetByLabel('Achievements/AuraText/CompletedReactivatedText')) self._LoadDismissAcceptButtons() self.LoadTreeLink() self.SetCaption(GetByLabel('UI/Achievements/OpportunitiesHint')) self.SetOrder(0) self.activeStep = STEP_COMPLETED_NEXT self.FadeInTransition() def Step_PresentOpportunity(self, btn=None, groupToPresent=None, *args): if groupToPresent: nextGroup = groupToPresent else: nextGroup = GetFirstIncompleteAchievementGroup() if not nextGroup: return self.Step_AllDone() self.FadeOutTransition() self.mainContent.Flush() self.LoadLargeText(GetByLabel(nextGroup.groupName)) self.LoadDivider() self.LoadMediumText(GetByLabel(nextGroup.groupDescription)) self.LoadPresentButtons(groupToPresent) self.LoadTreeLink() self.SetCaption(GetByLabel('Achievements/UI/NewOpportunity')) self.SetOrder(0) self.activeStep = STEP_PRESENT_OPPORTUNITY self.FadeInTransition() def Step_TaskInfo(self, achievementTask, activeGroup, manualLoad=False): self.FadeOutTransition() self.mainContent.Flush() if activeGroup: self.SetCaption(GetByLabel(activeGroup.groupName)) self.LoadLargeText(achievementTask.name) self.LoadDivider() self.LoadMediumText(achievementTask.description) extraInfo = ACHIEVEMENT_TASK_EXTRAINFO.get( achievementTask.achievementID, None) if extraInfo: grid = LayoutGrid(parent=self.mainContent, align=uiconst.TOTOP, cellPadding=2, columns=2) for taskInfoEntry in extraInfo: if isinstance(taskInfoEntry, TaskInfoEntry_Text): label = EveLabelMedium(text=taskInfoEntry.text, color=taskInfoEntry.textColor, width=200) grid.AddCell(label, colSpan=2) elif isinstance(taskInfoEntry, TaskInfoEntry_ImageText): texturePath = taskInfoEntry.GetTexturePath() icon = Sprite(name='icon', parent=grid, pos=(0, 0, taskInfoEntry.imageSize, taskInfoEntry.imageSize), texturePath=texturePath, state=uiconst.UI_DISABLED, align=uiconst.CENTER, color=taskInfoEntry.imageColor) text = GetByLabel(taskInfoEntry.textPath) label = EveLabelMedium(text=text, color=taskInfoEntry.textColor, width=180, align=uiconst.CENTERLEFT) grid.AddCell(label) self.LoadTreeLink() self.SetOrder(0) settings.char.ui.Set('opportunities_suppress_taskinfo', False) if manualLoad: self.activeStep = STEP_TASK_INFO_MANUAL else: self.activeStep = STEP_TASK_INFO self.FadeInTransition() def Step_TaskInfo_Manual(self, achievementTask, achievementGroup): self.Step_TaskInfo(achievementTask, achievementGroup, manualLoad=True) def Step_AllDone(self): self.FadeOutTransition() self.mainContent.Flush() self.LoadLargeText( GetByLabel('Achievements/AuraText/AllCompletedHeader')) self.LoadMediumText( GetByLabel('Achievements/AuraText/AllCompletedText')) self._LoadAllDoneButtons() self.SetCaption(GetByLabel('UI/Achievements/OpportunitiesHint')) self.SetOrder(0) self.activeStep = STEP_ALL_DONE self.FadeInTransition() def _LoadDismissAcceptButtons(self): self.LoadButtons(((GetByLabel('Achievements/UI/next'), self.Step_PresentOpportunity, None), )) def LoadPresentButtons(self, groupToPresent): self.LoadButtons(((GetByLabel('Achievements/UI/next'), self.ActivateNextIncompleteOpportunity, (False, groupToPresent)), )) def _LoadAllDoneButtons(self): self.LoadButtons(((GetByLabel('Achievements/UI/next'), self.ActivateCareerFunnel, (False, )), )) def ActivateNextIncompleteOpportunity(self, emphasize, groupToPresent=None, **kwargs): if groupToPresent: nextGroup = groupToPresent else: nextGroup = GetFirstIncompleteAchievementGroup() if nextGroup: if True: self.FadeOutTransitionAndClose() done = settings.char.ui.Get('opportunities_aura_activated', []) if nextGroup.groupID not in done: done.append(nextGroup.groupID) settings.char.ui.Set('opportunities_aura_activated', done) sm.GetService('achievementSvc').SetActiveAchievementGroupID( nextGroup.groupID, emphasize=emphasize) else: self.UpdateOpportunityState() def ActivateCareerFunnel(self, *args): self.FadeOutTransitionAndClose() sm.GetService('achievementSvc').SetActiveAchievementGroupID(None) sm.StartService('tutorial').ShowCareerFunnel() def UpdateOpportunityState(self, activeGroupChanged=False, activeGroupCompleted=False): activeGroup = GetActiveAchievementGroup() nextGroup = GetFirstIncompleteAchievementGroup() if activeGroup: if nextGroup: if activeGroupCompleted: self.Step_PresentOpportunity() return elif nextGroup: if self.activeStep not in (STEP_INTRO, STEP_INTRO2, STEP_PRESENT_OPPORTUNITY): self.Step_AskStart() return self.Step_AllDone() def LoadDivider(self): divider = Sprite( parent=self.mainContent, height=1, align=uiconst.TOTOP, texturePath= 'res:/UI/Texture/classes/achievements/divider_horizontal.png', color=(1, 1, 1, 0.3), padding=(0, 2, 0, 2)) def LoadLargeText(self, text, *args, **kwargs): label = Label(parent=self.mainContent, text=text, align=uiconst.TOTOP, fontsize=18, color=(1, 1, 1, 1), **kwargs) def LoadMediumText(self, text, *args, **kwargs): label = EveLabelMedium(parent=self.mainContent, text=text, align=uiconst.TOTOP, **kwargs) def LoadButton(self, label, func, args=None): buttonContainer = Container(parent=self.mainContent, align=uiconst.TOTOP) button = Button(parent=buttonContainer, label=label, func=func, args=args, align=uiconst.CENTERLEFT) buttonContainer.height = button.height + 8 def LoadButtons(self, buttonData): buttonContainer = FlowContainer(parent=self.mainContent, align=uiconst.TOTOP, padTop=14, contentSpacing=(4, 4), contentAlignment=CONTENT_ALIGN_RIGHT) for label, func, args in buttonData: button = Button(parent=buttonContainer, label=label, func=func, args=args, align=uiconst.NOALIGN) def LoadTreeLink(self): buttonContainer = ContainerAutoSize(parent=self.mainContent, align=uiconst.TOTOP, alignMode=uiconst.TOPLEFT)
class AchievementGroupEntry(ContainerAutoSize): __notifyevents__ = ['OnAchievementChanged'] default_padTop = 0 default_padBottom = 3 default_state = uiconst.UI_NORMAL default_alignMode = uiconst.TOTOP texturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesIcon_Explore.png' progressBackground = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesFillBar.png' fillBox = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesFillBox.png' checkmarkPath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesCheck.png' groupData = None def ApplyAttributes(self, attributes): ContainerAutoSize.ApplyAttributes(self, attributes) self.ConstructLayout() self.LoadGroupData(attributes.groupInfo, attributes.blinkAchievementID, attributes.animateIn) sm.RegisterNotify(self) def ConstructLayout(self): headerContainer = Container(parent=self, align=uiconst.TOTOP, height=28, padTop=4, padBottom=6) self.groupName = EveLabelLarge(parent=headerContainer, align=uiconst.CENTERLEFT, left=8) Frame(texturePath= 'res:/UI/Texture/classes/Achievements/pointRightHeaderFrame.png', cornerSize=16, offset=-14, parent=headerContainer, color=(1, 1, 1, 0.25), align=uiconst.TOALL) progressClipper = Container(parent=headerContainer, align=uiconst.TOALL, clipChildren=True, padRight=-POINTER_PADRIGHT) self.progress = Frame( texturePath= 'res:/UI/Texture/classes/Achievements/pointRightHeaderBackground.png', cornerSize=15, offset=-13, parent=progressClipper, color=(1, 1, 1, 0.25)) self.progress.padRight = 400 self.progress.opacity = 0.0 self.tasksContainer = ContainerAutoSize(parent=self, name='tasksContainer', align=uiconst.TOTOP, state=uiconst.UI_NORMAL) def LoadGroupData(self, groupData, blinkAchievementID=None, animateIn=False): if not self.groupData or self.groupData.groupID != groupData.groupID: self.groupData = groupData self.groupName.text = self.groupData.groupName self.AddAchievementTasks(blinkAchievementID=blinkAchievementID, animateIn=animateIn) if animateIn: self.AnimateIn() self.UpdateState() def UpdateState(self): self.UpdateProgress() self.UpdateAchievementTasks() def OnAchievementChanged(self, achievement, *args, **kwds): if self.groupData.HasAchievement(achievement.achievementID): self.UpdateState() def UpdateProgress(self): progressProportion = self.groupData.GetProgressProportion() maxWidth = ReverseScaleDpi(self.displayWidth) - POINTER_PADRIGHT uicore.animations.MorphScalar(self.progress, 'padRight', startVal=self.progress.padRight, endVal=POINTER_PADRIGHT + maxWidth * (1 - progressProportion), curveType=uiconst.ANIM_SMOOTH, duration=0.33) uicore.animations.MorphScalar(self.progress, 'opacity', startVal=self.progress.opacity, endVal=min(progressProportion, 0.25), curveType=uiconst.ANIM_SMOOTH, duration=0.33) def OpenAchievementAuraWindow(self, *args): AchievementAuraWindow.Open() def UpdateAchievementTasks(self): detailsShown = False for each in self.tasksContainer.children: if not detailsShown and not each.achievementTask.completed: each.ShowDetails() detailsShown = True each.UpdateAchievementTaskState() def AddAchievementTasks(self, blinkAchievementID=None, animateIn=False): self.tasksContainer.Flush() for achievementTask in self.groupData.GetAchievementTasks(): AchievementTaskEntry( parent=self.tasksContainer, align=uiconst.TOTOP, achievement=achievementTask, blinkIn=not animateIn and achievementTask.achievementID == blinkAchievementID, opacity=0.0 if animateIn else 1.0, achievementGroup=self.groupData, callbackTaskExpanded=self.OnTaskExpanded) def OnTaskExpanded(self, expandedTask, *args): for each in self.tasksContainer.children: if each is not expandedTask: each.HideDetails() def AnimateIn(self): to = 0.0 for each in self.tasksContainer.children: uicore.animations.FadeIn(each, duration=0.08, timeOffset=to, curveType=uiconst.ANIM_OVERSHOT) if hasattr(each, 'ShowIntroAnimation'): each.ShowIntroAnimation() to += 0.05 def LoadTooltipPanel(self, tooltipPanel, *args, **kwds): tooltipPanel.LoadGeneric2ColumnTemplate() if not self.groupData.extraInfo: return extraInfo = self.groupData.extraInfo tipsHeader = EveLabelSmall( text=GetByLabel('UI/Achievements/TipsAndInfoHeader'), width=200, bold=True) tooltipPanel.AddCell(tipsHeader, colSpan=tooltipPanel.columns) tipsText = EveLabelSmall(text=self.groupData.groupDescription, align=uiconst.TOTOP) tooltipPanel.AddCell(tipsText, colSpan=tooltipPanel.columns) for info in extraInfo: icon = Sprite(name='icon', parent=tooltipPanel, pos=(0, 0, info['size'], info['size']), texturePath=info['path'], state=uiconst.UI_DISABLED, align=uiconst.TOPLEFT, color=info.get('color', None)) label = EveLabelSmall(name='tipsHeader', text=info['text'], parent=tooltipPanel, width=180, align=uiconst.CENTERLEFT)
class GroupInfoWnd(Window): default_minSize = (200, 130) default_width = 300 default_iconNum = 'res:/UI/Texture/WindowIcons/accessGroups.png' default_captionLabelPath = 'UI/Structures/AccessGroups/AccessGroup' def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.SetWndIcon(self.iconNum, mainTop=-8) self.sr.mainIcon.state = uiconst.UI_NORMAL self.sr.mainIcon.GetDragData = self.GetDragDataForIcon self.sr.mainIcon.isDragObject = True self.groupID = attributes.groupID self.groupInfo = GetGroupInfo(self.groupID) self.groupName = self.groupInfo['name'] wndCaption = WndCaptionLabel(text=self.groupName, parent=self.sr.topParent, align=uiconst.RELATIVE) scrollContainer = ScrollContainer(parent=self.sr.main, padding=(10, 0, 10, 10)) self.contentCont = ContainerAutoSize(parent=scrollContainer, align=uiconst.TOTOP, columns=1) self.LoadContentCont() w, h = self.contentCont.GetAbsoluteSize() newHeight = h + self.sr.topParent.height + 40 self.height = newHeight def LoadContentCont(self): self.contentCont.Flush() groupDesc = self.groupInfo['description'] admins = self.groupInfo['admins'] if groupDesc: EveLabelMedium(parent=self.contentCont, text=groupDesc, padTop=6, align=uiconst.TOTOP) else: descText = GetByLabel( 'UI/Structures/AccessGroups/NoGroupDescription') EveLabelMedium(parent=self.contentCont, text=descText, align=uiconst.TOTOP, padTop=6, italic=True) for adminID in admins: ownerInfo = cfg.eveowners.Get(adminID) charName = ownerInfo.name charText = GetShowInfoLink(ownerInfo.typeID, charName, itemID=adminID) text = GetByLabel('UI/Structures/AccessGroups/GroupOwner', ownerName=charText) EveLabelMedium(parent=self.contentCont, text=text, align=uiconst.TOTOP, padTop=6, state=uiconst.UI_NORMAL) def GetDragDataForIcon(self): ret = KeyVal(nodeType='AccessGroupEntry', groupID=self.groupID, label=self.groupName) return [ret]
class ScrollContainer(Container): """ A container with vertical and horizontal scrolling functionality. Children must all use the same alignment mode, which must be either TOPLEFT, TOLEFT or TOTOP. Note that all children appended to this container will actually end up in self.mainCont, which is necessary for scrolling to work without the need for users to know about the existance of self.mainCont. """ __guid__ = 'uicls.ScrollContainer' default_name = 'scrollContainer' default_state = uiconst.UI_NORMAL dragHoverScrollAreaSize = 30 dragHoverScrollSpeed = 60.0 default_showUnderlay = False isTabStop = True pushContent = True def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) pushContent = attributes.pushContent or self.pushContent showUnderlay = attributes.Get('showUnderlay', self.default_showUnderlay) self.scrollbarsDisabled = False self.scrollToVerticalPending = None self.scrollToHorizontalPending = None self.noContentHint = None self.verticalScrollBar = ScrollBar( parent=self, align=uiconst.TORIGHT if pushContent else uiconst.TORIGHT_NOPUSH) self.verticalScrollBar.OnScrolled = self._OnVerticalScrollBar self.horizontalScrollBar = ScrollBar( parent=self, align=uiconst.TOBOTTOM if pushContent else uiconst.TOBOTTOM_NOPUSH) self.horizontalScrollBar.OnScrolled = self._OnHorizontalScrollBar self.clipCont = Container(name='clipCont', parent=self, clipChildren=True) self.mainCont = ContainerAutoSize(name='mainCont', parent=self.clipCont, state=uiconst.UI_NORMAL) self.mainCont._OnSizeChange_NoBlock = self._OnMainContSizeChange self.children.insert = self._InsertChild self.children.append = self._AppendChild self.children.remove = self._RemoveChild self._mouseHoverCookie = uicore.uilib.RegisterForTriuiEvents( uiconst.UI_MOUSEHOVER, self.OnGlobalMouseHover) if showUnderlay: self.underlay = BumpedUnderlay(bgParent=self) else: self.underlay = None def Close(self, *args): uicore.uilib.UnregisterForTriuiEvents(self._mouseHoverCookie) Container.Close(self, *args) def _InsertChild(self, idx, obj): self.mainCont.children.insert(idx, obj) self.mainCont.align = obj.align def _AppendChild(self, obj): self.mainCont.children.append(obj) self.mainCont.align = obj.align def _RemoveChild(self, obj): self.mainCont.children.remove(obj) def OnGlobalMouseHover(self, obj, *args): """ Scroll when drag-hovering over top or bottom parts of scroll """ if uicore.IsDragging() and (obj == self or obj.IsUnder(self.mainCont)): l, t, w, h = self.GetAbsolute() if self.verticalScrollBar.display and h > 0: fraction = self.dragHoverScrollSpeed / float(h) y = uicore.uilib.y - t if y <= self.dragHoverScrollAreaSize: self.ScrollMoveVertical(-fraction) self.verticalScrollBar.AnimFade() elif y > h - self.dragHoverScrollAreaSize: self.ScrollMoveVertical(fraction) self.verticalScrollBar.AnimFade() if self.horizontalScrollBar.display and w > 0: fraction = self.dragHoverScrollSpeed / float(w) x = uicore.uilib.x - l if x <= self.dragHoverScrollAreaSize: self.ScrollMoveHorizontal(-fraction) self.horizontalScrollBar.AnimFade() elif x > w - self.dragHoverScrollAreaSize: self.ScrollMoveHorizontal(fraction) self.horizontalScrollBar.AnimFade() return True def _OnSizeChange_NoBlock(self, width, height): self._UpdateHandleSizesAndPosition(width, height, updatePos=False) def _OnMainContSizeChange(self, width, height): self._UpdateScrollbars() def Flush(self): self.mainCont.Flush() def DisableScrollbars(self): self.scrollbarsDisabled = True self._UpdateScrollbars() def EnableScrollbars(self): self.scrollbarsDisabled = False self._UpdateScrollbars() def _UpdateScrollbars(self): w, h = self.GetAbsoluteSize() self._UpdateHandleSizesAndPosition(w, h) def _UpdateHandleSizesAndPosition(self, width, height, updatePos=True): if self.mainCont.height > 0 and not self.scrollbarsDisabled: size = float(height) / self.mainCont.height else: size = 1.0 self.verticalScrollBar.SetScrollHandleSize(size) if updatePos: denum = self.mainCont.height - height if denum <= 0.0: pos = 0.0 else: pos = float(-self.mainCont.top) / denum self.verticalScrollBar.ScrollTo(pos) else: pos = self.verticalScrollBar.handlePos self._OnVerticalScrollBar(pos) if self.mainCont.width != 0 and not self.scrollbarsDisabled: size = float(width) / self.mainCont.width else: size = 1.0 self.horizontalScrollBar.SetScrollHandleSize(size) if updatePos: denum = self.mainCont.width - width if denum <= 0.0: pos = 0.0 else: pos = float(-self.mainCont.left) / denum self.horizontalScrollBar.ScrollTo(pos) else: pos = self.horizontalScrollBar.handlePos self._OnHorizontalScrollBar(pos) if self.horizontalScrollBar.display and self.verticalScrollBar.display: self.verticalScrollBar.padBottom = self.horizontalScrollBar.height else: self.verticalScrollBar.padBottom = 0 def _OnVerticalScrollBar(self, posFraction): w, h = self.clipCont.GetAbsoluteSize() posFraction = max(0.0, min(posFraction, 1.0)) self.mainCont.top = -posFraction * (self.mainCont.height - h) self.OnScrolledVertical(posFraction) def _OnHorizontalScrollBar(self, posFraction): w, h = self.clipCont.GetAbsoluteSize() posFraction = max(0.0, min(posFraction, 1.0)) self.mainCont.left = -posFraction * (self.mainCont.width - w) self.OnScrolledHorizontal(posFraction) def OnScrolledHorizontal(self, posFraction): """ Overwriteable""" pass def OnScrolledVertical(self, posFraction): """ Overwriteable""" pass def ScrollToVertical(self, posFraction): """ Call this method to scroll the vertical scrollbar to a given position [0.0 - 1.0] """ if self._alignmentDirty: self.scrollToVerticalPending = posFraction elif self.verticalScrollBar.display: self.verticalScrollBar.ScrollTo(posFraction) self._OnVerticalScrollBar(self.verticalScrollBar.handlePos) def ScrollToHorizontal(self, posFraction): """ Call this method to scroll the horizontal scrollbar to a given position [0.0 - 1.0] """ if self._alignmentDirty: self.scrollToHorizontalPending = posFraction elif self.horizontalScrollBar.display: self.horizontalScrollBar.ScrollTo(posFraction) self._OnHorizontalScrollBar(self.horizontalScrollBar.handlePos) def GetPositionVertical(self): return self.verticalScrollBar.handlePos def GetPositionHorizontal(self): return self.horizontalScrollBar.handlePos def UpdateAlignment(self, *args, **kwds): ret = Container.UpdateAlignment(self, *args, **kwds) if self.scrollToVerticalPending: self.verticalScrollBar.ScrollTo(self.scrollToVerticalPending) self._OnVerticalScrollBar(self.verticalScrollBar.handlePos) self.scrollToVerticalPending = None if self.scrollToHorizontalPending: self.horizontalScrollBar.ScrollTo(self.scrollToHorizontalPending) self._OnHorizontalScrollBar(self.horizontalScrollBar.handlePos) self.scrollToHorizontalPending = None return ret def ScrollMoveVertical(self, moveFraction): """ Move the vertical scrollbar by an arbitrary negative or positive float value """ self.verticalScrollBar.ScrollMove(moveFraction) self._OnVerticalScrollBar(self.verticalScrollBar.handlePos) def ScrollMoveHorizontal(self, moveFraction): """ Move the horizontal scrollbar by a given arbitrary negative or positive float value """ self.horizontalScrollBar.ScrollMove(moveFraction) self._OnHorizontalScrollBar(self.horizontalScrollBar.handlePos) def OnMouseWheel(self, dz): if self.verticalScrollBar.display: prop = -dz / float(self.mainCont.height) if math.fabs(prop) < 0.1: prop = math.copysign(0.1, prop) self.ScrollMoveVertical(prop) self.verticalScrollBar.AnimFade() elif self.horizontalScrollBar.display: prop = -dz / float(self.mainCont.width) if math.fabs(prop) < 0.1: prop = math.copysign(0.1, prop) self.ScrollMoveHorizontal(prop) self.horizontalScrollBar.AnimFade() def OnKeyDown(self, key, flag): if key == uiconst.VK_PRIOR: self.ScrollByPage(up=True) elif key == uiconst.VK_NEXT: self.ScrollByPage(up=False) def ScrollByPage(self, up=True): if not self.verticalScrollBar.display: return w, h = self.clipCont.GetAbsoluteSize() if up: mainContTopNewTop = self.mainCont.top + h mainContTopNewTop = min(0, mainContTopNewTop) else: mainContTopNewTop = self.mainCont.top - h mainContTopNewTop = max(h - self.mainCont.height, mainContTopNewTop) self.mainCont.top = mainContTopNewTop self._UpdateScrollbars() self.verticalScrollBar.AnimFade() def ShowNoContentHint(self, text): """ Show a hint that explains why the scroll container is empty """ self.noContentHint = Label(parent=self, align=uiconst.TOTOP, padding=(16, 32, 16, 0), text=text, fontsize=20, uppercase=True, letterspace=1) def HideNoContentHint(self): if self.noContentHint: self.noContentHint.Close() self.noContentHint = None def OnSetFocus(self, *args): if self.underlay: self.underlay.AnimEntry() def OnKillFocus(self, *args): if self.underlay: self.underlay.AnimExit()
class ProcessorContainer(BasePinContainer): __guid__ = 'planet.ui.ProcessorContainer' default_name = 'ProcessorContainer' default_width = 320 INFO_CONT_HEIGHT = 95 def _GetActionButtons(self): btns = [ util.KeyVal(id=planetCommon.PANEL_SCHEMATICS, panelCallback=self.PanelShowSchematics), util.KeyVal(id=planetCommon.PANEL_PRODUCTS, panelCallback=self.PanelShowProducts) ] btns.extend(BasePinContainer._GetActionButtons(self)) return btns def PanelShowSchematics(self): self.schematicsCont = uiprimitives.Container(parent=self.actionCont, name='schematicsCont', align=uiconst.TOALL, state=uiconst.UI_HIDDEN) self.schematicsScroll = uicontrols.Scroll(parent=self.schematicsCont, name='schematicsScroll', align=uiconst.TOALL) self.schematicsScroll.Startup() self.schematicsScroll.sr.id = 'planetProcessorSchematicsScroll' self.schematicsScroll.multiSelect = False self.schematicsScroll.OnSelectionChange = self.OnSchematicScrollSelectionChange self.selectedSchematicCont = uiprimitives.Container( parent=self.schematicsCont, idx=0, name='selectedSchematicCont', height=138, padTop=7, align=uiconst.TOBOTTOM, state=uiconst.UI_PICKCHILDREN) self.LoadSchematicsScroll() return self.schematicsCont def LoadSchematicsScroll(self): scrolllist = [] for schematic in planetCommon.GetSchematicData(self.pin.typeID): data = util.KeyVal(label=schematic.name, schematic=schematic, itemID=None, typeID=schematic.outputs[0].typeID, getIcon=True, OnClick=None, OnDblClick=self.InstallSchematic) sortBy = schematic.name scrolllist.append((sortBy, listentry.Get('Item', data=data))) scrolllist = uiutil.SortListOfTuples(scrolllist) self.schematicsScroll.Load(contentList=scrolllist, headers=[]) self.schematicsScroll.SetSelected(0) def OnSchematicScrollSelectionChange(self, entries): if not entries: return entry = entries[0] uicore.animations.FadeOut(self.selectedSchematicCont, duration=0.125, sleep=True) self.selectedSchematicCont.Flush() self.SubPanelSelectedSchematic(entry.schematic) uicore.animations.FadeIn(self.selectedSchematicCont, duration=0.125) def SubPanelSelectedSchematic(self, schematic): leftCont = uiprimitives.Container(parent=self.selectedSchematicCont, width=0.5, align=uiconst.TOLEFT_PROP, state=uiconst.UI_PICKCHILDREN) rightCont = uiprimitives.Container(parent=self.selectedSchematicCont, width=0.5, align=uiconst.TOLEFT_PROP, state=uiconst.UI_PICKCHILDREN) output = schematic.outputs[0] schematicTxt = localization.GetByLabel('UI/PI/Common/ItemAmount', amount=int(output.quantity), itemName=output.name) CaptionAndSubtext( parent=leftCont, caption=localization.GetByLabel('UI/PI/Common/OutputProduct'), subtext=schematicTxt, iconTypeID=output.typeID, left=5, top=0) CaptionAndSubtext( parent=leftCont, caption=localization.GetByLabel('UI/PI/Common/CycleTime'), subtext=localization.GetByLabel('UI/PI/Common/TimeHourMinSec', time=schematic.cycleTime * const.SEC), left=5, top=40) outputVolumeTxt = localization.GetByLabel( 'UI/PI/Common/CapacityAmount', amount=schematic.outputVolume) CaptionAndSubtext( parent=leftCont, caption=localization.GetByLabel('UI/PI/Common/OutputPerHour'), subtext=outputVolumeTxt, left=5, top=80) for i, input in enumerate(schematic.inputs): topPos = i * 40 caption = localization.GetByLabel('UI/PI/Common/InputNumberX', inputNum=i + 1) subtext = localization.GetByLabel('UI/PI/Common/ItemAmount', amount=int(input.quantity), itemName=evetypes.GetName( input.typeID)) CaptionAndSubtext(parent=rightCont, caption=caption, subtext=subtext, iconTypeID=input.typeID, top=topPos) btns = [[ localization.GetByLabel('UI/PI/Common/InstallSchematic'), self.InstallSchematic, () ]] self.buttons = uicontrols.ButtonGroup( btns=btns, idx=0, parent=self.selectedSchematicCont, line=False, alwaysLite=True) def InstallSchematic(self, *args): entries = self.schematicsScroll.GetSelected() if not entries: return entry = entries[0] schematicID = entry.schematic.schematicID self.planetUISvc.myPinManager.InstallSchematic(self.pin.id, schematicID) self.RenderIngredientGauges() self.ShowPanel(self.PanelShowProducts, planetCommon.PANEL_PRODUCTS) def _GetInfoCont(self): self.currProductTxt = CaptionAndSubtext( parent=self.infoContLeft, caption=localization.GetByLabel('UI/PI/Common/Producing')) self.ingredientsTxt = CaptionAndSubtext( parent=self.infoContLeft, caption=localization.GetByLabel('UI/PI/Common/SchematicInput'), top=50) self.ingredientsTxt.state = uiconst.UI_DISABLED self.ingredientCont = ContainerAutoSize(parent=self.infoContLeft, top=63, state=uiconst.UI_PICKCHILDREN) self.RenderIngredientGauges() self.currCycleGauge = uicls.Gauge( parent=self.infoContRight, value=0.0, color=planetCommon.PLANET_COLOR_CYCLE, width=140) self.amountPerCycleTxt = CaptionAndSubtext( parent=self.infoContRight, caption=localization.GetByLabel('UI/PI/Common/OutputPerCycle'), top=40) self.amountPerHourTxt = CaptionAndSubtext( parent=self.infoContRight, caption=localization.GetByLabel('UI/PI/Common/OutputPerHour'), top=70) def RenderIngredientGauges(self): self.ingredientCont.Flush() self.ingredientGauges = {} i = 0 for typeID, amount in self.pin.GetConsumables().iteritems(): gauge = ProcessorGaugeContainer(parent=self.ingredientCont, iconTypeID=typeID, maxAmount=amount, top=0, left=i * 24) self.ingredientGauges[typeID] = gauge i += 1 if not self.pin.GetConsumables(): self.ingredientsTxt.SetSubtext( localization.GetByLabel('UI/PI/Common/NoSchematicSelected')) else: self.ingredientsTxt.SetSubtext('') def _UpdateInfoCont(self): if self.pin.schematicID: schematicObj = cfg.schematics.Get(self.pin.schematicID) schematicName = schematicObj.schematicName for t in cfg.schematicstypemap.get(self.pin.schematicID, []): if not t.isInput: outputPerCycle = t.quantity outputTypeID = t.typeID if self.pin.activityState < basePin.STATE_IDLE: currCycle = 0 currCycleProportion = 0.0 status = localization.GetByLabel('UI/Common/Inactive') elif self.pin.IsActive(): nextCycle = self.pin.GetNextRunTime() if nextCycle is None or nextCycle < blue.os.GetWallclockTime(): status = localization.GetByLabel( 'UI/PI/Common/ProductionCompletionImminent') else: status = localization.GetByLabel( 'UI/PI/Common/InProduction') currCycle = self.pin.GetCycleTime() - ( self.pin.GetNextRunTime() - blue.os.GetWallclockTime()) currCycleProportion = currCycle / float( self.pin.GetCycleTime()) else: status = localization.GetByLabel( 'UI/PI/Common/WaitingForResources') currCycle = 0 currCycleProportion = 0.0 else: schematicName = localization.GetByLabel( 'UI/PI/Common/NothingExtracted') status = localization.GetByLabel('UI/Common/Inactive') currCycleProportion = 0.0 currCycle = 0 outputPerCycle = 0 outputTypeID = None for typeID, amountNeeded in self.pin.GetConsumables().iteritems(): amount = self.pin.GetContents().get(typeID, 0) gauge = self.ingredientGauges.get(typeID) if not gauge: continue gauge.SetValue(float(amount) / amountNeeded) name = evetypes.GetName(typeID) gauge.hint = localization.GetByLabel( 'UI/PI/Common/ProductionGaugeHint', resourceName=name, amount=amount, amountNeeded=amountNeeded) self.currProductTxt.SetSubtext(schematicName) if self.pin.schematicID: if self.pin.activityState < basePin.STATE_IDLE: self.currCycleGauge.SetSubText( localization.GetByLabel('UI/PI/Common/InactiveEditMode')) else: self.currCycleGauge.SetSubText( localization.GetByLabel('UI/PI/Common/CycleTimeElapsed', currTime=long(currCycle), totalTime=self.pin.GetCycleTime())) self.currProductTxt.SetIcon(outputTypeID) self.currCycleGauge.SetValueInstantly(currCycleProportion) self.currCycleGauge.SetText(status) self.amountPerCycleTxt.SetSubtext( localization.GetByLabel('UI/PI/Common/UnitsAmount', amount=outputPerCycle)) self.amountPerHourTxt.SetSubtext( localization.GetByLabel('UI/PI/Common/CapacityAmount', amount=self.pin.GetOutputVolumePerHour()))
class InfoPanelChallenges(InfoPanelBase): __guid__ = 'uicls.InfoPanelChallenges' default_name = 'InfoPanelChallenges' default_iconTexturePath = CHALLENGES_PANEL_ICON default_state = uiconst.UI_PICKCHILDREN default_height = 120 label = CHALLENGES_PANEL_LABEL hasSettings = False panelTypeID = PANEL_CHALLENGES challengeContainer = None __notifyevents__ = [ 'OnChallengeProgressUpdateInClient', 'OnChallengeCompletedInClient', 'OnChallengeExpiredInClient' ] def ApplyAttributes(self, attributes): self.seasonService = sm.GetService('seasonService') self._LoadActiveChallenge() self.challengeContainer = None self.challengeTaskEntry = None self.openChallengesLinkGrid = None InfoPanelBase.ApplyAttributes(self, attributes) self.titleLabel = self.headerCls(name='title', text='<color=white>%s</color>' % GetByLabel(self.label), parent=self.headerCont, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED) self._ConstructPanel() def _LoadActiveChallenge(self): try: challengeID = self.seasonService.get_last_active_challenge() self.challenge = self._GetChallenge(challengeID) except ChallengeForCharacterNotFoundError: self.challenge = None @staticmethod def IsAvailable(): return sm.GetService('seasonService').is_season_active() def _IsCollapsed(self): return sm.GetService('infoPanel').GetModeForPanel( PANEL_CHALLENGES) == MODE_COLLAPSED def _ShouldShowChallengeDetails(self): return not self._IsCollapsed() and settings.char.ui.Get( 'show_challenge_details_in_info_panel', True) def _ConstructChallengeContainer(self): if not self.challengeContainer or self.challengeContainer.destroyed: self.mainCont.Flush() if self.challenge is None: self.challengeContainer = None else: self.challengeContainer = ContainerAutoSize( parent=self.mainCont, name='challengeContainer', align=uiconst.TOTOP) if self.challengeContainer: self.challengeContainer.Flush() def _ConstructChallengeDetails(self): if self.challenge is None: self.challengeTaskEntry = None return self.challengeTaskEntry = ChallengeInfoPanelTaskEntry( name='challengeInfoPanelTaskEntry', parent=self.challengeContainer, align=uiconst.TOTOP, challenge=self.challenge, open_challenges_function=self._OpenChallenges, show_details=self._ShouldShowChallengeDetails()) def _GetChallenge(self, challengeID): return self.seasonService.get_challenge(challengeID) def _OpenChallenges(self, *args): SeasonWindow.Open() def OnChallengeProgressUpdateInClient(self, challengeID, newProgress): self.hideChallengeTimerThread = None if not self._IsChallengeAlreadyShown(challengeID): self.challenge = self._GetChallenge(challengeID) self._ConstructPanel() self.challengeTaskEntry.update_challenge_progress(newProgress) def OnChallengeCompletedInClient(self, oldChallengeID): if oldChallengeID is None: return if not self._IsChallengeAlreadyShown(oldChallengeID): self.challenge = self.seasonService.get_challenge(oldChallengeID) self._ConstructPanel() self.challengeTaskEntry.complete_challenge() setattr( self, 'hideChallengeTimerThread', AutoTimer(HIDE_CHALLENGE_TIMEOUT, self._HideCompletedChallenge)) def OnChallengeExpiredInClient(self, challengeID): if challengeID is None: return if not self._IsChallengeAlreadyShown(challengeID): self.challenge = self.seasonService.get_challenge(challengeID) self._ConstructPanel() self.challengeTaskEntry.expire_challenge() setattr( self, 'hideChallengeTimerThread', AutoTimer(HIDE_CHALLENGE_TIMEOUT, self._HideCompletedChallenge)) def _IsAnyChallengeShown(self): return self.challenge is not None def _IsChallengeAlreadyShown(self, challengeID): return self._IsAnyChallengeShown( ) and self.challenge.challenge_id == challengeID def _HideCompletedChallenge(self): try: if self.hideChallengeTimerThread: uicore.animations.FadeOut( self.challengeTaskEntry, duration=COMPLETED_CHALLENGE_FADE_OUT_DURATION, callback=self._ResetPanel()) finally: self.hideChallengeTimerThread = None self._ResetPanel() def _ConstructPanel(self): self._ConstructChallengeContainer() self._ConstructChallengeDetails() def _ResetPanel(self): self.challengeContainer = None self._LoadActiveChallenge() self._ConstructPanel()
class InfoPanelAchievements(InfoPanelBase): __guid__ = 'uicls.InfoPanelAchievements' default_name = 'InfoPanelAchievements' default_iconTexturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesPanelIcon.png' default_state = uiconst.UI_PICKCHILDREN default_height = 120 label = 'UI/Achievements/OpportunitiesHint' hasSettings = False panelTypeID = PANEL_ACHIEVEMENTS groupEntry = None achievementContent = None __notifyevents__ = [ 'OnAchievementsDataInitialized', 'OnAchievementActiveGroupChanged', 'OnAchievementChanged' ] def ApplyAttributes(self, attributes): InfoPanelBase.ApplyAttributes(self, attributes) self.titleLabel = self.headerCls( name='title', text='<color=white>' + GetByLabel('UI/Achievements/InfoPanelHeader'), parent=self.headerCont, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED) @staticmethod def IsAvailable(): """ Is this info panel currently available for viewing """ return sm.GetService('achievementSvc').IsEnabled() def ConstructCompact(self): self.mainCont.Flush() self.achievementContent = None def ConstructNormal(self, blinkAchievementID=None): if not self.achievementContent or self.achievementContent.destroyed: self.mainCont.Flush() self.achievementContent = ContainerAutoSize( parent=self.mainCont, name='achievementContent', align=uiconst.TOTOP, alignMode=uiconst.TOTOP) grid = LayoutGrid(parent=self.mainCont, align=uiconst.TOTOP, columns=2, opacity=0.0) button = ButtonIcon( texturePath= 'res:/ui/Texture/Classes/InfoPanels/opportunitiesTreeIcon.png', align=uiconst.TOPLEFT, iconSize=16, parent=grid, func=self.OpenOpportunitiesTree, pos=(0, 0, 16, 16)) subTextLabel = InfoPanelLabel(parent=grid, align=uiconst.CENTERLEFT, text='See all opportunities', state=uiconst.UI_NORMAL, fontsize=EVE_SMALL_FONTSIZE, bold=True, left=4) subTextLabel.OnClick = self.OpenOpportunitiesTree uicore.animations.FadeIn(grid) groupID = sm.GetService('achievementSvc').GetActiveAchievementGroupID() self.LoadContent(groupID, blinkAchievementID=blinkAchievementID) def LoadContent(self, groupID=None, blinkAchievementID=None): activeGroupData = GetAchievementGroup(groupID) if activeGroupData: if self.groupEntry is None or self.groupEntry.destroyed: self.achievementContent.Flush() self.groupEntry = AchievementGroupEntry( parent=self.achievementContent, align=uiconst.TOTOP, groupInfo=activeGroupData, blinkAchievementID=blinkAchievementID, animateIn=True) else: self.groupEntry.LoadGroupData( activeGroupData, blinkAchievementID=blinkAchievementID, animateIn=True) return self.achievementContent.Flush() self.groupEntry = None label = InfoPanelLabel(name='noActiveOpp', text=GetByLabel('Achievements/UI/noActiveOpp'), parent=self.achievementContent, fontsize=EVE_LARGE_FONTSIZE, padding=(0, 2, 0, 2), state=uiconst.UI_NORMAL, align=uiconst.TOTOP) def OpenAchievementAuraWindow(self, *args): AchievementAuraWindow.Open() def OpenOpportunitiesTree(self, *args): AchievementTreeWindow.Open() def OnAchievementActiveGroupChanged(self, groupID, emphasize): if self.mode != MODE_NORMAL: self.SetMode(MODE_NORMAL) self.Refresh() if emphasize: uicore.animations.BlinkIn(self, duration=0.4, loops=4) def OnAchievementChanged(self, achievement, *args, **kwds): if achievement: blinkAchievementID = achievement.achievementID else: blinkAchievementID = None self.Refresh(blinkAchievementID) def OnAchievementsDataInitialized(self): self.Refresh() def Refresh(self, blinkAchievementID=None): if self.mode != infoPanelConst.MODE_NORMAL: self.ConstructCompact() else: self.ConstructNormal(blinkAchievementID=blinkAchievementID)
class AchievementAuraWindow(Window): __notifyevents__ = [ 'OnAchievementChanged', 'OnAchievementActiveGroupChanged' ] default_captionLabelPath = 'UI/Achievements/OpportunitiesHint' default_windowID = 'AchievementAuraWindow' default_width = WINDOW_WIDTH default_fixedWidth = default_width default_height = 64 default_fixedHeight = default_height default_top = 200 default_topParentHeight = 0 aura = None activeStep = None animHeight = 0 def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.MakeUnMinimizable() self.MakeUnpinable() self.MakeUnstackable() mainArea = self.GetMainArea() mainArea.clipChildren = True leftSide = Container(parent=mainArea, align=uiconst.TOLEFT, width=AURA_SIZE * 0.8) auraSprite = Sprite( parent=leftSide, texturePath='res:/UI/Texture/classes/achievements/auraAlpha.png', pos=(0, -4, AURA_SIZE, AURA_SIZE), align=uiconst.CENTERTOP) self.mainContent = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(0, 6, 10, 10)) self.sizeTimer = AutoTimer(10, self.UpdateWindowSize) if not settings.char.ui.Get('opportunities_aura_introduced', False): settings.char.ui.Set('opportunities_aura_introduced', True) self.Step_Intro() elif attributes.loadAchievementTask: self.Step_TaskInfo_Manual(attributes.loadAchievementTask, attributes.loadAchievementGroup) else: self.UpdateOpportunityState() def OpenOpportunitiesTree(self, *args): from achievements.client.achievementTreeWindow import AchievementTreeWindow AchievementTreeWindow.Open() def Prepare_HeaderButtons_(self, *args, **kwds): Window.Prepare_HeaderButtons_(self, *args, **kwds) def UpdateWindowSize(self): if self.destroyed: self.sizeTimer = None return headerHeight = self.GetCollapsedHeight() newheight = max( WINDOW_MIN_HEIGHT, headerHeight + self.mainContent.height + self.mainContent.padTop + self.mainContent.padBottom) if newheight != self.height: self.height = newheight self.SetFixedHeight(self.height) def OnAchievementChanged(self, achievement, activeGroupCompleted=False, *args, **kwds): self.UpdateOpportunityState(activeGroupCompleted=activeGroupCompleted) def OnAchievementActiveGroupChanged(self, groupID, *args, **kwargs): self.UpdateOpportunityState(activeGroupChanged=True) def CloseByUser(self, *args, **kwds): Window.CloseByUser(self, *args, **kwds) if self.activeStep == STEP_TASK_INFO: settings.char.ui.Set('opportunities_suppress_taskinfo', True) elif self.activeStep in (STEP_INTRO, STEP_INTRO2, STEP_PRESENT_OPPORTUNITY): sm.GetService('achievementSvc').SetActiveAchievementGroupID(None) def Step_Intro(self): self.mainContent.Flush() self.LoadMediumText(GetByLabel('Achievements/AuraText/intro'), padRight=8) self.LoadButtons( ((GetByLabel('Achievements/UI/Accept'), self.Step_PresentOpportunity, None), (GetByLabel('Achievements/UI/Dismiss'), self.Close, None))) self.LoadTreeLink() self.SetOrder(0) self.activeStep = STEP_INTRO settings.char.ui.Set('opportunities_suppress_taskinfo', False) def Step_AskStart(self): self.mainContent.Flush() self.LoadLargeText( GetByLabel('Achievements/AuraText/IntroAfterDismissHeader')) self.LoadMediumText( GetByLabel('Achievements/AuraText/IntroAfterDismissText')) self.LoadButtons( ((GetByLabel('Achievements/UI/Accept'), self.Step_PresentOpportunity, None), (GetByLabel('Achievements/UI/Dismiss'), self.Close, None))) self.LoadTreeLink() self.SetCaption(GetByLabel('UI/Achievements/OpportunitiesHint')) self.SetOrder(0) self.activeStep = STEP_INTRO2 def Step_ActiveCompleted(self): self.mainContent.Flush() self.LoadLargeText( GetByLabel('Achievements/AuraText/CompletedReactivatedHeader')) self.LoadMediumText( GetByLabel('Achievements/AuraText/CompletedReactivatedText')) self.LoadButtons( ((GetByLabel('Achievements/UI/Accept'), self.Step_PresentOpportunity, None), (GetByLabel('Achievements/UI/Dismiss'), self.Close, None))) self.LoadTreeLink() self.SetCaption(GetByLabel('UI/Achievements/OpportunitiesHint')) self.SetOrder(0) self.activeStep = STEP_COMPLETED_NEXT def Step_PresentOpportunity(self, *args): nextGroup = GetFirstIncompleteAchievementGroup() if not nextGroup: return self.Step_AllDone() self.mainContent.Flush() self.LoadLargeText(nextGroup.groupName) self.LoadDivider() self.LoadMediumText(nextGroup.groupDescription) self.LoadButtons( ((GetByLabel('Achievements/UI/Accept'), self.ActivateNextIncompleteOpportunity, (False, )), (GetByLabel('Achievements/UI/Dismiss'), self.Close, None))) self.LoadTreeLink() self.SetCaption(GetByLabel('Achievements/UI/NewOpportunity')) self.SetOrder(0) self.activeStep = STEP_PRESENT_OPPORTUNITY def Step_TaskInfo(self, achievementTask, activeGroup, manualLoad=False): self.mainContent.Flush() if activeGroup: self.SetCaption(activeGroup.groupName) self.LoadLargeText(achievementTask.name) self.LoadDivider() self.LoadMediumText(achievementTask.description) extraInfo = ACHIEVEMENT_TASK_EXTRAINFO.get( achievementTask.achievementID, None) if extraInfo: grid = LayoutGrid(parent=self.mainContent, align=uiconst.TOTOP, cellPadding=2, columns=2) for taskInfoEntry in extraInfo: if isinstance(taskInfoEntry, TaskInfoEntry_Text): label = EveLabelMedium(text=taskInfoEntry.text, color=taskInfoEntry.textColor, width=200) grid.AddCell(label, colSpan=2) elif isinstance(taskInfoEntry, TaskInfoEntry_ImageText): texturePath = taskInfoEntry.GetTexturePath() icon = Sprite(name='icon', parent=grid, pos=(0, 0, taskInfoEntry.imageSize, taskInfoEntry.imageSize), texturePath=texturePath, state=uiconst.UI_DISABLED, align=uiconst.CENTER, color=taskInfoEntry.imageColor) text = GetByLabel(taskInfoEntry.textPath) label = EveLabelMedium(text=text, color=taskInfoEntry.textColor, width=180, align=uiconst.CENTERLEFT) grid.AddCell(label) self.LoadTreeLink() self.SetOrder(0) settings.char.ui.Set('opportunities_suppress_taskinfo', False) if manualLoad: self.activeStep = STEP_TASK_INFO_MANUAL else: self.activeStep = STEP_TASK_INFO def Step_TaskInfo_Manual(self, achievementTask, achievementGroup): self.Step_TaskInfo(achievementTask, achievementGroup, manualLoad=True) def Step_AllDone(self): self.mainContent.Flush() self.LoadLargeText( GetByLabel('Achievements/AuraText/AllCompletedHeader')) self.LoadMediumText( GetByLabel('Achievements/AuraText/AllCompletedText')) self.LoadButtons( ((GetByLabel('Achievements/UI/Accept'), self.ActivateCareerFunnel, (False, )), (GetByLabel('Achievements/UI/Dismiss'), self.Close, None))) self.SetCaption(GetByLabel('UI/Achievements/OpportunitiesHint')) self.SetOrder(0) self.activeStep = STEP_ALL_DONE def ActivateNextIncompleteOpportunity(self, emphasize, **kwargs): nextGroup = GetFirstIncompleteAchievementGroup() if nextGroup: if True: self.Close() sm.GetService('achievementSvc').SetActiveAchievementGroupID( nextGroup.groupID, emphasize=emphasize) else: self.UpdateOpportunityState() def ActivateCareerFunnel(self, *args): self.Close() sm.GetService('achievementSvc').SetActiveAchievementGroupID(None) sm.StartService('tutorial').ShowCareerFunnel() def UpdateOpportunityState(self, activeGroupChanged=False, activeGroupCompleted=False): activeGroup = GetActiveAchievementGroup() nextGroup = GetFirstIncompleteAchievementGroup() if activeGroup: nextTask = activeGroup.GetNextIncompleteTask() if nextTask: self.Step_TaskInfo(nextTask, activeGroup) return if nextGroup: if activeGroupCompleted: self.Step_PresentOpportunity() else: self.Step_ActiveCompleted() return elif nextGroup: if self.activeStep not in (STEP_INTRO, STEP_INTRO2, STEP_PRESENT_OPPORTUNITY): self.Step_AskStart() return self.Step_AllDone() def LoadDivider(self): divider = Sprite( parent=self.mainContent, height=1, align=uiconst.TOTOP, texturePath= 'res:/UI/Texture/classes/achievements/divider_horizontal.png', color=(1, 1, 1, 0.3), padding=(0, 2, 0, 2)) def LoadLargeText(self, text, *args, **kwargs): label = Label(parent=self.mainContent, text=text, align=uiconst.TOTOP, fontsize=18, **kwargs) def LoadMediumText(self, text, *args, **kwargs): label = EveLabelMedium(parent=self.mainContent, text=text, align=uiconst.TOTOP, **kwargs) def LoadButton(self, label, func, args=None): buttonContainer = Container(parent=self.mainContent, align=uiconst.TOTOP) button = Button(parent=buttonContainer, label=label, func=func, args=args, align=uiconst.CENTERLEFT) buttonContainer.height = button.height + 8 def LoadButtons(self, buttonData): buttonContainer = FlowContainer(parent=self.mainContent, align=uiconst.TOTOP, padTop=14, contentSpacing=(4, 4), contentAlignment=CONTENT_ALIGN_RIGHT) for label, func, args in buttonData: button = Button(parent=buttonContainer, label=label, func=func, args=args, align=uiconst.NOALIGN) def LoadTreeLink(self): buttonContainer = ContainerAutoSize(parent=self.mainContent, align=uiconst.TOTOP) textButton = IconTextButton( parent=buttonContainer, align=uiconst.TOPRIGHT, label=GetByLabel('Achievements/UI/showAll'), texturePath= 'res:/ui/Texture/Classes/InfoPanels/opportunitiesTreeIcon.png', func=self.OpenOpportunitiesTree, iconSize=16, top=10)
class SkillExtractorWindow(Window): __guid__ = 'form.SkillExtractorWindow' __notifyevents__ = ['OnSessionChanged'] default_width = 350 default_height = 500 default_minSize = (default_width, default_height) default_windowID = 'SkillExtractorWindow' default_captionLabelPath = 'UI/SkillTrading/SkillExtractorWindowCaption' default_iconNum = 'res:/UI/Texture/WindowIcons/augmentations.png' default_topParentHeight = 0 default_clipChildren = True default_isCollapseable = False default_isPinable = False default_isStackable = False @classmethod def OpenOrReload(cls, *args, **kwargs): if cls.IsOpen(): wnd = cls.GetIfOpen() if wnd.controller.isCompleted: wnd.Close() wnd = cls.Open(*args, **kwargs) else: wnd.controller.itemID = kwargs.get('itemID') wnd.Maximize() else: cls.Open(*args, **kwargs) def ApplyAttributes(self, attributes): super(SkillExtractorWindow, self).ApplyAttributes(attributes) self.controller = SkillExtractorController(attributes.itemID) self.filterSettings = SkillFilterSettings() self.Layout() self.Reload() self.filterSettings.onUpdate.connect(self.UpdateNoContentMessage) self.controller.onUpdate.connect(self.OnUpdate) self.controller.onSkillListUpdate.connect(self.Reload) sm.GetService('audio').SendUIEvent('st_activate_skill_extractor_play') def Layout(self): self.HideHeader() self.contentCont = Container(parent=self.GetMainArea(), align=uiconst.TOALL) topCont = Container(parent=self.contentCont, align=uiconst.TOTOP, height=90, top=10) SkillExtractorBar(parent=topCont, align=uiconst.CENTER, state=uiconst.UI_NORMAL, width=250, controller=self.controller) middleCont = Container(parent=self.contentCont, align=uiconst.TOALL, padding=(8, 0, 8, 8)) self.filterCont = Container(parent=middleCont, align=uiconst.TOTOP, height=26, opacity=0.0) SkillFilterMenu( parent=self.filterCont, align=uiconst.CENTERRIGHT, settings=self.filterSettings, hint=localization.GetByLabel('UI/SkillTrading/FilterSettings')) SkillFilterEdit(parent=self.filterCont, align=uiconst.CENTERRIGHT, left=20, filterSettings=self.filterSettings) self.skillScroll = ScrollContainer(parent=middleCont, align=uiconst.TOALL, showUnderlay=True, opacity=0.0) self.loadingPanel = Container(parent=middleCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=250, height=150) LoadingWheel(parent=self.loadingPanel, align=uiconst.CENTERTOP) text = localization.GetByLabel('UI/SkillTrading/LoadingSkills') EveHeaderMedium(parent=self.loadingPanel, align=uiconst.TOTOP, top=50, text='<center>%s</center>' % text) self.messagePanel = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.CENTER, alignMode=uiconst.TOTOP, width=300, opacity=0.0, idx=0) def Reload(self): uthread.new(self._Reload) def _Reload(self): self.AnimShowLoading() self.CheckShipAndShowMessage() self.entryDataList = self._GenerateSkillEntries(self.controller.skills) self._FlushAndPopulateSkillScroll(self.entryDataList) self.UpdateNoContentMessage() self.AnimHideLoading() def AnimShowLoading(self): self.skillScroll.Disable() self.filterCont.Disable() animations.FadeIn(self.loadingPanel) animations.FadeOut(self.skillScroll, duration=0.3) animations.FadeOut(self.filterCont, duration=0.3, sleep=True) def AnimHideLoading(self): self.skillScroll.Enable() self.filterCont.Enable() animations.FadeOut(self.loadingPanel) animations.FadeIn(self.skillScroll) animations.FadeIn(self.filterCont) def _GenerateSkillEntries(self, skills): skillDataByGroupID = itertoolsext.bucket( skills, keyprojection=lambda s: evetypes.GetGroupID(s.typeID), valueprojection=lambda s: SkillEntryData(s, self.controller, self. filterSettings)) groups = [ SkillGroupData(gid, self.filterSettings, children=data) for gid, data in skillDataByGroupID.iteritems() ] return sorted(groups, key=lambda x: x.GetLabel().lower()) def _FlushAndPopulateSkillScroll(self, groups): self.skillScroll.Flush() for groupData in groups: SkillGroupEntry(parent=self.skillScroll, data=groupData, defaultExpanded=False) blue.pyos.BeNice() def OnUpdate(self): self.UpdateNoContentMessage() self.CheckCompletedAndShowMessage() def UpdateNoContentMessage(self): self.skillScroll.HideNoContentHint() if all((data.isFiltered for data in self.entryDataList)): emptyHint = localization.GetByLabel('UI/SkillTrading/NoSkillsHint') self.skillScroll.ShowNoContentHint(emptyHint) def CheckCompletedAndShowMessage(self): if self.controller.isCompleted: self.PrepareCompleteMessage() self.AnimShowMessage() def PrepareCompleteMessage(self): self.messagePanel.Flush() text = localization.GetByLabel( 'UI/SkillTrading/CompleteMessageCaption') EveCaptionMedium(parent=self.messagePanel, align=uiconst.TOTOP, text='<center>%s</center>' % text) text = localization.GetByLabel('UI/SkillTrading/CompleteMessageMain', amount=self.controller.SKILL_POINT_GOAL, injector=invconst.typeSkillInjector) EveLabelMedium(parent=self.messagePanel, align=uiconst.TOTOP, top=4, text='<center>%s</center>' % text) iconCont = Container(parent=self.messagePanel, align=uiconst.TOTOP, top=8, height=64) Icon(parent=iconCont, align=uiconst.CENTER, left=-40, typeID=invconst.typeSkillInjector, size=64, state=uiconst.UI_DISABLED) Sprite( parent=iconCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/skilltrading/arrow_right.png', width=32, height=32, opacity=0.6) Sprite(parent=iconCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, left=40, texturePath='res:/UI/Texture/WindowIcons/itemHangar.png', width=64, height=64) text = localization.GetByLabel('UI/SkillTrading/CompleteMessageTail', injector=invconst.typeSkillInjector) EveLabelMedium(parent=self.messagePanel, align=uiconst.TOTOP, top=8, text='<center>%s</center>' % text) buttonCont = Container(parent=self.messagePanel, align=uiconst.TOTOP, top=16, height=40) Button(parent=buttonCont, align=uiconst.CENTER, label=localization.GetByLabel('UI/Common/Done'), func=self.Close) def CheckShipAndShowMessage(self): if self.controller.isCompleted: return ship = sm.GetService('godma').GetItem(session.shipid) if ship.groupID != const.groupCapsule: self.PrepareShipMessage() self.AnimShowMessage() else: self.AnimHideMessage() def PrepareShipMessage(self): self.messagePanel.Flush() text = 'Must Be In Capsule' EveCaptionMedium(parent=self.messagePanel, align=uiconst.TOTOP, text='<center>%s</center>' % text) text = 'A direct connection to your capsule is required in order to extract skill points. Please leave your active ship to continue.' EveLabelMedium(parent=self.messagePanel, align=uiconst.TOTOP, top=4, text='<center>%s</center>' % text) buttonCont = Container(parent=self.messagePanel, align=uiconst.TOTOP, top=16, height=40) Button(parent=buttonCont, align=uiconst.CENTER, label='Leave Current Ship', func=self.LeaveShip, args=()) def AnimShowMessage(self): self.contentCont.Disable() animations.FadeTo(self.contentCont, startVal=self.contentCont.opacity, endVal=0.1) animations.FadeIn(self.messagePanel) def AnimHideMessage(self): self.contentCont.Enable() animations.FadeTo(self.contentCont, startVal=self.contentCont.opacity, endVal=1.0) animations.FadeOut(self.messagePanel) def Close(self, *args, **kwargs): super(SkillExtractorWindow, self).Close(*args, **kwargs) self.controller.Close() def OnSessionChanged(self, isRemote, sess, change): if 'stationid2' in change: self.Close() elif 'shipid' in change: self.CheckShipAndShowMessage() def LeaveShip(self): ship = sm.GetService('godma').GetItem(session.shipid) sm.StartService('station').TryLeaveShip(ship) self.AnimHideMessage()
class SettingSection(ContainerAutoSize): default_name = 'SettingSection' default_align = uiconst.TOTOP def ApplyAttributes(self, attributes): ContainerAutoSize.ApplyAttributes(self, attributes) self.structureProfileController = attributes.structureProfileController self.ChangeSignalConnection() self.settingID = attributes.settingID sgControllers = self.structureProfileController.GetGroupsBySettingID( self.settingID) canHaveGroups = CanHaveGroups(self.settingID) if not canHaveGroups and not sgControllers: self.structureProfileController.AddGroup(self.settingID, groupID=NO_GROUP_ID, doSignal=False) sgControllers = self.structureProfileController.GetGroupsBySettingID( self.settingID) self.AddHeader(canHaveGroups, sgControllers) self.sectionCont = ContainerAutoSize(parent=self, name='sectionCont', align=uiconst.TOTOP) self.LoadGroups() def ChangeSignalConnection(self, connect=True): signalAndCallback = [(self.structureProfileController.on_groups_added, self.OnGroupsAdded), (self.structureProfileController.on_group_changed, self.OnGroupsChanged)] ChangeSignalConnect(signalAndCallback, connect) def LoadGroups(self): self.sectionCont.Flush() canHaveGroups = CanHaveGroups(self.settingID) if not canHaveGroups: return sgControllers = self.structureProfileController.GetGroupsBySettingID( self.settingID) if sgControllers: accessGroupsController = sm.GetService( 'structureControllers').GetAccessGroupController() groupIDs = [c.GetGroupID() for c in sgControllers] accessGroupsController.PopulatePublicGroupInfo(groupIDs) toSort = [] for c in sgControllers: groupInfo = accessGroupsController.GetGroupInfoFromID( c.GetGroupID()) if groupInfo is None: continue nameLower = groupInfo['name'].lower() toSort.append((nameLower, (c, groupInfo))) sortedControllers = SortListOfTuples(toSort) for c, groupInfo in sortedControllers: GroupEntry( parent=self.sectionCont, groupID=c.GetGroupID(), settingGroupController=c, structureProfileController=self.structureProfileController, groupInfo=groupInfo) else: x = Generic(parent=self.sectionCont, height=30) x.Startup() x.Load( node=Bunch(label=GetByLabel('UI/StructureSettingWnd/NoGroups'), sublevel=1)) def AddHeader(self, canHaveGroups, sgControllers): if canHaveGroups: self.header = SettingSectionHeaderWithGroups( parent=self, structureProfileController=self.structureProfileController, expanderFunc=self.OnExpandGroups, settingID=self.settingID) else: sgController = list(sgControllers)[0] if sgController.GetSettingType( ) == structures.SETTINGS_TYPE_PERCENTAGE: headerClass = SettingSectionHeaderWithPercentage elif sgController.GetSettingType( ) == structures.SETTINGS_TYPE_BOOL: headerClass = SettingSectionHeaderWithCheckbox else: raise RuntimeError('Bad settingType', sgController.GetSettingType(), sgController.GetSettingID()) self.header = headerClass( parent=self, structureProfileController=self.structureProfileController, sgController=sgController, settingID=self.settingID) def OnExpandGroups(self): isExpanded = settings.user.ui.Get(UI_EXPANDED_SETTING % self.settingID, True) self.sectionCont.display = isExpanded def DragChanged(self, initiated): canHaveGroups = CanHaveGroups(self.settingID) if not canHaveGroups: return self.header.OnGroupsDragged(initiated) def Close(self): self.ChangeSignalConnection(connect=False) self.structureProfileController = None ContainerAutoSize.Close(self) def OnGroupsAdded(self, settingID, groupIDs): if settingID != self.settingID: return self.LoadGroups() self.header.BlinkBgFill() def OnGroupsChanged(self): self.LoadGroups()
class InfoPanelAchievements(InfoPanelBase): __guid__ = 'uicls.InfoPanelAchievements' default_name = 'InfoPanelAchievements' default_iconTexturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesPanelIcon.png' default_state = uiconst.UI_PICKCHILDREN default_height = 120 label = 'UI/Achievements/OpportunitiesHint' hasSettings = False panelTypeID = PANEL_ACHIEVEMENTS __notifyevents__ = [ 'OnAchievementGroupSelectionChanged', 'OnAchievementsReady', 'OnAchievementChanged' ] def ApplyAttributes(self, attributes): InfoPanelBase.ApplyAttributes(self, attributes) self.headerTextCont = Container(name='headerTextCont', parent=self.headerCont, align=uiconst.TOALL) self.titleLabel = self.headerCls( name='title', text=GetByLabel('UI/Achievements/InfoPanelHeader'), parent=self.headerTextCont, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED) @staticmethod def IsAvailable(): """ Is this info panel currently available for viewing """ return settings.user.ui.Get('opportunities_showTemp', False) def GetAllGroups(self): allGroups = AllAchievementGroups().GetGroups() return allGroups def GetGroupFromGroupID(self, groupID): allGroups = AllAchievementGroups().GetGroups() return allGroups.get(groupID, None) def ConstructCompact(self): self.mainCont.Flush() def ConstructNormal(self): self.mainCont.Flush() completedText = self.GetCompletedText() subTextCont = Container(parent=self.mainCont, name='subTextCont', align=uiconst.TOTOP, height=20) self.backSprite = Sprite( name='arrow', parent=subTextCont, pos=(0, 0, 14, 14), texturePath= 'res:/UI/Texture/Classes/InfoPanels/opportunitiesReturnArrow.png', state=uiconst.UI_NORMAL, align=uiconst.CENTERLEFT) self.backSprite.OnClick = self.OnBackClicked self.backSprite.display = False self.subTextLabel = EveLabelMediumBold(parent=subTextCont, align=uiconst.CENTERLEFT, text=completedText, state=uiconst.UI_DISABLED) self.subTextLabel.OnClick = self.OnBackClicked self.achievementContent = ContainerAutoSize(parent=self.mainCont, name='achievementContent', height=30, align=uiconst.TOTOP, padBottom=4) groupID = settings.user.ui.Get('opportunities_infoPanel_group', None) self.LoadContent(groupID) def GetCompletedText(self): allGroups = self.GetAllGroups() completedGroups = 0 for eachGroupInfo in allGroups.itervalues(): totalNum = len(eachGroupInfo.achievements) completed = len( [x for x in eachGroupInfo.achievements if x.completed]) if completed == totalNum: completedGroups += 1 completedText = GetByLabel('UI/Achievements/InfoPanelCompletedText', completedNum=completedGroups, totalNum=len(allGroups)) return completedText def LoadContent(self, groupID=None): self.achievementContent.Flush() self.ChangeSubTextCont(bool(groupID)) if groupID: self.LoadOneDetailedGroup(groupID) else: self.LoadGroups() def LoadOneDetailedGroup(self, groupID): settings.user.ui.Set('opportunities_infoPanel_group', groupID) selectedGroup = self.GetGroupFromGroupID(groupID) if not selectedGroup: return self.LoadGroups() self.AddGroupEntry(selectedGroup, isExpanded=True) def LoadGroups(self): settings.user.ui.Set('opportunities_infoPanel_group', None) allGroups = self.GetAllGroups() for eachGroupID, eachGroup in allGroups.iteritems(): self.AddGroupEntry(eachGroup, isExpanded=False) def AddGroupEntry(self, groupInfo, isExpanded): entry = AchievementGroup(parent=self.achievementContent, align=uiconst.TOTOP, groupInfo=groupInfo, isExpanded=isExpanded, clickCallback=self.OnGroupClicked) return entry def OnGroupClicked(self, groupInfo, isExpanded): if isExpanded: self.GoBack() else: self.ExpandGroup(groupInfo) def OnBackClicked(self, *args): self.GoBack() def GoBack(self): self.ChangeSubTextCont(groupIsExpanded=False) self.LoadContent() def ExpandGroup(self, groupInfo): self.LoadContent(groupInfo.groupID) self.ChangeSubTextCont(groupIsExpanded=True) def ChangeSubTextCont(self, groupIsExpanded): if groupIsExpanded: self.backSprite.display = True self.subTextLabel.left = 20 self.subTextLabel.text = GetByLabel( 'UI/Achievements/InfoPanelShowAllCategories') self.subTextLabel.state = uiconst.UI_NORMAL else: self.backSprite.display = False self.subTextLabel.left = 0 self.subTextLabel.text = self.GetCompletedText() self.subTextLabel.state = uiconst.UI_DISABLED def OnInfoHeaderClicked(self, container, *args): return self.OnHeaderClicked(self.infoContent, container.isOpen) def OnAchievementHeaderClicked(self, container, *args): return self.OnHeaderClicked(self.achievementContent, container.isOpen) def OnHeaderClicked(self, subContainer, isOpen): if isOpen: subContainer.display = True else: subContainer.display = False def OnAchievementGroupSelectionChanged(self): self.Refresh() def OnAchievementsReady(self, *args): self.Refresh() def OnAchievementChanged(self): self.Refresh() def Refresh(self): if self.mode != infoPanelConst.MODE_NORMAL: self.ConstructCompact() else: self.ConstructNormal()
class ControlCatalogWindow(Window): default_windowID = 'ControlCatalogWindow' default_topParentHeight = 0 default_caption = 'UI Control Catalog' default_width = 900 default_height = 800 def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.entriesByID = {} self.currClassData = None self.currSampleNum = 1 self.numSamples = 0 uthread.new(self.ConstuctLayout) def ConstuctLayout(self): self.leftCont = DragResizeCont( name='leftCont', parent=self.sr.main, align=uiconst.TOLEFT_PROP, settingsID='ControlCatalogWindowLeftCont') self.infoCont = ContainerAutoSize(name='infoCont', parent=self.sr.main, align=uiconst.TOTOP, padding=6) self.topCont = DragResizeCont( name='topCont', parent=self.sr.main, align=uiconst.TOTOP_PROP, settingsID='ControlCatalogWindowSampleCont', minSize=0.3, maxSize=0.9, defaultSize=0.5, clipChildren=True) tabCont = ContainerAutoSize(name='tabCont', parent=self.topCont.mainCont, align=uiconst.TOBOTTOM) self.mainButtonGroup = ButtonGroup(name='mainButtonGroup', parent=self.sr.main) self.editCont = Container(name='editCont', parent=self.sr.main) GradientSprite(bgParent=self.leftCont, rotation=0, rgbData=[(0, (1.0, 1.0, 1.3))], alphaData=[(0.8, 0.0), (1.0, 0.05)]) self.controlScroll = ScrollContainer(parent=self.leftCont) self.PopulateScroll() self.leftButtonGroup = ButtonGroup(name='leftButtonGroup', parent=self.leftCont, idx=0) self.ConstructLeftButtonGroup() self.classNameLabel = Label(parent=self.infoCont, align=uiconst.TOTOP, fontsize=15, bold=True) self.classDocLabel = EveLabelSmall(parent=self.infoCont, align=uiconst.TOTOP) GradientSprite(align=uiconst.TOTOP, parent=self.infoCont, rotation=-math.pi / 2, height=16, padding=(-4, -10, -4, 0), rgbData=[(0, (1.0, 1.0, 1.3))], alphaData=[(0.0, 0.0), (1.0, 0.03)]) GradientSprite(align=uiconst.TOTOP, parent=tabCont, state=uiconst.UI_DISABLED, rotation=math.pi / 2, height=16, padding=(-4, 0, -4, -10), rgbData=[(0, (1.0, 1.0, 1.3))], alphaData=[(0.0, 0.0), (1.0, 0.03)]) self.sampleNameLabel = EveLabelSmall(parent=tabCont, align=uiconst.TOTOP, padBottom=5) self.tabs = ToggleButtonGroup(parent=Container(parent=tabCont, align=uiconst.TOTOP, height=16), align=uiconst.CENTER, height=16, callback=self.OnTabSelected) sampleParent = Container(name='sampleParent', parent=self.topCont.mainCont, clipChildren=True) self.sampleCont = ContainerAutoSize(name='sampleCont', parent=sampleParent, align=uiconst.CENTER) self.codeEdit = EditPlainText(parent=self.editCont, align=uiconst.TOALL, fontcolor=(1, 1, 1, 1), ignoreTags=True) self.codeEdit.OnKeyDown = self.OnCodeEditKeyDown self.ConstructMainButtonGroup() uthread.new(self._SpyOnSampleCodeReloadThread) def OnSampleFileReload(self, path): self.PopulateScroll() self.SetSelectedControl(self.currClassData) def _SpyOnSampleCodeReloadThread(self): try: from eve.common.modules.sake.platform.win32.win32api import Waitables from eve.common.modules.sake.autocompile import SpyFolder class ControlCatalogSpyFolder(SpyFolder): def __init__(self, callback, *args, **kw): SpyFolder.__init__(self, *args, **kw) self.callback = callback def process_folder(self, path): try: self.callback(path) except Exception as e: log.LogException(e) spy = ControlCatalogSpyFolder( self.OnSampleFileReload, Waitables(), (os.path.abspath(os.path.dirname(__file__)), )) while not self.destroyed: spy.waitables.Wait(0) blue.pyos.synchro.Sleep(50) except ImportError: pass def ConstructLeftButtonGroup(self): for label, func in (('Browse', self.BrowseControls), ): self.leftButtonGroup.AddButton(label, func) def ConstructMainButtonGroup(self): for label, func, hint in (('Reload', self.ReloadSamples, 'Reload all sample code [ctrl+s]'), ('Edit module', self.OpenModuleCodeInEditor, 'Open module containing class in editor'), ('Edit samples', self.OpenSampleCodeInEditor, 'Open sample code in editor')): self.mainButtonGroup.AddButton(label, func, hint=hint) def OpenSampleCodeInEditor(self, *args): self.currClassData.OpenSampleCodeInEditor() def BrowseControls(self, *args): controlData.BrowseControls() def OpenModuleCodeInEditor(self, *args): self.currClassData.OpenModuleCodeInEditor() def PopulateScroll(self): self.controlScroll.Flush() for data in controlData.GetControlData(): TreeViewEntry(parent=self.controlScroll, data=data, eventListener=self) if self.currClassData and self.currClassData.GetID() == data.GetID( ): self.currClassData = data def RegisterID(self, entry, entryID): if entryID in self.entriesByID: raise ValueError('Same entry registered again: %s' % entryID) self.entriesByID[entryID] = entry def UnregisterID(self, entryID): self.entriesByID.pop(entryID) def OnTreeViewClick(self, selected): if selected.data.HasChildren(): selected.ToggleChildren() else: for entry in self.entriesByID.values(): entry.UpdateSelectedState((selected.data.GetID(), )) self.currSampleNum = 1 self.SetSelectedControl(selected.data) def SetSelectedControl(self, data): self.codeEdit.Clear() self.sampleCont.Flush() self.codeEdit.SetText(data.GetCode(), html=False) self.currClassData = data self.UpdateInfoCont() self.ReloadSamples() def UpdateInfoCont(self): cls = self.currClassData.GetBaseClass() if not hasattr(cls, '__module__'): raise RuntimeError( 'Unable to identify sample class. IMPORTANT: Make sure the first line in the example imports the example class itself.' ) self.classNameLabel.text = '<center>' + cls.__module__ + '.' + cls.__name__ doc = cls.__doc__ or '' self.classDocLabel.text = '<center>' + doc.strip() if 'depricated' in doc.lower(): self.classNameLabel.text = '<color=red>' + self.classNameLabel.text self.classDocLabel.text = '<color=red>' + self.classDocLabel.text def GetCodeText(self): return self.codeEdit.GetAllText() def ReloadSamples(self, *args): numSamples = controlData.GetNumSamples(self.GetCodeText()) if numSamples != self.numSamples: self.numSamples = numSamples self.ReconstructTabs() self.tabs.SelectByID(self.currSampleNum) def ReconstructTabs(self): self.tabs.ClearButtons() for i in xrange(1, self.numSamples + 1): self.tabs.AddButton(i, 'Sample %s' % i) self.tabs.width = self.numSamples * 65 def OnTabSelected(self, sampleNum): self.currSampleNum = sampleNum self.ReloadCurrentSample() def ReloadCurrentSample(self): self.sampleCont.Flush() uicore.animations.FadeTo(self.sampleCont, 0.0, 1.0, 0.1) if self.numSamples: exec(self.GetCodeText() + '\n', globals()) exec 'Sample%s(parent=self.sampleCont)' % self.currSampleNum sampleName = None exec 'sampleName = Sample%s.__doc__' % self.currSampleNum if sampleName: self.sampleNameLabel.Show() self.sampleNameLabel.text = '<center>' + sampleName else: self.sampleNameLabel.Hide() self.sampleNameLabel.text = '' def OnCodeEditKeyDown(self, key, flag): if uicore.uilib.Key(uiconst.VK_CONTROL) and key == uiconst.VK_S: self.ReloadSamples() else: return EditPlainText.OnKeyDown(self.codeEdit, key, flag)
class AchievementGroupEntry(ContainerAutoSize): __notifyevents__ = ['OnAchievementChanged'] default_padTop = 0 default_padBottom = 3 default_state = uiconst.UI_NORMAL default_alignMode = uiconst.TOTOP texturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesIcon_Explore.png' progressBackground = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesFillBar.png' fillBox = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesFillBox.png' checkmarkPath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesCheck.png' groupData = None loadTaskBackgrounds = True def ApplyAttributes(self, attributes): ContainerAutoSize.ApplyAttributes(self, attributes) self.loadTaskBackgrounds = attributes.get('loadTaskBackgrounds', self.loadTaskBackgrounds) self.ConstructLayout() self.LoadGroupData(attributes.groupInfo, attributes.blinkAchievementID, attributes.animateIn) sm.RegisterNotify(self) def ConstructLayout(self): headerContainer = Container(parent=self, align=uiconst.TOTOP, height=28, padTop=4, padBottom=6) self.groupName = EveLabelLarge(parent=headerContainer, align=uiconst.CENTERLEFT, left=8) self.rewardAmount = themeColored.LabelThemeColored( parent=headerContainer, align=uiconst.CENTERRIGHT, left=8, state=uiconst.UI_NORMAL) self.rewardAmountThemeColor = self.rewardAmount.color.GetRGBA() Frame(texturePath=POINT_RIGHT_HEADER_FRAME_TEXTURE_PATH, cornerSize=16, offset=-14, parent=headerContainer, color=POINT_RIGHT_HEADER_COLOR, align=uiconst.TOALL) progressClipper = Container(parent=headerContainer, align=uiconst.TOALL, clipChildren=True, padRight=-POINTER_PADRIGHT) self.progress = Frame( texturePath=POINT_RIGHT_HEADER_BACKGROUND_TEXTURE_PATH, cornerSize=15, offset=-13, parent=progressClipper, color=POINT_RIGHT_HEADER_COLOR) self.progress.padRight = 400 self.progress.opacity = 0.0 self.tasksContainer = ContainerAutoSize(parent=self, name='tasksContainer', align=uiconst.TOTOP, state=uiconst.UI_NORMAL) def LoadGroupData(self, groupData, blinkAchievementID=None, animateIn=False): if not self.groupData or self.groupData.groupID != groupData.groupID: self.groupData = groupData self.groupName.text = GetByLabel(self.groupData.groupName) rewardText = '' import util rewardAmount = GROUP_TO_REWARD.get(self.groupData.groupID, 0) if rewardAmount > 0: rewardText = util.FmtISK(rewardAmount, showFractionsAlways=False) self.rewardAmount.text = rewardText if rewardText != '': self.rewardAmount.state = uiconst.UI_NORMAL else: self.rewardAmount.state = uiconst.UI_HIDDEN self.AddAchievementTasks(blinkAchievementID=blinkAchievementID, animateIn=animateIn) if animateIn: self.AnimateIn() self.UpdateState() def UpdateState(self, changedAchievementID=None): self.UpdateProgress() self.UpdateAchievementTasks(changedAchievementID=changedAchievementID) def OnAchievementChanged(self, achievement, *args, **kwds): if self.groupData.HasAchievement(achievement.achievementID): self.UpdateState(changedAchievementID=achievement.achievementID) def UpdateProgress(self): if self.groupData.IsCompleted(): self.rewardAmount.hint = GetByLabel( 'UI/Achievements/OpportunityRewardGiven') self.rewardAmount.bold = True self.rewardAmount.color = self.rewardAmountThemeColor else: self.rewardAmount.color = (1.0, 1.0, 1.0, 0.5) self.rewardAmount.hint = GetByLabel( 'UI/Achievements/OpportunityRewardNotGiven') self.rewardAmount.bold = False progressProportion = self.groupData.GetProgressProportion() maxWidth = ReverseScaleDpi(self.displayWidth) - POINTER_PADRIGHT uicore.animations.MorphScalar(self.progress, 'padRight', startVal=self.progress.padRight, endVal=POINTER_PADRIGHT + maxWidth * (1 - progressProportion), curveType=uiconst.ANIM_SMOOTH, duration=0.33) uicore.animations.MorphScalar(self.progress, 'opacity', startVal=self.progress.opacity, endVal=min(progressProportion, 0.25), curveType=uiconst.ANIM_SMOOTH, duration=0.33) def OpenAchievementAuraWindow(self, *args): AchievementAuraWindow.Open() def UpdateAchievementTasks(self, changedAchievementID=None): if changedAchievementID and not self.groupData.HasAchievement( changedAchievementID): return nextTask = self.groupData.GetNextIncompleteTask( currentAchievementTaskID=changedAchievementID) showDetails = None for each in self.tasksContainer.children: if nextTask and each.achievementTask.achievementID == nextTask.achievementID: showDetails = each each.UpdateAchievementTaskState(animate=changedAchievementID == each.achievementTask.achievementID) if showDetails: uthread.new(showDetails.ShowDetails) def AddAchievementTasks(self, blinkAchievementID=None, animateIn=False): self.tasksContainer.Flush() for achievementTask in self.groupData.GetAchievementTasks(): AchievementTaskEntry( parent=self.tasksContainer, align=uiconst.TOTOP, achievement=achievementTask, blinkIn=not animateIn and achievementTask.achievementID == blinkAchievementID, opacity=0.0 if animateIn else 1.0, achievementGroup=self.groupData, callbackTaskExpanded=self.OnTaskExpanded, showBackground=self.loadTaskBackgrounds) def OnTaskExpanded(self, expandedTask, *args): for each in self.tasksContainer.children: if each is not expandedTask: each.HideDetails() def AnimateIn(self): to = 0.0 for each in self.tasksContainer.children: uicore.animations.FadeIn(each, duration=0.08, timeOffset=to, curveType=uiconst.ANIM_OVERSHOT) if hasattr(each, 'ShowIntroAnimation'): each.ShowIntroAnimation() to += 0.05 def LoadTooltipPanel(self, tooltipPanel, *args, **kwds): return tooltipPanel.LoadGeneric2ColumnTemplate() extraInfo = self.groupData.extraInfo tipsHeader = EveLabelSmall( text=GetByLabel('UI/Achievements/TipsAndInfoHeader'), width=200, bold=True) tooltipPanel.AddCell(tipsHeader, colSpan=tooltipPanel.columns) tipsText = EveLabelSmall(text=GetByLabel( self.groupData.groupDescription), align=uiconst.TOTOP) tooltipPanel.AddCell(tipsText, colSpan=tooltipPanel.columns) for info in extraInfo: icon = Sprite(name='icon', parent=tooltipPanel, pos=(0, 0, info['size'], info['size']), texturePath=info['path'], state=uiconst.UI_DISABLED, align=uiconst.TOPLEFT, color=info.get('color', None)) label = EveLabelSmall(name='tipsHeader', text=info['text'], parent=tooltipPanel, width=180, align=uiconst.CENTERLEFT)
class AssetSafetyDeliverWindow(Window): __guid__ = 'form.AssetSafetyDeliverWindow' default_width = 600 default_height = 100 default_windowID = 'AssetSafetyDeliverWindow' default_topParentHeight = 0 default_clipChildren = True default_isPinable = False LINE_COLOR = (1, 1, 1, 0.2) BLUE_COLOR = (0.0, 0.54, 0.8, 1.0) GREEN_COLOR = (0.0, 1.0, 0.0, 0.8) GRAY_COLOR = Color.GRAY5 PADDING = 15 def ApplyAttributes(self, attributes): Window.ApplyAttributes(self, attributes) self.solarSystemID = attributes.solarSystemID self.assetWrapID = attributes.assetWrapID self.nearestNPCStationInfo = attributes.nearestNPCStationInfo self.autoDeliveryTimestamp = attributes.autoDeliveryTimestamp self.manualDeliveryTimestamp = attributes.manualDeliveryTimestamp self.Layout() uthread.new(self.ReloadContent) def Layout(self): self.MakeUnMinimizable() self.HideHeader() self.MakeUnResizeable() self.container = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.TOTOP, alignMode=uiconst.TOTOP, state=uiconst.UI_PICKCHILDREN, padding=(self.PADDING, self.PADDING, self.PADDING, self.PADDING), callback=self.OnContainerResized) text = GetByLabel('UI/Inventory/AssetSafety/DeliverToStation') header = EveLabelLargeBold(parent=self.container, align=uiconst.TOTOP, text=text) self.explanationLabel = EveLabelMedium(parent=self.container, align=uiconst.TOTOP, text='', color=self.GRAY_COLOR, padding=(0, 0, 0, 15), state=uiconst.UI_NORMAL) Line(parent=self.container, align=uiconst.TOTOP, color=self.LINE_COLOR) self.sameSolarSystemParent = ScrollContainer(parent=self.container, align=uiconst.TOTOP) self.sameSolarSystem = ContainerAutoSize(parent=self.sameSolarSystemParent, align=uiconst.TOTOP, alignMode=uiconst.TOTOP) self.nearestStationLabel = EveLabelMedium(parent=self.container, align=uiconst.TOTOP, text='', color=self.GRAY_COLOR, padding=(0, 0, 0, 0)) self.closeButton = Button(parent=self.container, label=GetByLabel('UI/Generic/Cancel'), func=self.Close, align=uiconst.TOTOP, fontsize=13, padding=(220, 10, 220, 0)) uicore.animations.FadeTo(self.container, startVal=0.0, endVal=1.0, duration=0.5) def SetText(self, systemStations): solarSystemName = GetShowInfoLink(const.typeSolarSystem, cfg.evelocations.Get(self.solarSystemID).name, self.solarSystemID) now = blue.os.GetWallclockTime() timeUntilAuto = FormatTimeIntervalShortWritten(long(max(0, self.autoDeliveryTimestamp - now))) nearestNPCStationText = GetShowInfoLink(self.nearestNPCStationInfo['typeID'], self.nearestNPCStationInfo['name'], self.nearestNPCStationInfo['itemID']) stationsInSystem = len(systemStations) if self.manualDeliveryTimestamp - now < 0: if stationsInSystem: path = 'UI/Inventory/AssetSafety/DeliveryExplanationText' else: path = 'UI/Inventory/AssetSafety/DeliveryExplanationTextNoStations' text = GetByLabel(path, solarSystemName=solarSystemName, npcStationName=nearestNPCStationText, timeUntil=timeUntilAuto) else: timeUntilManual = FormatTimeIntervalShortWritten(long(max(0, self.manualDeliveryTimestamp - now))) if stationsInSystem: path = 'UI/Inventory/AssetSafety/DeliveryNotAvailableNowExplanationText' else: path = 'UI/Inventory/AssetSafety/DeliveryNotAvailableTextNoStations' text = GetByLabel(path, solarSystemName=solarSystemName, timUntilManualDelivery=timeUntilManual, npcStationName=nearestNPCStationText, timeUntilAutoDelivery=timeUntilAuto) self.explanationLabel.text = text def OnContainerResized(self): self.width = self.default_width self.height = self.container.height + self.PADDING * 2 def ReloadContent(self): if self.destroyed: return self.sameSolarSystem.DisableAutoSize() self.sameSolarSystem.Flush() systemStations, nearestNPCStation = sm.RemoteSvc('structureAssetSafety').GetStructuresICanDeliverTo(self.solarSystemID) self.SetText(systemStations) if systemStations: stationIDs = [ station['itemID'] for station in systemStations ] cfg.evelocations.Prime(stationIDs) stations = [ s for s in systemStations if evetypes.GetCategoryID(s['typeID'] == const.categoryStation) ] sortedStations = GetSortedStationList(self.solarSystemID, systemStations) otherStructures = GetSortedStructures(self.solarSystemID, systemStations) buttonIsDisabled = self.manualDeliveryTimestamp - blue.os.GetWallclockTime() > 0 for each in otherStructures + sortedStations: self.AddStation(each, buttonIsDisabled) self.sameSolarSystem.EnableAutoSize() self.sameSolarSystemParent.height = min(MAX_STATIONCONT_HEIGHT, self.sameSolarSystem.height) def AddStation(self, station, buttonIsDisabled): parent = self.sameSolarSystem container = ContainerAutoSize(parent=parent, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, state=uiconst.UI_PICKCHILDREN, bgColor=(0.2, 0.2, 0.2, 0.3)) container.DisableAutoSize() label = GetShowInfoLink(station['typeID'], station['name'], station['itemID']) EveLabelMediumBold(parent=container, height=30, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, text=label, padding=(7, 8, 140, 5)) btn = Button(parent=container, label=GetByLabel('UI/Inventory/AssetSafety/DeliverBtn'), align=uiconst.CENTERRIGHT, fontsize=13, fixedwidth=140, fixedheight=25, pos=(5, 0, 0, 0), func=self.DoDeliver, args=station['itemID']) if buttonIsDisabled: btn.Disable() Line(parent=parent, align=uiconst.TOTOP, color=self.LINE_COLOR) container.EnableAutoSize() def DoDeliver(self, *args): if eve.Message('SureYouWantToMoveAssetSafetyItemsToLocation', {}, uiconst.YESNO) != uiconst.ID_YES: return try: sm.RemoteSvc('structureAssetSafety').MoveSafetyWrapToStructure(self.assetWrapID, self.solarSystemID, destinationID=args[0]) finally: AssetSafetyDeliverWindow.CloseIfOpen() sm.GetService('objectCaching').InvalidateCachedMethodCall('structureAssetSafety', 'GetStructuresICanDeliverTo') sm.GetService('objectCaching').InvalidateCachedMethodCall('structureAssetSafety', 'GetItemsInSafety')