public TngFile(System.IO.Stream fileStream)
        {
            using (TngBinaryReader reader = new TngBinaryReader(EndianBitConverter.Little, fileStream))
            {
                magic = reader.ReadInt32();
                if (magic != 100)
                {
                    throw new Exception("This is not a tng file!");
                }
                entryCount = reader.ReadInt32();
                infoSize = reader.ReadInt32();
                long endInfoLocation = reader.BaseStream.Position + infoSize;

                TngInfo info;
                TngInfo = new SortedDictionary<int, TngInfo>();
                while (reader.BaseStream.Position < endInfoLocation)
                {
                    info = new TngInfo(reader, this);
                }

                TngEntry = new TngEntry[entryCount];
                TngEntry tngEntry;
                for (int i = 0; i < entryCount; i++)
                {
                    tngEntry = new TngEntry(reader, this);
                    TngEntry[tngEntry.Id] = tngEntry;
                }
            }
        }
示例#2
0
        public TngFile(System.IO.Stream fileStream)
        {
            using (TngBinaryReader reader = new TngBinaryReader(EndianBitConverter.Little, fileStream))
            {
                magic = reader.ReadInt32();
                if (magic != 100)
                {
                    throw new Exception("This is not a tng file!");
                }
                entryCount = reader.ReadInt32();
                infoSize   = reader.ReadInt32();
                long endInfoLocation = reader.BaseStream.Position + infoSize;

                TngInfo info;
                TngInfo = new SortedDictionary <int, TngInfo>();
                while (reader.BaseStream.Position < endInfoLocation)
                {
                    info = new TngInfo(reader, this);
                }

                TngEntry = new TngEntry[entryCount];
                TngEntry tngEntry;
                for (int i = 0; i < entryCount; i++)
                {
                    tngEntry = new TngEntry(reader, this);
                    TngEntry[tngEntry.Id] = tngEntry;
                }
            }
        }
        public void Add()
        {
            TngInfo tInfo = new TngInfo();
            tInfo.Id = infoSize;
            tInfo.Name = "gear_8th";
            tInfo.IsParent = false;
            infoSize += Encoding.UTF8.GetByteCount(tInfo.Name) + 1;
            TngInfo.Add(tInfo.Id, tInfo);

            tInfo = new TngInfo();
            tInfo.Id = infoSize;
            tInfo.Name = "F1/Transmission/Gear 8 Ratio Adjust";
            tInfo.IsParent = true;
            infoSize += Encoding.UTF8.GetByteCount(tInfo.Name) + 1;
            TngInfo.Add(tInfo.Id, tInfo);

            Array.Resize(ref TngEntry, entryCount + 1);
            TngEntry[entryCount] = TngEntry[27];
            entryCount++;
        }
示例#4
0
        public void Add()
        {
            TngInfo tInfo = new TngInfo();

            tInfo.Id       = infoSize;
            tInfo.Name     = "gear_8th";
            tInfo.IsParent = false;
            infoSize      += Encoding.UTF8.GetByteCount(tInfo.Name) + 1;
            TngInfo.Add(tInfo.Id, tInfo);

            tInfo          = new TngInfo();
            tInfo.Id       = infoSize;
            tInfo.Name     = "F1/Transmission/Gear 8 Ratio Adjust";
            tInfo.IsParent = true;
            infoSize      += Encoding.UTF8.GetByteCount(tInfo.Name) + 1;
            TngInfo.Add(tInfo.Id, tInfo);

            Array.Resize(ref TngEntry, entryCount + 1);
            TngEntry[entryCount] = TngEntry[27];
            entryCount++;
        }