コード例 #1
0
ファイル: TduFile.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Updates common information when loading is finished
        /// </summary>
        /// <param name="fileName"></param>
        private void _FinalizeLoading(string fileName)
        {
            FileInfo fi = new FileInfo(fileName);

            // Mise à jour des attributs communs
            _FileName = fi.FullName;

            if (fi.Exists)
            {
                _FileSize   = (uint)fi.Length;
                _FileExists = true;


                _LastLoadedAt = DateTime.Now;

                //Log.Info("DEBUG: setting lla=" + _LastLoadedAt);

                // Common properties
                // EVO_149: Type description property added
                Property.ComputeValueDelegate fileNameDelegate = () => _FileName;
                Property.ComputeValueDelegate fileSizeDelegate = () => _FileSize.ToString();
                Property.ComputeValueDelegate fileTypeDelegate = () => GetTypeDescription(_FileName);

                Properties.Add(new Property("Full path", "Common", fileNameDelegate));
                Properties.Add(new Property("Type", "Common", fileTypeDelegate));
                Properties.Add(new Property("Size (bytes)", "Common", fileSizeDelegate));
            }
        }
コード例 #2
0
        /// <summary>
        /// Defines file properties
        /// </summary>
        protected void _SetProperties()
        {
            Property.ComputeValueDelegate wpCountDelegate = () => CheckpointCount.ToString();
            Property.ComputeValueDelegate modeDelegate    = () => ChallengeMode.ToString();
            Property.ComputeValueDelegate typeDelegate    = () => ChallengeType.ToString();
            Property.ComputeValueDelegate nameDelegate    = () => TrackName;

            Properties.Add(new Property("Track name", "DFE/IGE", nameDelegate));
            Properties.Add(new Property("Challenge mode", "DFE/IGE", modeDelegate));
            Properties.Add(new Property("Challenge type", "DFE/IGE", typeDelegate));
            Properties.Add(new Property("Waypoint count", "DFE/IGE", wpCountDelegate));
        }
コード例 #3
0
ファイル: BNK.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Initialise les infos avec le contenu du fichier (redéfinition). To be called one in constructor.
        /// If you need reloading file, use _ReloadIfNecessary() method instead.
        /// </summary>
        protected override void _ReadData()
        {
            // Clearing all data lists
            _NameList.Clear();
            _PathList.Clear();
            __FileList.Clear();
            __FileByPathList.Clear();
            __FileInfoByPathList.Clear();

            // Initializing sections
            _CreateSections();

            // Reading file
            using (BinaryReader bnkReader
                       = new BinaryReader(new FileStream(_FileName, FileMode.Open, FileAccess.Read)))
            {
                // Section 1: header
                _ReadSection(SectionType.Header, bnkReader);

                // Section 2: fileSize
                _ReadSection(SectionType.FileSize, bnkReader);

                // Section 3: typeMapping (optional)
                Section typeMappingSection = _GetSection(SectionType.TypeMapping);

                if (typeMappingSection.address > 0)
                {
                    _ReadSection(SectionType.TypeMapping, bnkReader);
                }
                else
                {
                    typeMappingSection.isPresent = false;
                }

                // Section 4: fileName
                _ReadSection(SectionType.FileName, bnkReader);

                // Section 5: fileOrder
                _ReadSection(SectionType.FileOrder, bnkReader);

                // Section 6: fileData
                _ReadSection(SectionType.FileData, bnkReader);
            }

            // EVO_65: Properties
            Property.ComputeValueDelegate fileCountDelegate = () => PackedFilesCount.ToString();
            Property.ComputeValueDelegate yearDelegate      = () => Year.ToString();

            Properties.Add(new Property("Packed files count", "BNK", fileCountDelegate));
            Properties.Add(new Property("Year", "BNK", yearDelegate));
        }
