Exemplo n.º 1
0
        internal static SpriteFrameSave FromXElement(System.Xml.Linq.XElement element)
        {
            SpriteFrameSave sfs = new SpriteFrameSave();

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "BorderSides":
                    sfs.BorderSides = SceneSave.AsInt(subElement);
                    break;

                case "ParentSprite":
                    sfs.ParentSprite = SpriteSave.FromXElement(subElement);
                    break;

                case "SpriteBorderWidth":
                    sfs.SpriteBorderWidth = SceneSave.AsFloat(subElement);
                    break;

                case "TextureBorderWidth":
                    sfs.TextureBorderWidth = SceneSave.AsFloat(subElement);
                    break;

                default:
                    throw new NotImplementedException();

                    //break;
                }
            }

            return(sfs);
        }
Exemplo n.º 2
0
        internal static DisplayRegionGridSave FromXElement(System.Xml.Linq.XElement element)
        {
            DisplayRegionGridSave drgs = new DisplayRegionGridSave();

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "ReferenceGrid":
                    drgs.ReferenceGrid = ToFloatRectangleArrayArray(subElement);

                    break;

                case "FirstPaintedX":
                    drgs.FirstPaintedX = SceneSave.AsFloatList(subElement);
                    break;

                case "FirstPaintedY":
                    drgs.FirstPaintedY = SceneSave.AsFloat(subElement);
                    break;

                default:
                    throw new NotImplementedException(subElement.Name.LocalName);
                    //break;
                }
            }

            return(drgs);
        }
Exemplo n.º 3
0
        static FloatRectangle ToFloatRectangle(System.Xml.Linq.XElement element)
        {
            FloatRectangle toReturn = new FloatRectangle();

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "Bottom":
                    toReturn.Bottom = SceneSave.AsFloat(subElement);
                    break;

                case "Left":
                    toReturn.Left = SceneSave.AsFloat(subElement);
                    break;

                case "Right":
                    toReturn.Right = SceneSave.AsFloat(subElement);
                    break;

                case "Top":
                    toReturn.Top = SceneSave.AsFloat(subElement);
                    break;

                default:
                    throw new NotImplementedException(subElement.Name.LocalName);
                    //break;
                }
            }


            return(toReturn);
        }
Exemplo n.º 4
0
        private static void AddCameraFromXElement(SpriteEditorScene toReturn, System.Xml.Linq.XElement element)
        {
            CameraSave cameraSave = new CameraSave();

            toReturn.Camera = cameraSave;

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "FarClipPlane":
                    cameraSave.FarClipPlane = SceneSave.AsFloat(subElement);
                    break;

                case "Name":
                    //cameraSave. = subElement.Value;
                    break;

                case "NearClipPlane":
                    cameraSave.NearClipPlane = SceneSave.AsFloat(subElement);
                    break;

                case "Orthogonal":
                    cameraSave.Orthogonal = AsBool(subElement);
                    break;

                case "OrthogonalHeight":
                    cameraSave.OrthogonalHeight = SceneSave.AsFloat(subElement);
                    break;

                case "OrthogonalWidth":
                    cameraSave.OrthogonalWidth = SceneSave.AsFloat(subElement);
                    break;

                case "X":
                    cameraSave.X = SceneSave.AsFloat(subElement);
                    break;

                case "Y":
                    cameraSave.Y = SceneSave.AsFloat(subElement);
                    break;

                case "Z":
                    cameraSave.Z = SceneSave.AsFloat(subElement);
                    break;

                case "AspectRatio":
                    cameraSave.AspectRatio = SceneSave.AsFloat(subElement);
                    break;

                default:

                    throw new NotImplementedException("Error trying to apply property " +
                                                      subElement.Name.LocalName + " on Camera");
                    //break;
                }
            }
        }
Exemplo n.º 5
0
        private static void LoadFromElement(SpriteEditorScene toReturn, System.Xml.Linq.XElement element)
        {
            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "Sprite":
                    AddSpriteFromXElement(toReturn, subElement);

                    break;

                case "SpriteFrame":
                    SpriteFrameSave sfs = SpriteFrameSave.FromXElement(subElement);
                    toReturn.SpriteFrameSaveList.Add(sfs);
                    break;

                case "Camera":
                    AddCameraFromXElement(toReturn, subElement);

                    break;

                case "Text":
                    AddTextFromXElement(toReturn, subElement);
                    break;

                case "PixelSize":
                    toReturn.PixelSize = SceneSave.AsFloat(subElement);
                    break;

                case "AssetsRelativeToSceneFile":
                    toReturn.AssetsRelativeToSceneFile = AsBool(subElement);
                    break;

                case "CoordinateSystem":
                    toReturn.CoordinateSystem = (CoordinateSystem)Enum.Parse(typeof(CoordinateSystem), subElement.Value, true);
                    break;

                case "Snapping":
                    toReturn.Snapping = AsBool(subElement);
                    break;

                case "SpriteGrid":
                    SpriteGridSave spriteGridSave = SpriteGridSave.FromXElement(subElement);
                    toReturn.SpriteGridList.Add(spriteGridSave);
                    break;

                case "FileName":

                    // do nothing with this, shouldn't be here anyway:
                    break;

                default:
                    throw new NotImplementedException("Unexpected node in XML: " +
                                                      subElement.Name.LocalName);
                    //break;
                }
            }
        }
