Пример #1
0
        public LayerPropertiesModel(LayerPropertiesModel source = null)
        {
            if (source == null)
            {
                return;
            }

            // Clone the source's properties onto the new properties model (useful when changing property type)
            X                 = source.X;
            Y                 = source.Y;
            Width             = source.Width;
            Height            = source.Height;
            Contain           = source.Contain;
            Opacity           = source.Opacity;
            AnimationSpeed    = source.AnimationSpeed;
            Conditions        = source.Conditions;
            ConditionType     = source.ConditionType;
            DynamicProperties = source.DynamicProperties;
            Brush             = source.Brush;
            HeightEase        = source.HeightEase;
            WidthEase         = source.WidthEase;
            OpacityEase       = source.OpacityEase;
            HeightEaseTime    = source.HeightEaseTime;
            WidthEaseTime     = source.WidthEaseTime;
            OpacityEaseTime   = source.OpacityEaseTime;
        }
Пример #2
0
        public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
        {
            if (applied?.Brush == null)
                return;

            const int scale = 4;
            // Set up variables for this frame
            var rect = props.Contain
                ? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
                : new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);

            var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);

            // Take an offset of 4 to allow layers to slightly leave their bounds
            var progress = (6.0 - props.AnimationProgress)*10.0;
            if (progress < 0)
            {
                // Can't meddle with the original brush because it's frozen.
                var brush = applied.Brush.Clone();
                brush.Opacity = 1 + 0.025*progress;
                if (brush.Opacity < 0)
                    brush.Opacity = 0;
                if (brush.Opacity > 1)
                    brush.Opacity = 1;
                applied.Brush = brush;
            }
            rect.Inflate(-rect.Width/100.0*progress, -rect.Height/100.0*progress);
            clip.Inflate(-clip.Width/100.0*progress, -clip.Height/100.0*progress);

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(applied.Brush, null, rect);
            c.Pop();
        }
Пример #3
0
 internal void ApplyProperty(IDataModel dataModel, LayerPropertiesModel properties)
 {
     if (LayerPropertyType == LayerPropertyType.PercentageOf)
         ApplyPercentageOf(dataModel, properties, PercentageSource);
     if (LayerPropertyType == LayerPropertyType.PercentageOfProperty)
         ApplyPercentageOfProperty(dataModel, properties);
 }
Пример #4
0
 internal void ApplyProperty(IDataModel dataModel, LayerPropertiesModel properties)
 {
     if (LayerPropertyType == LayerPropertyType.PercentageOf)
     {
         ApplyPercentageOf(dataModel, properties, PercentageSource);
     }
     if (LayerPropertyType == LayerPropertyType.PercentageOfProperty)
     {
         ApplyPercentageOfProperty(dataModel, properties);
     }
 }
Пример #5
0
        private void ApplyHeight(LayerPropertiesModel properties, float percentage)
        {
            var newHeight = Math.Round(percentage*(float) properties.Height, 2);
            var difference = properties.Height - newHeight;
            if (newHeight < 0)
                newHeight = 0;

            properties.Height = newHeight;

            if (LayerPropertyOptions == LayerPropertyOptions.Downwards)
                properties.Y = properties.Y + difference;
        }
Пример #6
0
        private void ApplyWidth(LayerPropertiesModel properties, float percentage)
        {
            var newWidth = Math.Round(percentage*(float) properties.Width, 2);
            var difference = properties.Width - newWidth;
            if (newWidth < 0)
                newWidth = 0;

            properties.Width = newWidth;

            // Apply the right to left option
            if (LayerPropertyOptions == LayerPropertyOptions.RightToLeft)
                properties.X = properties.X + difference;
        }
Пример #7
0
        private void ApplyPercentageOf(IDataModel dataModel, LayerPropertiesModel properties, float src)
        {
            if (GameProperty == null)
                return;

            var gameProperty = dataModel.GetPropValue<float>(GameProperty);
            var percentage = gameProperty/src;

            if (LayerProperty == "Width")
                ApplyWidth(properties, percentage);
            else if (LayerProperty == "Height")
                ApplyHeight(properties, percentage);
            else if (LayerProperty == "Opacity")
                ApplyOpacity(properties, percentage);
        }
Пример #8
0
        private void ApplyHeight(LayerPropertiesModel properties, float percentage)
        {
            var newHeight  = Math.Round(percentage * (float)properties.Height, 2);
            var difference = properties.Height - newHeight;

            if (newHeight < 0)
            {
                newHeight = 0;
            }

            properties.Height = newHeight;

            if (LayerPropertyOptions == LayerPropertyOptions.Downwards)
            {
                properties.Y = properties.Y + difference;
            }
        }