コード例 #4
0
        /// <summary>
        /// Initialise les infos avec le contenu du fichier (redéfinition)
        /// </summary>
        protected override void _ReadData()
        {
            using (TextReader reader = new StreamReader(new FileStream(_FileName, FileMode.Open, FileAccess.Read)))
            {
                // Clearing all data
                _Entries.Clear();
                entriesById.Clear();

                // Browsing all lines
                string contents = reader.ReadToEnd();

                string[] endOfEntrySeparator = new string[] { "\r\n" };
                int      entryCount          = 0;
                foreach (string currentLine in contents.Split(endOfEntrySeparator, StringSplitOptions.RemoveEmptyEntries))
                {
                    Entry entry = _GenerateEntryFromLine(currentLine);

                    if (entry.isValid)
                    {
                        // Searching topic in first comment entry
                        if (_CurrentTopic == DB.Topic.None && entry.isComment)
                        {
                            _CurrentTopic = _SearchForCurrentTopic(entry);
                        }

                        entry.index = ++entryCount;
                        _Entries.Add(entry);

                        // Accelerator update
                        if (entry.id != null && !entriesById.ContainsKey(entry.id))
                        {
                            entriesById.Add(entry.id, entry);
                        }
                    }
                }
            }

            // EVO_65: Properties
            Property.ComputeValueDelegate encryptedDelegate  = (() => "No");
            Property.ComputeValueDelegate entryCountDelegate = (() => _Entries.Count.ToString());

            Properties.Add(new Property("Encrypted ?", "DB Resources", encryptedDelegate));
            Properties.Add(new Property("Entry count", "DB Resources", entryCountDelegate));
        }
コード例 #5
0
ファイル: _2DB.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Lit le contenu du fichier
        /// </summary>
        protected override void _ReadData()
        {
            FileStream   input  = null;
            BinaryReader reader = null;

            try
            {
                input  = new FileStream(_FileName, FileMode.Open, FileAccess.Read);
                reader = new BinaryReader(input);

                // En-tête
                _Header.dwTwo           = reader.ReadUInt32();
                _Header.dwZero1         = reader.ReadUInt32();
                _Header.dwSize          = reader.ReadUInt32();
                _Header.bID1            = reader.ReadBytes(4);
                _Header.bID2            = reader.ReadBytes(4);
                _Header.dwZero2         = reader.ReadUInt32();
                _Header.dwSize2         = reader.ReadUInt32();
                _Header.dwSize2Bis      = reader.ReadUInt32();
                _Header.strName         = reader.ReadBytes(8);
                _Header.width           = reader.ReadInt16();
                _Header.height          = reader.ReadInt16();
                _Header.one             = reader.ReadInt16();
                _Header.bMipMapCount    = reader.ReadByte();
                _Header.bMipMapCountBis = reader.ReadByte();
                _Header.bFormat         = reader.ReadByte();
                _Header.bUnk2           = reader.ReadByte();
                _Header.unk3            = reader.ReadInt16();
                _Header.dwUnk4          = reader.ReadUInt32();
                _Header.dwUnk5          = reader.ReadUInt32();
                _Header.dwType          = reader.ReadUInt32();
                _Header.dwFlags         = reader.ReadUInt32();
                _Header.dwUnk6          = reader.ReadUInt32();
                _Header.dwUnk7          = reader.ReadUInt32();
                _Header.dwZero3         = reader.ReadUInt32();

                // Données d'image
                FileInfo fi = new FileInfo(_FileName);

                _ImageData = reader.ReadBytes((int)(fi.Length - HEADER_SIZE));

                // EVO_65: property support
                Property.ComputeValueDelegate nameDelegate = delegate
                {
                    string textureName =
                        Array2.BytesToString(_Header.strName);

                    return(Tools.OutlineExtendedCharacters(textureName));
                };
                Property.ComputeValueDelegate dimensionsDelegate = delegate { return(_Header.width + "x" + _Header.height); };
                Property.ComputeValueDelegate mipmapDelegate     = delegate { return(_Header.bMipMapCount.ToString()); };
                Property.ComputeValueDelegate formatDelegate     = delegate { return(GetFormatName(_Header.bFormat)); };
                Property.ComputeValueDelegate typeDelegate       = delegate { return(_Header.dwType.ToString()); };
                Property.ComputeValueDelegate flagsDelegate      = delegate { return(_Header.dwFlags.ToString()); };
                Property.ComputeValueDelegate magicDelegate      = delegate { return(_Header.dwUnk6 + " - " + _Header.dwUnk7); };

                _Properties.Add(new Property("Texture name", "2DB", nameDelegate));
                _Properties.Add(new Property("Dimensions", "Texture", dimensionsDelegate));
                _Properties.Add(new Property("Mipmap count", "Texture", mipmapDelegate));
                _Properties.Add(new Property("Format", "2DB", formatDelegate));
                _Properties.Add(new Property("Type", "2DB", typeDelegate));
                _Properties.Add(new Property("Flags", "2DB", flagsDelegate));
                _Properties.Add(new Property("Magic", "2DB", magicDelegate));
            }
            catch (Exception ex)
            {
                Exception2.PrintStackTrace(ex);

                throw;
            }
            finally
            {
                // Fermeture
                if (reader != null)
                {
                    reader.Close();
                }
                if (input != null)
                {
                    input.Close();
                }
            }
        }