Exemplo n.º 6
0
        internal static List <float> AsFloatList(System.Xml.Linq.XElement element)
        {
            List <float> toReturn = new List <float>();

            foreach (var subElement in element.Elements())
            {
                toReturn.Add(SceneSave.AsFloat(subElement));
            }

            return(toReturn);
        }
        //public AnimationFrame ToAnimationFrame(TextureAtlas textureAtlas)
        //{
        //    AnimationFrame toReturn = ToAnimationFrame(null, false);
        //    var entry = textureAtlas.GetEntryFor(this.TextureName);

        //    if (entry != null)
        //    {

        //        float left;
        //        float right;
        //        float top;
        //        float bottom;


        //        entry.FullToReduced(toReturn.LeftCoordinate, toReturn.RightCoordinate,
        //            toReturn.TopCoordinate, toReturn.BottomCoordinate,
        //            out left, out right, out top, out bottom);

        //        toReturn.LeftCoordinate = left;
        //        toReturn.RightCoordinate = right;
        //        toReturn.TopCoordinate = top;
        //        toReturn.BottomCoordinate = bottom;

        //    }

        //    return toReturn;
        //}


        internal static AnimationFrameSave FromXElement(System.Xml.Linq.XElement element)
        {
            AnimationFrameSave toReturn = new AnimationFrameSave();


            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "FlipHorizontal":
                    toReturn.FlipHorizontal = SceneSave.AsBool(subElement);
                    break;

                case "FlipVertical":
                    toReturn.FlipVertical = SceneSave.AsBool(subElement);
                    break;

                case "TextureName":
                    toReturn.TextureName = subElement.Value;
                    break;

                case "FrameLength":
                    toReturn.FrameLength = SceneSave.AsFloat(subElement);
                    break;

                case "LeftCoordinate":
                    toReturn.LeftCoordinate = SceneSave.AsFloat(subElement);
                    break;

                case "RightCoordinate":
                    toReturn.RightCoordinate = SceneSave.AsFloat(subElement);
                    break;

                case "TopCoordinate":
                    toReturn.TopCoordinate = SceneSave.AsFloat(subElement);
                    break;

                case "BottomCoordinate":
                    toReturn.BottomCoordinate = SceneSave.AsFloat(subElement);
                    break;

                case "RelativeX":
                    toReturn.RelativeX = SceneSave.AsFloat(subElement);
                    break;

                case "RelativeY":
                    toReturn.RelativeY = SceneSave.AsFloat(subElement);
                    break;
                }
            }

            return(toReturn);
        }
        public static AnimationChainGridSave FromXElement(System.Xml.Linq.XElement element)
        {
            AnimationChainGridSave acs = new AnimationChainGridSave();

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "FirstPaintedY":
                    acs.FirstPaintedY = SceneSave.AsFloat(subElement);
                    break;

                case "ReferenceGrid":
                    acs.ReferenceGrid = ToAnimationChainReferenceArrayArray(subElement);
                    break;

                default:
                    throw new NotImplementedException("Node not understood: " + subElement.Name.LocalName);
                }
            }

            return(acs);
        }
Exemplo n.º 9
0
        internal static SpriteGridSave FromXElement(System.Xml.Linq.XElement element)
        {
            SpriteGridSave sgs = new SpriteGridSave();

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "AnimationChainGridSave":
                    sgs.AnimationChainGridSave = AnimationChainGridSave.FromXElement(subElement);
                    break;

                case "Axis":
                    sgs.Axis = SpriteEditorScene.AsChar(subElement);
                    break;

                case "Blueprint":
                    sgs.Blueprint = SpriteSave.FromXElement(subElement);
                    break;

                case "BaseTexture":
                    sgs.BaseTexture = (string)subElement.Value;
                    break;

                case "CreatesAutomaticallyUpdatedSprites":
                    sgs.CreatesAutomaticallyUpdatedSprites = SpriteEditorScene.AsBool(subElement);
                    break;

                case "CreatesParticleSprites":
                    sgs.CreatesParticleSprites = SpriteEditorScene.AsBool(subElement);
                    break;

                case "DisplayRegionGridSave":
                    sgs.DisplayRegionGridSave = DisplayRegionGridSave.FromXElement(subElement);
                    break;

                case "DrawableBatch":
                    sgs.DrawableBatch = SpriteEditorScene.AsBool(subElement);
                    break;

                case "DrawDefaultTile":
                    sgs.DrawDefaultTile = SpriteEditorScene.AsBool(subElement);
                    break;

                case "FirstPaintedX":
                    sgs.FirstPaintedX = SpriteEditorScene.AsFloatList(subElement);
                    break;

                case "FirstPaintedY":
                    sgs.FirstPaintedY = SceneSave.AsFloat(subElement);
                    break;

                case "GridSpacing":
                    sgs.GridSpacing = SceneSave.AsFloat(subElement);
                    break;

                case "GridTexturesArray":
                    sgs.GridTexturesArray = SpriteEditorScene.AsStringArrayArray(subElement);
                    break;

                case "Name":
                    sgs.Name = subElement.Value;
                    break;

                case "OrderingMode":
                    sgs.OrderingMode = (Graphics.OrderingMode)Enum.Parse(typeof(Graphics.OrderingMode), subElement.Value, true);
                    break;

                case "XLeftBound":
                    sgs.XLeftBound = SceneSave.AsFloat(subElement);
                    break;

                case "XRightBound":
                    sgs.XRightBound = SceneSave.AsFloat(subElement);
                    break;

                case "YBottomBound":
                    sgs.YBottomBound = SceneSave.AsFloat(subElement);
                    break;

                case "YTopBound":
                    sgs.YTopBound = SceneSave.AsFloat(subElement);
                    break;

                case "ZCloseBound":
                    sgs.ZCloseBound = SceneSave.AsFloat(subElement);
                    break;

                case "ZFarBound":
                    sgs.ZFarBound = SceneSave.AsFloat(subElement);
                    break;

                default:
                    throw new NotImplementedException("Node not understood: " + subElement.Name.LocalName);
                }
            }


            return(sgs);
        }
