private void DecomposeParticleModifierScaleAnimator(IAnimator animator, out NumericAnimator zoomAnimator, out NumericAnimator aspectRatioAnimator) { zoomAnimator = new NumericAnimator { TargetPropertyPath = "Scale" }; aspectRatioAnimator = new NumericAnimator() { TargetPropertyPath = "AspectRatio" }; if (animator.ReadonlyKeys.Count == 0) { return; } foreach (var key in animator.ReadonlyKeys) { float aspectRatio; float zoom; ParticleEmitter.DecomposeScale((Vector2)key.Value, out aspectRatio, out zoom); zoomAnimator.Keys.Add(key.Frame, zoom, key.Function); aspectRatioAnimator.Keys.Add(key.Frame, aspectRatio, key.Function); } }
void ParseAnimator(Node node) { IAnimator animator = null; string type = lexer.ParseQuotedString(); frames.Clear(); functions.Clear(); values.Clear(); lexer.ParseToken('{'); string propertyName = ""; string className = ""; while (lexer.PeekChar() != '}') { var name = lexer.ParseWord(); switch (name) { case "Property": string[] s = lexer.ParseQuotedString().Split('@'); propertyName = s[0]; className = s[1]; switch (propertyName) { case "AlongTrackOrientation": propertyName = "AlongPathOrientation"; break; case "File": propertyName = "Sample"; break; case "TexCoordForMins": propertyName = "UV0"; break; case "TexCoordForMaxs": propertyName = "UV1"; break; case "WidgetName": propertyName = "WidgetId"; break; case "TexturePath": propertyName = "Texture"; break; case "Anchor": propertyName = "Position"; break; case "BlendMode": propertyName = "Blending"; break; case "AnimationFPS": propertyName = "AnimationFps"; break; case "Life": propertyName = "Lifetime"; break; case "FontSize": propertyName = "FontHeight"; break; case "HAlign": propertyName = "HAlignment"; break; case "VAlign": propertyName = "VAlignment"; break; case "SplineName": propertyName = "SplineId"; break; case "RandMotionRadius": propertyName = "RandomMotionRadius"; break; case "RandMotionRotation": propertyName = "RandomMotionRotation"; break; case "RandMotionSpeed": propertyName = "RandomMotionSpeed"; break; case "RandMotionAspectRatio": propertyName = "RandomMotionAspectRatio"; break; case "TextColor": propertyName = "TextColor"; break; } switch (propertyName + '@' + className) { case "ShadowColor@Hot::Text": case "TextColor@Hot::TextPresenter": case "ShadowColor@Hot::TextPresenter": animator = new Color4Animator(); break; case "Blending@Hot::MaskedEffect": animator = new Animator <Blending>(); break; case "AlongTrackOrientation@Hot::ParticleEmitter": animator = new Animator <bool>(); break; case "WidgetId@Hot::Gear": animator = new Animator <NodeReference <Widget> >(); break; case "SplineId@Hot::Gear": animator = new Animator <NodeReference <Spline> >(); break; case "AspectRatio@Hot::ParticleTemplate": case "Scale@Hot::ParticleTemplate": animator = new NumericAnimator(); break; default: animator = node.Animators[propertyName]; break; } break; case "Frames": lexer.ParseToken('['); while (lexer.PeekChar() != ']') { if (!isTangerine) { frames.Add(lexer.ParseInt() * 2); } else { frames.Add(lexer.ParseInt()); } } lexer.ParseToken(']'); break; case "Attributes": lexer.ParseToken('['); while (lexer.PeekChar() != ']') { functions.Add((KeyFunction)lexer.ParseInt()); } lexer.ParseToken(']'); break; case "Keys": KeyReader keyReader = GetKeyReader(type, propertyName, className); lexer.ParseToken('['); while (lexer.PeekChar() != ']') { values.Add(keyReader()); } lexer.ParseToken(']'); break; default: throw new Lime.Exception("Unknown property '{0}'. Parsing: {1}", name, animator); } } lexer.ParseToken('}'); if (values.Count > 0 && values[0] is Tuple <Blending, ShaderId> ) { ProcessBlendingAndShaderAnimators(node, animator); } else { for (int i = 0; i < frames.Count; i++) { animator.Keys.Add(frames[i], values[i], functions[i]); } } switch (propertyName + '@' + className) { case "AspectRatio@Hot::ParticleTemplate": particleModifierAspectRatioAnimator = animator as NumericAnimator; break; case "Scale@Hot::ParticleTemplate": particleModifierScaleAnimator = animator as NumericAnimator; break; } if (animator.ReadonlyKeys.Count == 0) { node.Animators.Remove(animator); } }