def Show(self, *args): Sprite.Show(self, *args) uicore.animations.FadeTo(self, 0.3, 0.35, duration=3.0, curveType=uiconst.ANIM_WAVE, loops=uiconst.ANIM_REPEAT)
class ItemIcon(Container): default_align = uiconst.TOPLEFT default_state = uiconst.UI_NORMAL default_width = 32 default_height = 32 isDragObject = True def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.typeID = attributes.typeID self.itemID = attributes.Get('itemID', None) self.bpData = attributes.Get('bpData', False) self.techIcon = Sprite(name='techIcon', parent=self, width=16, height=16) self.icon = Icon(parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED) self.SetTypeID(self.typeID, self.bpData) def SetTypeID(self, typeID, bpData = None): self.typeID = typeID self.bpData = bpData self.icon.LoadIconByTypeID(typeID, ignoreSize=True, isCopy=self.IsBlueprintCopy()) from eve.client.script.ui.util.uix import GetTechLevelIconPathAndHint texturePath, hint = GetTechLevelIconPathAndHint(typeID) if texturePath: self.techIcon.texturePath = texturePath self.techIcon.hint = hint self.techIcon.Show() else: self.techIcon.Hide() def IsBlueprintCopy(self): if not self.bpData: return False return not self.bpData.original def GetMenu(self): return sm.GetService('menu').GetMenuFormItemIDTypeID(self.itemID, self.typeID, ignoreMarketDetails=0, abstractInfo=KeyVal(bpData=self.bpData)) def OnClick(self): sm.GetService('info').ShowInfo(self.typeID, self.itemID, abstractinfo=KeyVal(bpData=self.bpData)) def GetHint(self): return cfg.invtypes.Get(self.typeID).description def GetDragData(self): return [KeyVal(__guid__='uicls.GenericDraggableForTypeID', typeID=self.typeID, label=cfg.invtypes.Get(self.typeID).name, bpData=self.bpData)]
class PrimaryButton(Button): def ApplyAttributes(self, attributes): Button.ApplyAttributes(self, attributes) self.isStopPending = False self.isArrowsAnimating = False self.sr.label.uppercase = True self.sr.label.fontsize = 13 self.sr.label.bold = True self.pattern = Sprite(name='bgGradient', bgParent=self, texturePath='res:/UI/Texture/Classes/Industry/CenterBar/buttonPattern.png', color=Color.GRAY2, idx=0) self.bg = Sprite(name='bg', bgParent=self, opacity=0.0, texturePath='res:/UI/Texture/Classes/Industry/CenterBar/buttonBg.png', color=Color.GRAY2, idx=0, state=uiconst.UI_HIDDEN) self.arrows = Sprite(bgParent=self, texturePath='res:/UI/Texture/Classes/Industry/CenterBar/arrowMask.png', textureSecondaryPath='res:/UI/Texture/Classes/Industry/CenterBar/arrows.png', spriteEffect=trinity.TR2_SFX_MODULATE, color=Color.GRAY2, idx=0) self.arrows.translationSecondary = (-0.16, 0) self.errorFrame = ErrorFrame(bgParent=self) self.errorFrame.Hide() color = attributes.color if color is None: color = sm.GetService('uiColor').GetUIColor(uiconst.COLORTYPE_UIHILIGHT) self.SetColor(color) def Update_Size_(self): if self.iconPath is None: self.width = self.fixedwidth or max(64, self.sr.label.width + 60) self.height = self.fixedheight or max(32, self.sr.label.textheight + 12) def AnimateArrows(self): if self.destroyed: return self.arrows.Show() if self.isArrowsAnimating: return diff = math.fabs(-0.16 - self.arrows.translationSecondary[0]) duration = diff / 0.16 if diff > 0.001: uicore.animations.MorphVector2(self.arrows, 'translationSecondary', self.arrows.translationSecondary, (-0.16, 0.0), duration=duration, curveType=uiconst.ANIM_LINEAR, callback=self._LoopArrowAnimation) else: self._LoopArrowAnimation() self.isArrowsAnimating = True def _LoopArrowAnimation(self): uicore.animations.MorphVector2(self.arrows, 'translationSecondary', (0.16, 0.0), (-0.16, 0.0), duration=2.0, curveType=uiconst.ANIM_LINEAR, loops=uiconst.ANIM_REPEAT) def StopAnimateArrows(self): if self.destroyed: return diff = math.fabs(-0.16 - self.arrows.translationSecondary[0]) duration = diff / 0.16 if diff: uicore.animations.MorphVector2(self.arrows, 'translationSecondary', self.arrows.translationSecondary, (-0.16, 0.0), duration=duration, curveType=uiconst.ANIM_LINEAR) self.isArrowsAnimating = False def HideArrows(self): self.StopAnimateArrows() self.arrows.Hide() def UpdateLabel(self): label = self.GetLabel() if label: text = localization.GetByLabel(label) if self.text != text: self.SetLabelAnimated(text) else: self.SetLabel('') def SetColor(self, color): underlayColor = Color(*color).SetBrightness(0.4).GetRGBA() self.underlay.SetFixedColor(underlayColor) blinkColor = Color(*color).SetSaturation(0.5).SetBrightness(0.9).GetRGBA() self.sr.hilite.SetRGBA(*blinkColor) for obj in (self.pattern, self.bg, self.arrows): uicore.animations.SpColorMorphTo(obj, obj.GetRGBA(), color, duration=0.3) def SetLabelAnimated(self, text): uthread.new(self._SetLabelAnimated, text) def _SetLabelAnimated(self, text): uicore.animations.FadeOut(self.sr.label, duration=0.15, sleep=True) self.SetLabel(text) uicore.animations.FadeIn(self.sr.label, duration=0.3)
class BaseContainerMETE(Container): default_align = uiconst.TOPLEFT default_state = uiconst.UI_NORMAL def ApplyAttributes(self, attributes): Container.ApplyAttributes(self, attributes) self.value = 0.0 iconPath = attributes.iconPath iconSize = attributes.iconSize minValue = attributes.minValue maxValue = attributes.maxValue showBG = attributes.get('showBG', True) isCompact = attributes.get('isCompact', False) self.jobData = attributes.jobData self.gauge = Gauge(parent=self, align=uiconst.TOBOTTOM, state=uiconst.UI_DISABLED, height=6, gaugeHeight=6, padTop=1, backgroundColor=(1.0, 1.0, 1.0, 0.05)) if isCompact: self.icon = None self.valueLabel = None return mainCont = Container(name='mainCont', parent=self) if showBG: self.bg = StretchSpriteHorizontal( bgParent=mainCont, texturePath='res:/UI/Texture/Classes/Industry/Center/bgMETE.png' ) FillThemeColored(bgParent=self, opacity=0.5) else: self.bg = None left = 8 if showBG else 2 self.icon = Sprite(name='icon', parent=mainCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(left, 3, self.ICONSIZE, self.ICONSIZE), texturePath=self.ICONPATH, opacity=0.6) self.valueLabel = EveLabelMediumBold(parent=mainCont, align=uiconst.TOPRIGHT, top=4, left=left) self.removeIcon = Sprite( parent=mainCont, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, texturePath='res:/ui/texture/icons/73_16_45.png', pos=(0, 0, 12, 12), color=Color.RED, hint=localization.GetByLabel('UI/Industry/PreviewModeHint')) self.removeIcon.OnClick = self.OnRemoveIconClick self.previewEdit = SinglelineEdit(name='previewEdit', parent=mainCont, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, ints=(0, self.MAXVAL), OnChange=self.OnPreviewEdit, pos=(12, 0, 34, 20)) self.errorFrame = ErrorFrame(bgParent=self, padding=(1, 1, 1, 8)) def SetValue(self, value): if self.value * (value or 1) < 0.0: self.gauge.SetValueInstantly(0.0) self.value = value if value < 0: self.gauge.SetGaugeAlign(uiconst.TORIGHT_PROP) self.gauge.SetValue(float(value) / self.MINVAL) self.gauge.SetColor(COLOR_NOTREADY) else: self.gauge.SetGaugeAlign(uiconst.TOLEFT_PROP) self.gauge.SetValue(float(value) / self.MAXVAL) self.gauge.SetColor(COLOR_READY) if not self.valueLabel: return if value < 0: self.valueLabel.text = '<color=%s>%s%%' % (Color.RGBtoHex( *COLOR_NOTREADY), value) elif value == 0: self.valueLabel.text = '<color=%s>%s%%' % (Color.RGBtoHex( *COLOR_FRAME), value) else: self.valueLabel.text = '<color=%s>%s%%' % (Color.RGBtoHex( *COLOR_READY), value) def OnMouseEnter(self, *args): sm.GetService('audio').SendUIEvent('ind_mouseEnter') def OnRemoveIconClick(self): self.ExitPreviewMode() def EnterPreviewMode(self): if not self.IsPreviewEnabled(): return self.previewEdit.Show() self.previewEdit.SetValue(self.GetPreviewEditValue()) self.valueLabel.Hide() self.errorFrame.Show() self.removeIcon.Show() uicore.registry.SetFocus(self.previewEdit) def ExitPreviewMode(self): self.previewEdit.Hide() self.valueLabel.Show() self.errorFrame.Hide() self.removeIcon.Hide() if self.jobData: self.jobData.timeEfficiency = None self.jobData.materialEfficiency = None self.jobData.update(self.jobData) def OnClick(self, *args): self.EnterPreviewMode() def OnMouseEnter(self, *args): if self.bg and self.IsPreviewEnabled(): uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.5, duration=0.3) def OnMouseExit(self, *args): if self.bg: uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.0, duration=0.3) def OnNewJobData(self, jobData): self.jobData = jobData self.ExitPreviewMode() def IsPreviewEnabled(self): if not self.jobData or self.jobData.activityID != industry.MANUFACTURING or self.jobData.jobID: return False return True def IsPreviewActive(self): return self.errorFrame.display def GetHint(self): if self.IsPreviewEnabled() and not self.IsPreviewActive(): return '<br><br>' + localization.GetByLabel( 'UI/Industry/EnterPreviewModeHint') return ''
class NotificationEntry(Container): default_height = MINENTRYHEIGHT default_state = uiconst.UI_NORMAL notification = None contentLoaded = False blinkSprite = None titleLabel = None subtextLabel = None timeLabel = None def GetFormattedTimeString(self, timestamp): delta = blue.os.GetWallclockTime() - timestamp return formatUtil.FmtTimeIntervalMaxParts(delta, breakAt='second', maxParts=2) def UpdateNotificationEntryHeight(self): pl, pt, pr, pb = TITLE_PADDING size = EveLabelMedium.MeasureTextSize(self.title, width=MAINAREA_WIDTH - pl - pr, bold=True) height = size[1] + pt + pb if self.subtext: pl, pt, pr, pb = SUBTEXT_PADDING size = EveLabelMedium.MeasureTextSize(self.subtext, width=MAINAREA_WIDTH - pl - pr) height += size[1] + pt + pb if self.created: pl, pt, pr, pb = TIMETEXT_PADDING size = EveLabelSmall.MeasureTextSize(TIMETEXT_PLACEHOLDER, width=MAINAREA_WIDTH - pl - pr) height += size[1] + pt + pb return max(MINENTRYHEIGHT, height) def ApplyAttributes(self, attributes): self.notification = attributes.notification self.developerMode = attributes.developerMode self.created = attributes.created self.title = self.notification.subject self.subtext = self.notification.subtext attributes.height = self.UpdateNotificationEntryHeight() Container.ApplyAttributes(self, attributes) def LoadContent(self): if self.contentLoaded: return self.contentLoaded = True self._CreateMainBackground() self._CreatePanels() self._CreateNotificationText() self._CreateNotificationImage() if self.created: timeinterval = max(blue.os.GetWallclockTime() - self.created, 0) createdText = localization.GetByLabel(TIME_AGO_LABEL, time=timeinterval) self.timeLabel = EveLabelSmall(name='timeLabel', parent=self.rightContainer, align=uiconst.TOTOP, color=TIMETEXT_COLOR, padding=TIMETEXT_PADDING) self.timeLabel.text = createdText notification = self.notification if notification.typeID in [ notificationConst.notificationTypeKillReportFinalBlow, notificationConst.notificationTypeKillReportVictim ]: shipTypeID = KillMailFinalBlowFormatter.GetVictimShipTypeID( notification.data) if shipTypeID is not None: parentContainer = self.leftContainer Icon(name='shipTypeIcon', parent=parentContainer, align=uiconst.TOPRIGHT, size=SHIP_TYPE_ICON_SIZE, typeID=shipTypeID) shipTechIcon = Sprite(name='shipTechIcon', parent=parentContainer, width=SHIP_TECH_ICON_SIZE, height=SHIP_TECH_ICON_SIZE, idx=0) uiUtils.GetTechLevelIcon(shipTechIcon, 0, shipTypeID) self.imageSprite.GetDragData = lambda *args: self.MakeKillDragObject( notification) if self.ShouldDisplayPortrait(notification): item = cfg.eveowners.Get(notification.senderID) if item.IsCharacter(): sm.GetService('photo').GetPortrait(notification.senderID, CHAR_PORTRAIT_SIZE, self.characterSprite) if notification.typeID in notificationConst.notificationShowStanding: charinfo = item self.imageSprite.GetMenu = lambda: sm.GetService( 'menu').GetMenuFormItemIDTypeID( notification.senderID, charinfo.typeID) self.imageSprite.GetDragData = lambda *args: self.MakeCharacterDragObject( notification.senderID) charData = KeyVal() charData.charID = notification.senderID charData.charinfo = charinfo AddAndSetFlagIconFromData(charData, parentCont=self.leftContainer, top=self.characterSprite.height - FLAG_ICON_PADDING) else: self.corpLogo = GetLogoIcon(itemID=notification.senderID, parent=self.leftContainer, align=uiconst.TOPLEFT, size=CORP_LOGO_SIZE, state=uiconst.UI_DISABLED, ignoreSize=True) self.characterSprite.state = uiconst.UI_NORMAL def _CreateMainBackground(self): self.filler = Frame(name='mainBackgroundFrame', bgParent=self, texturePath=HISTORY_READ_UP_TEXTURE_PATH, cornerSize=MAIN_BACKGROUND_CORNER_SIZE, offset=MAIN_BACKGROUND_OFFSET) def _CreatePanels(self): self.leftContainer = Container( name='leftContainer-notificationGraphic', width=LEFT_PANEL_WIDTH, padding=LEFT_PANEL_PADDING, parent=self, align=uiconst.TOLEFT) self.rightContainer = ContainerAutoSize( name='rightContainer-notificationInfo', width=MAINAREA_WIDTH, parent=self, align=uiconst.TOLEFT) def _CreateNotificationText(self): self.titleLabel = EveLabelMedium(name='notificationSubjectLabel', parent=self.rightContainer, align=uiconst.TOTOP, text=self.title, padding=TITLE_PADDING, bold=True) if self.subtext: self.subtextLabel = EveLabelMedium(name='notificationSubtextLabel', parent=self.rightContainer, align=uiconst.TOTOP, text=self.subtext, padding=SUBTEXT_PADDING) def _CreateNotificationImage(self): if self.notification: texture = self.GetTexturePathForNotification( self.notification.typeID) else: texture = DEFAULT_NOTIFICATION_TEXTURE_PATH self.imageSprite = Sprite(name='notificationSprite', parent=self.leftContainer, texturePath=texture, align=uiconst.TOPLEFT, width=NOTIFICATION_SPRITE_SIZE, height=NOTIFICATION_SPRITE_SIZE) self.characterSprite = Sprite(name='notificationCharacterSprite', parent=self.leftContainer, texturePath=texture, align=uiconst.TOPLEFT, width=NOTIFICATION_SPRITE_SIZE, height=NOTIFICATION_SPRITE_SIZE, state=uiconst.UI_HIDDEN) def BlinkFinished(self, *args): if self.blinkSprite and not self.blinkSprite.destroyed: self.blinkSprite.Close() self.blinkSprite = None def Blink(self): if self.blinkSprite is None: self.blinkSprite = Sprite(bgParent=self, name='blinkSprite', texturePath=BLINK_SPRITE_TEXTURE_PATH, idx=0) self.blinkSprite.Show() uicore.animations.SpSwoopBlink(self.blinkSprite, rotation=BLINK_SPRITE_ROTATION, duration=BLINK_SPRITE_DURATION, loops=BLINK_SPRITE_LOOPS, callback=self.BlinkFinished) def GetTexturePathForNotification(self, notificationTypeID): texture = NOTIFICATION_TYPE_TO_TEXTURE.get(notificationTypeID, '') if not texture or not blue.paths.exists(texture): texture = None return texture def ShouldDisplayPortrait(self, notification): if notification and notification.typeID in notificationConst.notificationDisplaySender: return True else: return False def GetHint(self): if self.notification and self.developerMode: return '%s %s %s %s' % ( str(self.notification.typeID), str(self.notification.subject), str(self.notification.senderID), self.notification.body) else: return '' def MakeCharacterDragObject(self, charid): typeID = cfg.eveowners.Get(charid).typeID fakeNode = KeyVal() fakeNode.charID = charid fakeNode.info = cfg.eveowners.Get(charid) fakeNode.itemID = charid fakeNode.__guid__ = 'listentry.User' return [fakeNode] def MakeKillDragObject(self, notification): fakeNode = KeyVal() kmID, kmHash = KillMailBaseFormatter.GetKillMailIDandHash( notification.data) theRealKm = sm.RemoteSvc('warStatisticMgr').GetKillMail(kmID, kmHash) fakeNode.mail = theRealKm fakeNode.__guid__ = 'listentry.KillMail' return [fakeNode] def OnMouseEnter(self, *args): self.filler.texturePath = HISTORY_READ_OVER_TEXTURE_PATH def OnMouseExit(self, *args): self.filler.texturePath = HISTORY_READ_UP_TEXTURE_PATH
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 SubmitButton(Button): def ApplyAttributes(self, attributes): Button.ApplyAttributes(self, attributes) self.tooltipErrors = None self.jobData = attributes.jobData self.isStopPending = False self.isArrowsAnimating = False self.func = self.ClickFunc self.sr.label.uppercase = True self.sr.label.fontsize = 13 self.sr.label.bold = True self.pattern = Sprite( name='bgGradient', bgParent=self, texturePath= 'res:/UI/Texture/Classes/Industry/CenterBar/buttonPattern.png', color=Color.GRAY2, idx=0) self.bg = Sprite( name='bg', bgParent=self, opacity=0.0, texturePath= 'res:/UI/Texture/Classes/Industry/CenterBar/buttonBg.png', color=Color.GRAY2, idx=0, state=uiconst.UI_HIDDEN) self.arrows = Sprite( bgParent=self, texturePath= 'res:/UI/Texture/Classes/Industry/CenterBar/arrowMask.png', textureSecondaryPath= 'res:/UI/Texture/Classes/Industry/CenterBar/arrows.png', spriteEffect=trinity.TR2_SFX_MODULATE, color=Color.GRAY2, idx=0) self.arrows.translationSecondary = (-0.16, 0) self.errorFrame = ErrorFrame(bgParent=self) self.errorFrame.Hide() def OnNewJobData(self, jobData): self.oldJobData = self.jobData self.jobData = jobData self.isStopPending = False if self.jobData: self.jobData.on_updated.connect(self.OnJobUpdated) self.jobData.on_errors.connect(self.OnJobUpdated) self.UpdateState() def OnJobUpdated(self, *args): self.UpdateState() def GetColor(self): if not self.jobData or self.jobData.status == industry.STATUS_DELIVERED: return Color.GRAY2 if self.jobData.errors or self.isStopPending: return industryUIConst.COLOR_RED color = industryUIConst.GetJobColor(self.jobData) if self.jobData and self.jobData.status == industry.STATUS_UNSUBMITTED: color = Color(*color).SetAlpha(0.5).GetRGBA() return color def AnimateArrows(self): self.arrows.Show() if self.isArrowsAnimating: return uicore.animations.MorphVector2(self.arrows, 'translationSecondary', (0.16, 0.0), (-0.16, 0.0), duration=2.0, curveType=uiconst.ANIM_LINEAR, loops=uiconst.ANIM_REPEAT) self.isArrowsAnimating = True def StopAnimateArrows(self): if self.destroyed: return diff = math.fabs(-0.16 - self.arrows.translationSecondary[0]) duration = diff / 0.16 if diff: uicore.animations.MorphVector2(self.arrows, 'translationSecondary', self.arrows.translationSecondary, (-0.16, 0.0), duration=duration, curveType=uiconst.ANIM_LINEAR) self.isArrowsAnimating = False def HideArrows(self): self.StopAnimateArrows() self.arrows.Hide() def UpdateState(self): uicore.animations.FadeIn(self.sr.label) color = self.GetColor() underlayColor = Color(*color).SetBrightness(0.4).GetRGBA() self.underlay.SetFixedColor(underlayColor) blinkColor = Color( *color).SetSaturation(0.5).SetBrightness(0.9).GetRGBA() self.sr.hilite.SetRGBA(*blinkColor) for obj in (self.pattern, self.bg, self.arrows): uicore.animations.SpColorMorphTo(obj, obj.GetRGBA(), color, duration=0.3) self.UpdateLabel() if not self.jobData: return if self.jobData.errors: self.errorFrame.Show() self.HideArrows() else: self.errorFrame.Hide() self.arrows.Show() if self.jobData.status == industry.STATUS_INSTALLED: if not self.oldJobData or self.oldJobData.status != industry.STATUS_INSTALLED: self.AnimateArrows() elif self.jobData.status == industry.STATUS_DELIVERED: self.HideArrows() else: self.StopAnimateArrows() if self.jobData.status == industry.STATUS_READY: self.Blink(time=3000) else: self.Blink(False) if self.jobData and self.jobData.status > industry.STATUS_READY: self.Disable() else: self.Enable() def UpdateLabel(self): if not self.jobData or self.jobData.status == industry.STATUS_UNSUBMITTED: label = 'UI/Industry/Start' elif self.jobData.status in (industry.STATUS_INSTALLED, industry.STATUS_PAUSED): if self.isStopPending: label = 'UI/Common/Confirm' else: label = 'UI/Industry/Stop' elif self.jobData.status == industry.STATUS_READY: label = 'UI/Industry/Deliver' else: label = None if label: text = localization.GetByLabel(label) if self.text != text: self.SetLabelAnimated(text) else: self.SetLabel('') def SetLabelAnimated(self, text): uthread.new(self._SetLabelAnimated, text) def _SetLabelAnimated(self, text): uicore.animations.FadeOut(self.sr.label, duration=0.15, sleep=True) self.SetLabel(text) uicore.animations.FadeIn(self.sr.label, duration=0.3) def LoadTooltipPanel(self, tooltipPanel, *args): if self.tooltipErrors is not None: errors = self.tooltipErrors self.tooltipErrors = None else: errors = self.jobData.errors SubmitButtonTooltipPanel(status=self.jobData.status, errors=errors, tooltipPanel=tooltipPanel) def GetTooltipDelay(self): return TOOLTIP_DELAY_GAMEPLAY def ClickFunc(self, *args): if self.jobData.IsInstalled(): if self.jobData.status == industry.STATUS_READY: sm.GetService('industrySvc').CompleteJob(self.jobData.jobID) sm.GetService('audio').SendUIEvent('ind_jobDelivered') elif self.isStopPending: try: sm.GetService('industrySvc').CancelJob(self.jobData.jobID) finally: self.isStopPending = False self.UpdateState() else: self.isStopPending = True self.UpdateState() else: try: self.Disable() if not self.jobData.errors: self.AnimateArrows() sm.GetService('industrySvc').InstallJob(self.jobData) sm.GetService('audio').SendUIEvent('ind_jobStarted') except UserError as exception: if getattr(exception, 'msg', None) == 'IndustryValidationError': self.tooltipErrors = exception.args[1]['errors'] uicore.uilib.tooltipHandler.RefreshTooltipForOwner(self) raise finally: self.Enable() self.StopAnimateArrows() def OnMouseEnter(self, *args): Button.OnMouseEnter(self, *args) sm.GetService('audio').SendUIEvent('ind_mouseEnter')