Beispiel #1
0
        public TextureSetFile WithTextureCollection([NotNull] TileTextureCollection c)
        {
            if (c == null)
            {
                throw new ArgumentNullException(nameof(c));
            }

            Collections.Add(c);
            return(this);
        }
Beispiel #2
0
        public TileTextureCollection CreateDeepCopy()
        {
            var retval = new TileTextureCollection(FormattingMetaData.CreateCopy());

            foreach (var g in Grids)
            {
                retval.Grids.Add(g.CreateDeepCopy());
            }

            return(retval);
        }
Beispiel #3
0
        public static XElement GenerateCollection(TileTextureCollection tileTextureCollection)
        {
            var collectionElement = new XElement(Namespace + "collection");
            var metaData          = GenerateFormattingMetaData(tileTextureCollection.FormattingMetaData);

            if (!string.IsNullOrEmpty(tileTextureCollection.LastExportLocation))
            {
                metaData.Add(new XAttribute("last-export-location", tileTextureCollection.LastExportLocation ?? ""));
            }

            if (metaData.HasAttributes || metaData.HasElements)
            {
                collectionElement.Add(metaData);
            }

            collectionElement.Add(new XAttribute("id", tileTextureCollection.Id ?? ""));
            collectionElement.AddRange(tileTextureCollection.Grids.Select(GenerateGrid));
            return(collectionElement);
        }
Beispiel #4
0
        public static TileTextureCollection ReadCollection(XElement root, TexturePackLoaderContext context)
        {
            var id = (string?)root.AttributeLocal("id") ?? "Unnamed Collection";

            var grids =
                from e in root.Elements()
                where e.Name.LocalName == "grid"
                select ReadGrid(e, context);

            var retval = new TileTextureCollection();

            retval.Id = id;
            retval.Grids.AddRange(grids);
            ParseFormattingInfo(root, retval.FormattingMetaData);

            var lastExportLocation = (string?)root.ElementLocal("metadata")?.Attribute("last-export-location");

            retval.LastExportLocation = lastExportLocation;
            return(retval);
        }