Esempio n. 1
0
        public Project()
        {
            Uid = Guid.NewGuid();
            _services = new ServiceContainer();

            Name = "Project";

            _levels = new NamedResourceCollection<Level>();
            _levels.Modified += (s, e) => OnModified(EventArgs.Empty);

            _libraryManager = new LibraryManager();
            _libraryManager.Libraries.Modified += (s, e) => OnModified(EventArgs.Empty);

            Library defaultLibrary = new Library();

            _libraryManager.Libraries.Add(defaultLibrary);

            Extra = new List<XmlElement>();

            _texturePool = defaultLibrary.TexturePool;
            _tilePools = new MetaTilePoolManager();
            _tilePools.AddManager(defaultLibrary.Uid, defaultLibrary.TilePoolManager);
            _objectPools = new MetaObjectPoolManager();
            _objectPools.AddManager(defaultLibrary.Uid, defaultLibrary.ObjectPoolManager);
            _tileBrushes = new MetaTileBrushManager();
            _tileBrushes.AddManager(defaultLibrary.Uid, defaultLibrary.TileBrushManager);

            SetDefaultLibrary(defaultLibrary);

            _services.AddService(typeof(TilePoolManager), _tilePools);

            ResetModified();
        }
Esempio n. 2
0
        public ImportTilePool(Project project)
        {
            InitializeComponent();

            _project = project;

            _localTexturePool = new TexturePool();
            _localManager = new TilePoolManager(_localTexturePool);

            _buttonOK.Enabled = false;

            _layerControl = new LayerGraphicsControl();
            _layerControl.Dock = DockStyle.Fill;
            _layerControl.WidthSynced = true;
            _layerControl.CanvasAlignment = CanvasAlignment.UpperLeft;
            _layerControl.TextureCache.SourcePool = _localManager.TexturePool;

            _rootLayer = new GroupLayerPresenter();
            _layerControl.RootLayer = new GroupLayer(_rootLayer);

            _previewPanel.Controls.Add(_layerControl);

            _message.Text = "";

            _buttonTransColor.Click += ButtonTransColorClickHandler;
            _checkboxTransColor.Click += CheckboxTransColorClickHandler;
            _layerControl.MouseDown += PreviewControlClickHandler;
        }
Esempio n. 3
0
        public static TexturePool FromXmlProxy(LibraryX.TextureGroupX proxy)
        {
            if (proxy == null)
                return null;

            TexturePool pool = new TexturePool();
            foreach (var defProxy in proxy.Textures) {
                TextureResource resource = TextureResource.FromXmlProxy(defProxy.TextureData);
                if (resource != null) {
                    pool._resources[defProxy.Uid.ValueOrNew()] = resource;
                }
            }

            return pool;
        }
Esempio n. 4
0
        private ObjectClass(LibraryX.ObjectClassX proxy, TexturePool texturePool)
            : this(proxy.Name)
        {
            _uid = proxy.Uid;
            _textureId = proxy.Texture;
            _image = texturePool.GetResource(_textureId);
            _imageBounds = proxy.ImageBounds;
            _maskBounds = proxy.MaskBounds;
            _origin = proxy.Origin;

            if (proxy.Properties != null) {
                foreach (var propertyProxy in proxy.Properties)
                    CustomProperties.Add(Property.FromXmlProxy(propertyProxy));
            }
        }
Esempio n. 5
0
        public static LibraryX.TextureGroupX ToXmlProxyX(TexturePool pool)
        {
            if (pool == null)
                return null;

            List<LibraryX.TextureX> defs = new List<LibraryX.TextureX>();
            foreach (var kv in pool._resources)
                defs.Add(new LibraryX.TextureX() {
                    Uid = kv.Key,
                    TextureData = TextureResource.ToXmlProxy(kv.Value),
                });

            return new LibraryX.TextureGroupX() {
                Textures = defs,
            };
        }
Esempio n. 6
0
 public TilePoolManager(TexturePool texPool)
 {
     _texPool = texPool;
 }
Esempio n. 7
0
        private void SetDefaultLibrary(Library library)
        {
            _defaultLibraryUid = library.Uid;

            _texturePool = library.TexturePool;

            _tilePools.Default = library.Uid;
            _objectPools.Default = library.Uid;
            _tileBrushes.Default = library.Uid;
        }
Esempio n. 8
0
        public static ObjectClass FromXProxy(LibraryX.ObjectClassX proxy, TexturePool texturePool)
        {
            if (proxy == null)
                return null;

            return new ObjectClass(proxy, texturePool);
        }
Esempio n. 9
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed) {
                if (disposing) {
                    ReleaseAll();
                    SourcePool = null;
                    GraphicsDevice = null;
                }

                _disposed = true;
            }
        }