def ConstructLayout(self): invitorCont = uiprimitives.Container(name='invitorCont', parent=self.sr.main, align=uiconst.TOTOP, pos=(0, 0, 0, 70), padding=(const.defaultPadding, const.defaultPadding, const.defaultPadding, 0), state=uiconst.UI_PICKCHILDREN) challangerImgCont = uiprimitives.Container( name='challangerImgCont', parent=invitorCont, align=uiconst.TOLEFT, pos=(0, 0, 64, 0), padding=(0, 0, const.defaultPadding, 0), state=uiconst.UI_PICKCHILDREN) challangerCont = uiprimitives.Container(name='challangerCont', parent=invitorCont, align=uiconst.TOALL, pos=(0, 0, 0, 0), padding=(const.defaultPadding, 0, 0, 0)) uiutil.GetOwnerLogo(challangerImgCont, self.charID, size=64, noServerCall=True) stateFlag = FlagIconWithState(parent=challangerImgCont, align=uiconst.BOTTOMRIGHT, left=4, top=10) labels = [ uicontrols.EveLabelMedium( name='charNameLabel', text=localization.GetByLabel('UI/Common/Name'), parent=challangerCont, left=0, top=0, align=uiconst.TOPLEFT, width=60, state=uiconst.UI_NORMAL, idx=0), uicontrols.EveLabelMedium( name='corpNameLabel', text=localization.GetByLabel('UI/Common/Corporation'), parent=challangerCont, left=0, top=21, align=uiconst.TOPLEFT, width=270, state=uiconst.UI_NORMAL, idx=0) ] if self.allianceID is not None: labels.append( uicontrols.EveLabelMedium( name='allianceNameLabel', text=localization.GetByLabel('UI/Common/Alliance'), parent=challangerCont, left=0, top=42, align=uiconst.TOPLEFT, width=270, state=uiconst.UI_NORMAL, idx=0)) labelLength = max( (l.textwidth for l in labels)) + 2 * const.defaultPadding uicontrols.EveLabelMedium(name='charName', text=util.FmtOwnerLink(self.charID), parent=challangerCont, left=labelLength, top=0, align=uiconst.TOPLEFT, width=270, state=uiconst.UI_NORMAL, idx=0) uicontrols.EveLabelMedium(name='corpName', text=util.FmtOwnerLink(self.corpID), parent=challangerCont, left=labelLength, top=21, align=uiconst.TOPLEFT, width=270, state=uiconst.UI_NORMAL, idx=0) if self.allianceID is not None: uicontrols.EveLabelMedium(name='allianceName', text=util.FmtOwnerLink(self.allianceID) if self.allianceID else '', parent=challangerCont, left=labelLength, top=42, align=uiconst.TOPLEFT, width=270, state=uiconst.UI_NORMAL, idx=0) uiprimitives.Sprite( name='logo', parent=invitorCont, texturePath= 'res:/UI/Texture/Crimewatch/Crimewatch_LimitedEngagement_64.png', width=64, height=64, align=uiconst.TOPRIGHT, padding=(0, 0, const.defaultPadding, 0)) bodyTextCont = uiprimitives.Container( name='bodyTextCont', parent=self.sr.main, align=uiconst.TOTOP, pos=(0, 0, 0, 30), padding=(const.defaultPadding, const.defaultPadding * 2, const.defaultPadding, 0), state=uiconst.UI_PICKCHILDREN) box = uiprimitives.Container( parent=bodyTextCont, name='frame', align=uiconst.TOLEFT, width=64, height=64, padding=(const.defaultPadding, const.defaultPadding * 3, const.defaultPadding, const.defaultPadding * 3)) self.time = uicontrols.Label(parent=box, name='counter', text='60', fontsize=32, bold=False, align=uiconst.CENTERRIGHT, color=Colors.Engagement.GetRGBA(), left=15) captionCont = uiprimitives.Container(name='captionCont', parent=bodyTextCont, align=uiconst.TOALL, pos=(0, 0, 0, 0)) l = uicontrols.EveLabelSmall( name='charName', text=localization.GetByLabel('UI/Crimewatch/Duel/DuelDecleration'), parent=captionCont, left=0, top=0, align=uiconst.TOALL, state=uiconst.UI_NORMAL) bodyTextCont.height = max(64, l.textheight) controlsCont = uiprimitives.Container( name='controlsCont', parent=self.sr.main, align=uiconst.TOTOP, pos=(0, 0, 0, 20 + const.defaultPadding), padding=(const.defaultPadding, const.defaultPadding, const.defaultPadding, 0)) self.blockOption = uicontrols.Checkbox(text=localization.GetByLabel( 'UI/Crimewatch/Duel/BlockCommunications'), parent=controlsCont, configName='block', retval=1, checked=0, groupname=None, pos=(const.defaultPadding, 0, 300, 0), align=uiconst.TOPLEFT) self.btnGroup = uicontrols.ButtonGroup( btns=[[ localization.GetByLabel('UI/Crimewatch/Duel/Accept'), self.Confirm, (), 81, 1, 0, 0 ], [ localization.GetByLabel('UI/Crimewatch/Duel/Decline'), self.Decline, (), 81, 1, 1, 0 ]], parent=self.sr.main, align=uiconst.TOTOP) self.SetHeight(sum((c.height for c in self.sr.main.children)) + 40) uicore.registry.SetFocus(self.btnGroup.children[0]) icon = challangerImgCont.children[0] icon.isDragObject = True icon.GetDragData = self.CharGetDragData icon.OnClick = self.CharOnClick slimItem = sm.GetService('crimewatchSvc').GetSlimItemDataForCharID( self.charID) if slimItem is not None: stateSvc = sm.GetService('state') flagCode = stateSvc.CheckFilteredFlagState(slimItem) flagInfo = stateSvc.GetStatePropsColorAndBlink(flagCode) stateFlag.ModifyIcon(flagInfo=flagInfo)
class EngagementEntry(uiprimitives.Container): __guid__ = 'crimewatchTimers.EngagementEntry' default_align = uiconst.TOTOP default_height = 32 default_padBottom = 1 default_state = uiconst.UI_NORMAL isDragObject = True __notifyevents__ = ['OnCrimewatchEngagementUpdated'] def ApplyAttributes(self, attributes): uiprimitives.Container.ApplyAttributes(self, attributes) self.charID = attributes.get('charID') self.timeout = attributes.get('timeout') self.isDragObject = True self.itemID = self.charID self.info = cfg.eveowners.Get(self.charID) self.activeBlink = None self.highlight = uiprimitives.Fill(bgParent=self, color=(1, 1, 1, 0.1), state=uiconst.UI_HIDDEN) leftCont = uiprimitives.Container(parent=self, align=uiconst.TOLEFT, width=54) self.time = uicontrols.Label(parent=leftCont, name='counter', text='', fontsize=16, bold=False, align=uiconst.CENTERLEFT, color=Colors.Engagement.GetRGBA(), left=2 * const.defaultPadding) self.portrait = uiprimitives.Sprite(parent=self, pos=(50, 0, 32, 32), state=uiconst.UI_DISABLED) uicontrols.EveLabelSmall(parent=self, name='name', text=self.info.ownerName, align=uiconst.TOPLEFT, top=1, left=96) self.corpText = uicontrols.EveLabelSmall(parent=self, name='corporation', text='', align=uiconst.TOPLEFT, top=17, left=96) self.stateFlag = FlagIconWithState(parent=self, align=uiconst.TOPRIGHT, left=13, top=4) self.LoadData() sm.RegisterNotify(self) def LoadData(self): self.SetTimer() sm.GetService('photo').GetPortrait(self.charID, 32, self.portrait) uthread.new(self.LazyLoadData) def OnMouseEnter(self, *args): self.highlight.display = True def OnMouseExit(self, *args): self.highlight.display = False def SetTimer(self): if self.timeout == const.crimewatchEngagementTimeoutOngoing: self.time.text = FmtTime(const.crimewatchEngagementDuration) if self.activeBlink is None: self.activeBlink = uicore.animations.BlinkOut( self.time, duration=1.0, loops=uiconst.ANIM_REPEAT) else: self.time.text = FmtTime(self.timeout - blue.os.GetWallclockTime()) if self.activeBlink is not None: self.activeBlink.Stop() self.activeBlink = None self.time.opacity = 1.0 def LazyLoadData(self): slimItem = sm.GetService('crimewatchSvc').GetSlimItemDataForCharID( self.charID) if slimItem is not None: self.corpText.text = cfg.eveowners.Get(slimItem.corpID).ownerName stateSvc = sm.GetService('state') flagCode = stateSvc.CheckFilteredFlagState( slimItem, (state.flagLimitedEngagement, )) flagInfo = stateSvc.GetStatePropsColorAndBlink(flagCode) self.stateFlag.ModifyIcon(flagInfo=flagInfo) self.slimItem = copy.copy(slimItem) def OnClick(self): sm.GetService('info').ShowInfo(typeID=self.info.typeID, itemID=self.charID) def GetDragData(self, *args): if self and not self.destroyed: fakeNode = KeyVal() fakeNode.charID = self.charID fakeNode.typeID = self.info.typeID fakeNode.info = self.info fakeNode.itemID = self.itemID fakeNode.__guid__ = 'listentry.User' return [fakeNode] else: return [] def GetMenu(self): if self.slimItem: if self.slimItem.itemID: return sm.GetService('menu').CelestialMenu( self.slimItem.itemID) else: return sm.GetService('menu').GetMenuFormItemIDTypeID( self.itemID, self.info.typeID) def OnCrimewatchEngagementUpdated(self, otherCharId, timeout): if otherCharId == self.charID: if timeout is None: uicore.animations.FadeOut(self, duration=0.5, sleep=True) self.Close() sm.ScatterEvent('OnEngagementTimerHintResize') else: self.timeout = timeout
class AccessMemberEntry(MouseInsideScrollEntry): __guid__ = 'AccessMemberEntry' default_name = 'DashboardEntry' portraitSize = 32 ENTRYHEIGHT = 37 isDragObject = True __notifyevents__ = ['OnContactChange'] def ApplyAttributes(self, attributes): MouseInsideScrollEntry.ApplyAttributes(self, attributes) node = attributes.node self.controller = node.controller self.memberID = node.memberID self.groupID = node.groupID self.entryType = node.entryType self.ownerPicture = Container(name='ownerPicture', parent=self, align=uiconst.TOPLEFT, pos=(2, 2, self.portraitSize, self.portraitSize)) membershipLeft = self.ownerPicture.left + self.ownerPicture.width + 4 self.membershipTypeSprite = Sprite(name='membershipTypeSprite', parent=self, align=uiconst.CENTERLEFT, pos=(membershipLeft, -1, 20, 20)) ownerLabelLeft = self.membershipTypeSprite.left + self.membershipTypeSprite.width + 8 self.ownerNameLabel = EveLabelMedium(name='ownerNameLabel', parent=self, left=ownerLabelLeft, align=uiconst.CENTERLEFT) texturePath = 'res:/UI/Texture/Icons/73_16_50.png' self.optionIcon = ButtonIcon(name='MyButtonIcon', parent=self, align=uiconst.TOPRIGHT, pos=(2, 2, 16, 16), iconSize=16, texturePath=texturePath, func=self.OnClickOption) self.optionIcon.opacity = 0.0 self.stateFlag = FlagIconWithState(parent=self, align=uiconst.BOTTOMRIGHT, left=4, top=4) sm.RegisterNotify(self) def Load(self, node): membershipType = node.membershipType self.ownerNameLabel.text = node.ownerName self.LoadOwnerPicture() if membershipType == MEMBERSHIP_TYPE_MEMBER: self.membershipTypeSprite.display = False else: accessTexturePath, hintPath = GetMembershipTypeTextureAndLabelPaths(membershipType) self.membershipTypeSprite.texturePath = accessTexturePath self.membershipTypeSprite.hint = GetByLabel(hintPath) self.membershipTypeSprite.display = True def LoadOwnerPicture(self): self.ownerPicture.Flush() if self.entryType == PUBLIC_MEMBER_ID: texturePath = 'res:/UI/Texture/classes/AccessGroups/browser.png' Sprite(parent=self.ownerPicture, align=uiconst.CENTER, pos=(0, 0, 32, 32), texturePath=texturePath) else: GetOwnerLogo(self.ownerPicture, self.memberID, size=32, noServerCall=True) self.LoadOwnerFlag() def GetMenu(self, *args): selectedNodes = self.sr.node.scroll.GetSelectedNodes(self.sr.node) return self.controller.GetMenuForMember(self.groupID, selectedNodes) def OnClick(self, *args): self.sr.node.scroll.SelectNode(self.sr.node) def GetDragData(self, *args): selectedNodes = self.sr.node.scroll.GetSelectedNodes(self.sr.node) ret = [] for eachNode in selectedNodes: memberID = eachNode.memberID if memberID == PUBLIC_MEMBER_ID: continue ownerInfo = eachNode.ownerInfo k = KeyVal(__guid__='listentry.User', itemID=memberID, charID=memberID, info=ownerInfo, membershipType=eachNode.membershipType) ret.append(k) return ret def OnClickOption(self, *args): carbonui.control.menu.ShowMenu(self) def OnMouseEnter(self, *args): MouseInsideScrollEntry.OnMouseEnter(self, *args) self.FadeOptionIcon(self.optionIcon.opacity, 1.0) def OnMouseNoLongerInEntry(self): MouseInsideScrollEntry.OnMouseNoLongerInEntry(self) self.FadeOptionIcon(self.optionIcon.opacity, 0.0) def FadeOptionIcon(self, fromValue, toValue): uicore.animations.FadeTo(self.optionIcon, startVal=fromValue, endVal=toValue, duration=0.1, loops=1) def OnContactChange(self, contactIDs, contactType = None): if self.memberID in contactIDs: self.LoadOwnerFlag() def LoadOwnerFlag(self): ownerInfo = self.sr.node.ownerInfo if ownerInfo is None: return flagInfo = self.GetOwnerFlagInfo(ownerInfo) self.stateFlag.ModifyIcon(flagInfo) def GetOwnerFlagInfo(self, ownerInfo): allianceID = None corpID = None charID = None if ownerInfo.typeID == const.typeAlliance: allianceID = ownerInfo.ownerID elif ownerInfo.typeID == const.typeCorporation: corpID = ownerInfo.ownerID else: charID = ownerInfo.ownerID flag = GetRelationShipFlag(charID, corpID, allianceID) flagInfo = sm.GetService('state').GetStatePropsColorAndBlink(flag) return flagInfo def OnDropData(self, dragObj, nodes): data = self.sr.node if data.OnDropData: data.OnDropData(dragObj, nodes)