当前位置: 首页>>代码示例>>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;未经允许,请勿转载。