public static void SetFromScene(FlatRedBall.Scene scene, SpriteEditorScene spriteEditorScene) { foreach (Sprite sprite in scene.Sprites) { spriteEditorScene.SpriteList.Add(SpriteSave.FromSprite(sprite)); } foreach (FlatRedBall.ManagedSpriteGroups.SpriteGrid spriteGrid in scene.SpriteGrids) { spriteEditorScene.SpriteGridList.Add( FlatRedBall.Content.SpriteGrid.SpriteGridSave.FromSpriteGrid(spriteGrid)); } foreach (FlatRedBall.ManagedSpriteGroups.SpriteFrame spriteFrame in scene.SpriteFrames) { spriteEditorScene.SpriteFrameSaveList.Add( SpriteFrameSave.FromSpriteFrame(spriteFrame)); } foreach (Text text in scene.Texts) { spriteEditorScene.TextSaveList.Add( TextSave.FromText(text)); } }
public static SpriteEditorScene FromScene(FlatRedBall.Scene scene) { SpriteEditorScene spriteEditorScene = new SpriteEditorScene(); SetFromScene(scene, spriteEditorScene); return(spriteEditorScene); }
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; } } }
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; } } }
public static void LoadScene(string fileName) { if (mScene != null) { FlatRedBallServices.Unload(ContentManagerName); mScene.RemoveFromManagers(); } FlatRedBall.Content.SpriteEditorScene ses = FlatRedBall.Content.SpriteEditorScene.FromFile(fileName); EditorData.Scene = ses.ToScene(EditorData.ContentManagerName); }
private static void AddSpriteFromXElement(SpriteEditorScene toReturn, System.Xml.Linq.XElement element) { toReturn.SpriteList.Add(SpriteSave.FromXElement(element)); }
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; } } }