コード例 #6
0
ファイル: DB.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Lit les données du fichier. A implémenter si nécessaire
        /// </summary>
        protected override sealed void _ReadData()
        {
            // Decrypting needed
            string   tempFolder = File2.SetTemporaryFolder(null, LibraryConstants.FOLDER_TEMP, true);
            FileInfo fi         = new FileInfo(_FileName);
            string   tempFile   = tempFolder + @"\" + fi.Name + ".OK";

            XTEAEncryption.Decrypt(_FileName, tempFile);

            // Parsing clear file
            using (TextReader reader = new StreamReader(new FileStream(tempFile, FileMode.Open, FileAccess.Read)))
            {
                // Clearing all data
                _Entries.Clear();
                _EntriesByPrimaryKey.Clear();

                // First lines = header comments
                StringBuilder sbHeader    = new StringBuilder();
                string        currentLine = reader.ReadLine();

                while (currentLine != null && currentLine.StartsWith(_CHAR_COMMENTS))
                {
                    sbHeader.AppendLine(currentLine);
                    currentLine = reader.ReadLine();
                }

                _HeaderComments = sbHeader.ToString();

                // Column list
                _Structure = new List <Cell>();
                int count          = 0;
                int unicityCounter = 1;

                while (currentLine != null && currentLine[0] == _CHAR_START_TEXT)
                {
                    // Parsing column description
                    int    nameEndPosition = currentLine.IndexOf(_CHAR_END_TEXT);
                    string name            = currentLine.Substring(1, nameEndPosition - 1);

                    if (count++ == 0)
                    {
                        // First column is just file reference
                        _CurrentTopic  = _GetTopicByName(name);
                        _FileReference = currentLine.Substring(nameEndPosition + 2);
                    }
                    else
                    {
                        Cell currentCell = new Cell();

                        // Regular column description
                        string type = currentLine.Substring(nameEndPosition + 2, 1);

                        currentCell.name      = name;
                        currentCell.valueType = _GetValueTypeBySymbol(type);
                        currentCell.index     = count - 2;

                        if (currentCell.valueType == ValueType.Reference || currentCell.valueType == ValueType.ReferenceL)
                        {
                            string reference = currentLine.Substring(nameEndPosition + 4);

                            currentCell.optionalRef = reference;
                        }

                        _Structure.Add(currentCell);

                        // Index update
                        // BUGFIX: on TDU_PNJ, 6 columns have the same name
                        // Column name is suffixed by a counter
                        if (_ColumnIndexByName.ContainsKey(currentCell.name))
                        {
                            currentCell.name = currentCell.name + "_" + unicityCounter;
                            unicityCounter++;
                        }

                        _ColumnIndexByName.Add(currentCell.name, currentCell.index);
                    }

                    currentLine = reader.ReadLine();
                }

                // Comment for line count
                string countComment = currentLine;
                currentLine = reader.ReadLine();

                // Values
                int    entryCount    = 0;
                int    maxEntryCount = _GetMaxEntryCount(countComment);
                string separator     = new string(_CHAR_VALUE_SEPARATOR, 1);

                // BUGFIX: does not take entries when count is higher than expected
                while (currentLine != null && currentLine.Contains(separator))
                {
                    if (entryCount > maxEntryCount)
                    {
                        break;
                    }

                    // Getting all values by splitting between ;
                    string[] allValues = currentLine.Split(_CHAR_VALUE_SEPARATOR);

                    // BUG_65: ensure current line is valid. If last separator is missing, entry is also considered as OK.
                    if (allValues.Length < _Structure.Count || allValues.Length > _Structure.Count + 1)
                    {
                        Log.Info("Current DB entry is invalid (" + _FileName + "):\r\n" + currentLine);

                        break;
                    }

                    Entry  currentEntry = new Entry();
                    string primaryKey   = null;

                    currentEntry.index = entryCount;
                    currentEntry.cells = new List <Cell>();

                    for (int i = 0; i < allValues.Length - 1; i++)
                    {
                        Cell currentCell = _Structure[i];

                        currentCell.value      = allValues[i];
                        currentCell.index      = i;
                        currentCell.entryIndex = entryCount;
                        currentEntry.cells.Add(currentCell);

                        if (currentCell.valueType == ValueType.PrimaryKey)
                        {
                            primaryKey = currentCell.value;
                        }
                    }

                    // If no REF column found, primary key is automatically built with contents of first 2 columns
                    if (primaryKey == null && currentEntry.cells.Count >= 2)
                    {
                        primaryKey = string.Format(DatabaseHelper.FORMAT_COMPLEX_PK,
                                                   currentEntry.cells[0].value,
                                                   currentEntry.cells[1].value);
                    }

                    currentEntry.primaryKey = primaryKey;

                    _Entries.Add(currentEntry);

                    // Debug only - very slow !
                    //Log.Info("primary key = " + primaryKey);

                    // TODO potential problem with Elise duplicated rims 1297992029
                    // Duplicate risk with TDU_Achievements
                    if (primaryKey != null && !_EntriesByPrimaryKey.ContainsKey(primaryKey))
                    {
                        _EntriesByPrimaryKey.Add(primaryKey, currentEntry);
                    }

                    currentLine = reader.ReadLine();
                    entryCount++;
                }
            }

            // Adding current reference to global association
            if (_FileReference != null && !_DBFilesByReference.ContainsKey(_FileReference))
            {
                _DBFilesByReference.Add(_FileReference, _CurrentTopic.ToString());
            }

            // EVO_65: Properties
            Property.ComputeValueDelegate encryptedDelegate = (() => "Yes");

            Properties.Add(new Property("Encrypted ?", "Database", encryptedDelegate));
        }
