當前位置: 首頁>>代碼示例>>C#>>正文


C# Acciones.Get_Format方法代碼示例

本文整理匯總了C#中Acciones.Get_Format方法的典型用法代碼示例。如果您正苦於以下問題:C# Acciones.Get_Format方法的具體用法?C# Acciones.Get_Format怎麽用?C# Acciones.Get_Format使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Acciones的用法示例。


在下文中一共展示了Acciones.Get_Format方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadFNT

        public static sFolder ReadFNT(string romFile, uint fntOffset, Estructuras.sFAT[] fat, Acciones accion)
        {
            sFolder root = new sFolder();
            root.files = new List<sFile>();
            List<Estructuras.MainFNT> mains = new List<Estructuras.MainFNT>();

            BinaryReader br = new BinaryReader(File.OpenRead(romFile));
            br.BaseStream.Position = fntOffset;

            br.BaseStream.Position += 6;
            ushort number_directories = br.ReadUInt16();  // Get the total number of directories (mainTables)
            br.BaseStream.Position = fntOffset;

            for (int i = 0; i < number_directories; i++)
            {
                Estructuras.MainFNT main = new Estructuras.MainFNT();
                main.offset = br.ReadUInt32();
                main.idFirstFile = br.ReadUInt16();
                main.idParentFolder = br.ReadUInt16();

                if (i != 0)
                {
                    if (br.BaseStream.Position > fntOffset + mains[0].offset)
                    {                                      //  Error, in some cases the number of directories is wrong
                        number_directories--;              // Found in FF Four Heroes of Light, Tetris Party deluxe
                        i--;
                        continue;
                    }
                }

                long currOffset = br.BaseStream.Position;           // Posición guardada donde empieza la siguienta maintable
                br.BaseStream.Position = fntOffset + main.offset;      // SubTable correspondiente

                // SubTable
                byte id = br.ReadByte();                            // Byte que identifica si es carpeta o archivo.
                ushort idFile = main.idFirstFile;

                while (id != 0x0)   // Indicador de fin de la SubTable
                {
                    if (id < 0x80)  // File
                    {
                        sFile currFile = new sFile();

                        if (!(main.subTable.files is List<sFile>))
                            main.subTable.files = new List<sFile>();

                        int lengthName = id;
                        currFile.name = new String(Encoding.GetEncoding("shift_jis").GetChars(br.ReadBytes(lengthName)));
                        currFile.id = idFile; idFile++;

                        // FAT part
                        currFile.offset = fat[currFile.id].offset;
                        currFile.size = fat[currFile.id].size;
                        currFile.path = romFile;

                        // Temporaly, for plugins (Get_Format):
                        root.files.Add(currFile);
                        accion.Root = root;

                        // Get the format
                        long pos = br.BaseStream.Position;
                        br.BaseStream.Position = currFile.offset;
                        currFile.format = accion.Get_Format(br.BaseStream, currFile.name, currFile.id, currFile.size);
                        br.BaseStream.Position = pos;

                        main.subTable.files.Add(currFile);
                    }
                    if (id > 0x80)  // Directorio
                    {
                        sFolder currFolder = new sFolder();

                        if (!(main.subTable.folders is List<sFolder>))
                            main.subTable.folders = new List<sFolder>();

                        int lengthName = id - 0x80;
                        currFolder.name = new String(Encoding.GetEncoding("shift_jis").GetChars(br.ReadBytes(lengthName)));
                        currFolder.id = br.ReadUInt16();

                        main.subTable.folders.Add(currFolder);
                    }

                    id = br.ReadByte();
                }

                mains.Add(main);
                br.BaseStream.Position = currOffset;
            }

            // Clear previous values
            root = new sFolder();
            accion.Root = new sFolder();

            root = Jerarquizar_Carpetas(mains, 0, "root");
            root.id = number_directories;

            br.Close();

            return root;
        }
開發者ID:MetLob,項目名稱:tinke,代碼行數:99,代碼來源:FNT.cs


注:本文中的Acciones.Get_Format方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。