Exemplo n.º 1
0
        /// <summary>
        /// Add Resources referenced from XML Files
        /// </summary>
        /// <param name="names"></param>
        public void AddFromXml(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] index = (SimPe.Interfaces.Files.IPackedFileDescriptor[])pkg.Index.Clone();
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in index)
            {
                SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                if (!cpf.CanHandleType(pfd.Type))
                {
                    continue;
                }

                cpf.ProcessData(pfd, pkg);

                //xobj
                AddFromXml(cpf.GetItem("material"), "_txmt", Data.MetaData.TXMT);

                //hood object
                if (pfd.Type == Data.MetaData.XNGB)
                {
                    AddFromXml(cpf.GetItem("modelname"), "_cres", Data.MetaData.CRES);
                }

                //fences
                AddFromXml(cpf.GetItem("diagrail"), "_cres", Data.MetaData.CRES);
                AddFromXml(cpf.GetItem("post"), "_cres", Data.MetaData.CRES);
                AddFromXml(cpf.GetItem("rail"), "_cres", Data.MetaData.CRES);
                AddFromXml(cpf.GetItem("diagrail"), "_txmt", Data.MetaData.TXMT);
                AddFromXml(cpf.GetItem("post"), "_txmt", Data.MetaData.TXMT);
                AddFromXml(cpf.GetItem("rail"), "_txmt", Data.MetaData.TXMT);

                //terrain
                AddFromXml(cpf.GetItem("texturetname"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetname"), "_detail_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetname"), "-bump_txtr", Data.MetaData.TXTR);

                //roof
                AddFromXml(cpf.GetItem("textureedges"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetop"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetopbump"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("texturetrim"), "_txtr", Data.MetaData.TXTR);
                AddFromXml(cpf.GetItem("textureunder"), "_txtr", Data.MetaData.TXTR);

                SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items =
                    FileTable.FileIndex.FindFile(
                        cpf.GetSaveItem("stringsetrestypeid").UIntegerValue,
                        cpf.GetSaveItem("stringsetgroupid").UIntegerValue,
                        cpf.GetSaveItem("stringsetid").UIntegerValue,
                        null
                        );
                AddFromXml(items);
            }
        }