コード例 #7
0
ファイル: DDS.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Lecture du contenu du fichier
        /// </summary>
        protected override void _ReadData()
        {
            FileStream   input  = null;
            BinaryReader reader = null;

            try
            {
                input  = new FileStream(_FileName, FileMode.Open, FileAccess.Read);
                reader = new BinaryReader(input);

                // En-tête
                DDSURFACEDESC2 resultSurface;
                DDPIXELFORMAT  resultPixelFormat;
                DDCAPS2        resultCaps;

                _Header.dwMagic = reader.ReadUInt32();

                resultSurface.dwSize              = reader.ReadUInt32();
                resultSurface.dwFlags             = reader.ReadUInt32();
                resultSurface.dwHeight            = reader.ReadUInt32();
                resultSurface.dwWidth             = reader.ReadUInt32();
                resultSurface.dwPitchOrLinearSize = reader.ReadUInt32();
                resultSurface.dwDepth             = reader.ReadUInt32();
                resultSurface.dwMipMapCount       = reader.ReadUInt32();
                resultSurface.dwReserved1         = reader.ReadBytes(44);

                resultPixelFormat.dwSize            = reader.ReadUInt32();
                resultPixelFormat.dwFlags           = reader.ReadUInt32();
                resultPixelFormat.dwFourCC          = reader.ReadUInt32();
                resultPixelFormat.dwRGBBitCount     = reader.ReadUInt32();
                resultPixelFormat.dwRBitMask        = reader.ReadUInt32();
                resultPixelFormat.dwGBitMask        = reader.ReadUInt32();
                resultPixelFormat.dwBBitMask        = reader.ReadUInt32();
                resultPixelFormat.dwRGBAlphaBitMask = reader.ReadUInt32();

                resultCaps.dwCaps1  = reader.ReadUInt32();
                resultCaps.dwCaps2  = reader.ReadUInt32();
                resultCaps.Reserved = reader.ReadBytes(8);

                resultSurface.dwReserved2 = reader.ReadUInt32();

                resultSurface.ddsCaps         = resultCaps;
                resultSurface.ddpfPixelFormat = resultPixelFormat;
                _Header.ddsd = resultSurface;

                // Données d'image
                FileInfo fi = new FileInfo(_FileName);

                _ImageData = reader.ReadBytes((int)(fi.Length - HEADER_SIZE));

                // EVO_65: property support
                Property.ComputeValueDelegate dimensionsDelegate = delegate { return(resultSurface.dwWidth + "x" + resultSurface.dwHeight); };
                Property.ComputeValueDelegate mipmapDelegate     = delegate { return(resultSurface.dwMipMapCount.ToString()); };
                Property.ComputeValueDelegate formatDelegate     = delegate { return(GetFormatName(resultPixelFormat.dwFourCC)); };
                Property.ComputeValueDelegate bitCountDelegate   = delegate { return(resultPixelFormat.dwRGBBitCount.ToString()); };

                _Properties.Add(new Property("Dimensions", "Texture", dimensionsDelegate));
                _Properties.Add(new Property("Mipmap count", "Texture", mipmapDelegate));
                _Properties.Add(new Property("Format", "DDS", formatDelegate));
                _Properties.Add(new Property("RGB bit count", "DDS", bitCountDelegate));
            }
            catch (Exception ex)
            {
                Exception2.PrintStackTrace(ex);
                throw;
            }
            finally
            {
                // Fermeture
                if (reader != null)
                {
                    reader.Close();
                }
                if (input != null)
                {
                    input.Close();
                }
            }
        }
