private StaticTileBrush(LibraryX.StaticTileBrushX proxy, TilePoolManager manager) : base(proxy.Uid, proxy.Name, proxy.TileWidth, proxy.TileHeight) { _tiles = new Dictionary <TileCoord, TileStack>(); if (proxy.Tiles != null) { foreach (var stack in proxy.Tiles) { string[] coord = stack.At.Split(','); string[] tileIds = stack.Items.Split(','); int x = (coord.Length > 0) ? Convert.ToInt32(coord[0].Trim()) : 0; int y = (coord.Length > 1) ? Convert.ToInt32(coord[1].Trim()) : 0; foreach (string tileId in tileIds) { Guid id = new Guid(tileId.Trim()); TilePool pool = manager.PoolFromItemKey(id); if (pool == null) { continue; } AddTile(new TileCoord(x, y), pool.GetTile(id)); } } } Normalize(); }
private TileBrushManager(LibraryX.TileBrushGroupX proxy, TilePoolManager tileManager, DynamicTileBrushClassRegistry registry) { _staticBrushCollection = StaticTileBrushCollection.FromXProxy(proxy.StaticBrushes, tileManager); _dynamicBrushCollection = DynamicTileBrushCollection.FromXProxy(proxy.DynamicBrushes, tileManager, registry); Pools.Add(_staticBrushCollection); Pools.Add(_dynamicBrushCollection); }
public static TileBrushManager FromXProxy(LibraryX.TileBrushGroupX proxy, TilePoolManager tileManager, DynamicTileBrushClassRegistry registry) { if (proxy == null) { return(null); } return(new TileBrushManager(proxy, tileManager, registry)); }
public static StaticTileBrush FromXProxy(LibraryX.StaticTileBrushX proxy, TilePoolManager manager) { if (proxy == null) { return(null); } return(new StaticTileBrush(proxy, manager)); }
public static TilePool FromXProxy(LibraryX.TilePoolX proxy, TilePoolManager manager) { if (proxy == null) { return(null); } return(new TilePool(proxy, manager)); }
internal TilePool(TilePoolManager manager, string name, int tileWidth, int tileHeight) : this() { _name = new ResourceName(this, name); _tiles = new TileResourceCollection(tileWidth, tileHeight, 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)); }
public static DynamicTileBrush FromXProxy(LibraryX.DynamicTileBrushX proxy, TilePoolManager manager, DynamicTileBrushClassRegistry registry) { if (proxy == null) { return(null); } DynamicTileBrush brush = new DynamicTileBrush(proxy, manager, registry); if (brush._brushClass == null) { return(null); } return(brush); }
public Library() : this(Guid.NewGuid(), "Default") { Extra = new List <XmlElement>(); TexturePool = new TexturePool(); ObjectPoolManager = new ObjectPoolManager(TexturePool); ObjectPoolManager.PoolModified += (s, e) => OnModified(EventArgs.Empty); TilePoolManager = new TilePoolManager(TexturePool); TilePoolManager.PoolModified += (s, e) => OnModified(EventArgs.Empty); TileBrushManager = new TileBrushManager(); TileBrushManager.PoolModified += (s, e) => OnModified(EventArgs.Empty); }
private void Initialize(LibraryX proxy) { if (proxy.PropertyGroup != null) { Extra = new List <XmlElement>(proxy.PropertyGroup.Extra ?? new XmlElement[0]); } TexturePool = TexturePool.FromXmlProxy(proxy.TextureGroup) ?? new TexturePool(); ObjectPoolManager = ObjectPoolManager.FromXmlProxy(proxy.ObjectGroup, TexturePool) ?? new ObjectPoolManager(TexturePool); ObjectPoolManager.PoolModified += (s, e) => OnModified(EventArgs.Empty); TilePoolManager = TilePoolManager.FromXmlProxy(proxy.TileGroup, TexturePool) ?? new TilePoolManager(TexturePool); TilePoolManager.PoolModified += (s, e) => OnModified(EventArgs.Empty); TileBrushManager = TileBrushManager.FromXProxy(proxy.TileBrushGroup, TilePoolManager, Project.DynamicBrushClassRegistry) ?? new TileBrushManager(); TileBrushManager.PoolModified += (s, e) => OnModified(EventArgs.Empty); }
//internal override Guid TakeKey () //{ // return Guid.NewGuid(); //} //internal Guid TakeId () //{ // return Guid.NewGuid(); //} public static LibraryX.TileGroupX ToXmlProxyX(TilePoolManager manager) { if (manager == null) { return(null); } List <LibraryX.TilePoolX> pools = new List <LibraryX.TilePoolX>(); foreach (TilePool pool in manager.Pools) { pools.Add(TilePool.ToXProxy(pool)); } return(new LibraryX.TileGroupX() { TilePools = pools, }); }
public static TilePoolManager FromXmlProxy(LibraryX.TileGroupX proxy, TexturePool texturePool) { if (proxy == null) { return(null); } TilePoolManager manager = new TilePoolManager(texturePool); if (proxy.TilePools != null) { foreach (var pool in proxy.TilePools) { TilePool.FromXProxy(pool, manager); } } return(manager); }
public static LibraryX ToXProxy(Library library) { if (library == null) { return(null); } return(new LibraryX() { TextureGroup = TexturePool.ToXmlProxyX(library.TexturePool), ObjectGroup = ObjectPoolManager.ToXmlProxyX(library.ObjectPoolManager), TileGroup = TilePoolManager.ToXmlProxyX(library.TilePoolManager), TileBrushGroup = TileBrushManager.ToXProxy(library.TileBrushManager), PropertyGroup = new LibraryX.PropertyGroupX() { LibraryGuid = library.Uid, LibraryName = library.Name, Extra = (library.Extra != null && library.Extra.Count > 0) ? library.Extra.ToArray() : null, }, }); }
private DynamicTileBrush(LibraryX.DynamicTileBrushX proxy, TilePoolManager manager, DynamicTileBrushClassRegistry registry) : base(proxy.Uid, proxy.Name, proxy.TileWidth, proxy.TileHeight) { _brushClass = registry.Lookup(proxy.Type); if (_brushClass == null) { return; } _tiles = _brushClass.CreateTileProxyList(); foreach (var entry in proxy.Entries) { TilePool pool = manager.PoolFromItemKey(entry.TileId); if (pool == null) { continue; } SetTile(entry.Slot, pool.GetTile(entry.TileId)); } }
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)); } } }
public StaticTileBrushCollection(LibraryX.TileBrushCollectionX <LibraryX.StaticTileBrushX> proxy, TilePoolManager tileManager) : base(proxy.Uid, proxy.Name) { if (proxy.Brushes != null) { foreach (var brush in proxy.Brushes) { Brushes.Add(StaticTileBrush.FromXProxy(brush, tileManager)); } } }
public static DynamicTileBrushCollection FromXProxy(LibraryX.TileBrushCollectionX <LibraryX.DynamicTileBrushX> proxy, TilePoolManager tileManager, DynamicTileBrushClassRegistry registry) { if (proxy == null) { return(null); } return(new DynamicTileBrushCollection(proxy, tileManager, registry)); }
public DynamicTileBrushCollection(LibraryX.TileBrushCollectionX <LibraryX.DynamicTileBrushX> proxy, TilePoolManager tileManager, DynamicTileBrushClassRegistry registry) : base(proxy.Uid, proxy.Name) { if (proxy.Brushes != null) { foreach (var brush in proxy.Brushes) { Brushes.Add(DynamicTileBrush.FromXProxy(brush, tileManager, registry)); } } }
public static StaticTileBrushCollection FromXProxy(LibraryX.TileBrushCollectionX <LibraryX.StaticTileBrushX> proxy, TilePoolManager tileManager) { if (proxy == null) { return(null); } return(new StaticTileBrushCollection(proxy, tileManager)); }