Пример #1
0
        public XElement GetAsXML(bool exportImageData, Palette existingPalette = null)
        {
            XElement xml = new XElement(MK64IMAGE);

            xml.Add(new XAttribute(TEXTURE_OFFSET, TextureOffset));
            xml.Add(new XAttribute(TEXTURE_BLOCK_OFFSET, TextureBlockOffset));
            xml.Add(new XAttribute(TEXTURE_ENCODING, TextureEncoding));

            XElement palettesXml = new XElement(PALETTES);

            for (int i = 0; i < PaletteOffset.Count; i++)
            {
                XElement paletteXml = new XElement(PALETTE);
                paletteXml.Add(new XAttribute(PALETTE_OFFSET, PaletteOffset[i]));
                paletteXml.Add(new XAttribute(PALETTE_BLOCK_OFFSET, PaletteBlockOffset[i]));
                paletteXml.Add(new XAttribute(PALETTE_ENCODING, PaletteEncoding[i]));
                paletteXml.Add(new XAttribute(PALETTE_COLOR_COUNT, PaletteColorCount[i]));
                paletteXml.Add(new XAttribute(PALETTE_COLOR_OFFSET, PaletteColorOffset[i]));
                palettesXml.Add(paletteXml);
            }
            xml.Add(palettesXml);

            xml.Add(new XAttribute(TKMK_LENGTH, TKMKLength));
            xml.Add(new XAttribute(TKMK_ALPHA_COLOR, TKMKAlphaColor));

            xml.Add(new XAttribute(FORMAT, Format));
            xml.Add(new XAttribute(PIXEL_SIZE, PixelSize));
            xml.Add(new XAttribute(WIDTH, Width));
            xml.Add(new XAttribute(HEIGHT, Height));
            xml.Add(new XAttribute(IS_ORIGINAL_IMAGE, IsOriginalImage));
            xml.Add(new XAttribute(IMAGE_NAME, ImageName));

            if (exportImageData || TextureOffset == -1 || PaletteOffset.Count(p => p == -1) > 0)
            {
                if (TKMKReference != null)
                {
                    xml.Add(TKMKReference.GetAsXML(true));
                }
                else
                {
                    xml.Add(ImageReference.GetAsXML(existingPalette));
                }
            }

            return(xml);
        }