class SectionHeader(Container): default_height = 20 def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.isOpen = True headerText = attributes.headerText self.toggleFunc = attributes.toggleFunc self.arrowSprite = Sprite( name='arrow', parent=self, pos=(0, 0, 16, 16), texturePath='res:/UI/Texture/Icons/38_16_229.png', state=uiconst.UI_DISABLED, align=uiconst.CENTERLEFT) self.tipsHeader = EveLabelMediumBold(name='tipsHeader', text=headerText, parent=self, left=16, align=uiconst.CENTERLEFT) def OnClick(self, *args): if self.isOpen: self.arrowSprite.SetTexturePath( 'res:/UI/Texture/Icons/38_16_228.png') else: self.arrowSprite.SetTexturePath( 'res:/UI/Texture/Icons/38_16_229.png') self.isOpen = not self.isOpen self.toggleFunc(self)
class AchievementEntry(Container): default_padLeft = 5 default_padRight = 5 default_padTop = 5 default_padBottom = 2 checkedTexturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesCheck.png' uncheckedTexturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesIncompleteBox.png' backgroundGradient = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesCriteriaRowBack.png' def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.bgSprite = Sprite(parent=self, texturePath=self.backgroundGradient, align=uiconst.TOALL) self.achievement = attributes.achievement self.checkbox = Sprite(parent=self, texturePath=self.uncheckedTexturePath, pos=(4, 4, 14, 14)) self.achievementText = EveLabelMedium(name='achievementText', text=self.achievement.name, parent=self, padLeft=2 * self.checkbox.left + self.checkbox.width, align=uiconst.TOTOP, padTop=4) self.SetCompletedStates(self.achievement.completed) def SetCompletedStates(self, checked): if checked: texturePath = self.checkedTexturePath bgColor = COLOR_COMPLETED_BG textColor = COLOR_COMPLETED else: texturePath = self.uncheckedTexturePath bgColor = COLOR_INCOMPLETE_BG textColor = COLOR_NOT_STARTED_TEXT self.checkbox.SetTexturePath(texturePath) self.bgSprite.SetRGBA(*bgColor) self.achievementText.SetRGB(*textColor) def UpdateAlignment(self, *args, **kwds): retVal = Container.UpdateAlignment(self, *args, **kwds) if getattr(self, 'achievementText', None) and getattr( self, 'checkbox', None): newHeight = max( self.checkbox.height + 2 * self.checkbox.top, self.achievementText.textheight + 2 * self.achievementText.padTop) self.height = newHeight return retVal
class CategoryTypeCont(Container): default_align = uiconst.TOTOP default_height = 32 def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.categorySprite = Sprite(parent=self, name='profileTypeSprite', align=uiconst.CENTERLEFT, pos=(0, 0, 26, 26)) self.categoryNameLabel = EveCaptionSmall(name='groupName', parent=self, padLeft=32, align=uiconst.CENTERLEFT) def SetCategoryName(self, categoryID): categoryNamePath = structures.CATEGORY_LABELS[categoryID] self.categoryNameLabel.text = GetByLabel(categoryNamePath) texturePath = structures.CATEGORY_TEXTURES[categoryID] self.categorySprite.SetTexturePath(texturePath=texturePath)
class SkillIcon(Container): default_name = 'SkillIcon' default_state = uiconst.UI_NORMAL default_width = 67 default_height = 46 default_bgTexturePath = 'res:/UI/Texture/classes/Industry/Center/skillFrame.png' def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.jobData = attributes.jobData self.skills = [] self.skillIcon = Sprite(name='skillIcon', parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, pos=(0, -1, 33, 33)) self.patternSprite = Sprite(name='patternSprite', bgParent=self, texturePath='res:/UI/Texture/classes/Industry/Center/skillFramePattern.png') FillUnderlay(bgParent=self, padding=3) self.UpdateState() def UpdateState(self, *args): if not self.jobData: return self.jobData.on_updated.connect(self.UpdateState) texturePath, _ = sm.GetService('skills').GetRequiredSkillsLevelTexturePathAndHint(self.skills) self.skillIcon.SetTexturePath(texturePath) color = GetJobColor(self.jobData) uicore.animations.SpColorMorphTo(self.patternSprite, self.patternSprite.GetRGBA(), color, duration=0.3) def OnNewJobData(self, jobData): self.jobData = jobData if not self.jobData: self.skills = [] return skills = self.jobData.required_skills self.skills = [ (skill.typeID, skill.level) for skill in skills if skill.typeID is not None ] self.UpdateState() def LoadTooltipPanel(self, tooltipPanel, *args): self.tooltipPanel = SkillTooltipPanel(skills=self.skills, tooltipPanel=tooltipPanel) def GetTooltipDelay(self): return TOOLTIP_DELAY_GAMEPLAY def GetTooltipPointer(self): return uiconst.POINT_LEFT_2 def OnMouseEnter(self, *args): sm.GetService('audio').SendUIEvent('ind_mouseEnter') uicore.animations.FadeTo(self, self.opacity, 1.5, duration=0.3) def OnMouseExit(self, *args): uicore.animations.FadeTo(self, self.opacity, 1.0, duration=0.3)
class AuditLogEntryBase(MouseInsideScrollEntry): default_name = 'AuditLogEntry' changeIconSize = 32 ENTRYHEIGHT = 36 def ApplyAttributes(self, attributes): MouseInsideScrollEntry.ApplyAttributes(self, attributes) self.node = attributes.node self.ConstructUI() def ConstructUI(self): self.changeSprite = Sprite(name='changeSprite', parent=self, align=uiconst.CENTERLEFT, pos=(4, 0, 20, 20)) labelLeft = self.changeSprite.left + self.changeSprite.width + 10 self.logLabel = EveLabelMedium(name='logLabel', parent=self, left=labelLeft, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL) def Load(self, node): timeStamp = FmtDate(node.eventInfo.logDate) text, texturePath = self.GetTextAndTextureForEvent(node.eventInfo) self.logLabel.text = ' '.join([timeStamp, text]) self.changeSprite.SetTexturePath(texturePath) def OnClick(self, *args): self.sr.node.scroll.SelectNode(self.sr.node) def GetMenu(self): return [] @classmethod def GetTextAndTextureForEvent(cls, eventInfo): return ('', '') @classmethod def GetCopyData(cls, node): timeStamp = FmtDate(node.eventInfo.logDate) text, texturePath = cls.GetTextAndTextureForEvent(node.eventInfo) eventText = node.eventInfo.newText or '' return '<t>'.join([timeStamp, text, eventText])
class BaseSensorSuiteHint(PointerContainer): """ This is the base implementation of a sensor suite hint """ default_name = 'BaseSensorSuiteHint' default_height = 122 default_width = 300 default_minDisplayTime = SEC default_outsideBoundsTime = 400 * MSEC default_updateLoopTimeMSec = 200 default_captionLabel = None default_iconTexturePath = None def GetCaptionText(self): raise NotImplementedError() def CreateIconSpite(self): self.ownerIcon = Sprite(parent=self.iconCont, pos=(0, 0, 32, 32), state=uiconst.UI_DISABLED, align=uiconst.TOPLEFT) def ApplyAttributes(self, attributes): PointerContainer.ApplyAttributes(self, attributes) self.data = attributes.data self.callback = attributes.callback self.minDisplayTime = attributes.Get('minDisplayTime', self.default_minDisplayTime) self.outsideBoundsTime = attributes.Get('outsideBoundsTime', self.default_outsideBoundsTime) self.updateLoopTimeMSec = attributes.Get('updateLoopTimeMSec', self.default_updateLoopTimeMSec) self._updateThread = None self.michelle = sm.GetService('michelle') self.sensorSuite = sm.GetService('sensorSuite') self.topContainer = Container(parent=self, height=20, align=uiconst.TOTOP) self.bottomContainer = Container(parent=self, align=uiconst.TOALL) self.contentContainer = Container(parent=self.bottomContainer, align=uiconst.TOALL, padLeft=16) Fill(bgParent=self.bottomContainer, color=(0, 0, 0, 0.4)) Line(parent=self.bottomContainer, align=uiconst.TOBOTTOM) leftPadContainer = Container(parent=self.topContainer, align=uiconst.TOLEFT, width=12) Line(parent=leftPadContainer, align=uiconst.TORIGHT) Line(parent=leftPadContainer, align=uiconst.TOBOTTOM) textContainer = Container(parent=self.topContainer, align=uiconst.TOLEFT, width=150) Fill(bgParent=textContainer, color=(0, 0, 0, 0.5)) Line(parent=textContainer, align=uiconst.TOTOP) Line(parent=textContainer, align=uiconst.TORIGHT) self.captionLabel = EveLabelMediumBold(parent=textContainer, text=self.GetCaptionText(), align=uiconst.CENTER) textContainer.width = self.captionLabel.textwidth + 16 rightPadContainer = Container(parent=self.topContainer, align=uiconst.TOALL) Line(parent=rightPadContainer, align=uiconst.TOBOTTOM) self.iconCont = Container(parent=self.contentContainer, pos=(8, 8, 32, 32), state=uiconst.UI_DISABLED, align=uiconst.TOPRIGHT) if self.default_iconTexturePath: self.CreateIconSpite() self.ownerIcon.SetTexturePath(self.default_iconTexturePath) self.ownerIcon.state = uiconst.UI_DISABLED topTextCont = ContainerAutoSize(top=8, name='topTextCont', parent=self.contentContainer, align=uiconst.TOTOP) self.mainLabel = EveCaptionMedium(name='mainLabel', parent=topTextCont, color=(0.235, 0.745, 0.765), text='', align=uiconst.TOTOP, singleline=True) self.mainLabel.SetRightAlphaFade(fadeEnd=250, maxFadeWidth=30) self.subLabel = EveLabelMediumBold(name='subLabel', parent=topTextCont, align=uiconst.TOTOP, text='', singleline=True) self.subLabel.SetRightAlphaFade(fadeEnd=250, maxFadeWidth=30) bottomTextCont = ContainerAutoSize(top=2, name='bottomTextCont', parent=self.contentContainer, align=uiconst.TOBOTTOM) self.dataLabel = EveLabelMediumBold(name='dataLabel', parent=bottomTextCont, align=uiconst.TOBOTTOM, text='') self.rangeLabel = EveLabelMediumBold(name='rangeLabel', parent=bottomTextCont, align=uiconst.TOBOTTOM, text='') self.buttonContainer = Container(parent=self.contentContainer, align=uiconst.BOTTOMRIGHT, heigh=32) GradientSprite(parent=self.bottomContainer, align=uiconst.TOALL, rotation=-pi / 2, rgbData=[(0, (0.25, 0.25, 0.25)), (0.3, (0.0, 0.0, 0.0))], alphaData=[(0, 0.5)], state=uiconst.UI_DISABLED) self.warpButton = Button(parent=self.contentContainer, top=8, left=88, icon='res:/UI/Texture/Icons/44_32_18.png', func=self.WarpToAction, hint=localization.GetByLabel('UI/Commands/WarpTo'), align=uiconst.BOTTOMRIGHT) self.bookmarkButton = Button(parent=self.contentContainer, top=8, left=48, icon='res:/UI/Texture/Icons/bookmark.png', func=self.BookmarkSite, hint=localization.GetByLabel('UI/Inflight/BookmarkLocation'), align=uiconst.BOTTOMRIGHT) self.probeScannerButton = Button(parent=self.contentContainer, top=8, left=4, icon='res:/UI/Texture/Icons/probe_scan.png', func=OpenProbeScanner, hint=localization.GetByLabel('UI/Inflight/Scanner/SensorOverlayProbeScanButtonHint'), align=uiconst.BOTTOMRIGHT) uicore.event.RegisterForTriuiEvents(uiconst.UI_MOUSEDOWN, self.OnGlobalMouseDown) self._updateThread = uthread.new(self.UpdateHint) def SetFactionIcon(self, factionID): iconID = LogoIcon.GetFactionIconID(factionID, isSmall=True) if iconID is not None: resPath = Icon.ConvertIconNoToResPath(iconID) if resPath is not None: self.CreateIconSpite() self.ownerIcon.SetTexturePath(resPath[0]) self.iconCont.state = uiconst.UI_NORMAL self.iconCont.OnClick = lambda : sm.GetService('info').ShowInfo(itemID=factionID, typeID=typeFaction) def SetOwnerIcon(self, ownerID): GetOwnerLogo(self.iconCont, ownerID, size=32) self.iconCont.state = uiconst.UI_NORMAL self.iconCont.OnClick = lambda : sm.GetService('info').ShowInfo(itemID=ownerID, typeID=typeCorporation) def GetBestDockPlacement(self): dockPlacementOrder = (DockPlacement.LeftCenter, DockPlacement.RightCenter, DockPlacement.TopCenter, DockPlacement.BottomCenter) screenRect = uicore.layer.sensorsuite.GetAbsolute() anchorRect = self.anchor.GetAbsolute() bestDockPlacement = self.dockPlacement for dockPlacement in dockPlacementOrder: left, top = self.CalcPosition(dockPlacement, anchorRect) hintRect = (left, top, self.width, self.height) if IsRectBWithinA(screenRect, hintRect): bestDockPlacement = dockPlacement break return bestDockPlacement def UpdateWidth(self): buttonOffset = 144 listWidths = (self.default_width, self.mainLabel.textwidth + 16 + 32 + 8 + 4, self.rangeLabel.textwidth + buttonOffset, self.dataLabel.textwidth + buttonOffset) self.width = max(listWidths) def WarpToAction(self, *args): WarpToItem(self.data.siteID) def BookmarkSite(self, *args): sm.GetService('addressbook').BookmarkLocationPopup(self.data.siteID, typeCosmicAnomaly, session.solarsystemid, locationName=localization.GetByMessageID(self.data.dungeonNameID)) def UpdateHint(self): """ This is the hint automatic fade out logic """ startTime = blue.os.GetSimTime() + self.minDisplayTime outsideBoundsEndTime = None doUpdates = True try: while doUpdates: timeNow = blue.os.GetSimTime() if not self or self.destroyed: return if timeNow > startTime: if not (uicore.uilib.mouseOver in (self, self.anchor) or IsUnder(uicore.uilib.mouseOver, self) or IsUnder(uicore.uilib.mouseOver, self.anchor)): if outsideBoundsEndTime is None: outsideBoundsEndTime = timeNow + self.outsideBoundsTime elif timeNow > outsideBoundsEndTime: doUpdates = False else: outsideBoundsEndTime = None if self.sensorSuite.activeBracketHint is not self: doUpdates = False if doUpdates: try: self.OnUpdateHint() self.UpdateWarpButton() blue.pyos.synchro.SleepWallclock(self.updateLoopTimeMSec) except InvalidClientStateError: doUpdates = False finally: if self and not self.destroyed: animations.FadeOut(self, sleep=True) uthread.new(self.Close) def OnUpdateHint(self): """ This is for auto-magical update of data in the hint """ pass def UpdateWarpButton(self): if self.data.IsAccurate() and self.michelle.IsPositionWithinWarpDistance(self.data.position): self.warpButton.Enable() else: self.warpButton.Disable() def _OnClose(self, *args): PointerContainer._OnClose(self, *args) if self._updateThread is not None: self._updateThread.kill() self.callback() def DoUpdateLayout(self, dockPlacement): pass def IsMouseOverHint(self): isMouseOverHint = False if uicore.uilib.mouseOver is self or IsUnder(uicore.uilib.mouseOver, self): isMouseOverHint = True elif self.sensorSuite.HasActiveOverlapContainerInstance(): overlapContainer = self.sensorSuite.GetOverlapContainerInstance() if uicore.uilib.mouseOver is overlapContainer or IsUnder(uicore.uilib.mouseOver, overlapContainer): isMouseOverHint = True return isMouseOverHint def OnGlobalMouseDown(self, cont, *_): if self.IsMouseOverHint() or isinstance(cont, SensorSuiteBracket): return True else: self.Close() return False
class GhostShipIcon(Container): default_name = 'GhostShipIcon' default_align = uiconst.TOPRIGHT default_state = uiconst.UI_NORMAL isDragObject = True def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.typeID = attributes.typeID self.bgFrame = Frame( bgParent=self, cornerSize=10, opacity=OPACITY_NORMAL_FRAME, texturePath= 'res:/UI/Texture/Classes/ShipTree/groups/frameUnlocked.png') self.iconTransform = Transform(parent=self, align=uiconst.TOALL, scalingCenter=(0.5, 0.5)) self.iconSprite = Sprite(name='iconSprite', parent=self.iconTransform, align=uiconst.CENTER, state=uiconst.UI_DISABLED, blendMode=trinity.TR2_SBM_ADD, pos=(0, 0, self.width, self.width), idx=0, opacity=OPACITY_NORMAL) self.LoadTexturePath() def SetShipTypeID(self, typeID): self.typeID = typeID self.LoadTexturePath() def LoadTexturePath(self): try: texturePath = inventorycommon.typeHelpers.GetHoloIconPath( self.typeID) except AttributeError as e: texturePath = None log.LogException(e) self.iconSprite.SetTexturePath(texturePath) def OnMouseEnter(self, *args): uicore.animations.FadeTo(self.iconSprite, self.iconSprite.opacity, OPACITY_MOUSEOVER, duration=1.0, loops=1) uicore.animations.FadeTo(self.bgFrame, self.bgFrame.opacity, OPACITY_MOUSEOVER_FRAME, duration=1.0, loops=1) uicore.animations.Tr2DScaleTo(self.iconTransform, self.iconTransform.scale, (1.05, 1.05), duration=0.3) def OnMouseExit(self, *args): uicore.animations.FadeTo(self.iconSprite, self.iconSprite.opacity, OPACITY_NORMAL, duration=1.3) uicore.animations.FadeTo(self.bgFrame, self.bgFrame.opacity, OPACITY_NORMAL_FRAME, duration=1.0, loops=1) uicore.animations.Tr2DScaleTo(self.iconTransform, self.iconTransform.scale, (1.0, 1.0), duration=0.3) def GetHint(self): return GetByLabel('UI/Fitting/FittingWindow/SimulateMyShip', typeID=self.typeID) def OnClick(self, *args): sm.GetService('ghostFittingSvc').LoadCurrentShip()
class AchievementTaskEntry(ContainerAutoSize): default_padLeft = 0 default_padRight = 0 default_padTop = 0 default_padBottom = 4 default_state = uiconst.UI_NORMAL default_clipChildren = False default_alignMode = uiconst.TOTOP checkedTexturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesCheck.png' uncheckedTexturePath = 'res:/UI/Texture/Classes/InfoPanels/opportunitiesIncompleteBox.png' tooltipPointer = uiconst.POINT_LEFT_2 achievementGroup = None autoShowDetails = False detailsParent = None callbackTaskExpanded = None def ApplyAttributes(self, attributes): ContainerAutoSize.ApplyAttributes(self, attributes) self.autoShowDetails = bool(attributes.autoShowDetails) or True Fill(bgParent=self, color=(0, 0, 0, 0.3)) self.headerContainer = Container(parent=self, align=uiconst.TOTOP) self.mouseOverFill = FillThemeColored(bgParent=self.headerContainer, colorType=uiconst.COLORTYPE_UIHILIGHT, opacity=0.0) self.completedFill = FillThemeColored(bgParent=self.headerContainer, colorType=uiconst.COLORTYPE_UIHILIGHT, opacity=0.0) self.backgroundContainer = InfoPanelHeaderBackground(bgParent=self.headerContainer) self.achievementTask = attributes.achievement self.achievementGroup = attributes.achievementGroup self.callbackTaskExpanded = attributes.callbackTaskExpanded self.checkbox = Sprite(parent=self.headerContainer, texturePath=self.uncheckedTexturePath, pos=(4, 3, 14, 14)) self.achievementText = EveLabelMedium(name='achievementText', text=self.achievementTask.name, parent=self.headerContainer, padLeft=2 * self.checkbox.left + self.checkbox.width, align=uiconst.TOTOP, padTop=2) self.UpdateAchievementTaskState() newHeight = max(self.checkbox.height + 2 * self.checkbox.top, self.achievementText.textheight + 2 * self.achievementText.padTop) self.headerContainer.height = newHeight if attributes.blinkIn and self.achievementTask.completed: uthread.new(uicore.animations.BlinkIn, self, duration=0.2, loops=4) def ToggleDetails(self): if self.detailsParent and not self.detailsParent.destroyed: self.HideDetails() else: self.ShowDetails() def HideDetails(self, *args): if self.detailsParent and not self.detailsParent.destroyed: detailsParent = self.detailsParent self.detailsParent = None detailsParent.DisableAutoSize() uicore.animations.FadeOut(detailsParent, duration=0.15) uicore.animations.MorphScalar(detailsParent, 'height', detailsParent.height, 0, duration=0.15, callback=detailsParent.Close) def ShowDetails(self): if self.detailsParent and not self.detailsParent.destroyed: return uthread.new(self._ShowDetails) def _ShowDetails(self): if not self.autoShowDetails: return self.detailsParent = ContainerAutoSize(align=uiconst.TOTOP, parent=self, clipChildren=True) if self.callbackTaskExpanded: self.callbackTaskExpanded(self) self.detailsParent.DisableAutoSize() label = EveLabelMedium(parent=self.detailsParent, text=self.achievementTask.description, align=uiconst.TOTOP, padding=(6, 3, 6, 2)) extraInfo = ACHIEVEMENT_TASK_EXTRAINFO.get(self.achievementTask.achievementID, None) if extraInfo: grid = LayoutGrid(parent=self.detailsParent, align=uiconst.TOTOP, cellPadding=1, columns=2, padLeft=4, padBottom=2) for taskInfoEntry in extraInfo: if isinstance(taskInfoEntry, TaskInfoEntry_Text): label = EveLabelMedium(text=taskInfoEntry.text, color=taskInfoEntry.textColor, width=240, state=uiconst.UI_NORMAL) 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=220, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL) grid.AddCell(label) blue.synchro.Yield() height = self.detailsParent.GetAutoSize()[1] uicore.animations.FadeIn(self.detailsParent, duration=0.3) uicore.animations.MorphScalar(self.detailsParent, 'height', self.detailsParent.height, height, duration=0.25, sleep=True) self.detailsParent.EnableAutoSize() def OnMouseEnter(self, *args): if self.autoShowDetails: return uicore.animations.MorphScalar(self, 'opacity', startVal=self.opacity, endVal=2.0, curveType=uiconst.ANIM_OVERSHOT3, duration=0.5) CheckMouseOverUtil(self, self.ResetMouseOverState) def ResetMouseOverState(self, *args): if self.destroyed: return uicore.animations.MorphScalar(self, 'opacity', startVal=self.opacity, endVal=1.0, duration=0.1) def OnClick(self, *args): if self.autoShowDetails: self.ToggleDetails() else: aura = AchievementAuraWindow.GetIfOpen() if aura: aura.Step_TaskInfo_Manual(self.achievementTask, self.achievementGroup) else: AchievementAuraWindow.Open(loadAchievementTask=self.achievementTask, loadAchievementGroup=self.achievementGroup) def UpdateAchievementTaskState(self, animate = False): if self.achievementTask.completed: self.checkbox.SetTexturePath(self.checkedTexturePath) uicore.animations.FadeTo(self.completedFill, startVal=self.completedFill.opacity, endVal=0.75) else: self.checkbox.SetTexturePath(self.uncheckedTexturePath) uicore.animations.FadeTo(self.completedFill, startVal=self.completedFill.opacity, endVal=0.0) def LoadTooltipPanel(self, tooltipPanel, *args, **kwds): return if uicore.uilib.tooltipHandler.IsUnderTooltip(self): return achievementID = self.achievementTask.achievementID tooltipPanel.LoadGeneric2ColumnTemplate() if self.achievementTask.description: tooltipPanel.AddLabelMedium(text=self.achievementTask.description, colSpan=tooltipPanel.columns, wrapWidth=200) extraInfo = ACHIEVEMENT_TASK_EXTRAINFO.get(achievementID, None) if extraInfo: for taskInfoEntry in extraInfo: if isinstance(taskInfoEntry, TaskInfoEntry_Text): tooltipPanel.AddLabelMedium(text=taskInfoEntry.text, color=taskInfoEntry.textColor, colSpan=tooltipPanel.columns, wrapWidth=200) elif isinstance(taskInfoEntry, TaskInfoEntry_ImageText): texturePath = taskInfoEntry.GetTexturePath() icon = Sprite(name='icon', parent=tooltipPanel, 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) tooltipPanel.AddCell(label) def GetHint(self): return None
class SkillEntry(LayoutGridRow): default_name = 'SkillEntry' default_state = uiconst.UI_NORMAL default_showLevel = True isDragObject = True def ApplyAttributes(self, attributes): LayoutGridRow.ApplyAttributes(self, attributes) self.typeID = attributes.typeID self.level = attributes.level self.showLevel = attributes.Get('showLevel', self.default_showLevel) self.bgPattern = Sprite( bgParent=self, align=uiconst.TOALL, padBottom=1, texturePath= 'res:/UI/Texture/Classes/Industry/Output/hatchPattern.png', tileX=True, tileY=True, color=SkillTreeEntry.COLOR_RESTRICTED, opacity=0.0) self.bgFill = Fill(bgParent=self, padBottom=1) leftCont = ContainerAutoSize(padding=(0, 3, 0, 3), align=uiconst.CENTERLEFT) self.icon = Sprite(name='icon', parent=leftCont, align=uiconst.CENTERLEFT, pos=(2, 0, 16, 16), state=uiconst.UI_NORMAL) if self.showLevel: text = GetByLabel('UI/InfoWindow/SkillAndLevelInRoman', skill=self.typeID, levelInRoman=util.IntToRoman(self.level)) else: text = cfg.invtypes.Get(self.typeID).name self.label = Label(name='label', parent=leftCont, align=uiconst.CENTERLEFT, left=self.icon.width + 4, text=text) self.AddCell(leftCont) self.skillBar = SkillLevels(align=uiconst.CENTERRIGHT, typeID=self.typeID) self.AddCell(self.skillBar, cellPadding=(8, 8, 8, 8)) self.UpdateState() def UpdateState(self): mySkill = sm.GetService('skills').MySkills(byTypeID=True).get( self.typeID, None) if mySkill: self.skillBar.SetLevel(mySkill) myLevel = mySkill.skillLevel else: myLevel = None isTrialRestricted = sm.GetService('skills').IsTrialRestricted( self.typeID) if isTrialRestricted: self.icon.SetTexturePath( 'res:/UI/Texture/classes/Skills/trial-restricted-16.png') self.icon.color = SkillTreeEntry.COLOR_RESTRICTED self.icon.state = uiconst.UI_NORMAL self.icon.OnClick = self.OpenSubscriptionPage self.icon.hint = GetByLabel( 'UI/InfoWindow/SkillRestrictedForTrial') self.bgFill.SetRGBA(0.2, 0.1, 0.05, 1.0) self.bgPattern.opacity = 0.15 elif myLevel is None: self.icon.SetTexturePath('res:/UI/Texture/icons/38_16_194.png') self.icon.hint = GetByLabel('UI/InfoWindow/NotTrained') self.bgFill.SetRGBA(*SkillTreeEntry.COLOR_NOTTRAINED) self.skillBar.opacity = 0.4 self.bgPattern.opacity = 0.0 elif myLevel < self.level: self.icon.SetTexturePath('res:/UI/Texture/icons/38_16_195.png') self.icon.hint = GetByLabel( 'UI/InfoWindow/TrainedButNotOfRequiredLevel') self.bgFill.SetRGBA(*SkillTreeEntry.COLOR_PARTIAL) self.skillBar.opacity = 1.0 self.bgPattern.opacity = 0.0 else: self.icon.SetTexturePath('res:/UI/Texture/icons/38_16_193.png') self.icon.hint = GetByLabel( 'UI/InfoWindow/TrainedAndOfRequiredLevel') self.bgFill.SetRGBA(*SkillTreeEntry.COLOR_TRAINED) self.skillBar.opacity = 1.0 self.bgPattern.opacity = 0.0 def GetMenu(self): return sm.GetService('menu').GetMenuForSkill(self.typeID) def OnClick(self): sm.GetService('info').ShowInfo(self.typeID) def GetDragData(self): ret = KeyVal(__guid__='uicls.GenericDraggableForTypeID', typeID=self.typeID, label=cfg.invtypes.Get(self.typeID).name) return (ret, ) def OpenSubscriptionPage(self, *args): sm.GetService('shipTree').OpenSubscriptionPage(['skill', self.typeID])
class QuestEntry(ContainerAutoSize): default_alignMode = uiconst.TOTOP default_clipChildren = False default_state = uiconst.UI_NORMAL default_padTop = 4 def ApplyAttributes(self, attributes): super(QuestEntry, self).ApplyAttributes(attributes) self.quest = attributes.quest self.isCompleteMode = self.quest.isComplete self._updateThread = None self.details = None self.Layout() self.UpdateQuest() if self.isCompleteMode: self.ShowCompleted() else: self.ShowDetails() def Layout(self): Fill(bgParent=self, color=(0, 0, 0, 0.2)) BlurredBackgroundSprite(bgParent=self, color=(1, 1, 1, 0.9)) headerContainer = ContainerAutoSize(parent=self, align=uiconst.TOTOP, alignMode=uiconst.TOPLEFT) self.completedFill = FillThemeColored( bgParent=headerContainer, colorType=uiconst.COLORTYPE_UIHILIGHT, opacity=0.0) self.headerFill = InfoPanelHeaderBackground(bgParent=headerContainer) headerGrid = LayoutGrid(parent=headerContainer) if self.quest.isComplete: texturePath = RES_COMPLETED else: texturePath = RES_AVAILABLE self.check = Sprite(align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, texturePath=texturePath, width=14, height=14) headerGrid.AddCell(self.check, cellPadding=(4, 3, 4, 3)) headerGrid.AddCell(EveLabelMedium(align=uiconst.TOPLEFT, text=self.quest.titleLabel), cellPadding=(0, 2, 0, 2)) self.timer = EveLabelMedium(parent=headerContainer, align=uiconst.CENTERRIGHT, state=uiconst.UI_DISABLED, left=4, opacity=0.0) def ShowCompleted(self): self.check.SetTexturePath(RES_COMPLETED) self.completedFill.opacity = 0.5 self.timer.opacity = 0.6 self.timer.state = uiconst.UI_NORMAL def UpdateQuest(self, quest=None): if quest is None: quest = self.quest if self.quest.id != quest.id: return self.quest = quest if not self.isCompleteMode and self.quest.isComplete: self.isCompleteMode = True self.AnimComplete() self.timer.state = uiconst.UI_NORMAL elif self.isCompleteMode and not self.quest.isComplete: self.isCompleteMode = False self.AnimAvailable() self.timer.state = uiconst.UI_DISABLED if self.isCompleteMode: if not self._updateThread: self._updateThread = uthread.new(self._UpdateThread) self.timer.text = self.quest.nextAvailableShortLabel self.timer.hint = self.quest.nextAvailableLabel def AnimComplete(self): self.check.SetTexturePath(RES_COMPLETED) animations.BlinkIn(self.check) animations.MorphScalar(self.completedFill, 'displayWidth', startVal=0.0, endVal=self.displayWidth) animations.FadeTo(self.completedFill, startVal=1.5, endVal=0.5, duration=1.5, timeOffset=0.5) animations.FadeIn(self.timer, endVal=0.6, timeOffset=0.5) def AnimAvailable(self): self.check.SetTexturePath(RES_AVAILABLE) animations.BlinkIn(self.check) animations.FadeTo(self.completedFill, startVal=self.completedFill.opacity, endVal=0.0) animations.FadeOut(self.timer, duration=0.3) def OnClick(self, *args): self.ToggleDetails() def ToggleDetails(self): if self.details and not self.details.destroyed: self.HideDetails() else: self.ShowDetails() def HideDetails(self): if not self.details or self.details.destroyed: return details = self.details self.details = None details.DisableAutoSize() animations.FadeOut(details, duration=0.15) animations.MorphScalar(details, 'height', startVal=details.height, endVal=0, duration=0.15, callback=details.Close) def ShowDetails(self): if self.details: return def thread(): self.details = ContainerAutoSize(parent=self, align=uiconst.TOTOP, clipChildren=True) self.details.DisableAutoSize() EveLabelMedium(parent=self.details, align=uiconst.TOTOP, padding=(6, 3, 6, 2), text=self.quest.descriptionLabel) EveLabelMedium( parent=self.details, align=uiconst.TOTOP, padding=(6, 3, 6, 2), text=localization.GetByLabel('UI/Quest/RewardTitle')) EveLabelMedium(parent=self.details, align=uiconst.TOTOP, padding=(12, 6, 6, 12), text=self.quest.rewardLabel) _, height = self.details.GetAutoSize() animations.FadeIn(self.details, duration=0.3) animations.MorphScalar(self.details, 'height', startVal=self.details.height, endVal=height, duration=0.25, callback=self.details.EnableAutoSize) uthread.new(thread) def OnMouseEnter(self, *args): animations.FadeTo(self.headerFill.colorFill, startVal=self.headerFill.colorFill.opacity, endVal=0.3, curveType=uiconst.ANIM_OVERSHOT3, duration=0.5) def OnMouseExit(self, *args): animations.FadeTo(self.headerFill.colorFill, startVal=self.headerFill.colorFill.opacity, endVal=0.15, duration=0.1) def _UpdateThread(self): while self and not self.destroyed and self.isCompleteMode: self.UpdateQuest() blue.pyos.synchro.SleepWallclock(1000) self._updateThread = None
class DamageStateCont(Container): size = 64 default_height = size default_width = size default_top = 0 default_align = uiconst.TOPLEFT default_state = uiconst.UI_HIDDEN default_opacity = 1.0 def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.isBeingRepaired = False self.endTime = None leftRampCont = Container(parent=self, name='leftRampCont', pos=(0, 0, self.size / 2, self.size), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, clipChildren=True) self.leftRamp = Sprite( parent=leftRampCont, align=uiconst.TOPLEFT, width=self.size, height=self.size, texturePath= 'res:\\UI\\Texture\\classes\\ShipUI\\slotDamage_Base.png', textureSecondaryPath= 'res:\\UI\\Texture\\classes\\PieCircle\\halfMask32.png', blendMode=1, spriteEffect=64) rightRampCont = Container(parent=self, name='rightRampCont', pos=(self.size / 2, 0, self.size / 2, self.size), align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, clipChildren=True) self.rightRamp = Sprite( parent=rightRampCont, align=uiconst.TOPRIGHT, width=self.size, height=self.size, texturePath= 'res:\\UI\\Texture\\classes\\ShipUI\\slotDamage_Base.png', textureSecondaryPath= 'res:\\UI\\Texture\\classes\\PieCircle\\halfMask32.png', blendMode=1, spriteEffect=64) def SetLeftRampValue(self, hpPercentage): hpPercentage = min(1.0, max(0.5, hpPercentage)) self.leftRamp.rotationSecondary = -0.8 * (2 * hpPercentage - 1) * math.pi def SetRightRampValue(self, hpPercentage): hpPercentage = max(0, min(0.5, hpPercentage)) self.rightRamp.rotationSecondary = 0.8 * (1 - 2 * hpPercentage) * math.pi def SetRampValues(self, hpPercentage): self.leftRamp.spriteEffect = 64 self.rightRamp.spriteEffect = 64 self.SetLeftRampValue(hpPercentage) self.SetRightRampValue(hpPercentage) def SetDamage(self, damage): imageIndex = max(1, int(damage * 8)) texturePath = 'res:/UI/Texture/classes/ShipUI/slotDamage_%s.png' % imageIndex self.leftRamp.SetTexturePath(texturePath) self.rightRamp.SetTexturePath(texturePath) self.leftRamp.spriteEffect = 32 self.rightRamp.spriteEffect = 32 def Blink(self, damageAmount): for ramp in (self.rightRamp, self.leftRamp): sm.GetService('ui').BlinkSpriteA(ramp, 1.0, 2000 - 1000 * damageAmount, 2, passColor=0) def AnimateRepair(self, dmg, hp, repairTime, startTime): if not repairTime: return self.isBeingRepaired = True self.endTime = repairTime + startTime while self and not self.destroyed and self.isBeingRepaired: newNow = blue.os.GetSimTime() percentageDone = (newNow - startTime) / float(repairTime) damageLeft = 1 - percentageDone hpPercentage = (hp - dmg * damageLeft) / hp self.SetRampValues(hpPercentage) blue.pyos.synchro.Yield() self.endTime = None def StopRepair(self): self.isBeingRepaired = False
class ChallengeInfoPanelTaskEntry(ContainerAutoSize): default_padLeft = 0 default_padRight = 0 default_padTop = 0 default_padBottom = 4 default_state = uiconst.UI_NORMAL default_clipChildren = False default_alignMode = uiconst.TOTOP tooltipPointer = uiconst.POINT_LEFT_2 details_container = None callbackTaskExpanded = None counter_background = None def ApplyAttributes(self, attributes): ContainerAutoSize.ApplyAttributes(self, attributes) self.challenge = attributes.challenge self.open_challenges = attributes.open_challenges_function show_details = attributes.Get('show_details', DEFAULT_SHOW_DETAILS) self._construct_header() if show_details: self._show_details() self.objects_for_animations = [] def _construct_header(self): self.header_container = ChallengeTaskProgressBar(name='header_container', parent=self, align=uiconst.TOTOP, challenge=self.challenge, progress_frame_width=CHALLENGE_CONTAINER_WIDTH, progress_frame_width_offset=PROGRESS_FRAME_WIDTH_OFFSET, height=HEADER_HEIGHT, padTop=HEADER_PAD_TOP, padBottom=HEADER_PAD_BOTTOM, label_type_function=EveLabelMediumBold, state=uiconst.UI_NORMAL, show_expiration_timer=True, progress_label_left=PROGRESS_LABEL_LEFT) self.header_container.OnClick = self._toggle_details def _toggle_details(self): if self.are_details_shown(): self._hide_details() else: self._show_details() def _hide_details(self, *args): if self.are_details_shown(): settings.char.ui.Set('show_challenge_details_in_info_panel', False) self.details_container.Close() self.details_container.Flush() def _show_details(self): if self.are_details_shown(): return settings.char.ui.Set('show_challenge_details_in_info_panel', True) uthread.new(self._show_details_thread) def are_details_shown(self): return self.details_container is not None and not self.details_container.destroyed def _show_details_thread(self): global blue self.details_container = Container(name='details_container', align=uiconst.TOTOP, parent=self, height=DETAILS_SIZE, padRight=DETAILS_PAD_RIGHT, state=uiconst.UI_NORMAL) self.details_container.OnClick = self.open_challenges self._construct_details_header() self._construct_details_info() if self._is_completed(): self._animate_completion() elif self.challenge.is_expired: self.expire_challenge() if self.callbackTaskExpanded: self.callbackTaskExpanded(self) blue.synchro.Yield() def _construct_details_header(self): self.details_header_container = Container(name='details_header_container', parent=self.details_container, align=uiconst.TOTOP, height=LABEL_CONTAINER_HEIGHT) self.counter_background = InfoPanelHeaderBackground(bgParent=self.details_header_container) self.objects_for_animations.append(self.counter_background.colorFill) self.construct_finish_check() self._construct_header_label() self._construct_reward() def construct_finish_check(self): self.finished_check_container = Container(name='finished_check_container', parent=self.details_header_container, width=FINISHED_CHECK_WIDTH, align=uiconst.TOLEFT, padLeft=DETAILS_PAD_LEFT) finished_check_icon_container = Container(name='finished_check_container', parent=self.finished_check_container, width=FINISHED_CHECK_WIDTH, height=FINISHED_CHECK_WIDTH, align=uiconst.CENTER) self.finished_check = Sprite(name='finished_check', parent=finished_check_icon_container, align=uiconst.TOALL) self.finished_check_container.Hide() def _construct_header_label(self): challenge_header_label_container = Container(name='challenge_header_label_container', parent=self.details_header_container, align=uiconst.TOLEFT, width=LABEL_CONTAINER_WIDTH, padLeft=DETAILS_PAD_LEFT) self.challenge_header_label = EveLabelMediumBold(name='challenge_header_label', parent=challenge_header_label_container, text=self.challenge.name, align=uiconst.CENTERLEFT) def _construct_reward(self): season_points_container = Container(name='challenge_header_label_container', parent=self.details_header_container, align=uiconst.TORIGHT, padRight=DETAILS_PAD_RIGHT) season_points = SeasonPoints(name='reward_container', parent=season_points_container, points=self.challenge.points_awarded, align=uiconst.TOTOP, height=DEFAULT_SEASON_POINTS_SIZE, reward_label_class=EveLabelMediumBold, state=uiconst.UI_NORMAL) season_points.OnClick = self.open_challenges season_points_container.width = season_points.width def _construct_details_info(self): self.details_info_container = Container(name='details_info_container', align=uiconst.TOTOP, parent=self.details_container, height=DETAILS_INFO_SIZE) Fill(bgParent=self.details_info_container, color=DETAILS_BACKGROUND_COLOR) BlurredBackgroundSprite(bgParent=self.details_info_container, color=DETAILS_BLURRED_BACKGROUND_COLOR) self._construct_agent() self._construct_challenge_description() self._set_details_info_size() def _construct_agent(self): agent_container = Container(name='agent_container', parent=self.details_info_container, align=uiconst.TOLEFT, width=AGENT_CONTAINER_SIZE, padding=AGENT_ICON_PADDING) agent_picture_container = Container(name='agent_container', parent=agent_container, align=uiconst.CENTERTOP, width=AGENT_CONTAINER_SIZE, height=AGENT_CONTAINER_SIZE, padding=AGENT_BORDER_WIDTH) agent_background_container = InfoPanelHeaderBackground(bgParent=agent_picture_container, color=AGENT_BORDER_COLOR) self.objects_for_animations.append(agent_background_container.colorFill) agent_icon = get_agent_icon(name='agent_icon', parent=agent_picture_container, align=uiconst.CENTER, size=AGENT_CONTAINER_SIZE - AGENT_ICON_SIZE_OFFSET, agent_id=self.challenge.agent_id) agent_icon.OnClick = self.open_challenges def _construct_challenge_description(self): self.challenge_description_container = Container(name='challenge_description_container', parent=self.details_info_container, align=uiconst.TOTOP, height=DETAILS_INFO_SIZE) self.challenge_description_label = EveLabelMedium(name='challenge_description_label', parent=self.challenge_description_container, align=uiconst.CENTERLEFT, width=CHALLENGE_DESCRIPTION_WIDTH - CHALLENGE_DESCRIPTION_PAD_SIDES, padLeft=CHALLENGE_DESCRIPTION_PAD_SIDES, text=self.challenge.message_text, color=CHALLENGE_DESCRIPTION_COLOR) self.objects_for_animations.append(self.challenge_description_label) def _set_details_info_size(self): details_info_height = max(self.challenge_description_label.height + CHALLENGE_DESCRIPTION_PADDING, self.details_info_container.height) self.details_info_container.height = details_info_height self.challenge_description_container.height = details_info_height def OnMouseEnter(self, *args): animations.MorphScalar(self.header_container, 'opacity', startVal=self.opacity, endVal=HEADER_MOUSE_OVER_ANIMATION_SCALE, curveType=uiconst.ANIM_OVERSHOT, duration=HEADER_MOUSE_OVER_ANIMATION_DURATION) CheckMouseOverUtil(self, self.ResetMouseOverState) def ResetMouseOverState(self, *args): if self.destroyed: return animations.MorphScalar(self.header_container, 'opacity', startVal=self.opacity, endVal=HEADER_MOUSE_RESET_ANIMATION_SCALE, duration=HEADER_MOUSE_RESET_ANIMATION_DURATION) def GetHint(self): return None def update_challenge_progress(self, new_progress): self.challenge.progress = new_progress self.header_container.update_challenge(new_progress) self._update_counter() def _update_counter(self): if not hasattr(self, 'challenge_text'): return challenge_progress_counter_text = get_challenge_progress_counter_label_text(self.challenge) self.challenge_header_label.SetText(challenge_progress_counter_text) def complete_challenge(self): self.update_challenge_progress(self.challenge.max_progress) if not self.are_details_shown(): return self._animate_completion() def _is_completed(self): return self.challenge.progress >= self.challenge.max_progress def _animate_completion(self): uthread.new(self._animation_thread, COMPLETED_BACKGROUND_HIGHLIGHT_COLOR, icon_path=COMPLETED_CHECK_RES_PATH) def _animation_thread(self, background_highlight_color, icon_path = None): if self.counter_background is not None: self.counter_background.colorFill.color = background_highlight_color if icon_path: self._add_finished_check(icon_path) def _add_finished_check(self, icon_path): self.finished_check.SetTexturePath(icon_path) self.finished_check_container.Show() animations.SpGlowFadeIn(self.finished_check, glowColor=FINISHED_CHECK_ANIMATION_GLOW_COLOR, glowExpand=FINISHED_CHECK_ANIMATION_GLOW_EXPAND, duration=FINISHED_CHECK_ANIMATION_DURATION, curveType=uiconst.ANIM_WAVE) def expire_challenge(self): uthread.new(self._animation_thread, EXPIRED_BACKGROUND_HIGHLIGHT_COLOR)
class DefenseMultiplierIcon(Container): default_align = uiconst.CENTER default_iconSize = 64 default_showValue = False shieldTexturePath_big = 'res:/UI/Texture/classes/Sov/bonusShieldBase.png' shieldTexturePath_medium = 'res:/UI/Texture/classes/Sov/bonusShieldBase_32.png' shieldTexturePath_small = 'res:/UI/Texture/classes/Sov/bonusShieldBase_24.png' shieldFillTexturePath_big = 'res:/UI/Texture/classes/Sov/bonusShieldFill.png' shieldFillTexturePath_small = 'res:/UI/Texture/classes/Sov/bonusShieldFill24.png' shieldCapitalFillTexturePath_big = 'res:/UI/Texture/classes/Sov/bonusShieldFillCapital.png' shieldCapitalFillTexturePath_small = 'res:/UI/Texture/classes/Sov/bonusShieldFillCapital24.png' capitalStarTexturePath_big = 'res:/UI/Texture/classes/Sov/captitalStar64.png' capitalStarTexturePath_small = 'res:/UI/Texture/classes/Sov/captitalStar24.png' minOffset = -0.23 maxOffset = 0.21 numSteps = 6 offsetRange = maxOffset - minOffset labelPadding = 3 def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.currentMultiplier = attributes.get('currentMultiplier', 1.0) self.devIndexes = attributes.get('devIndexes', (0, 0, 0)) self.showValue = attributes.get('showValue', self.default_showValue) self.iconSize = attributes.get('iconSize', self.default_iconSize) self.isCapital = attributes.get('isCapital', False) self.capitalOwnerID = attributes.get('capitalOwnerID', None) self.height = self.iconSize self.width = self.iconSize self.valueLabel = None self.capitalStar = None self.shieldCont = Container(name='shieldCont', parent=self, pos=(0, 0, self.iconSize, self.iconSize), align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL) shieldTexturePath, shieldFillTexturePath, _ = self.GetTexturePathsToUse() self.shieldSprite = Sprite(name='shieldSprite', parent=self.shieldCont, texturePath=shieldFillTexturePath, textureSecondaryPath=shieldTexturePath, align=uiconst.TOALL, spriteEffect=trinity.TR2_SFX_MODULATE, state=uiconst.UI_DISABLED) self.shieldSprite.scale = (1.0, 0.5) self.shieldCont.LoadTooltipPanel = self.LoadTooltipPanel self.shieldCont.GetTooltipPointer = self.GetTooltipPointer self.SetStatusFromMultiplier(self.currentMultiplier, self.devIndexes) self.ChangeCapitalState(self.isCapital) def GetTexturePathsToUse(self): if self.iconSize > 32: shieldTexturePath = self.shieldTexturePath_big starTexturePath = self.capitalStarTexturePath_big elif self.iconSize > 24: shieldTexturePath = self.shieldTexturePath_medium starTexturePath = self.capitalStarTexturePath_big else: shieldTexturePath = self.shieldTexturePath_small starTexturePath = self.capitalStarTexturePath_small if self.isCapital: if self.iconSize > 24: shieldFillTexturePath = self.shieldCapitalFillTexturePath_big else: shieldFillTexturePath = self.shieldCapitalFillTexturePath_small elif self.iconSize > 24: shieldFillTexturePath = self.shieldFillTexturePath_big else: shieldFillTexturePath = self.shieldFillTexturePath_small return (shieldTexturePath, shieldFillTexturePath, starTexturePath) def GetCapitalStar(self, create = True): if create and (not self.capitalStar or self.capitalStar.destroyed): _, _, starTexturePath = self.GetTexturePathsToUse() self.capitalStar = Sprite(name='capitalStar', parent=self.shieldCont, texturePath=starTexturePath, align=uiconst.TOPLEFT, pos=(0, 0, self.iconSize, self.iconSize), idx=0, state=uiconst.UI_DISABLED) return self.capitalStar def GetValueLabel(self): if self.valueLabel is None: self.valueLabel = EveLabelMedium(parent=self, align=uiconst.CENTERLEFT, left=self.iconSize + self.labelPadding, state=uiconst.UI_NORMAL) return self.valueLabel def SetStatusFromMultiplier(self, multiplierValue, devIndexes): newValue = multiplierValue / self.numSteps self.SetStatus(newValue, devIndexes) def SetStatus(self, value, devIndexes, animate = False): self.devIndexes = devIndexes newOffset = self.offsetRange * value newShieldValue = self.minOffset + newOffset self.currentMultiplier = value * self.numSteps self.shieldSprite.StopAnimations() if animate: currentTranslation = self.shieldSprite.translationPrimary uicore.animations.MorphVector2(self.shieldSprite, 'translationPrimary', startVal=currentTranslation, endVal=(currentTranslation[0], newShieldValue), duration=0.75) else: self.shieldSprite.translationPrimary = (0, newShieldValue) if self.showValue: valueLabel = self.GetValueLabel() text = GetByLabel('UI/Sovereignty/DefenseMultiplierDisplayNumber', bonusMultiplier=self.currentMultiplier) valueLabel.text = text self.width = self.iconSize + valueLabel.textwidth + self.labelPadding def ChangeCapitalState(self, isCapital): self.isCapital = isCapital capitalStar = self.GetCapitalStar(create=isCapital) if capitalStar: capitalStar.display = isCapital _, shieldFillTexturePath, _ = self.GetTexturePathsToUse() self.shieldSprite.SetTexturePath(shieldFillTexturePath) def LoadTooltipPanel(self, tooltipPanel, *args): tooltipPanel.columns = 5 tooltipPanel.margin = 6 tooltipPanel.cellPadding = 3 tooltipPanel.cellSpacing = 0 text = GetByLabel('UI/Sovereignty/ActivityDefenseMultiplier') label = EveLabelMedium(text=text, align=uiconst.TOTOP, padTop=1, bold=True) tooltipPanel.AddCell(cellObject=label, colSpan=4) text = GetByLabel('UI/Sovereignty/DefenseMultiplierDisplayNumber', bonusMultiplier=self.currentMultiplier) label = EveLabelLarge(text=text, align=uiconst.TOPRIGHT, bold=True) tooltipPanel.AddCell(cellObject=label) valueAndTextures = [(self.devIndexes[2], 'res:/UI/Texture/classes/Sov/strategicIndex.png', 'UI/Sovereignty/StrategicIndex'), (self.devIndexes[0], 'res:/UI/Texture/classes/Sov/militaryIndex.png', 'UI/Sovereignty/MilitaryIndex'), (self.devIndexes[1], 'res:/UI/Texture/classes/Sov/industryIndex.png', 'UI/Sovereignty/IndustryIndex')] for indexValue, texturePath, labelPath in valueAndTextures: indexSprite = Sprite(name='indexSprite', parent=tooltipPanel, pos=(0, 0, 16, 16), align=uiconst.CENTERLEFT, texturePath=texturePath) label = EveLabelMedium(text=GetByLabel(labelPath)) tooltipPanel.AddCell(cellObject=label) indexBars = IndexBars(currentIndex=indexValue, align=uiconst.CENTERRIGHT) tooltipPanel.AddCell(cellObject=indexBars, cellPadding=(16, 0, 3, 0), colSpan=3) if self.isCapital: tooltipPanel.state = uiconst.UI_NORMAL l = LineThemeColored(height=1, align=uiconst.TOTOP, opacity=0.3) tooltipPanel.AddCell(l, colSpan=5, cellPadding=(1, 1, 1, 3)) capitalSprite = Sprite(name='capitalSprite', parent=tooltipPanel, pos=(0, 0, 16, 16), align=uiconst.CENTERLEFT, texturePath='res:/UI/Texture/classes/Sov/bonusShieldCapital16.png') capitalLabel = EveLabelMedium(text=GetByLabel('UI/Sovereignty/Capital'), align=uiconst.CENTERLEFT) tooltipPanel.AddCell(cellObject=capitalLabel) infoLabel = GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=cfg.eveowners.Get(self.capitalOwnerID).name, info=('showinfo', const.typeAlliance, self.capitalOwnerID)) tooltipPanel.AddLabelMedium(text=infoLabel, colSpan=3, wrapWidth=160, align=uiconst.CENTERRIGHT, state=uiconst.UI_NORMAL) def GetTooltipPointer(self): return uiconst.POINT_TOP_1
class FittingSlotGhost(FittingSlotBase): __guid__ = 'xtriui.FittingSlotGhost' __notifyevents__ = ['OnRefreshModuleBanks'] default_name = 'fittingSlot' default_width = 44 default_height = 54 default_align = uiconst.TOPLEFT default_state = uiconst.UI_NORMAL isDragObject = True slotsToHintDict = { 'hiSlot': ('UI/Fitting/EmptyHighPowerSlot', 'EmptyHighSlot'), 'medSlot': ('UI/Fitting/EmptyMediumPowerSlot', 'EmptyMidSlot'), 'loSlot': ('UI/Fitting/EmptyLowPowerSlot', 'EmptyLowSlot'), 'subSystemSlot': ('UI/Fitting/EmptySubsystemSlot', ''), 'rigSlot': ('UI/Fitting/EmptyRigSlot', '') } @telemetry.ZONE_METHOD def ApplyAttributes(self, attributes): FittingSlotBase.ApplyAttributes(self, attributes) self.flagIcon = uicontrols.Icon(parent=self, name='flagIcon', align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=self.width, height=self.height) self.sr.underlay = Sprite( bgParent=self, name='underlay', state=uiconst.UI_DISABLED, padding=(-10, -5, -10, -5), texturePath='res:/UI/Texture/Icons/81_64_1.png') self.dontHaveLine = None self.moduleSlotFill = None self.skillSprite = None self.groupMark = None self.chargeIndicator = None sm.RegisterNotify(self) self.radCosSin = attributes.radCosSin self.invReady = 1 self.UpdateFitting() self.controller.on_simulation_mode_changed.connect( self.UpdateSimulationMode) def ConstructDontHaveLine(self): if self.dontHaveLine: return self.dontHaveLine = Sprite( parent=self, name='dontHaveLine', align=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Fitting/moduleFrameDots.png', padding=(-10, -5, -10, -5), color=(1, 1, 0, 1.0)) def ConstructModuleSlotFill(self): if self.moduleSlotFill: return self.moduleSlotFill = Sprite( parent=self, name='moduleSlotFill', align=uiconst.TOALL, state=uiconst.UI_DISABLED, padding=(-8, -4, -8, -4), texturePath='res:/UI/Texture/classes/Fitting/moduleSlotFill.png', color=(1, 1, 1, 0.5)) self.moduleSlotFill.display = False def ConstructSkillSprite(self): if self.skillSprite: return self.skillSprite = Sprite( parent=self, name='skillSprite', align=uiconst.TOALL, state=uiconst.UI_DISABLED, padding=(-8, -4, -8, -4), texturePath='res:/UI/Texture/classes/Fitting/slotGlowInner.png', color=(1, 1, 1, 0.5)) self.skillSprite.display = False def ConstructGroupMark(self): if self.groupMark: return self.groupMark = Sprite(parent=self, name='groupMark', pos=(-10, 14, 16, 16), align=uiconst.CENTER, state=uiconst.UI_NORMAL, idx=0) self.groupMark.GetMenu = self.GetGroupMenu def ConstructChargeIndicator(self): if self.chargeIndicator: return self.chargeIndicator = Sprite( parent=self, name='chargeIndicator', padTop=-2, height=7, align=uiconst.TOTOP, state=uiconst.UI_HIDDEN, texturePath='res:/UI/Texture/Icons/81_64_2.png', ignoreSize=True) self.chargeIndicator.rectWidth = 44 self.chargeIndicator.rectHeight = 7 def OnRefreshModuleBanks(self): self.SetGroup() def SetGroup(self): try: if self.controller.GetModule( ) is not None and not self.controller.SlotExists(): self.controller.DestroyWeaponBank() except ReferenceError: pass parentID = self.controller.GetParentID() allGroupsDict = settings.user.ui.Get('linkedWeapons_groupsDict', {}) groupDict = allGroupsDict.get(parentID, {}) ret = self.GetBankGroup(groupDict) if ret is None: if self.groupMark: self.groupMark.Hide() return groupNumber = ret.groupNumber self.ConstructGroupMark() self.groupMark.state = uiconst.UI_NORMAL self.groupMark.rotation = -self.GetRotation() if groupNumber < 0: availGroups = [1, 2, 3, 4, 5, 6, 7, 8] for masterID, groupNum in groupDict.iteritems(): if groupNum in availGroups: availGroups.remove(groupNum) groupNumber = availGroups[0] if availGroups else '' self.groupMark.texturePath = 'res:/UI/Texture/Icons/73_16_%s.png' % ( 176 + groupNumber) self.groupMark.hint = localization.GetByLabel('UI/Fitting/GroupNumber', groupNumber=groupNumber) groupDict[ret.masterID] = groupNumber allGroupsDict[parentID] = groupDict settings.user.ui.Set('linkedWeapons_groupsDict', allGroupsDict) def GetBankGroup(self, groupDict): module = self.controller.GetModule() try: if not module: return None except ReferenceError: return None masterID = self.controller.IsInWeaponBank() if not masterID: return None if masterID in groupDict: groupNumber = groupDict.get(masterID) else: groupNumber = -1 ret = util.KeyVal() ret.masterID = masterID ret.groupNumber = groupNumber return ret def PrepareUtilButtons(self): for btn in self.utilButtons: btn.Close() self.utilButtons = [] if not self.controller.GetModule(): return myrad, cos, sin, cX, cY = self.radCosSin btns = self.GetUtilBtns() rad = myrad - 34 i = 0 for btnData in btns: left = int((rad - i * 16) * cos) + cX - 16 / 2 top = int((rad - i * 16) * sin) + cY - 16 / 2 utilBtn = FittingUtilBtn(parent=self.parent, icon=btnData.iconPath, left=left, top=top, btnData=btnData, mouseOverFunc=self.ShowUtilButtons, controller=self.controller) if btnData.onlineBtn == 1: self.sr.onlineButton = utilBtn self.utilButtons.append(utilBtn) i += 1 def GetUtilBtns(self): btns = [] if self.controller.GetCharge(): btns += self.GetChargesBtns() isRig = False for effect in cfg.dgmtypeeffects.get(self.controller.GetModuleTypeID(), []): if effect.effectID == const.effectRigSlot: isRig = True break isSubSystem = evetypes.GetCategoryID( self.controller.GetModuleTypeID()) == const.categorySubSystem isOnlinable = self.controller.IsOnlineable() if isRig: btns += self.GetRigsBtns() elif isSubSystem: btns += self.GetSubSystemBtns() else: btns += self.GetModuleBtns(isOnlinable) return btns def GetChargesBtns(self): moduleTypeID = self.controller.GetModuleTypeID() btns = [ UtilBtnData(localization.GetByLabel('UI/Fitting/RemoveCharge'), 'ui_38_16_200', self.controller.Unfit, 1, 0), UtilBtnData(localization.GetByLabel('UI/Fitting/ShowChargeInfo'), 'ui_38_16_208', self.ShowChargeInfo, 1, 0), UtilBtnData(evetypes.GetName(moduleTypeID), inventorycommon.typeHelpers.GetIconFile(moduleTypeID), None, 1, 0) ] return btns def GetSubSystemBtns(self): btns = [ UtilBtnData(localization.GetByLabel('UI/Commands/ShowInfo'), 'ui_38_16_208', self.ShowInfo, 1, 0) ] return btns def DisableSlot(self): FittingSlotBase.DisableSlot(self) self.UpdateGhostFittingIcons(None) self.Hilite(0) def EnableSlot(self): FittingSlotBase.EnableSlot(self) self.sr.underlay.display = True def HideSlot(self): self.state = uiconst.UI_HIDDEN @telemetry.ZONE_METHOD def UpdateFitting(self): if self.destroyed: return if not self.controller.SlotExists() and not self.controller.GetModule( ): if self.controller.IsSubsystemSlot( ) and self.controller.parentController.HasStance(): self.HideSlot() else: self.DisableSlot() return self.EnableSlot() self.SetDragState() if self.controller.GetCharge(): chargeQty = self.controller.GetChargeQuantity() if self.controller.GetModule() is None: portion = 1.0 else: cap = self.controller.GetChargeCapacity() if cap.capacity == 0: portion = 1.0 else: portion = cap.used / cap.capacity step = max(0, min(4, int(portion * 5.0))) self.ConstructChargeIndicator() self.chargeIndicator.rectTop = 10 * step self.chargeIndicator.state = uiconst.UI_NORMAL self.chargeIndicator.hint = '%s %d%%' % (evetypes.GetName( self.controller.GetCharge().typeID), portion * 100) elif not self.controller.GetModule(): self.HideUtilButtons(1) if self.chargeIndicator: self.chargeIndicator.Hide() elif self.controller.IsChargeable(): self.ConstructChargeIndicator() self.chargeIndicator.rectTop = 0 self.chargeIndicator.state = uiconst.UI_NORMAL self.chargeIndicator.hint = localization.GetByLabel( 'UI/Fitting/NoCharge') elif self.chargeIndicator: self.chargeIndicator.Hide() if self.controller.GetModule(): self.tooltipPanelClassInfo = TooltipModuleWrapper() modulehint = evetypes.GetName(self.controller.GetModuleTypeID()) if self.controller.GetCharge(): modulehint += '<br>%s' % localization.GetByLabel( 'UI/Fitting/ChargeQuantity', charge=self.controller.GetCharge().typeID, chargeQuantity=chargeQty) if not self.controller.SlotExists(): modulehint = localization.GetByLabel( 'UI/Fitting/SlotDoesNotExist') self.hint = modulehint else: self.tooltipPanelClassInfo = None self.hint = self._emptyHint tooltipName = self._emptyTooltip if tooltipName: SetFittingTooltipInfo(targetObject=self, tooltipName=tooltipName, includeDesc=False) self.PrepareUtilButtons() iconSize = int(48 * GetScaleFactor()) self.flagIcon.SetSize(iconSize, iconSize) if self.controller.GetCharge() or self.controller.GetModule(): self.flagIcon.LoadIconByTypeID( (self.controller.GetCharge() or self.controller.GetModule()).typeID, ignoreSize=True) self.flagIcon.rotation = -self.GetRotation() else: rev = 0 slotIcon = { const.flagSubSystemSlot0: 'res:/UI/Texture/Icons/81_64_9.png', const.flagSubSystemSlot1: 'res:/UI/Texture/Icons/81_64_10.png', const.flagSubSystemSlot2: 'res:/UI/Texture/Icons/81_64_11.png', const.flagSubSystemSlot3: 'res:/UI/Texture/Icons/81_64_12.png', const.flagSubSystemSlot4: 'res:/UI/Texture/Icons/81_64_13.png' }.get(self.controller.GetFlagID(), None) if slotIcon is None: slotIcon = { const.effectLoPower: 'res:/UI/Texture/Icons/81_64_5.png', const.effectMedPower: 'res:/UI/Texture/Icons/81_64_6.png', const.effectHiPower: 'res:/UI/Texture/Icons/81_64_7.png', const.effectRigSlot: 'res:/UI/Texture/Icons/81_64_8.png' }.get(self.controller.GetPowerType(), None) else: rev = 1 if slotIcon is not None: self.flagIcon.LoadIcon(slotIcon, ignoreSize=True) if rev: self.flagIcon.rotation = mathUtil.DegToRad(180.0) else: self.flagIcon.rotation = 0.0 self.SetGroup() self.UpdateOnlineDisplay() self.UpdateStatusDisplay() self.UpdateGhostFittingIcons(self.controller.GetModule()) if not self.hilitedFromMathing: self.Hilite(0) def IsCharge(self, typeID): return evetypes.GetCategoryID(typeID) == const.categoryCharge def Add(self, item, sourceLocation=None): if self.controller.parentController.IsSimulated(): return self.AddSimulatedItem(item, sourceLocation) else: guid = getattr(item, '__guid__', None) if guid is None or guid in ('listentry.InvItem', 'xtriui.InvItem'): return self.AddRealItem(item, sourceLocation) sm.GetService('ghostFittingSvc').LoadCurrentShip() return self.AddSimulatedItem(item, sourceLocation) def AddSimulatedItem(self, item, sourceLocation): if not IsRightSlotForType(item.typeID, self.controller.GetPowerType()): return shipID = self.controller.GetParentID() ghostFittingSvc = sm.GetService('ghostFittingSvc') ghostFittingSvc.FitModuleToShipAndChangeState( shipID, self.controller.GetFlagID(), item.typeID) ghostFittingSvc.SendFittingSlotsChangedEvent() def AddRealItem(self, item, sourceLocation=None): if not getattr(item, 'typeID', None): return if not RigFittingCheck(item): return requiredSkills = sm.GetService('skills').GetRequiredSkills(item.typeID) for skillID, level in requiredSkills.iteritems(): if getattr( sm.GetService('skills').HasSkill(skillID), 'skillLevel', 0) < level: sm.GetService('tutorial').OpenTutorialSequence_Check( uix.skillfittingTutorial) break if self.IsCharge(item.typeID) and self.controller.IsChargeable(): self.controller.FitCharge(item) validFitting = False for effect in cfg.dgmtypeeffects.get(item.typeID, []): if self.IsFittableItem(effect.effectID): validFitting = True if effect.effectID == self.controller.GetPowerType(): shift = uicore.uilib.Key(uiconst.VK_SHIFT) isFitted = item.locationID == self.controller.GetParentID( ) and item.flagID != const.flagCargo if isFitted and shift: if self.controller.GetModule(): if self.controller.GetModule( ).typeID == item.typeID: self.controller.LinkWithWeapon(item) return else: uicore.Message( 'CustomNotify', { 'notify': localization.GetByLabel( 'UI/Fitting/GroupingIncompatible') }) return self.controller.FitModule(item) return uicore.Message( 'ItemDoesntFitPower', { 'item': evetypes.GetName(item.typeID), 'slotpower': cfg.dgmeffects.Get( self.controller.GetPowerType()).displayName, 'itempower': cfg.dgmeffects.Get(effect.effectID).displayName }) if not validFitting: raise UserError('ItemNotHardware', {'itemname': item.typeID}) def IsFittableItem(self, effectID): isFittableItem = effectID in (const.effectHiPower, const.effectMedPower, const.effectLoPower, const.effectSubSystem, const.effectRigSlot, const.effectServiceSlot) return isFittableItem def GetMenu(self): if self.controller.GetModuleTypeID() and self.controller.GetModuleID(): m = FittingSlotBase.GetMenu(self) m += self.GetGroupMenu() return m def GetGroupMenu(self, *args): masterID = self.controller.IsInWeaponBank() if masterID: return [(uiutil.MenuLabel('UI/Fitting/ClearGroup'), self.UnlinkModule, ())] return [] def OnDblClick(self, *args): if self.controller.IsSimulated(): sm.ScatterEvent('OnSlotDblClicked', self.controller.GetFlagID()) def OnClick(self, *args): if self.controller.IsSimulated() and self.controller.GetSimulationMode( ) == SIMULATION_MODULES: return self.OnClickSimulated() def OnClickSimulated(self): if self.controller.GetModule() is None: return uicore.registry.SetFocus(self) typeID = self.controller.GetModuleTypeID() itemKey = self.controller.GetModuleID() flagID = self.controller.GetFlagID() ghostFittingSvc = sm.GetService('ghostFittingSvc') ghostFittingSvc.SwitchBetweenModes(itemKey, typeID, flagID) self.UpdateStatusDisplay() def UpdateStatusDisplay(self): self.HideElement(self.moduleSlotFill) ghostFittingSvc = sm.GetService('ghostFittingSvc') simulationMode = ghostFittingSvc.GetSimulationMode() if not self.controller.parentController.IsSimulated( ) or simulationMode != SIMULATION_MODULES: return itemKey = self.controller.GetModuleID() typeID = self.controller.GetModuleTypeID() flagID = self.controller.GetFlagID() if itemKey is None or typeID is None: return typeEffectInfo = ghostFittingSvc.GetDefaultAndOverheatEffect(typeID) currentStatus = ghostFittingSvc.GetModuleStatus( itemKey, typeID, flagID) self.flagIcon.SetAlpha(1.0) self.ConstructModuleSlotFill() if typeEffectInfo.defaultEffect and typeEffectInfo.isActivatable: texturePath = 'res:/UI/Texture/classes/Fitting/slotGlowInner.png' else: texturePath = 'res:/UI/Texture/classes/Fitting/slotGlowOuter.png' self.moduleSlotFill.SetTexturePath(texturePath) self.moduleSlotFill.display = True if currentStatus == OFFLINE: self.flagIcon.SetAlpha(0.25) self.moduleSlotFill.SetRGB(0.5, 0.5, 0.5, 0.2) elif currentStatus == ONLINE: self.moduleSlotFill.SetRGB(0.5, 0.5, 0.5, 1.5) elif currentStatus == ACTIVE: self.ConstructModuleSlotFill() self.moduleSlotFill.SetRGB(1, 1, 0, 1.0) elif currentStatus == OVERHEATED: self.ConstructModuleSlotFill() self.moduleSlotFill.SetRGB(1, 0, 0, 1.0) def ShowChargeInfo(self, *args): if self.controller.GetCharge(): sm.GetService('info').ShowInfo(self.controller.GetCharge().typeID, self.controller.GetCharge().itemID) def UnlinkModule(self): self.controller.DestroyWeaponBank() def _OnEndDrag(self, *args): self.left = self.top = -2 def OnEndDrag(self, *args): if self.controller.GetModule() is not None: sm.ScatterEvent('OnResetSlotLinkingMode', self.controller.GetModule().typeID) def GetTooltipPosition(self): rect, point = self.PositionHint() return rect def GetTooltipPointer(self): rect, point = self.PositionHint() return point def UpdateInfo_TimedCall(self, *args): if self.destroyed or self.moduleButtonHint.destroyed: self.moduleButtonHint = None self.updateTimer = None return if self.controller.GetModuleTypeID(): if self.controller.GetCharge(): chargeItemID = self.controller.GetCharge().itemID else: chargeItemID = None self.moduleButtonHint.UpdateAllInfo(self.controller.GetModuleID(), chargeItemID, fromWhere='fitting') def PositionHint(self, *args): myRotation = self.rotation + 2 * math.pi myRotation = -myRotation sl, st, sw, sh = self.parent.GetAbsolute() cX = sl + sw / 2.0 cY = st + sh / 2.0 rad, cos, sin, oldcX, oldcY = self.radCosSin hintLeft = int(round(rad * cos)) hintTop = int(round(rad * sin)) cap = rad * 0.7 if hintLeft < -cap: point = uiconst.POINT_RIGHT_2 elif hintLeft > cap: point = uiconst.POINT_LEFT_2 elif hintTop < -cap: if hintLeft < 0: point = uiconst.POINT_BOTTOM_3 else: point = uiconst.POINT_BOTTOM_1 elif hintLeft < 0: point = uiconst.POINT_TOP_3 else: point = uiconst.POINT_TOP_1 return ((hintLeft + cX - 15, hintTop + cY - 15, 30, 30), point) def OnDropData(self, dragObj, nodes): if self.controller.GetModule( ) is not None and not self.controller.SlotExists(): return items = self.GetDroppedItems(nodes) chargeTypeID = None chargeItems = [] for item in items: if not getattr(item, 'typeID', None): lg.Info('fittingUI', 'Dropped a non-item here', item) return if self.controller.IsChargeable() and self.IsCharge(item.typeID): if chargeTypeID is None: chargeTypeID = item.typeID if chargeTypeID == item.typeID: chargeItems.append(item) else: uthread.new(self.Add, item) if len(chargeItems): self.controller.FitCharges(chargeItems) def _OnClose(self, *args): self.updateTimer = None moduleButtonHint = getattr(uicore.layer.hint, 'moduleButtonHint', None) if moduleButtonHint and not moduleButtonHint.destroyed: if moduleButtonHint.fromWhere == 'fitting': uicore.layer.hint.moduleButtonHint.FadeOpacity(0.0) def GetDroppedItems(self, nodes): items = [] for node in nodes: if node.__guid__ in ('listentry.InvItem', 'xtriui.InvItem'): invType = node.rec if self.controller.IsFittableType(invType.typeID): items.append(invType) elif node.__guid__ in ('listentry.GenericMarketItem', 'listentry.Item', 'listentry.FittingModuleEntry'): if self.controller.IsFittableType(node.typeID): items.append(node.invtype or util.KeyVal(typeID=node.typeID)) return items def UpdateGhostFittingIcons(self, invItem): fittingSvc = sm.GetService('fittingSvc') if fittingSvc.IsShipSimulated() and invItem: self.SetMissingIcon(invItem) self.SetSkillIcon(invItem) else: self.HideElement(self.dontHaveLine) self.HideElement(self.skillSprite) self.HideElement(self.moduleSlotFill) self.sr.underlay.display = True def HideElement(self, element): if element: element.display = False def SetMissingIcon(self, invItem): return self.ConstructDontHaveLine() self.dontHaveLine.display = False self.sr.underlay.display = True if invItem is None or not session.stationid2: return hangarInv = sm.GetService('invCache').GetInventory( const.containerHangar) items = hangarInv.List(const.flagHangar) for eachItem in items: if eachItem.typeID == invItem.typeID: return self.dontHaveLine.display = True self.sr.underlay.display = False def SetSkillIcon(self, invItem): simulationMode = sm.GetService('ghostFittingSvc').GetSimulationMode() fittingSvc = sm.GetService('fittingSvc') if invItem is None or simulationMode != SIMULATION_SKILLS or not fittingSvc.IsShipSimulated( ): self.HideElement(self.skillSprite) return dogmaLocation = fittingSvc.GetCurrentDogmaLocation() missingSkills = dogmaLocation.CheckSkillRequirementsForType( invItem.typeID) self.ConstructSkillSprite() self.skillSprite.display = True if missingSkills: self.skillSprite.SetRGB(1, 0, 0, 0.5) else: self.skillSprite.SetRGB(0, 1, 0, 0.5) def UpdateSimulationMode(self, newMode): self.UpdateOnlineDisplay() self.UpdateStatusDisplay() self.UpdateGhostFittingIcons(self.controller.GetModule())
class StructureStateIcon(Container): default_width = 32 default_height = 32 default_align = uiconst.CENTER default_state = uiconst.UI_NORMAL default_name = 'StructureStateIcon' def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) structureState = attributes.get('structureState', None) underAttack = attributes.get('underAttack', False) self.shield = Sprite(name='shield', parent=self, align=uiconst.TOALL, texturePath=SHIELD_TEXTURE_PATH, state=uiconst.UI_DISABLED, opacity=0) self.armor = Sprite(name='armor', parent=self, align=uiconst.TOALL, texturePath=ARMOR_TEXTURE_PATH, state=uiconst.UI_DISABLED, opacity=0) self.hull = Sprite(name='hull', parent=self, align=uiconst.TOALL, texturePath=HULL_TEXTURE_PATH, state=uiconst.UI_DISABLED, opacity=0) self.attackSprite = Sprite(parent=self, align=uiconst.TOALL, texturePath='', state=uiconst.UI_DISABLED) if structureState is not None: self.SetStructureState(structureState, underAttack=underAttack) def SetStructureState(self, structureState, underAttack=False): if structureState not in SECURE_STATES + VULNERABLE_STATES: self.display = False return self.display = True opacity, stateColor = self._GetStateColorAndOpacity( structureState, underAttack) self._SetAttackSprite(underAttack, stateColor, opacity) self.SetHintForIcon(structureState, underAttack) if structureState in (structures.STATE_ONLINE, structures.STATE_SHIELD_VULNERABLE): self._SetColorAndOpacity(self.shield, stateColor, opacity) self._SetColorAndOpacity(self.armor, stateColor, LOW_OPACITY) self._SetColorAndOpacity(self.hull, stateColor, LOW_OPACITY) elif structureState in (structures.STATE_SHIELD_REINFORCE, structures.STATE_ARMOR_VULNERABLE): self._SetColorAndOpacity(self.shield, GREY, LOW_OPACITY) self._SetColorAndOpacity(self.armor, stateColor, opacity) self._SetColorAndOpacity(self.hull, stateColor, LOW_OPACITY) elif structureState in (structures.STATE_ARMOR_REINFORCE, structures.STATE_HULL_VULNERABLE): self._SetColorAndOpacity(self.shield, GREY, LOW_OPACITY) self._SetColorAndOpacity(self.armor, GREY, LOW_OPACITY) self._SetColorAndOpacity(self.hull, stateColor, opacity) if structureState == structures.STATE_ONLINE: self.opacity = 0.25 else: self.opacity = 1.0 def _GetStateColorAndOpacity(self, state, underAttack): accentOpacity = FULL_OPACITY if state in SECURE_STATES: stateColor = BLUE accentOpacity = LOW_OPACITY elif underAttack: stateColor = RED else: stateColor = YELLOW return (accentOpacity, stateColor) def _SetColorAndOpacity(self, uiObject, color, opacity): newColor = color + (opacity, ) uiObject.SetRGBA(*newColor) def _SetAttackSprite(self, isUnderAttack, stateColor, opacity): if isUnderAttack: texturePath = UNDER_ATTACK_TEXTURE_PATH else: texturePath = NO_ATTACK_TEXTURE_PATH self.attackSprite.SetTexturePath(texturePath) newColor = stateColor + (opacity, ) self.attackSprite.SetRGBA(*newColor) def SetHintForIcon(self, structureState, isUnderAttack): hintPath = hintDict.get((structureState, isUnderAttack), None) if hintPath: self.hint = GetByLabel(hintPath) else: self.hint = ''