Example #1
0
        private MiscN64ElementContainer _miscElementContainer; //contains elements not sorted into existing containers

        public RomFile(XElement xml, byte[] rawData)
        {
            _elements = new N64DataElementCollection();
            _elements.UnknownDataAdded += _elements_UnknownDataAdded;
            _elements.UnknownDataRemoved += _elements_UnknownDataRemoved;

            _elementContainers = new List<IN64ElementContainer>();
            _miscElementContainer = new MiscN64ElementContainer();

            XAttribute attribute = xml.Attribute(FILENAME);
            if (attribute != null)
                FileName = attribute.Value;

            attribute = xml.Attribute(FILEID);
            if (attribute != null)
                FileID = int.Parse(attribute.Value);

            //Here, start the arduous process of making all the N64Data Elements
            XElement n64Elements = xml.Element(N64ELEMENTS);
            if (n64Elements != null)
            {
                foreach (XElement element in n64Elements.Elements())
                {
                    N64DataElement newElement = N64DataElementFactory.CreateN64DataElementFromType(element.Name.ToString(),
                        element, rawData);

                    AddElement(newElement);
                }
            }

            XElement n64Conatiners = xml.Element(N64CONTAINERS);
            if (n64Conatiners != null)
            {
                foreach (XElement element in n64Conatiners.Elements())
                {
                    IN64ElementContainer newContainer = N64ElementContainerFactory.CreateN64ElementContainerFromType(element.Name.ToString());

                    AddElementContainer(newContainer);
                }
            }

            FileLength = rawData.Length;
        }
Example #2
0
        public RomFile(string fileName, int fileID, UnknownData rawFileData)
        {
            FileName = fileName;
            FileID = fileID;

            _elements = new N64DataElementCollection();
            _elements.UnknownDataAdded += _elements_UnknownDataAdded;
            _elements.UnknownDataRemoved += _elements_UnknownDataRemoved;

            _elementContainers = new List<IN64ElementContainer>();
            _miscElementContainer = new MiscN64ElementContainer();

            FileLength = rawFileData.RawDataSize;

            _elements.AddElement(rawFileData);
        }