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 JobEntry(BaseListEntryCustomColumns): default_name = 'JobEntry' def ApplyAttributes(self, attributes): BaseListEntryCustomColumns.ApplyAttributes(self, attributes) self.jobData = self.node.jobData self.item = self.node.item self.viewMode = self.node.viewMode self.AddColumnStatusIcon() self.AddColumnStatus() self.AddColumnText('x %s' % self.jobData.runs) self.AddColumnActivity() self.AddColumnBlueprintLabel() self.AddColumnJumps() self.AddColumnText(self.GetSecurityLabel()) self.AddColumnInstallationName() if not IsPersonalJob(self.jobData.ownerID): self.AddColumnText(self.jobData.GetInstallerName()) self.AddColumnText(self.jobData.GetStartDateLabel()) self.AddColumnText(self.jobData.GetEndDateLabel()) def AddColumnBlueprintLabel(self): col = self.AddColumnContainer() texturePath, hint = uix.GetTechLevelIconPathAndHint( self.jobData.blueprint.blueprintTypeID) if texturePath: techIconSize = 16 if self.viewMode == VIEWMODE_ICONLIST else 12 Sprite(name='techIcon', parent=col, texturePath=texturePath, hint=hint, width=techIconSize, height=techIconSize) if self.viewMode == VIEWMODE_ICONLIST: iconSize = 32 Icon(parent=col, typeID=self.jobData.blueprint.blueprintTypeID, isCopy=not self.jobData.blueprint.original, ignoreSize=True, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, width=iconSize, height=iconSize, left=2) else: iconSize = 0 Label(parent=col, text=self.jobData.blueprint.GetLabel(), align=uiconst.CENTERLEFT, left=iconSize + 4, idx=0) def AddColumnStatusIcon(self): col = self.AddColumnContainer() self.statusIcon = Sprite(parent=col, align=uiconst.CENTER, width=16, height=16) self.UpdateStatusIcon() def UpdateStatusIcon(self): texturePath, color = industryUIConst.GetStatusIconAndColor( self.jobData.status) self.statusIcon.texturePath = texturePath self.statusIcon.SetRGBA(*color) def AddColumnStatus(self): col = self.AddColumnContainer() self.jobStateCont = JobStateContainer(parent=col, align=uiconst.TOALL, padding=2, jobData=self.jobData) def AddColumnActivity(self): col = self.AddColumnContainer() ICONSIZE = 20 if self.viewMode == VIEWMODE_ICONLIST else 16 InstallationActivityIcon(parent=col, align=uiconst.CENTER, pos=(0, 0, ICONSIZE, ICONSIZE), activityID=self.jobData.activityID, isEnabled=True) def AddColumnJumps(self): jumps = self.node.jumps if jumps != sys.maxint: self.AddColumnText(jumps) else: col = self.AddColumnContainer() Sprite(name='infinityIcon', parent=col, align=uiconst.CENTERLEFT, pos=(6, 0, 11, 6), texturePath='res:/UI/Texture/Classes/Industry/infinity.png', opacity=Label.default_color[3]) def AddColumnInstallationName(self): self.AddColumnText(self.jobData.GetFacilityName()) @staticmethod def GetDynamicHeight(node, width): if node.viewMode == VIEWMODE_ICONLIST: return 36 else: return 20 @staticmethod def GetDefaultColumnWidth(): return { localization.GetByLabel('UI/Generic/Status'): 90, localization.GetByLabel('UI/Industry/Activity'): 32, localization.GetByLabel('UI/Industry/Blueprint'): 230, localization.GetByLabel('UI/Industry/Facility'): 230, localization.GetByLabel('UI/ScienceAndIndustry/ScienceAndIndustryWindow/Installer'): 120 } def GetSecurityLabel(self): securityStatus = sm.GetService('map').GetSecurityStatus( self.jobData.solarSystemID) sec, col = FmtSystemSecStatus(securityStatus, 1) col.a = 1.0 color = StrFromColor(col) return '<color=%s>%s</color>' % (color, sec) @staticmethod def GetColumnSortValues(jobData, jumps): if jobData.facilityID == session.stationid2 or jobData.solarSystemID == session.solarsystemid: jumps = -1 if IsPersonalJob(jobData.ownerID): return (jobData.status, (-jobData.status, jobData.endDate), jobData.runs, jobData.activityID, cfg.invtypes.Get(jobData.blueprint.blueprintTypeID).name, jumps, sm.GetService('map').GetSecurityStatus( jobData.solarSystemID), jobData.GetFacilityName(), jobData.startDate, jobData.endDate) else: return (jobData.status, (jobData.status, jobData.endDate), jobData.runs, jobData.activityID, cfg.invtypes.Get(jobData.blueprint.blueprintTypeID).name, jumps, sm.GetService('map').GetSecurityStatus( jobData.solarSystemID), jobData.GetFacilityName(), jobData.GetInstallerName(), jobData.startDate, jobData.endDate) @staticmethod def GetHeaders(isPersonalJob=True): if isPersonalJob: return ( '', localization.GetByLabel('UI/Generic/Status'), localization.GetByLabel('UI/Industry/JobRuns'), localization.GetByLabel('UI/Industry/Activity'), localization.GetByLabel('UI/Industry/Blueprint'), localization.GetByLabel('UI/Common/Jumps'), localization.GetByLabel('UI/Common/Security'), localization.GetByLabel('UI/Industry/Facility'), localization.GetByLabel( 'UI/ScienceAndIndustry/ScienceAndIndustryWindow/InstallDate' ), localization.GetByLabel( 'UI/ScienceAndIndustry/ScienceAndIndustryWindow/EndDate')) else: return ( '', localization.GetByLabel('UI/Generic/Status'), localization.GetByLabel('UI/Industry/JobRuns'), localization.GetByLabel('UI/Industry/Activity'), localization.GetByLabel('UI/Industry/Blueprint'), localization.GetByLabel('UI/Common/Jumps'), localization.GetByLabel('UI/Common/Security'), localization.GetByLabel('UI/Industry/Facility'), localization.GetByLabel( 'UI/ScienceAndIndustry/ScienceAndIndustryWindow/Installer' ), localization.GetByLabel( 'UI/ScienceAndIndustry/ScienceAndIndustryWindow/InstallDate' ), localization.GetByLabel( 'UI/ScienceAndIndustry/ScienceAndIndustryWindow/EndDate')) def GetMenu(self): m = sm.GetService('menu').GetMenuFormItemIDTypeID( self.jobData.blueprint.blueprintID, self.jobData.blueprint.blueprintTypeID, ignoreMarketDetails=False, invItem=self.jobData.blueprint.GetItem()) label = MenuLabel('UI/Industry/Facility') m.append((label, sm.GetService('menu').CelestialMenu( itemID=self.jobData.facilityID))) if bool(session.role & ROLE_PROGRAMMER): m.append(None) m.append( ('GM: Complete Job', sm.GetService('industrySvc').CompleteJob, (self.jobData.jobID, ))) m.append(('GM: Cancel Job', sm.GetService('industrySvc').CancelJob, (self.jobData.jobID, ))) m.append(None) m.append(('jobID: {}'.format(self.jobData.jobID), blue.pyos.SetClipboardData, (str(self.jobData.jobID), ))) return m def UpdateValues(self, animate, num): self.jobStateCont.UpdateValue(animate, num) def OnStatusChanged(self, status, successfulRuns): self.jobData.status = status self.jobData.successfulRuns = successfulRuns self.jobStateCont.OnStatusChanged() if status > industry.STATUS_READY: if self.jobData.activityID == industry.MANUFACTURING: color = industryUIConst.COLOR_MANUFACTURING else: color = industryUIConst.COLOR_SCIENCE for col in self.columns: col.opacity = 0.3 self.AnimFlash(color) self.UpdateStatusIcon() def AnimFlash(self, color): width = 500 flashCont = Container(parent=self, idx=0, align=uiconst.TOPLEFT, width=width, height=self.height) flashGradient = GradientSprite(bgParent=flashCont, rgbData=[(0, color[:3])], alphaData=[(0, 0.0), (0.9, 0.4), (1.0, 0.0)]) arrows = Sprite( parent=flashCont, align=uiconst.CENTERLEFT, texturePath='res:/UI/Texture/Classes/Industry/CenterBar/arrows.png', pos=(0, 0, 375, self.height), color=color, opacity=0.15, tileX=True) duration = self.width / 600.0 uicore.animations.MorphScalar(flashCont, 'left', -width, self.width + width, duration=duration, curveType=uiconst.ANIM_LINEAR) uicore.animations.FadeTo(flashCont, 0.0, 1.0, duration=duration, callback=flashCont.Close, curveType=uiconst.ANIM_WAVE)
class ShipGroupIcon(Container): default_name = 'ShipGroupIcon' default_align = uiconst.TOPLEFT default_state = uiconst.UI_DISABLED default_width = 42 default_height = 42 __notifyevents__ = ('OnShipTreeZoomChanged', 'OnShipTreeShipGroupFocused') def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) sm.RegisterNotify(self) self.node = attributes.node if self.node.IsRestricted(): self.bgPattern = Sprite(bgParent=self, aling=uiconst.TOALL, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/ShipTree/groups/hatchPattern.png', textureSecondaryPath='res:/UI/Texture/classes/ShipTree/groups/bgVignette.png', spriteEffect=trinity.TR2_SFX_MODULATE, tileX=True, tileY=True, color=(0.965, 0.467, 0.157, 0.4)) self.bgFrame = Frame(name='bgFrame', bgParent=self, texturePath='res:/UI/Texture/Classes/ShipTree/Groups/groupIconFrame.png') self.bgFill = Fill(name='bgFill', bgParent=self, color=shipTreeConst.COLOR_BG) self.bgBlinkFill = None self.icon = Sprite(parent=self, align=uiconst.CENTER, state=uiconst.UI_DISABLED, texturePath=cfg.fsdInfoBubbleGroups[self.node.shipGroupID].icon, color=shipTreeConst.COLOR_HILIGHT, width=32, height=32) def OnShipTreeZoomChanged(self, zoom): self.UpdateState(0, True) def OnShipTreeShipGroupFocused(self, factionID, shipGroupID): if (factionID, shipGroupID) == (self.node.factionID, self.node.shipGroupID): self.Blink() elif self.bgBlinkFill and not self.node.IsBeingTrained(): uicore.animations.FadeOut(self.bgBlinkFill) def Blink(self): self.ConstructBgBlinkFill() uicore.animations.FadeTo(self.bgBlinkFill, 0.0, 0.5, loops=ANIM_REPEAT, duration=1.2, curveType=ANIM_WAVE) def ConstructBgBlinkFill(self): if self.node.IsLocked(): color = COLOR_HOVER_LOCKED else: color = COLOR_HOVER_UNLOCKED if not self.bgBlinkFill: self.bgBlinkFill = Sprite(name='bgFillBlink', bgParent=self, texturePath='res:/UI/Texture/Classes/ShipTree/groups/bgVignette.png', idx=0, color=color, opacity=0.0) else: self.bgBlinkFill.SetRGBA(color[0], color[1], color[2], self.bgBlinkFill.opacity) def OnMouseEnter(self, *args): self.ConstructBgBlinkFill() uicore.animations.FadeTo(self.bgBlinkFill, self.bgBlinkFill.opacity, 0.4, duration=0.3) def OnMouseExit(self, *args): if self.bgBlinkFill: uicore.animations.FadeTo(self.bgBlinkFill, self.bgBlinkFill.opacity, 0.0, duration=0.3) def UpdateState(self, i, animate = True): zoomLevel = sm.GetService('shipTreeUI').GetZoomLevel() isLocked = self.node.IsLocked() opacity = OPACITY_LOCKED if isLocked else 1.0 if animate: uicore.animations.FadeTo(self.icon, self.icon.opacity, opacity, timeOffset=0.05 * i, duration=0.3) else: self.icon.opacity = opacity if zoomLevel == ZOOMED_OUT: opacity = 0.0 elif isLocked: opacity = OPACITY_LOCKED else: opacity = 1.0 if animate: uicore.animations.FadeTo(self.bgFrame, self.bgFrame.opacity, opacity, timeOffset=0.05 * i, duration=0.3) else: self.bgFrame.opacity = opacity color = COLOR_BG if isLocked else COLOR_SHIPGROUP_UNLOCKED if animate: uicore.animations.SpColorMorphTo(self.bgFill, self.bgFill.GetRGBA(), color) else: self.bgFill.SetRGBA(*color) if self.node.IsBeingTrained(): self.Blink() elif self.bgBlinkFill: uicore.animations.FadeOut(self.bgBlinkFill)
class TaskNode(Container): default_align = uiconst.TOLEFT default_state = uiconst.UI_NORMAL def ApplyAttributes(self, attributes): super(TaskNode, self).ApplyAttributes(attributes) self.isCollapsed = False self.window = attributes.window self.task = attributes.task self.CreateLayout(attributes) self.SetStatus(attributes.task.status) def CreateLayout(self, attributes): self.stepFrame = Frame(name='myFrame', bgParent=self, frameConst=uiconst.FRAME_BORDER2_CORNER9, padding=(1, 1, 1, 1)) self.mainFrame = Frame(name='myFrame', bgParent=self, frameConst=uiconst.FRAME_FILLED_SHADOW_CORNER9, padding=(1, 1, 1, 1)) self.collapsedFrame = Sprite( name='myFrame', bgParent=self, texturePath= 'res:/UI/Texture/Classes/Industry/Output/hatchPattern.png', padding=(1, 1, 1, 1), tileX=True, tileY=True) self.collapsedFrame.display = False label = eveLabel.EveLabelSmall(parent=self, text=attributes.text, align=uiconst.CENTER, color=Color.WHITE) self.width = max(100, label.textwidth + 16) def EnableStepped(self): self.stepFrame.Show() def DisableStepped(self): self.stepFrame.Hide() def SetStatus(self, status): self.task.status = status self.mainFrame.SetRGBA(*STATUS_MAP[status].color[:3]) self.mainFrame.opacity = 0.4 self.stepFrame.SetRGBA(*STATUS_MAP[status].color[:3]) self.stepFrame.opacity = 0.5 self.collapsedFrame.SetRGBA(*STATUS_MAP[status].color[:3]) self.collapsedFrame.opacity = 0.3 def OnClick(self, *args): self.ToggleChildren() def ToggleChildren(self): self.SetCollapsed(not self.isCollapsed) def SetCollapsed(self, isCollapsed): self.collapsedFrame.display = isCollapsed self.isCollapsed = isCollapsed if hasattr(self.task, 'subtasks'): for taskID in self.task.subtasks: e = self.window.taskMap[taskID] e.display = not isCollapsed e.taskNode.SetCollapsed(isCollapsed) def GetTooltipDelay(self): return 500 def LoadTooltipPanel(self, tooltipPanel, *args): tooltipPanel.LoadGeneric2ColumnTemplate() tooltipPanel.AddLabelLarge(text=self.task.attributes.get( 'name', self.task.type), colSpan=2, bold=True, bgColor=(1, 1, 1, 0.1), align=uiconst.CENTER) tooltipPanel.AddLabelValue('Type', self.task.type, VALUE_COLOR) tooltipPanel.AddLabelValue('ID', self.task.id, VALUE_COLOR) tooltipPanel.AddLabelValue('Status', self.task.status, STATUS_MAP[self.task.status].color) tooltipPanel.AddLabelLarge(text='Attributes', colSpan=2, bold=True, bgColor=(1, 1, 1, 0.1), align=uiconst.CENTER) for attributeName, attributeValue in sorted( self.task.attributes.iteritems()): tooltipPanel.AddLabelValue(attributeName, str(attributeValue), VALUE_COLOR)
class ShipTreeShipIcon(Container): default_name = 'ShipTreeShipIcon' default_align = uiconst.TOPLEFT default_state = uiconst.UI_NORMAL isDragObject = True __notifyevents__ = ('OnShipTreeShipFocused', ) def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) sm.RegisterNotify(self) self.typeID = attributes.typeID self.factionID = attributes.factionID self.groupNode = attributes.groupNode self.masteryLevel = None self.isMasteryIconBlinking = False if self.groupNode.IsRestricted(): Sprite(bgParent=self, align=uiconst.TOALL, texturePath= 'res:/UI/Texture/classes/ShipTree/groups/hatchPattern.png', textureSecondaryPath= 'res:/UI/Texture/classes/ShipTree/groups/bgVignette.png', spriteEffect=trinity.TR2_SFX_MODULATE, tileX=True, tileY=True, color=(0.965, 0.467, 0.157, 0.4)) self.bgFrame = Frame( bgParent=self, cornerSize=10, opacity=0.5, texturePath= 'res:/UI/Texture/Classes/ShipTree/groups/frameUnlocked.png') self.bgBlinkFill = None self.bgVignette = Sprite( name='bgFill', bgParent=self, texturePath='res:/UI/Texture/Classes/ShipTree/groups/bgFill.png') Sprite(name='bgVignette', bgParent=self, texturePath= 'res:/UI/Texture/Classes/ShipTree/groups/bgVignette.png', color=COLOR_BG) self.recentUnlockBG = None texturePath = shipTreeConst.GetTagIconForType(self.typeID) if texturePath: self.techIcon = Sprite(name='techIcon', parent=self, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, width=32, height=32, texturePath=texturePath, idx=0) else: self.techIcon = None self.iconTransform = Transform(parent=self, align=uiconst.TOALL, scalingCenter=(0.5, 0.5)) try: texturePath = cfg.invtypes.Get(self.typeID).Graphic().isisIconPath except AttributeError as e: texturePath = None log.LogException(e) self.iconSprite = Sprite(name='iconSprite', parent=self.iconTransform, align=uiconst.TOPLEFT_PROP, state=uiconst.UI_DISABLED, texturePath=texturePath, blendMode=trinity.TR2_SBM_ADD, pos=(0.5, 0.08, self.width - 36, self.width - 36), idx=0) self.masteryIcon = Sprite(name='masterySprite', parent=self, align=uiconst.CENTERBOTTOM, state=uiconst.UI_DISABLED, pos=(0, -3, 45, 45), idx=0) def UpdateState(self, animate=True): self.masteryLevel = sm.GetService( 'certificates').GetCurrCharMasteryLevel(self.typeID) duration = 0.6 if animate else 0.01 if self.groupNode.IsLocked(): self._UpdateStateLocked(duration) else: self._UpdateStateUnlocked(duration) if self.groupNode.IsRecentlyUnlocked(): if not self.recentUnlockBG: self.ConstructRecentUnlockBG() i = self.parent.children.index(self) uicore.animations.FadeTo(self.recentUnlockBG, 0.7, 0.0, duration=2.4, loops=uiconst.ANIM_REPEAT, curveType=uiconst.ANIM_WAVE, timeOffset=i * 0.15) sm.GetService('audio').SendUIEvent('isis_line_2filled') elif self.recentUnlockBG: uicore.animations.FadeOut(self.recentUnlockBG) if sm.GetService('shipTree').IsShipMasteryRecentlyIncreased( self.typeID): if not self.isMasteryIconBlinking: uicore.animations.FadeTo(self.masteryIcon, OPACITY_MASTERY_LOCKED, 1.5, duration=2.4, loops=uiconst.ANIM_REPEAT, curveType=uiconst.ANIM_WAVE) if self.IsElite(): sm.GetService('audio').SendUIEvent( 'isis_masteryunlock_elite') else: sm.GetService('audio').SendUIEvent( 'isis_masteryunlock') self.isMasteryIconBlinking = True else: uicore.animations.FadeTo(self.masteryIcon, 1.0) texturePath = sm.GetService('certificates').GetMasteryIconForLevel( self.masteryLevel) self.masteryIcon.texturePath = texturePath def ConstructRecentUnlockBG(self): if not self.recentUnlockBG: if self.IsElite(): color = COLOR_HOVER_MASTERED else: color = COLOR_HOVER_UNLOCKED self.recentUnlockBG = Sprite( name='recentUnlockBG', bgParent=self, texturePath= 'res:/UI/Texture/Classes/ShipTree/groups/bgVignette.png', color=color) def IsElite(self): return self.masteryLevel == 5 def GetDragData(self): ret = KeyVal(__guid__='uicls.GenericDraggableForTypeID', typeID=self.typeID, label=cfg.invtypes.Get(self.typeID).name) return (ret, ) def _UpdateStateLocked(self, duration): self.bgVignette.SetRGBA(*shipTreeConst.COLOR_SHIPICON_LOCKED) for obj in (self.techIcon, self.iconSprite): if obj: uicore.animations.FadeTo(obj, obj.opacity, OPACITY_LOCKED, duration=duration) uicore.animations.FadeTo(self.masteryIcon, self.masteryIcon.opacity, OPACITY_MASTERY_LOCKED, duration=duration) uicore.animations.FadeTo(self.bgFrame, self.bgFrame.opacity, 0.25, duration=duration) self.iconSprite.SetRGBA(1.0, 1.0, 1.0, self.iconSprite.opacity) self.bgFrame.SetTexturePath( 'res:/UI/Texture/Classes/ShipTree/groups/frameLocked.png') def _UpdateStateUnlocked(self, duration): for obj in (self.techIcon, self.iconSprite): if obj: uicore.animations.FadeTo(obj, obj.opacity, 1.0, duration=duration) if not self.isMasteryIconBlinking: uicore.animations.FadeTo(self.masteryIcon, self.masteryIcon.opacity, 1.0, duration=duration) uicore.animations.FadeTo(self.bgFrame, self.bgFrame.opacity, 0.5, duration=duration) if self.IsElite(): texturePath = 'res:/UI/Texture/Classes/ShipTree/groups/frameElite.png' c = shipTreeConst.COLOR_MASTERED self.bgVignette.SetRGBA(c[0], c[1], c[2], 0.15) self.iconSprite.SetRGBA(c[0], c[1], c[2], self.iconSprite.opacity) else: texturePath = 'res:/UI/Texture/Classes/ShipTree/groups/frameUnlocked.png' self.bgVignette.SetRGBA(*shipTreeConst.COLOR_SHIPICON_UNLOCKED) self.iconSprite.SetRGBA(1.0, 1.0, 1.0, self.iconSprite.opacity) self.bgFrame.SetTexturePath(texturePath) def OnMouseEnter(self, *args): if not self.groupNode.IsLocked(): uicore.animations.FadeTo(self.iconSprite, self.iconSprite.opacity, 3.0, duration=3.0, curveType=uiconst.ANIM_WAVE, loops=uiconst.ANIM_REPEAT) uicore.animations.Tr2DScaleTo(self.iconTransform, self.iconTransform.scale, (1.05, 1.05), duration=0.3) else: uicore.animations.FadeTo(self.iconSprite, self.iconSprite.opacity, 1.0, duration=0.3) uicore.animations.FadeTo(self.masteryIcon, self.masteryIcon.opacity, 1.0, duration=0.3) sm.GetService('shipTreeUI').ShowInfoBubble(self, typeID=self.typeID) sm.GetService('audio').SendUIEventByTypeID(self.typeID) self.ConstructBgBlinkFill() uicore.animations.FadeTo(self.bgBlinkFill, self.bgBlinkFill.opacity, 0.5, duration=0.3) def OnMouseExit(self, *args): opacity = OPACITY_LOCKED if self.groupNode.IsLocked() else 1.0 uicore.animations.FadeTo(self.iconSprite, self.iconSprite.opacity, opacity, duration=0.3) opacity = OPACITY_MASTERY_LOCKED if self.groupNode.IsLocked() else 1.0 uicore.animations.FadeTo(self.masteryIcon, self.masteryIcon.opacity, opacity, duration=0.3) if self.bgBlinkFill: uicore.animations.FadeOut(self.bgBlinkFill, duration=0.3) uicore.animations.Tr2DScaleTo(self.iconTransform, self.iconTransform.scale, (1.0, 1.0), duration=0.3) sm.GetService('audio').SendUIEvent('ui_shipsound_stop') def GetMenu(self): return sm.GetService('menu').GetMenuFormItemIDTypeID( None, self.typeID, ignoreMarketDetails=False) def OnClick(self, *args): sm.GetService('info').ShowInfo(self.typeID) def OnShipTreeShipFocused(self, typeID): if typeID == self.typeID: self.Blink() elif self.bgBlinkFill: uicore.animations.FadeOut(self.bgBlinkFill) def Blink(self): self.ConstructBgBlinkFill() uicore.animations.FadeTo(self.bgBlinkFill, 0.0, 1.0, loops=ANIM_REPEAT, duration=1.2, curveType=ANIM_WAVE) def ConstructBgBlinkFill(self): if not self.bgBlinkFill: self.bgBlinkFill = Sprite( name='bgFillBlink', bgParent=self, texturePath= 'res:/UI/Texture/Classes/ShipTree/groups/bgVignette.png') if self.groupNode.IsLocked(): self.bgBlinkFill.SetRGBA(*COLOR_HOVER_LOCKED) elif self.IsElite(): self.bgBlinkFill.SetRGBA(*COLOR_HOVER_MASTERED) else: self.bgBlinkFill.SetRGBA(*COLOR_HOVER_UNLOCKED)
class FighterLaunchControlCont(Container): default_height = 196 default_width = 86 default_align = uiconst.TOLEFT def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.controller = SquadronMgmtController() self.shipFighterState = GetShipFighterState() self.tubeFlagID = attributes.tubeFlagID self.leftTube = Sprite( parent=self, texturePath= 'res:/UI/Texture/classes/CarrierBay/tubeSideElement.png', align=uiconst.TOLEFT_NOPUSH, width=15) self.rightTube = Sprite( parent=self, texturePath= 'res:/UI/Texture/classes/CarrierBay/tubeSideElementRIGHT.png', align=uiconst.TORIGHT_NOPUSH, width=15) inSpaceCont = Container(parent=self, height=86, align=uiconst.TOTOP) inSpaceCont.OnDropData = self.OnDropToSpace inSpaceCont.GetMenu = self.GetMenu self.squadronNumber = SquadronNumber(parent=inSpaceCont, top=1, left=1) self.squadronNumber.SetText(self.tubeFlagID) self.inStationCont = Container(parent=inSpaceCont, align=uiconst.TOALL) cantLaunchIcon = Sprite( parent=self.inStationCont, width=44, height=44, align=uiconst.CENTER, texturePath='res:/UI/Texture/classes/CarrierBay/unableToLaunch.png' ) self.stateCont = Container(parent=self, height=24, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) self.stateContBG = Fill(bgParent=self.stateCont, color=(0, 0, 0, 0)) deckCont = Container(parent=self, height=86, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) deckCont.OnDropData = self.OnDropToTube deckCont.GetMenu = self.GetMenu self.tubeStatusLabel = EveHeaderSmall(parent=self.stateCont, align=uiconst.CENTER, text='') self.loadingGauge = Gauge(parent=self.stateCont, align=uiconst.CENTERBOTTOM, backgroundColor=(0, 0, 0, 1), color=(0.2, 0.2, 0.2, 0.5), padLeft=1, padRight=1, top=1, width=75, value=0.0) self.loadingGauge.display = False spaceColor = Color(*COLOR_INSPACE) spaceColor.a = 1.0 self.launchIcon = ButtonIcon( parent=inSpaceCont, align=uiconst.CENTER, width=86, height=86, iconSize=44, texturePath='res:/UI/Texture/classes/CarrierBay/tubeLaunch_Up.png', downTexture= 'res:/UI/Texture/classes/CarrierBay/tubeLaunch_Down.png', hoverTexture= 'res:/UI/Texture/classes/CarrierBay/tubeLaunch_Over.png', iconColor=spaceColor.GetRGBA(), showGlow=False) self.launchIcon.OnClick = self.LaunchFightersFromTube self.launchIcon.OnDropData = self.OnDropToSpace returnColor = Color(*COLOR_RETURNING) returnColor.a = 1.0 self.scoopIcon = ButtonIcon( parent=deckCont, align=uiconst.CENTER, width=86, height=86, iconSize=44, texturePath='res:/UI/Texture/classes/CarrierBay/tubeRecall_Up.png', downTexture= 'res:/UI/Texture/classes/CarrierBay/tubeRecall_Down.png', hoverTexture= 'res:/UI/Texture/classes/CarrierBay/tubeRecall_Over.png', iconColor=returnColor.GetRGBA(), showGlow=False) self.scoopIcon.OnClick = self.RecallFighterToTube self.scoopIcon.OnDropData = self.OnDropToTube self.landingStrip = LandingStrip(parent=deckCont) self.landingStrip.display = False self.emptyTubeIcon = ButtonIcon( parent=deckCont, align=uiconst.CENTER, width=44, height=44, iconSize=44, texturePath='res:/UI/Texture/classes/CarrierBay/tubeOpen_Up.png', downTexture='res:/UI/Texture/classes/CarrierBay/tubeOpen_Down.png', hoverTexture='res:/UI/Texture/classes/CarrierBay/tubeOpen_Over.png', showGlow=False) self.emptyTubeIcon.OnDropData = self.OnDropToTube self.squadronInSpace = FightersHealthGauge(name='squadronInSpace', parent=inSpaceCont, align=uiconst.CENTER, width=86, height=86, state=TUBE_STATE_INSPACE, tubeFlagID=self.tubeFlagID) self.squadronInSpace.display = False self.squadronInSpace.GetMenu = self.GetMenu self.squadronInTube = FightersHealthGauge(name='squadronInTube', parent=deckCont, align=uiconst.CENTER, width=86, height=86, state=TUBE_STATE_READY, tubeFlagID=self.tubeFlagID) self.squadronInTube.OnDropData = self.OnDropToTube self.squadronInTube.display = False self.squadronInTube.GetMenu = self.GetMenu self.launchingStrip = LaunchingStrip(parent=inSpaceCont) self.launchingStrip.display = False self.UpdateLaunchTubeContentUI() self.UpdateLaunchTubeStateUI() self.UpdateInSpaceUI() self.shipFighterState.signalOnFighterTubeStateUpdate.connect( self.OnFighterTubeStateUpdate) self.shipFighterState.signalOnFighterTubeContentUpdate.connect( self.OnFighterTubeContentUpdate) self.shipFighterState.signalOnFighterInSpaceUpdate.connect( self.OnFighterInSpaceUpdate) def Close(self): self.shipFighterState.signalOnFighterTubeStateUpdate.disconnect( self.OnFighterTubeStateUpdate) self.shipFighterState.signalOnFighterTubeContentUpdate.disconnect( self.OnFighterTubeContentUpdate) self.shipFighterState.signalOnFighterInSpaceUpdate.disconnect( self.OnFighterInSpaceUpdate) def LaunchFightersFromTube(self): self.controller.LaunchFightersFromTube(self.tubeFlagID) def RecallFighterToTube(self): fighterInSpace = self.shipFighterState.GetFightersInSpace( self.tubeFlagID) self.controller.RecallFighterToTube(fighterInSpace.itemID) def ReturnAndOrbit(self): fighterInSpace = self.shipFighterState.GetFightersInSpace( self.tubeFlagID) sm.GetService('fighters').CmdReturnAndOrbit([fighterInSpace.itemID]) def OnDropToSpace(self, dragSource, dragData): data = dragData[0] if data.tubeFlagID == self.tubeFlagID and data.squadronState == TUBE_STATE_READY: self.LaunchFightersFromTube() def OnDropToTube(self, dragSource, dragData): data = dragData[0] if data.__guid__ == 'uicls.FightersHealthGauge': if data.tubeFlagID == self.tubeFlagID and data.squadronState == TUBE_STATE_INSPACE: self.RecallFighterToTube() elif data.__guid__ in ('xtriui.InvItem', 'listentry.InvItem'): tubeStatus = self.shipFighterState.GetTubeStatus(self.tubeFlagID) if tubeStatus.statusID in (TUBE_STATE_EMPTY, TUBE_STATE_READY): fighterID = data.itemID self.controller.LoadFightersToTube(fighterID, self.tubeFlagID) def UnloadTubeToFighterBay(self): self.controller.UnloadTubeToFighterBay(self.tubeFlagID) def UpdateLaunchTubeContentUI(self): fighterInTube = self.shipFighterState.GetFightersInTube( self.tubeFlagID) if fighterInTube is not None: self.squadronInTube.display = True if not self.ShouldShowStationUI(): self.launchIcon.display = True self.scoopIcon.display = False self.landingStrip.display = False self.squadronInTube.LoadFighterToSquadron(fighterInTube.typeID) self.squadronInTube.SetSquadronSize(fighterInTube.squadronSize) else: self.squadronInTube.display = False self.launchIcon.display = False def ShowStationUI(self): self.inStationCont.display = True self.launchIcon.display = False def UpdateLaunchTubeStateUI(self): tubeStatus = self.shipFighterState.GetTubeStatus(self.tubeFlagID) self.UpdateStatusUI(tubeStatus) if tubeStatus.endTime: if tubeStatus.statusID in (TUBE_STATE_RECALLING, TUBE_STATE_LANDING): self.landingStrip.display = True self.scoopIcon.display = False elif tubeStatus.statusID == TUBE_STATE_LAUNCHING: self.launchingStrip.display = True self.launchIcon.display = False else: self.loadingGauge.display = True now = gametime.GetSimTime() duration = float(tubeStatus.endTime - tubeStatus.startTime) loadingProgress = max( 0.0, min(1.0, (now - tubeStatus.startTime) / duration)) self.loadingGauge.SetValue(loadingProgress, animate=False) remainingTime = tubeStatus.endTime - now remainingTimeSeconds = max(float(remainingTime) / SEC, 0.1) self.loadingGauge.SetValueTimed(1.0, remainingTimeSeconds) self.tubeStatusLabel.top = -2 else: self.loadingGauge.SetValue(0) self.loadingGauge.display = False self.landingStrip.display = False self.launchingStrip.display = False self.tubeStatusLabel.top = 0 if tubeStatus.statusID == TUBE_STATE_EMPTY: self.emptyTubeIcon.display = True self.scoopIcon.display = False self.squadronNumber.SetColor(True) else: self.emptyTubeIcon.display = False self.squadronNumber.SetColor(False) def UpdateStatusUI(self, tubeStatus): stateText = LABEL_BY_STATE[tubeStatus.statusID] self.tubeStatusLabel.text = GetByLabel(stateText) if self.ShouldShowStationUI(): stateColor = Color(*COLOR_OPEN) else: stateColor = Color(*COLOR_BY_STATE[tubeStatus.statusID]) self.leftTube.SetRGBA(*stateColor.GetRGBA()) self.rightTube.SetRGBA(*stateColor.GetRGBA()) stateColor.a = 0.8 self.tubeStatusLabel.SetTextColor(stateColor.GetRGBA()) def UpdateInSpaceUI(self): if self.ShouldShowStationUI(): self.ShowStationUI() return self.inStationCont.display = False fighterInSpace = self.shipFighterState.GetFightersInSpace( self.tubeFlagID) if fighterInSpace is not None: self.scoopIcon.display = True self.squadronInSpace.display = True self.squadronInSpace.LoadFighterToSquadron(fighterInSpace.typeID) self.squadronInSpace.SetSquadronSize(fighterInSpace.squadronSize) else: self.scoopIcon.display = False self.squadronInSpace.display = False def GetMenu(self): m = [] fighterInTube = self.shipFighterState.GetFightersInTube( self.tubeFlagID) if fighterInTube is not None: if not session.stationid2: m.append((MenuLabel('UI/Inventory/Fighters/LaunchToSpace'), self.LaunchFightersFromTube)) m.append((MenuLabel('UI/Inventory/Fighters/UnloadFromLaunchTube'), self.UnloadTubeToFighterBay)) m.append((MenuLabel('UI/Commands/ShowInfo'), sm.GetService('menu').ShowInfo, (fighterInTube.typeID, fighterInTube.itemID))) fighterInSpace = self.shipFighterState.GetFightersInSpace( self.tubeFlagID) if fighterInSpace is not None: m.append((MenuLabel('UI/Inventory/Fighters/RecallToLaunchTube'), self.RecallFighterToTube)) m.append((MenuLabel('UI/Drones/ReturnDroneAndOrbit'), self.ReturnAndOrbit)) m.append((MenuLabel('UI/Commands/ShowInfo'), sm.GetService('menu').ShowInfo, (fighterInSpace.typeID, fighterInSpace.itemID))) return m def OnFighterTubeStateUpdate(self, tubeFlagID): if tubeFlagID == self.tubeFlagID: self.UpdateLaunchTubeStateUI() def OnFighterTubeContentUpdate(self, tubeFlagID): if tubeFlagID == self.tubeFlagID: self.UpdateLaunchTubeContentUI() def OnFighterInSpaceUpdate(self, fighterID, tubeFlagID): if tubeFlagID == self.tubeFlagID: self.UpdateInSpaceUI() def ShouldShowStationUI(self): return session.stationid2
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 = ''