Exemplo n.º 10
0
        private static void AddTextFromXElement(SpriteEditorScene toReturn, System.Xml.Linq.XElement element)
        {
            TextSave textSave = new TextSave();

            toReturn.TextSaveList.Add(textSave);

            foreach (var subElement in element.Elements())
            {
                switch (subElement.Name.LocalName)
                {
                case "Blue":
                    textSave.Blue = SceneSave.AsFloat(subElement);
                    break;

                case "ColorOperation":
                    textSave.ColorOperation = subElement.Value;
                    break;

                case "CursorSelectable":
                    textSave.CursorSelectable = AsBool(subElement);
                    break;

                case "DisplayText":
                    textSave.DisplayText = subElement.Value;
                    break;

                case "FontFile":
                    textSave.FontFile = subElement.Value;
                    break;

                case "FontTexture":
                    textSave.FontTexture = subElement.Value;
                    break;

                case "Green":
                    textSave.Green = SceneSave.AsFloat(subElement);
                    break;

                case "HorizontalAlignment":
                    textSave.HorizontalAlignment = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), subElement.Value, true);
                    break;

                case "MaxWidth":
                    textSave.MaxWidth = SceneSave.AsFloat(subElement);
                    break;

                case "MaxWidthBehavior":
                    textSave.MaxWidthBehavior = (MaxWidthBehavior)Enum.Parse(typeof(MaxWidthBehavior), subElement.Value, true);
                    break;

                case "Name":
                    textSave.Name = subElement.Value;
                    break;

                case "NewLineDistance":
                    textSave.NewLineDistance = SceneSave.AsFloat(subElement);
                    break;

                case "Red":
                    textSave.Red = SceneSave.AsFloat(subElement);
                    break;

                case "RelativeX":
                    textSave.RelativeX = SceneSave.AsFloat(subElement);
                    break;

                case "RelativeY":
                    textSave.RelativeY = SceneSave.AsFloat(subElement);
                    break;

                case "RelativeZ":
                    textSave.RelativeZ = SceneSave.AsFloat(subElement);
                    break;

                case "RelativeRotationX":
                    textSave.RelativeRotationX = SceneSave.AsFloat(subElement);
                    break;

                case "RelativeRotationY":
                    textSave.RelativeRotationY = SceneSave.AsFloat(subElement);
                    break;

                case "RelativeRotationZ":
                    textSave.RelativeRotationZ = SceneSave.AsFloat(subElement);
                    break;

                case "RotationX":
                    textSave.RotationX = SceneSave.AsFloat(subElement);
                    break;

                case "RotationY":
                    textSave.RotationY = SceneSave.AsFloat(subElement);
                    break;

                case "RotationZ":
                    textSave.RotationZ = SceneSave.AsFloat(subElement);
                    break;

                case "Scale":
                    textSave.Scale = SceneSave.AsFloat(subElement);
                    break;

                case "Spacing":
                    textSave.Spacing = SceneSave.AsFloat(subElement);
                    break;

                case "VerticalAlignment":
                    textSave.VerticalAlignment = (VerticalAlignment)Enum.Parse(typeof(VerticalAlignment), subElement.Value, true);
                    break;

                case "Visible":
                    textSave.Visible = AsBool(subElement);
                    break;

                case "X":
                    textSave.X = SceneSave.AsFloat(subElement);
                    break;

                case "Y":
                    textSave.Y = SceneSave.AsFloat(subElement);
                    break;

                case "Z":
                    textSave.Z = SceneSave.AsFloat(subElement);
                    break;


                default:
                    throw new NotImplementedException("Error trying to apply property " +
                                                      subElement.Name.LocalName + " on Text");

                    //break;
                }
            }
        }