Пример #9
0
        public LayerPropertiesModel(LayerPropertiesModel source = null)
        {
            if (source == null)
                return;

            // Clone the source's properties onto the new properties model (useful when changing property type)
            X = source.X;
            Y = source.Y;
            Width = source.Width;
            Height = source.Height;
            Contain = source.Contain;
            Opacity = source.Opacity;
            AnimationSpeed = source.AnimationSpeed;
            Conditions = source.Conditions;
            DynamicProperties = source.DynamicProperties;
            Brush = source.Brush;
        }
Пример #10
0
        private void ApplyWidth(LayerPropertiesModel properties, float percentage)
        {
            var newWidth   = Math.Round(percentage * (float)properties.Width, 2);
            var difference = properties.Width - newWidth;

            if (newWidth < 0)
            {
                newWidth = 0;
            }

            properties.Width = newWidth;

            // Apply the right to left option
            if (LayerPropertyOptions == LayerPropertyOptions.RightToLeft)
            {
                properties.X = properties.X + difference;
            }
        }
Пример #11
0
        public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
        {
            if (applied.Brush == null)
                return;

            const int scale = 4;
            // Set up variables for this frame
            var rect = props.Contain
                ? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
                : new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);

            var s1 = new Rect(new Point(rect.X, rect.Y + props.AnimationProgress), new Size(rect.Width, rect.Height));
            var s2 = new Rect(new Point(s1.X, s1.Y - rect.Height), new Size(rect.Width, rect.Height + .5));

            var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(applied.Brush, null, s1);
            c.DrawRectangle(applied.Brush, null, s2);
            c.Pop();
        }
Пример #12
0
        public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
        {
            if (applied.Brush == null)
                return;

            const int scale = 4;
            // Set up variables for this frame
            var rect = props.Contain
                ? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
                : new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);

            var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);

            // Can't meddle with the original brush because it's frozen.
            var brush = applied.Brush.Clone();
            brush.Opacity = (Math.Sin(props.AnimationProgress*Math.PI) + 1)*(props.Opacity/2);
            applied.Brush = brush;

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(applied.Brush, null, rect);
            c.Pop();
        }
Пример #13
0
        private void ApplyOpacity(LayerPropertiesModel properties, float percentage)
        {
            properties.Opacity = percentage * (float)properties.Opacity;
            if (properties.Opacity < 0.0)
            {
                properties.Opacity = 0.0;
            }
            if (properties.Opacity > 1.0)
            {
                properties.Opacity = 1.0;
            }

            // Apply the inverse/decrease option
            if (LayerPropertyOptions == LayerPropertyOptions.Decrease)
            {
                properties.Opacity = 1.0 - properties.Opacity;
            }

            var brush = properties.Brush.Clone();

            brush.Opacity    = properties.Opacity;
            properties.Brush = brush;
        }
Пример #14
0
        private void ApplyPercentageOf(IDataModel dataModel, LayerPropertiesModel properties, float src)
        {
            if (GameProperty == null)
            {
                return;
            }

            var gameProperty = dataModel.GetPropValue <float>(GameProperty);
            var percentage   = gameProperty / src;

            if (LayerProperty == "Width")
            {
                ApplyWidth(properties, percentage);
            }
            else if (LayerProperty == "Height")
            {
                ApplyHeight(properties, percentage);
            }
            else if (LayerProperty == "Opacity")
            {
                ApplyOpacity(properties, percentage);
            }
        }
Пример #15
0
 public KeyPressPropertiesModel(LayerPropertiesModel properties) : base(properties)
 {
 }
Пример #16
0
 public KeyboardPropertiesModel(LayerPropertiesModel properties = null) : base(properties)
 {
 }
Пример #17
0
 public AudioPropertiesModel(LayerPropertiesModel properties) : base(properties)
 {
 }
Пример #18
0
        private void ApplyOpacity(LayerPropertiesModel properties, float percentage)
        {
            properties.Opacity = percentage*(float) properties.Opacity;
            if (properties.Opacity < 0.0)
                properties.Opacity = 0.0;
            if (properties.Opacity > 1.0)
                properties.Opacity = 1.0;

            // Apply the inverse/decrease option
            if (LayerPropertyOptions == LayerPropertyOptions.Decrease)
                properties.Opacity = 1.0 - properties.Opacity;

            var brush = properties.Brush.Clone();
            brush.Opacity = properties.Opacity;
            properties.Brush = brush;
        }
Пример #19
0
        private void ApplyPercentageOfProperty(IDataModel dataModel, LayerPropertiesModel properties)
        {
            var value = dataModel.GetPropValue <float>(PercentageProperty);

            ApplyPercentageOf(dataModel, properties, value);
        }
Пример #20
0
 public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
 {
 }
Пример #21
0
 private void ApplyPercentageOfProperty(IDataModel dataModel, LayerPropertiesModel properties)
 {
     var value = dataModel.GetPropValue<float>(PercentageProperty);
     ApplyPercentageOf(dataModel, properties, value);
 }