# Path: xnb_parse/file_formats/xml_utils.py
# def output_xml(xml, filename):
# def output_xml(xml, filename):
# 
# Path: xnb_parse/xna_types/xna_graphics.py
# class Texture2D(object):
#     def __init__(self, surface_format, width, height, mip_levels, needs_swap=False):
#         self.surface_format = surface_format
#         self.width = width
#         self.height = height
#         self.mip_levels = mip_levels
#         self.needs_swap = needs_swap
# 
#     def __str__(self):
#         return "Texture2D f:{} d:{}x{} m:{} s:{}".format(self.surface_format, self.width, self.height,
#                                                          len(self.mip_levels), len(self.mip_levels[0]))
# 
#     def export(self, filename):
#         if not self.surface_format.reader:
#             raise ReaderError("No decoder found: '{}'".format(self.surface_format))
#         dirname = os.path.dirname(filename)
#         if not os.path.isdir(dirname):
#             os.makedirs(dirname)
# 
#         # hack for ArtObject/TrileSet alpha channel
#         alpha = 'yes'
#         if 'art objects' in filename or 'trile sets' in filename:
#             alpha = 'no'
#             rows = self.surface_format.reader(self.mip_levels[0], self.width, self.height, self.needs_swap,
#                                               alpha='only')
#             write_png(filename + '_alpha', self.width, self.height, rows)
#         rows = self.surface_format.reader(self.mip_levels[0], self.width, self.height, self.needs_swap, alpha=alpha)
#         write_png(filename, self.width, self.height, rows)
# 
#     def full_data(self, alpha='yes'):
#         if not self.surface_format.reader:
#             raise ReaderError("No decoder found: '{}'".format(self.surface_format))
# 
#         rows = self.surface_format.reader(self.mip_levels[0], self.width, self.height, self.needs_swap, alpha=alpha)
#         data = bytearray()
#         for row in rows:
#             data.extend(row)
#         return bytes(data)
# 
# FORMAT_COLOR = 1
# 
# def get_surface_format(xna_version, surface_format):
#     try:
#         if xna_version >= VERSION_40:
#             return SurfaceFormat4(surface_format)
#         else:
#             return SurfaceFormat(surface_format)
#     except KeyError:
#         raise ReaderError("Invalid surface format for V{}: {}".format(xna_version, surface_format))
# 
# VERSION_31 = 4
# 
# VERSION_40 = 5
# 
# FORMAT4_COLOR = 0


from xnb_parse.file_formats.xml_utils import ET
from xnb_parse.xna_types.xna_graphics import (Texture2D, FORMAT_COLOR, get_surface_format, VERSION_31, VERSION_40,
                                              FORMAT4_COLOR)
"""
FEZ graphics types
"""

from __future__ import print_function



class ArtObject(object):
    def __init__(self, name, cubemap_path, size, geometry, actor_type, no_silhouette, laser_outlets):
        self.name = name
        self.cubemap_path = cubemap_path
        self.size = size
        self.geometry = geometry
        self.actor_type = actor_type
        self.no_silhouette = no_silhouette
        self.laser_outlets = laser_outlets

    def __str__(self):
        return "ArtObject '{}' t:'{}' s:{} g:{}".format(self.name, self.cubemap_path, self.size,
                                                        len(self.geometry.vertices))

    def xml(self, parent=None):
        if parent is None:

# Path: xnb_parse/file_formats/xml_utils.py
# def output_xml(xml, filename):
# def output_xml(xml, filename):
# 
# Path: xnb_parse/xna_types/xna_graphics.py
# class Texture2D(object):
#     def __init__(self, surface_format, width, height, mip_levels, needs_swap=False):
#         self.surface_format = surface_format
#         self.width = width
#         self.height = height
#         self.mip_levels = mip_levels
#         self.needs_swap = needs_swap
# 
#     def __str__(self):
#         return "Texture2D f:{} d:{}x{} m:{} s:{}".format(self.surface_format, self.width, self.height,
#                                                          len(self.mip_levels), len(self.mip_levels[0]))
# 
#     def export(self, filename):
#         if not self.surface_format.reader:
#             raise ReaderError("No decoder found: '{}'".format(self.surface_format))
#         dirname = os.path.dirname(filename)
#         if not os.path.isdir(dirname):
#             os.makedirs(dirname)
# 
#         # hack for ArtObject/TrileSet alpha channel
#         alpha = 'yes'
#         if 'art objects' in filename or 'trile sets' in filename:
#             alpha = 'no'
#             rows = self.surface_format.reader(self.mip_levels[0], self.width, self.height, self.needs_swap,
#                                               alpha='only')
#             write_png(filename + '_alpha', self.width, self.height, rows)
#         rows = self.surface_format.reader(self.mip_levels[0], self.width, self.height, self.needs_swap, alpha=alpha)
#         write_png(filename, self.width, self.height, rows)
# 
#     def full_data(self, alpha='yes'):
#         if not self.surface_format.reader:
#             raise ReaderError("No decoder found: '{}'".format(self.surface_format))
# 
#         rows = self.surface_format.reader(self.mip_levels[0], self.width, self.height, self.needs_swap, alpha=alpha)
#         data = bytearray()
#         for row in rows:
#             data.extend(row)
#         return bytes(data)
# 
# FORMAT_COLOR = 1
# 
# def get_surface_format(xna_version, surface_format):
#     try:
#         if xna_version >= VERSION_40:
#             return SurfaceFormat4(surface_format)
#         else:
#             return SurfaceFormat(surface_format)
#     except KeyError:
#         raise ReaderError("Invalid surface format for V{}: {}".format(xna_version, surface_format))
# 
# VERSION_31 = 4
# 
# VERSION_40 = 5
# 
# FORMAT4_COLOR = 0


# Path: xnb_parse/xna_types/fez/fez_graphics.py
from xnb_parse.file_formats.xml_utils import ET
from xnb_parse.xna_types.xna_graphics import (Texture2D, FORMAT_COLOR, get_surface_format, VERSION_31, VERSION_40,
                                              FORMAT4_COLOR)

"""
FEZ graphics types
"""

from __future__ import print_function



class ArtObject(object):
    def __init__(self, name, cubemap_path, size, geometry, actor_type, no_silhouette, laser_outlets):
        self.name = name
        self.cubemap_path = cubemap_path
        self.size = size
        self.geometry = geometry
        self.actor_type = actor_type
        self.no_silhouette = no_silhouette
        self.laser_outlets = laser_outlets

    def __str__(self):
        return "ArtObject '{}' t:'{}' s:{} g:{}".format(self.name, self.cubemap_path, self.size,
                                                        len(self.geometry.vertices))

    def xml(self, parent=None):
        if parent is None:

            root = ET.Element('ArtObject')