public static Sprite GetSpriteFromFile(string filename, string basePath = null) { String xmlInput = TestHelpers.GetInputFile(filename); var xmlNode = XElement.Parse(xmlInput); var reader = new SpriteXmlReader(); if (basePath == null) { return(reader.LoadSprite(xmlNode)); } else { return(reader.LoadSprite(xmlNode, basePath)); } }
public IComponentInfo Load(XElement node, Project project) { var spriteComponent = new SpriteComponentInfo(); FilePath sheetPath = null; var sheetNode = node.Element("Tilesheet"); if (sheetNode != null) { sheetPath = FilePath.FromRelative(sheetNode.Value, project.BaseDir); spriteComponent.SheetPath = sheetPath; } foreach (var spriteNode in node.Elements("Sprite")) { if (sheetPath == null) { var sprite = _spriteReader.LoadSprite(spriteNode, project.BaseDir); spriteComponent.Sprites.Add(sprite.Name ?? "Default", sprite); } else { var sprite = _spriteReader.LoadSprite(spriteNode); sprite.SheetPath = sheetPath; spriteComponent.Sprites.Add(sprite.Name ?? "Default", sprite); } } if (spriteComponent.SheetPath != null || spriteComponent.Sprites.Any()) { return(spriteComponent); } else { return(null); } }
protected void LoadBase(HandlerInfo handler, XElement node, string basePath) { handler.Name = node.RequireAttribute("name").Value; var spriteLoader = new SpriteXmlReader(); foreach (var spriteNode in node.Elements("Sprite")) { var info = new HandlerSpriteInfo(); info.Sprite = spriteLoader.LoadSprite(spriteNode, basePath); handler.Objects.Add(info.Name, info); } var meterLoader = new MeterXmlReader(new SceneBindingXmlReader()); foreach (var meterNode in node.Elements("Meter")) { var meter = meterLoader.LoadMeter(meterNode, basePath); handler.Objects.Add(meter.Name, meter); } }