예제 #1
0
 public Usd1Pane(Usd1Pane p) : base("usd1", p.data)
 {
     order = p.order;
     LoadProperties();
     Properties = p.Properties;
 }
        public static bool ApplyLayoutPatch(this BflytFile f, PanePatch[] Patches)
        {
            for (int i = 0; i < Patches.Length; i++)
            {
                var p = Patches[i];
                var e = f[Patches[i].PaneName] as Pan1Pane;

                // The layout patching has been made less strict to allow some 8.x layouts to work on lower firmwares, not sure if this is a good idea in the layout editor as a way to detect layout incompatibilities may be desiderable.
                if (e == null)
                {
                    continue;
                }

                if (p.Visible != null)
                {
                    e.Visible = p.Visible.Value;
                }
                #region ChangeTransform
                if (p.Position != null)
                {
                    e.Position = new Vector3(
                        p.Position.Value.X ?? e.Position.X,
                        p.Position.Value.Y ?? e.Position.Y,
                        p.Position.Value.Z ?? e.Position.Z);
                }
                if (p.Rotation != null)
                {
                    e.Rotation = new Vector3(
                        p.Rotation.Value.X ?? e.Rotation.X,
                        p.Rotation.Value.Y ?? e.Rotation.Y,
                        p.Rotation.Value.Z ?? e.Rotation.Z);
                }
                if (p.Scale != null)
                {
                    e.Scale = new Vector2(
                        p.Scale.Value.X ?? e.Scale.X,
                        p.Scale.Value.Y ?? e.Scale.Y);
                }
                if (p.Size != null)
                {
                    e.Size = new Vector2(
                        p.Size.Value.X ?? e.Size.X,
                        p.Size.Value.Y ?? e.Size.Y);
                }
                #endregion
                #region Change other prperties
                if (p.OriginX != null)
                {
                    e.originX = (Pan1Pane.OriginX)p.OriginX.Value;
                }
                if (p.OriginY != null)
                {
                    e.originY = (Pan1Pane.OriginY)p.OriginY.Value;
                }
                if (p.ParentOriginX != null)
                {
                    e.ParentOriginX = (Pan1Pane.OriginX)p.ParentOriginX.Value;
                }
                if (p.ParentOriginY != null)
                {
                    e.ParentOriginY = (Pan1Pane.OriginY)p.ParentOriginY.Value;
                }
                #endregion
                #region ColorDataForPic1
                if (e.name == "pic1")
                {
                    var ee = e as Pic1Pane;
                    if (p.PaneSpecific0 != null)
                    {
                        ee.ColorTopLeft = new RGBAColor(p.PaneSpecific0);
                    }
                    if (p.PaneSpecific1 != null)
                    {
                        ee.ColorTopRight = new RGBAColor(p.PaneSpecific1);
                    }
                    if (p.PaneSpecific2 != null)
                    {
                        ee.ColorBottomLeft = new RGBAColor(p.PaneSpecific2);
                    }
                    if (p.PaneSpecific3 != null)
                    {
                        ee.ColorBottomRight = new RGBAColor(p.PaneSpecific3);
                    }
                }
                #endregion
                #region ColorForTextPanes
                if (e.name == "txt1")
                {
                    var ee = e as Txt1Pane;
                    if (p.PaneSpecific0 != null)
                    {
                        ee.FontTopColor = new RGBAColor(p.PaneSpecific0);
                    }
                    if (p.PaneSpecific1 != null)
                    {
                        ee.ShadowTopColor = new RGBAColor(p.PaneSpecific1);
                    }
                    if (p.PaneSpecific2 != null)
                    {
                        ee.FontBottomColor = new RGBAColor(p.PaneSpecific2);
                    }
                    if (p.PaneSpecific3 != null)
                    {
                        ee.ShadowBottomColor = new RGBAColor(p.PaneSpecific3);
                    }
                }
                #endregion
                #region usdPane
                if (e.UserData != null && p.UsdPatches != null)
                {
                    Usd1Pane usd = e.UserData;
                    foreach (var patch in p.UsdPatches)
                    {
                        var v = usd.FindName(patch.PropName);
                        if (v == null)
                        {
                            usd.Properties.Add(new Usd1Pane.EditableProperty()
                            {
                                Name = patch.PropName, value = patch.PropValues, type = (Usd1Pane.EditableProperty.ValueType)patch.type
                            });
                        }
                        if (v != null && v.ValueCount == patch.PropValues.Length && (int)v.type == patch.type)
                        {
                            v.value = patch.PropValues;
                        }
                    }
                    //usd.ApplyChanges();
                }
                #endregion
            }
            return(true);
        }
 public static bool ApplyLayoutPatch(this BflytFile f, PanePatch[] Patches)
 {
     for (int i = 0; i < Patches.Length; i++)
     {
         var p = Patches[i];
         var e = f[Patches[i].PaneName] as Pan1Pane;
         if (p.Visible != null)
         {
             e.Visible = p.Visible.Value;
         }
         #region ChangeTransform
         if (p.Position != null)
         {
             e.Position = new Vector3(
                 p.Position.Value.X ?? e.Position.X,
                 p.Position.Value.Y ?? e.Position.Y,
                 p.Position.Value.Z ?? e.Position.Z);
         }
         if (p.Rotation != null)
         {
             e.Rotation = new Vector3(
                 p.Rotation.Value.X ?? e.Rotation.X,
                 p.Rotation.Value.Y ?? e.Rotation.Y,
                 p.Rotation.Value.Z ?? e.Rotation.Z);
         }
         if (p.Scale != null)
         {
             e.Scale = new Vector2(
                 p.Scale.Value.X ?? e.Scale.X,
                 p.Scale.Value.Y ?? e.Scale.Y);
         }
         if (p.Size != null)
         {
             e.Size = new Vector2(
                 p.Size.Value.X ?? e.Size.X,
                 p.Size.Value.Y ?? e.Size.Y);
         }
         #endregion
         #region Change other prperties
         if (p.OriginX != null)
         {
             e.originX = (Pan1Pane.OriginX)p.OriginX.Value;
         }
         if (p.OriginY != null)
         {
             e.originY = (Pan1Pane.OriginY)p.OriginY.Value;
         }
         if (p.ParentOriginX != null)
         {
             e.ParentOriginX = (Pan1Pane.OriginX)p.ParentOriginX.Value;
         }
         if (p.ParentOriginY != null)
         {
             e.ParentOriginY = (Pan1Pane.OriginY)p.ParentOriginY.Value;
         }
         #endregion
         #region ColorDataForPic1
         if (e.name == "pic1")
         {
             var ee = e as Pic1Pane;
             if (p.ColorTL != null)
             {
                 ee.ColorTopLeft = new RGBAColor(p.ColorTL);
             }
             if (p.ColorTR != null)
             {
                 ee.ColorTopRight = new RGBAColor(p.ColorTR);
             }
             if (p.ColorBL != null)
             {
                 ee.ColorBottomLeft = new RGBAColor(p.ColorBL);
             }
             if (p.ColorBR != null)
             {
                 ee.ColorBottomRight = new RGBAColor(p.ColorBR);
             }
         }
         #endregion
         #region usdPane
         if (e.UserData != null && p.UsdPatches != null)
         {
             Usd1Pane usd = e.UserData;
             foreach (var patch in p.UsdPatches)
             {
                 var v = usd.FindName(patch.PropName);
                 if (v == null)
                 {
                     usd.Properties.Add(new Usd1Pane.EditableProperty()
                     {
                         Name = patch.PropName, value = patch.PropValues, type = (Usd1Pane.EditableProperty.ValueType)patch.type
                     });
                 }
                 if (v != null && v.ValueCount == patch.PropValues.Length && (int)v.type == patch.type)
                 {
                     v.value = patch.PropValues;
                 }
             }
             //usd.ApplyChanges();
         }
         #endregion
     }
     return(true);
 }