コード例 #8
0
ファイル: MAP.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Initialise les infos avec le contenu du fichier
        /// </summary>
        protected override sealed void _ReadData()
        {
            FileInfo     fileInfo = new FileInfo(_FileName);
            BinaryReader reader   = null;

            try
            {
                reader    = new BinaryReader(new FileStream(_FileName, FileMode.Open, FileAccess.Read));
                _FileSize = (uint)fileInfo.Length;

                reader.BaseStream.Seek(0x0L, SeekOrigin.Begin);

                // TAG
                _Tag = new string(reader.ReadChars((int)_TAG_LENGTH));

                // Lecture des entrées  (attention, tout est en Big Endian ici !)
                uint  count    = 0;
                bool  finished = false;
                Entry newEntry;

                _IsMagicMap = true;

                while (!finished)
                {
                    newEntry = new Entry {
                        entryNumber = count
                    };

                    // 1 octet inutilisé
                    reader.BaseStream.Seek(1, SeekOrigin.Current);

                    // Adresse
                    newEntry.address = (uint)reader.BaseStream.Position;

                    // Id du fichier : 4 octets
                    newEntry.fileId = BinaryTools.ToBigEndian(reader.ReadUInt32());

                    // Taille 1
                    newEntry.firstSize = BinaryTools.ToBigEndian(reader.ReadUInt32());

                    // Non utilisé : 4 octets
                    reader.BaseStream.Seek(4, SeekOrigin.Current);

                    // Taille 2
                    newEntry.secondSize = BinaryTools.ToBigEndian(reader.ReadUInt32());

                    // Non utilisé : 5 octets
                    reader.BaseStream.Seek(5, SeekOrigin.Current);

                    // Marqueur de fin d'entrée
                    if (finishMarker == null)
                    {
                        finishMarker = Encoding.ASCII.GetString(reader.ReadBytes(2));
                    }
                    else
                    {
                        reader.BaseStream.Seek(2, SeekOrigin.Current);
                    }

                    // Ajout de l'entrée à la collection
                    entryList.Add(newEntry.fileId, newEntry);

                    // Is it a magic map ?
                    if ((newEntry.firstSize != 0 || newEntry.secondSize != 0) && _IsMagicMap)
                    {
                        _IsMagicMap = false;
                    }

                    if (reader.BaseStream.Position >= _FileSize)
                    {
                        finished = true;
                    }

                    count++;
                }
            }
            catch (EndOfStreamException)
            {
                // Fin du fichier atteinte, on ne fait rien
            }
            finally
            {
                if (reader != null)
                {
                    reader.BaseStream.Seek(0, SeekOrigin.Begin);
                    reader.Close();
                }
            }

            // EVO_65: Properties
            Property.ComputeValueDelegate entryCountDelegate = () => EntryCount.ToString();
            Property.ComputeValueDelegate magicDelegate      = () => IsMagicMap ? "Yes" : "No";

            Properties.Add(new Property("Entry count", "Mapping", entryCountDelegate));
            Properties.Add(new Property("Magic Map?", "Mapping", magicDelegate));
        }
