public static TileResourceCollection FromXmlProxy(LibraryX.TilePoolX proxy, TilePool pool, ITexturePool texturePool) { if (proxy == null) { return(null); } TileResourceCollection collection = new TileResourceCollection(proxy.TileWidth, proxy.TileHeight, pool, texturePool); texturePool.RemoveResource(collection.TextureId); collection._tileSource = texturePool.GetResource(proxy.Texture); if (collection._tileSource != null) { collection._tileSource.Apply(c => { return((c.A == 0) ? Colors.Transparent : c); }); } if (proxy.TileDefinitions != null) { foreach (var tiledef in proxy.TileDefinitions) { TileResourceCollection.FromXmlProxy(tiledef, collection); } } if (collection.TextureResource != null) { collection.RecalculateOpenLocations(); } return(collection); }
public static TilePool FromXProxy(LibraryX.TilePoolX proxy, TilePoolManager manager) { if (proxy == null) { return(null); } return(new TilePool(proxy, manager)); }
public override TileRegistryContent Import(string filename, ContentImporterContext context) { //Form form = new Form(); //PresentationParameters presentation = new PresentationParameters(); //presentation.DeviceWindowHandle = form.Handle; //GraphicsAdapter.UseReferenceDevice = true; //GraphicsAdapter.UseNullDevice = true; //GraphicsDevice device = new GraphicsDevice( // GraphicsAdapter.DefaultAdapter, // GraphicsProfile.Reach, // presentation // ); Project project = new Project(); // project.Initialize(device); using (FileStream fs = File.OpenRead(filename)) { XmlReaderSettings settings = new XmlReaderSettings() { CloseInput = true, IgnoreComments = true, IgnoreWhitespace = true, }; using (XmlReader reader = XmlTextReader.Create(fs, settings)) { XmlSerializer serializer = new XmlSerializer(typeof(LibraryX.TilePoolX)); LibraryX.TilePoolX proxy = serializer.Deserialize(reader) as LibraryX.TilePoolX; TilePool.FromXProxy(proxy, (TilePoolManager)project.TilePoolManager); } /*XmlReader reader = XmlTextReader.Create(fs); * * XmlHelper.SwitchAll(reader, (xmlr, s) => * { * switch (s) { * case "tilesets": * * project.ReadXmlTilesets(reader); * break; * } * });*/ } TileRegistryContent content = new TileRegistryContent(project); content.Filename = filename; content.Directory = filename.Remove(filename.LastIndexOf('\\')); return(content); }
private TilePool(LibraryX.TilePoolX proxy, TilePoolManager manager) : this() { _uid = proxy.Uid; _name = new ResourceName(this, proxy.Name); Tiles = TileResourceCollection.FromXmlProxy(proxy, this, manager.TexturePool); Tiles.Modified += (s, e) => OnModified(EventArgs.Empty); Tiles.ResourceAdded += (s, e) => OnTileAdded(new TileEventArgs(e.Resource)); Tiles.ResourceRemoved += (s, e) => OnTileRemoved(new TileEventArgs(e.Resource)); Tiles.ResourceModified += (s, e) => OnTileModified(new TileEventArgs(e.Resource)); manager.Pools.Add(this); if (proxy.Properties != null) { foreach (var propertyProxy in proxy.Properties) { PropertyManager.CustomProperties.Add(Property.FromXmlProxy(propertyProxy)); } } }