def PlayHighlightAnimation(self): cs = trinity.TriCurveSet() expandCurve = trinity.Tr2ScalarCurve() expandCurve.interpolation = trinity.TR2CURVE_HERMITE expandCurve.length = 0.3 expandCurve.startValue = 0.0 expandCurve.endValue = 100.0 cs.curves.append(expandCurve) trinity.CreateBinding(cs, expandCurve, 'currentValue', self.sr.label.GetRenderObject(), 'glowExpand') alphaCurve = trinity.Tr2ScalarCurve() alphaCurve.interpolation = trinity.TR2CURVE_HERMITE alphaCurve.length = 0.3 alphaCurve.startValue = 1.0 alphaCurve.endValue = 0.0 cs.curves.append(alphaCurve) trinity.CreateBinding(cs, alphaCurve, 'currentValue', self.sr.label.GetRenderObject(), 'glowColor.a') depthCurve = trinity.Tr2ScalarCurve() depthCurve.interpolation = trinity.TR2CURVE_HERMITE depthCurve.length = 0.3 depthCurve.startValue = 0 depthCurve.endValue = -0.25 cs.curves.append(depthCurve) trinity.CreateBinding(cs, depthCurve, 'currentValue', self.GetRenderObject(), 'depthMin') trinity.CreateBinding(cs, depthCurve, 'currentValue', self.GetRenderObject(), 'depthMax') cs.Play() cs.StopAfter(cs.GetMaxCurveDuration()) trinity.device.curveSets.append(cs) self.animation = cs
def _BindToAnchor(self, anchor): """ When eve our anchor changes we want to update the hint location """ cs = uicore.uilib.bracketCurveSet self.bindings = [] self.bindings.append(trinity.CreateBinding(cs, anchor.renderObject, 'displayX', None, '')) self.bindings.append(trinity.CreateBinding(cs, anchor.renderObject, 'displayY', None, '')) for binding in self.bindings: binding.copyValueCallable = self._UpdateBoundValues
def _BindToAnchor(self, anchor): cs = uicore.uilib.bracketCurveSet self.bindings = [] self.bindings.append( trinity.CreateBinding(cs, anchor.renderObject, 'displayX', None, '')) self.bindings.append( trinity.CreateBinding(cs, anchor.renderObject, 'displayY', None, '')) for binding in self.bindings: binding.copyValueCallable = self._UpdateBoundValues
def ApplyAttributes(self, attributes): uicls.Label.ApplyAttributes(self, attributes) bracket = attributes.bracket cs = uicore.uilib.bracketCurveSet xBinding = trinity.CreateBinding(cs, bracket.renderObject, 'displayX', self.renderObject, 'displayX') yBinding = trinity.CreateBinding(cs, bracket.renderObject, 'displayY', self.renderObject, 'displayY') self.bindings = (xBinding, yBinding) self.OnMouseUp = bracket.OnMouseUp self.OnMouseDown = bracket.OnMouseDown self.OnMouseEnter = bracket.OnMouseEnter self.OnMouseExit = bracket.OnMouseExit self.OnMouseHover = bracket.OnMouseHover self.OnClick = bracket.OnClick self.GetMenu = bracket.GetMenu
def Play(self, curve, obj, attrName, loops=1, callback=None, sleep=False, curveSet=None): curve.cycle = loops is uiconst.ANIM_REPEAT or loops > 1 if not curveSet: curveSet = self.CreateCurveSet(useRealTime=True) curveSet.name = getattr(obj, 'name', str(id(obj))) curveSet.curves.append(curve) self.RegisterCurvesetForObject(obj, curveSet, attrName) if hasattr(obj, '__iroot__'): binding = trinity.CreateBinding(curveSet, curve, 'currentValue', obj, attrName) else: obj.isAnimated = True binding = trinity.CreatePythonBinding(curveSet, curve, 'currentValue', obj, attrName) binding.name = getattr(obj, 'name', str(id(obj))) + '_' + attrName curveSet.Play() if loops == uiconst.ANIM_REPEAT: return curveSet duration = loops * curveSet.GetMaxCurveDuration() duration += self.GetMaxTimeOffset(curveSet) if callback: curveSet.StopAfterWithCallback(duration, callback) else: curveSet.StopAfter(duration) if sleep: blue.pyos.synchro.SleepWallclock(duration * 1000) return curveSet
def PlayUnhighlightAnimation(self): cs = trinity.TriCurveSet() depthCurve = trinity.Tr2ScalarCurve() depthCurve.interpolation = trinity.TR2CURVE_HERMITE depthCurve.length = 0.3 depthCurve.startValue = -0.25 depthCurve.endValue = 0 cs.curves.append(depthCurve) trinity.CreateBinding(cs, depthCurve, 'currentValue', self.GetRenderObject(), 'depthMin') trinity.CreateBinding(cs, depthCurve, 'currentValue', self.GetRenderObject(), 'depthMax') cs.Play() cs.StopAfter(cs.GetMaxCurveDuration()) trinity.device.curveSets.append(cs) self.animation = cs
def _SetupStaticLight(self, offset, curveSet): light = trinity.Tr2PointLight() light.color = STATIC_WARP_LIGHT_COLOR light.position = (0, 0, offset) curve = trinity.TriPerlinCurve() curve.offset = 0.2 curve.scale = 0.2 curveSet.curves.append(curve) trinity.CreateBinding(curveSet, curve, 'value', light, 'radius') return light
def __init__(self, typeID, uiPointer, targetBall): self.itemID = targetBall.id self.bracket = SpaceObjectUiPointerBracket(parent=uicore.layer.bracket, name='SpaceObjectUiPointerBracket') self.bracket.trackBall = targetBall blue.pyos.synchro.Yield() height = 2 * const.defaultPadding + ICON_SIZE self.floatingBox = FloatingBox(name='SpaceObjectUiPointer.box', parent=uicore.layer.abovemain, top=(uicore.desktop.height - height) / 2, left=(uicore.desktop.width - POINTER_WIDTH) / 2, hint=localization.GetByLabel(uiPointer.hint) if uiPointer.hint else None, state=uiconst.UI_NORMAL, itemID=self.itemID) self.icon = uicls.Icon(typeID=typeID, parent=self.floatingBox, width=ICON_SIZE, height=ICON_SIZE, ignoreSize=True, padding=const.defaultPadding, align=uiconst.TOLEFT, OnClick=lambda : sm.GetService('info').ShowInfo(typeID=typeID)) textContainer = uicls.Container(parent=self.floatingBox, align=uiconst.TOALL) self.typeLabel = uicls.EveLabelLarge(name='typeNameLabel', parent=textContainer, text='<url=showinfo:%s//%s>%s</url>' % (typeID, self.itemID, cfg.invtypes.Get(typeID).typeName), top=const.defaultPadding, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) self.messgeLabel = uicls.EveLabelSmall(name='mesageLabel', parent=textContainer, text=localization.GetByLabel(uiPointer.message) if uiPointer.message else '', align=uiconst.TOTOP) self.line = uicls.VectorLine(widthFrom=1.2, widthTo=1.2, translationFrom=(0, 0), translationTo=(10, 10), parent=self.floatingBox, name='spaceObjectBracketPointer', left=self.floatingBox.width / 2, top=self.floatingBox.height / 2, color=TutorialColor.HINT_FRAME, align=uiconst.TOPLEFT) cs = uicore.uilib.bracketCurveSet self.bindings = [] self.bindings.append(trinity.CreateBinding(cs, self.bracket.renderObject, 'displayX', None, '')) self.bindings.append(trinity.CreateBinding(cs, self.bracket.renderObject, 'displayY', None, '')) self.bindings.append(trinity.CreateBinding(cs, self.floatingBox.renderObject, 'displayX', None, '')) self.bindings.append(trinity.CreateBinding(cs, self.floatingBox.renderObject, 'displayY', None, '')) for binding in self.bindings: binding.copyValueCallable = self.Update self.lastUpdateTime = blue.os.GetSimTime() self.speed = 0.0
def _SetupDynamicLight(self, curveSet): angle = random.random() * 2 * pi light = trinity.Tr2PointLight() light.color = geo2.Vec3Lerp(DYNAMIC_WARP_LIGHT_COLOR, (1, 1, 1, 1), random.random()) light.radius = 0.7 light.position = (sin(angle) * 1.5, cos(angle) * 1.5, 2) curve = trinity.Tr2ScalarCurve() curve.AddKey(0, 2) curve.AddKey(8.0 / 20.0, -6) curve.Sort() curve.timeOffset = curveSet.scaledTime curveSet.curves.append(curve) binding = trinity.CreateBinding(curveSet, curve, 'currentValue', light, 'position.z') return (light, curve, binding)
def _SetupLightingCurves(self, scene): """ Creates curves and bindings to dim secondary lighting when warp tunnel gets opaque """ self.lightingCurveSet = trinity.TriCurveSet() self.lights = [] curve = trinity.Tr2ScalarExprCurve() curve.expr = 'input3 - input3 * min(max(input1 - input2, 0), 1)' curve.input1 = 1 curve.input2 = 0 curve.input3 = gfxsettings.SECONDARY_LIGHTING_INTENSITY curve.length = 1 curve.cycle = True self.lightingCurveSet.curves.append(curve) def FindBinding(curveSet, binding): cs = [ x for x in self.gfx.curveSets if x.name == curveSet ][0] return [ x for x in cs.bindings if x.name == binding ][0] trinity.CreateBinding(self.lightingCurveSet, FindBinding('FadeInCurveSet', 'FadeInBinding').sourceObject, 'value', curve, 'input1') trinity.CreateBinding(self.lightingCurveSet, FindBinding('FadeOutCurveSet', 'FadeOutBindin').sourceObject, 'value', curve, 'input2') trinity.CreateBinding(self.lightingCurveSet, curve, 'currentValue', scene.shLightingManager, 'secondaryIntensity') if scene.shLightingManager: light = self._SetupStaticLight(-1, self.lightingCurveSet) self.lights.append((light, None, None)) scene.shLightingManager.lights.append(light) light = self._SetupStaticLight(1, self.lightingCurveSet) self.lights.append((light, None, None)) scene.shLightingManager.lights.append(light) curve = trinity.Tr2ScalarExprCurve() curve.expr = 'input1 * min(max(input2 + 2 * min(max(min(max(input3, 0), 1) - min(max(input4, 0), 1), 0), 1), 0), 1)' curve.input1 = 1 curve.input2 = 0 curve.input3 = 0 curve.input4 = 0 curve.length = 1 curve.cycle = True self.lightingCurveSet.curves.append(curve) trinity.CreateBinding(self.lightingCurveSet, FindBinding('_Setup_', 'brightness_tunnel').sourceObject, 'currentValue', curve, 'input1').scale = gfxsettings.SECONDARY_LIGHTING_INTENSITY trinity.CreateBinding(self.lightingCurveSet, FindBinding('SpeedModifier', 'additiveBinding').sourceObject, 'value', curve, 'input2') trinity.CreateBinding(self.lightingCurveSet, FindBinding('FadeInCurveSet', 'FadeInBindingAdditive').sourceObject, 'value', curve, 'input3') trinity.CreateBinding(self.lightingCurveSet, FindBinding('FadeOutCurveSet', 'FadeOutBindingAdditive').sourceObject, 'value', curve, 'input4') trinity.CreateBinding(self.lightingCurveSet, curve, 'currentValue', scene.shLightingManager, 'primaryIntensity').scale = 2 self.shLightingManager = scene.shLightingManager scene.curveSets.append(self.lightingCurveSet) self.lightingCurveSet.Play() uthread.new(self._AnimateLights, scene)