コード例 #9
0
ファイル: PCH.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Reads patch from a PCH (XML format) file
        /// </summary>
        protected override sealed void _ReadData()
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(FileName);

                // Properties
                XmlElement docElement = doc.DocumentElement;

                if (docElement != null)
                {
                    XmlNode propNode = docElement.SelectSingleNode(_PROPERTIES_NODE);

                    _Name              = propNode.Attributes[_NAME_ATTRIBUTE].Value;
                    _Version           = propNode.Attributes[_VERSION_ATTRIBUTE].Value;
                    _Author            = propNode.Attributes[_AUTHOR_ATTRIBUTE].Value;
                    _Date              = propNode.Attributes[_DATE_ATTRIBUTE].Value;
                    _Free              = Xml2.GetAttributeWithDefaultValue(propNode, _FREE_ATTRIBUTE, "");
                    _InstallerFileName = Xml2.GetAttributeWithDefaultValue(propNode, _INSTALLER_FILE_NAME_ATTRIBUTE,
                                                                           INSTALLER_FILE_NAME);

                    // EVO_131: roles
                    _RetrieveRoles(propNode);

                    // EVO_134: groups
                    _RetrieveGroups(propNode);

                    // New attributes
                    _SlotRef = Xml2.GetAttributeWithDefaultValue(propNode, _SLOT_REF_ATTRIBUTE, "");
                    InfoURL  = Xml2.GetAttributeWithDefaultValue(propNode, _INFO_URL_ATTRIBUTE, "");

                    // Instructions
                    XmlNode     instrNode           = docElement.SelectSingleNode(_INSTRUCTIONS_NODE);
                    XmlNodeList allInstructionNodes = instrNode.SelectNodes(_SINGLE_INSTRUCTION_NODE);
                    int         order = 1;

                    if (allInstructionNodes != null)
                    {
                        foreach (XmlNode anotherInstructionNode in allInstructionNodes)
                        {
                            try
                            {
                                PatchInstruction pi = _ProcessInstruction(anotherInstructionNode, order);

                                if (pi == null)
                                {
                                    throw new Exception();
                                }
                                _PatchInstructions.Add(pi);

                                // Groups update
                                if (!_Groups.Contains(pi.Group))
                                {
                                    _Groups.Add(pi.Group);
                                }

                                order++;
                            }
                            catch (Exception ex)
                            {
                                // Current instruction won't be added
                                Exception2.PrintStackTrace(new Exception("Invalid instruction.", ex));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Silent exception
                Exception2.PrintStackTrace(new Exception(_ERROR_LOADING_PATCH, ex));
            }

            // EVO_65: Properties
            Property.ComputeValueDelegate instructionCountDelegate = () => PatchInstructions.Count.ToString();
            Property.ComputeValueDelegate nameDelegate             = () => Name;
            Property.ComputeValueDelegate authorDelegate           = () => Author;
            Property.ComputeValueDelegate dateDelegate             = () => Date;
            Property.ComputeValueDelegate versionDelegate          = () => Version;
            Property.ComputeValueDelegate slotDelegate             = () => SlotRef;
            Property.ComputeValueDelegate groupCountDelegate       = () => Groups.Count.ToString();
            Property.ComputeValueDelegate installerDelegate        = () => InstallerFileName;
            Property.ComputeValueDelegate urlDelegate = () => InfoURL;

            Properties.Add(new Property("Patch name", "Patch", nameDelegate));
            Properties.Add(new Property("Author", "Patch", authorDelegate));
            Properties.Add(new Property("Date", "Patch", dateDelegate));
            Properties.Add(new Property("Version", "Patch", versionDelegate));
            Properties.Add(new Property("Group count", "Patch", groupCountDelegate));
            Properties.Add(new Property("Instruction count", "Patch", instructionCountDelegate));
            Properties.Add(new Property("Slot reference", "Patch", slotDelegate));
            Properties.Add(new Property("Installer file name", "Patch", installerDelegate));
            Properties.Add(new Property("Information URL", "Patch", urlDelegate));
        }
コード例 #10
0
ファイル: Cameras.cs プロジェクト: djey47/tdumt
        protected sealed override void _ReadData()
        {
            using (BinaryReader reader = new BinaryReader(new FileStream(_FileName, FileMode.Open, FileAccess.Read)))
            {
                // Header (TODO)
                _header = reader.ReadBytes(HeaderSize);

                // Index size (2 bytes)
                ushort indexSize = reader.ReadUInt16();

                // Zero1 (2 bytes)
                reader.ReadBytes(2);

                // Unknown1 ... (4 bytes) ... always=40
                _unknown1 = reader.ReadUInt32();

                // Cam index
                _index.Clear();

                for (int i = 0; i < indexSize; i++)
                {
                    // Camera id (2 bytes)
                    ushort camId = reader.ReadUInt16();

                    // Zero1 (2 bytes)
                    reader.ReadBytes(2);

                    // View count (2 bytes, ignored)
                    ushort viewCount = reader.ReadUInt16();

                    // Zeroes (6 bytes)
                    reader.ReadBytes(6);

                    _index.Add(camId, viewCount);
                }

                // Zero zone
                reader.ReadBytes(_ZeroZoneSize);

                // Beginning of interesting zone
                CamEntry      currentEntry = new CamEntry();
                List <ushort> processedIds = new List <ushort>();

                while (reader.BaseStream.Position < reader.BaseStream.Length)
                {
                    View newView = new View();

                    // Zero1 (4 bytes)
                    reader.ReadBytes(4);

                    // Unknown1 (180 bytes)
                    newView.unknown1 = reader.ReadBytes(0xB4);

                    // Tag (?)
                    newView.tag = reader.ReadUInt32();

                    // Camera id
                    ushort currentId = reader.ReadUInt16();

                    if (!processedIds.Contains(currentId))
                    {
                        // New camera entry: saving latest entry first
                        if (processedIds.Count > 0)
                        {
                            currentEntry.isValid = true;
                            _entries.Add(currentEntry);
                        }

                        // Creating new entry
                        currentEntry = new CamEntry {
                            id = currentId, views = new List <View>()
                        };
                        processedIds.Add(currentId);
                    }

                    newView.cameraId = currentId;

                    // Zero2 (2 bytes)
                    reader.ReadBytes(2);

                    // View type
                    ushort currentViewType = reader.ReadUInt16();

                    newView.type = (ViewType)Enum.Parse(typeof(ViewType), currentViewType.ToString());

                    // Zero3 (2 bytes)
                    reader.ReadBytes(2);

                    // View name
                    byte[] nameBytes = reader.ReadBytes(16);

                    newView.name = _GetViewName(nameBytes);

                    // Custom properties hack
                    Couple <string> customProps = _GetViewProperties(nameBytes);

                    if (customProps != null)
                    {
                        newView.parentCameraId = ushort.Parse(customProps.FirstValue);
                        newView.parentType     = (ViewType)Enum.Parse(typeof(ViewType), customProps.SecondValue, false);
                    }

                    // Unknown2 (420 bytes)
                    newView.unknown2 = reader.ReadBytes(0x1A4);
                    // Source and target positions
                    newView.source = (Position)((sbyte)newView.unknown2[195]);
                    newView.target = (Position)((sbyte)newView.unknown2[211]);

                    // Adding view to existing set
                    newView.isValid = true;
                    currentEntry.views.Add(newView);
                }

                // Finalization
                currentEntry.isValid = true;
                _entries.Add(currentEntry);

                // EVO_65: Properties
                Property.ComputeValueDelegate camCountDelegate = () => _entries.Count.ToString();

                Properties.Add(new Property("Camera sets count", "CAM-BIN", camCountDelegate));
            }
        }