def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) worker = attributes.worker self.state = uiconst.UI_NORMAL rightCont = Container(name='bonusCont', parent=self, align=uiconst.TORIGHT, width=90) self.leftCont = Container(name='textCont', parent=self, align=uiconst.TOALL) self.opacity = 0.15 if self.ShouldDim(worker, attributes.jobData) else 1.0 workerName = GetByLabel(SPE_LABELS[worker.specializationID]) bonus, quality = worker.GetBonusType() if attributes.isTopRow: top = 4 else: top = 2 self.workerName = EveLabelSmall(parent=self.leftCont, text=workerName, left=6, top=top) EveLabelSmall(parent=rightCont, text=GetByLabel('UI/Common/Formatting/PercentageDecimal', percentage=quality), align=uiconst.TORIGHT_NOPUSH, top=top, left=4) bonusIcon = Icon(parent=rightCont, width=16, height=16, align=uiconst.TORIGHT, left=38, state=uiconst.UI_PICKCHILDREN, opacity=0.6) groupNames = GetGroupNamesFromSpeciality(worker.specializationID) self.hint = GetByLabel('UI/Industry/workerHint', groupNames=groupNames) if bonus == 'ME': bonusIcon.LoadIcon('res:/UI/Texture/Classes/Industry/iconME.png') bonusIcon.width = 17 elif bonus == 'TE': bonusIcon.LoadIcon('res:/UI/Texture/Classes/Industry/iconTE.png') bonusIcon.width = 16
def Load(self, attributeValues, mouseExitFunc=None, onClickFunc=None): if not attributeValues: return self.attributeValues = attributeValues self.innerContainers = {} self.Flush() containerPercentage = 1.0 / len(attributeValues) for attributeID, value in attributeValues: innerCont = Container(parent=self, name='container_%s' % attributeID, width=containerPercentage, align=uiconst.TOLEFT_PROP, clipChildren=True) self.innerContainers[attributeID] = innerCont iconCont = Container(parent=innerCont, name='iconCont', width=self.iconSize, align=uiconst.TOLEFT, state=uiconst.UI_PICKCHILDREN) icon = Icon(parent=iconCont, pos=(0, 0, self.iconSize, self.iconSize), align=uiconst.CENTERLEFT, idx=0, ignoreSize=True, state=uiconst.UI_NORMAL) if mouseExitFunc: icon.OnMouseExit = mouseExitFunc if onClickFunc: icon.OnClick = (onClickFunc, attributeID) labelText = value or '-' innerCont.label = EveLabelSmall(parent=innerCont, text=labelText, align=uiconst.CENTERLEFT, left=self.iconSize) attributeInfo = cfg.dgmattribs.Get(attributeID) iconID = attributeInfo.iconID icon.LoadIcon(iconID, ignoreSize=True) icon.hint = attributeInfo.displayName tooltipTitleText, tooltipDescriptionText = GetAttributeTooltipTitleAndDescription( attributeID) if tooltipDescriptionText: SetTooltipHeaderAndDescription( targetObject=icon, headerText=tooltipTitleText, descriptionText=tooltipDescriptionText)
class OutcomeItemContainer(Container): default_state = uiconst.UI_NORMAL default_clipChildren = True __notifyevents__ = ['OnIndustryViewExpandCollapse'] def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) sm.RegisterNotify(self) self.jobData = attributes.jobData self.videoThread = None self.iconCont = Container(name='iconCont', parent=self, align=CENTER, state=uiconst.UI_NORMAL, width=64, height=64) self.errorFrame = ErrorFrame(parent=self, align=uiconst.CENTER, pos=(0, 0, 64, 64), state=uiconst.UI_HIDDEN) self.qtyLabel = EveLabelLargeBold(parent=self, align=CENTER, top=42) FrameThemeColored(name='bgVignette', parent=self, texturePath='res:/UI/Texture/Classes/Industry/Output/bgVignette.png', cornerSize=30) self.videoCont = Container(name='videoCont', parent=self, align=uiconst.CENTER, width=324, height=199) self.previewContFill = FillThemeColored(parent=self) self.previewCont = PreviewContainer(parent=self, align=uiconst.TOALL, state=uiconst.UI_HIDDEN) self.leftProbabilityGradient = GradientSprite(name='leftProbabilityGradient', parent=self, align=uiconst.CENTERLEFT, state=uiconst.UI_HIDDEN, pos=(0, 0, 160, 64), rgbData=((0, (1.0, 1.0, 1.0)),), alphaData=((0.0, 0.5), (1.0, 0.0))) self.rightProbabilityGradient = GradientSprite(name='rightProbabilityGradient', parent=self, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, pos=(0, 0, 160, 64), rgbData=((0, (1.0, 1.0, 1.0)),), alphaData=((0.0, 0.0), (1.0, 0.5))) self.previewCont.navigation.LoadTooltipPanel = self.LoadIconContTooltipPanel self.previewCont.navigation.GetTooltipDelay = self.GetIconContTooltipDelay self.previewCont.navigation.GetMenu = self.GetMenu self.iconCont.LoadTooltipPanel = self.LoadIconContTooltipPanel self.iconCont.GetTooltipDelay = self.GetIconContTooltipDelay self.iconCont.OnMouseEnter = self.OnIconContMouseEnter self.iconCont.OnMouseExit = self.OnIconContMouseExit self.iconCont.OnClick = self.OnIconContClick self.iconCont.GetMenu = self.GetMenu self.iconCont.GetDragData = self.GetIconContDragData self.iconCont.isDragObject = True self.techIcon = Sprite(name='techIcon', parent=self.iconCont, width=16, height=16) self.icon = Icon(parent=self.iconCont, align=CENTER, state=uiconst.UI_DISABLED) self.bgCont = Container(name='bgCont', parent=self, align=uiconst.CENTER, width=201, height=192) self.bg = Sprite(bgParent=self.bgCont, texturePath='res:/UI/Texture/Classes/Industry/Output/itemBg.png') self.itemPattern = Sprite(bgParent=self.bgCont, texturePath='res:/UI/Texture/Classes/Industry/Output/itemBgColor.png') self.UpdateState() self.AnimEntry() def OnIndustryViewExpandCollapse(self): if not self.previewCont or self.jobData and self.jobData.activityID != industry.MANUFACTURING: return isCollapsed = settings.user.ui.Get('industryWndIsViewCollapsed', False) if not isCollapsed: self.AnimFadeSceneContIn() else: self.previewCont.Hide() self.previewContFill.opacity = 1.0 def AnimFadeSceneContIn(self): self.previewCont.Hide() self.previewContFill.opacity = 1.0 blue.synchro.SleepWallclock(250) self.previewCont.Show() uicore.animations.FadeTo(self.previewContFill, 1.0, 0.0, duration=0.6) def OnNewJobData(self, jobData): self.jobData = jobData self.UpdateState() if self.jobData: self.jobData.on_updated.connect(self.UpdateState) self.AnimEntry() def UpdateState(self, *args): if not self.jobData: self.previewCont.Hide() return typeID = self.jobData.GetProductTypeID() if IsPreviewable(typeID) and self.jobData.activityID == industry.MANUFACTURING: self.previewCont.Show() self.iconCont.Hide() newModel = self.previewCont.PreviewType(typeID) if newModel: self.previewContFill.Show() self.previewContFill.opacity = 1.0 self.previewCont.AnimEntry(1.5, 0.0, 0.5, -0.3) self.previewCont.sceneContainer.scene.sunDirection = (-0.5, -1.0, -1.0) self.bg.Hide() self.qtyLabel.top = 86 self.leftProbabilityGradient.Hide() self.rightProbabilityGradient.Hide() else: self.iconCont.Show() self.previewCont.Hide() self.bg.Show() self.qtyLabel.top = 42 if self.jobData.activityID == industry.RESEARCH_MATERIAL: self.icon.LoadIcon('res:/UI/Texture/Classes/Industry/iconME.png') self.icon.width = self.icon.height = 17 self.techIcon.texturePath = None elif self.jobData.activityID == industry.RESEARCH_TIME: self.icon.LoadIcon('res:/UI/Texture/Classes/Industry/iconTE.png') self.techIcon.texturePath = None self.icon.width = self.icon.height = 16 else: isCopy = self.jobData.activityID in (industry.COPYING, industry.INVENTION) oldTypeID = self.icon.typeID self.icon.LoadIconByTypeID(typeID, ignoreSize=True, isCopy=isCopy) self.icon.width = self.icon.height = 64 texturePath, hint = GetTechLevelIconPathAndHint(typeID) self.techIcon.texturePath = texturePath self.techIcon.hint = hint if oldTypeID != typeID: uicore.animations.FadeTo(self.icon, 0.0, 1.0, duration=0.6) if self.jobData.activityID == industry.INVENTION: width = self.jobData.probability * 160 color = GetJobColor(self.jobData) for gradient in (self.leftProbabilityGradient, self.rightProbabilityGradient): gradient.Show() gradient.SetRGBA(*color) uicore.animations.MorphScalar(gradient, 'width', gradient.width, width, duration=0.6) else: self.leftProbabilityGradient.Hide() self.rightProbabilityGradient.Hide() if self.jobData and self.jobData.product: self.iconCont.opacity = 1.0 uicore.animations.FadeTo(self.bgCont, self.bgCont.opacity, 1.0, duration=0.3) self.errorFrame.Hide() else: self.iconCont.opacity = 0.0 uicore.animations.FadeTo(self.bgCont, 0.3, 1.0, duration=2.0, curveType=uiconst.ANIM_WAVE, loops=uiconst.ANIM_REPEAT) self.errorFrame.Show() self.UpdateOutputQty() self.StopVideo() if self.jobData.status == industry.STATUS_DELIVERED: self.PlayVideoDelivered() def PlayVideoDelivered(self): self.PlayVideo('res:/video/Industry/deliveredIntro.bk2', 'res:/video/Industry/deliveredOutro.bk2', industryUIConst.GetActivityColor(self.jobData.activityID)) def PlayVideoFailed(self): self.PlayVideo('res:/video/Industry/failedIntro.bk2', 'res:/video/Industry/failedOutro.bk2', industryUIConst.COLOR_NOTREADY) def StopVideo(self): if self.videoThread: self.videoThread.kill() self.videoCont.Flush() def PlayVideo(self, introPath, outroPath, color): self.videoThread = uthread.new(self._PlayVideo, introPath, outroPath, color) def _PlayVideo(self, introPath, outroPath, color): self.videoCont.Flush() videoSprite = VideoSprite(parent=self.videoCont, align=uiconst.TOALL, spriteEffect=trinity.TR2_SFX_COPY, videoPath=introPath, color=color) while not videoSprite.isFinished: blue.synchro.Yield() blue.synchro.SleepWallclock(3000) videoSprite.Close() videoSprite = VideoSprite(parent=self.videoCont, align=uiconst.TOALL, spriteEffect=trinity.TR2_SFX_COPY, videoPath=outroPath, color=color) while not videoSprite.isFinished: blue.synchro.Yield() uicore.animations.FadeOut(videoSprite, callback=videoSprite.Close) def GetMenu(self): abstractInfo = KeyVal(bpData=self.GetBpData()) return sm.GetService('menu').GetMenuFormItemIDTypeID(None, self.jobData.product.typeID, ignoreMarketDetails=False, abstractInfo=abstractInfo) def LoadIconContTooltipPanel(self, tooltipPanel, *args): if self.jobData.activityID in (industry.RESEARCH_TIME, industry.RESEARCH_MATERIAL): return self.tooltipPanel = OutcomeTooltipPanel(jobData=self.jobData, tooltipPanel=tooltipPanel) def GetIconContTooltipDelay(self): return TOOLTIP_DELAY_GAMEPLAY def GetIconContDragData(self, *args): typeID = self.jobData.GetProductTypeID() if not typeID: return if isinstance(self.jobData.product, industry.Blueprint): bpData = self.jobData.product.GetCopy() else: bpData = None return [KeyVal(__guid__='uicls.GenericDraggableForTypeID', typeID=typeID, label=cfg.invtypes.Get(typeID).name, bpData=bpData)] def UpdateOutputQty(self): if not self.jobData or not self.jobData.product: self.qtyLabel.text = '' return self.qtyLabel.text = self.jobData.GetProductAmountLabel() def AnimEntry(self): if not self.jobData: return uicore.animations.FadeTo(self.itemPattern, 0.0, 1.0, duration=0.6, timeOffset=1.35) uicore.animations.FadeTo(self.previewContFill, self.previewContFill.opacity, 0.0, duration=0.6, timeOffset=0, callback=self.previewContFill.Hide) def GetBpData(self): if not isinstance(self.jobData.product, industry.Blueprint): return None return self.jobData.product.GetCopy() def OnIconContClick(self, *args): if not self.jobData: return if self.jobData.activityID in (industry.RESEARCH_MATERIAL, industry.RESEARCH_TIME): return typeID = self.jobData.GetProductTypeID() if not typeID: return sm.GetService('info').ShowInfo(typeID, abstractinfo=KeyVal(bpData=self.GetBpData())) sm.GetService('audio').SendUIEvent('ind_click') def OnIconContMouseEnter(self, *args): uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.5, duration=0.15) sm.GetService('audio').SendUIEvent('ind_mouseEnter') def OnIconContMouseExit(self, *args): uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.0, duration=0.3)
class FittingServiceSlot(FittingSlotBase): SLOT_SIZE = 48 default_align = uiconst.BOTTOMLEFT default_height = SLOT_SIZE default_width = SLOT_SIZE isDragObject = True underlayTexturePath = 'res:/UI/Texture/classes/Fitting/stationServiceSlotFrame.png' def ApplyAttributes(self, attributes): FittingSlotBase.ApplyAttributes(self, attributes) self.sr.underlay = Sprite(bgParent=self, name='underlay', state=uiconst.UI_DISABLED, padding=(0, 0, 0, 0), texturePath=self.underlayTexturePath) self.flagIcon = Icon(parent=self, name='flagIcon', align=uiconst.CENTER, state=uiconst.UI_DISABLED, width=self.width, height=self.height) self.UpdateFitting() def UpdateFitting(self): if not self.controller.SlotExists() and not self.controller.GetModule( ): self.DisableSlot() return self.EnableSlot() self.SetDragState() self.PrepareUtilButtons() iconSize = int(self.SLOT_SIZE * GetScaleFactor()) self.flagIcon.SetSize(iconSize, iconSize) if self.controller.GetModule(): self.flagIcon.LoadIconByTypeID(self.controller.GetModule().typeID, ignoreSize=True) else: slotIcon = 'res:/UI/Texture/classes/Fitting/stationServiceSlot.png' self.flagIcon.LoadIcon(slotIcon, ignoreSize=True) if self.controller.GetModule(): self.tooltipPanelClassInfo = TooltipModuleWrapper() modulehint = evetypes.GetName(self.controller.GetModuleTypeID()) if not self.controller.SlotExists(): modulehint = GetByLabel('UI/Fitting/SlotDoesNotExist') self.hint = modulehint else: self.tooltipPanelClassInfo = None self.hint = self._emptyHint self.Hilite(0) self.UpdateOnlineDisplay() def OnDropData(self, dragObj, nodes): if self.controller.GetModule( ) is not None and not self.controller.SlotExists(): return items = self.GetDroppedItems(nodes) for item in items: if not getattr(item, 'typeID', None): return uthread.new(self.AddItem, item) def AddItem(self, item, sourceLocation=None): if not getattr(item, 'typeID', None): return validFitting = False for effect in cfg.dgmtypeeffects.get(item.typeID, []): if effect.effectID in (const.effectServiceSlot, ): validFitting = True if effect.effectID == self.controller.GetPowerType(): 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 OnMouseEnter(self, *args): if self.controller.GetModule() is not None: self.ShowUtilButtons() else: self.hint = self._emptyHint self.Hilite(1) uicore.Message('ListEntryEnter') def OnMouseExit(self, *args): if not self.controller.GetModule(): self.Hilite(0) def PrepareUtilButtons(self): for btn in self.utilButtons: btn.Close() self.utilButtons = [] if not self.controller.GetModule(): return btns = self.GetUtilBtns() i = 0 for btnData in btns: left = int(self.left + self.width / 2.0 - 8) top = self.height + 20 + i * 16 utilBtn = FittingUtilBtn(parent=self.parent, icon=btnData.iconPath, left=left, top=top, btnData=btnData, mouseOverFunc=self.ShowUtilButtons, align=uiconst.BOTTOMLEFT, controller=self.controller) if btnData.onlineBtn == 1: self.sr.onlineButton = utilBtn self.utilButtons.append(utilBtn) i += 1 def GetUtilBtns(self): btns = [] isRig = False for effect in cfg.dgmtypeeffects.get(self.controller.GetModuleTypeID(), []): if effect.effectID == const.effectRigSlot: isRig = True break isOnlinable = self.controller.IsOnlineable() if isRig: btns += self.GetRigsBtns() else: btns = self.GetModuleBtns(isOnlinable) return btns