示例#1
0
 public void SongInfoReadTest(string binName, string xlsxName)
 {
     using XlsxWriter xlsx = new XlsxWriter(xlsxName, true);
     using FileStream stream = new FileStream(binName, FileMode.Open, FileAccess.Read);
     IEnumerable<Record> records = SongInfo.ReadFile(stream);
     xlsx.AppendRows("songInfo", records);
 }
示例#2
0
        public static void ReadFile(Stream stream, XlsxWriter xlsx)
        {
            if (sheetNames.Any(sheetName => xlsx.HasWorksheet(sheetName)))
            {
                return;
            }
            int          count1  = Binary.ReadInt32(stream, true);
            const string format1 = "iiiss";

            Record[] records1 = new Record[count1];
            for (int i = 0; i < count1; i++)
            {
                records1[i] = new Record(format1);
                records1[i].Deserialise(stream);
            }
            xlsx.AppendRows("fanLetterInfo1", records1);

            int          count2  = Binary.ReadInt32(stream, true);
            const string format2 = "iii";

            Record[] records2 = new Record[count2];
            for (int i = 0; i < count2; i++)
            {
                records2[i] = new Record(format2);
                records2[i].Deserialise(stream);
            }
            xlsx.AppendRows("fanLetterInfo2", records2);

            int          count3  = Binary.ReadInt32(stream, true);
            const string format3 = "iii";

            Record[] records3 = new Record[count3];
            for (int i = 0; i < count3; i++)
            {
                records3[i] = new Record(format3);
                records3[i].Deserialise(stream);
            }
            xlsx.AppendRows("fanLetterInfo3", records3);

            int          count4  = Binary.ReadInt32(stream, true);
            const string format4 = "ss";

            Record[] records4 = new Record[count4];
            for (int i = 0; i < count4; i++)
            {
                records4[i] = new Record(format4);
                records4[i].Deserialise(stream);
            }
            xlsx.AppendRows("fanLetterInfo4", records4);

            int          lettCount  = Binary.ReadInt32(stream, true);
            const string lettFormat = "iiiiiiII";

            Record[] letts = new Record[lettCount];
            for (int i = 0; i < lettCount; i++)
            {
                letts[i] = new Record(lettFormat);
                letts[i].Deserialise(stream);
            }

            const string format6 = "i";

            Record[] records6 = new Record[6];
            for (int i = 0; i < 6; i++)
            {
                records6[i] = new Record(format6);
                records6[i].Deserialise(stream);
            }
            xlsx.AppendRows("fanLetterInfo6", records6);

            int stringPos = (int)stream.Position;

            int           id          = 0;
            List <Record> lettStrings = new List <Record>();

            string[] stringSheetHeaders = { "ID", "Position", "Text" };
            do
            {
                Record record = new Record("IIX", stringSheetHeaders);
                record[0] = id;
                record[1] = (int)(stream.Position - stringPos) / 2;
                ushort        c;
                StringBuilder stringBuilder = new StringBuilder();
                while ((c = Binary.ReadUInt16(stream, true)) != 0)
                {
                    stringBuilder.Append((char)c);
                }
                record[2] = stringBuilder.ToString();

                lettStrings.Add(record);
                id++;
            } while (stream.Position < stream.Length);

            foreach (Record record in letts)
            {
                record[6] = lettStrings.FindIndex(r => (int)r[1] == (int)record[4]);
                record[7] = lettStrings.FindIndex(r => (int)r[1] == (int)record[5]);
            }
            xlsx.AppendRows("fanLetterInts", letts);
            xlsx.AppendRows("fanLetterStrings", lettStrings);
        }
示例#3
0
        public static void ReadFile(Stream stream, XlsxWriter xlsx)
        {
            if (xlsx.HasWorksheet("jaJp") || xlsx.HasWorksheet("jaJpStrings"))
            {
                return;
            }
            List <Record> list       = new List <Record>();
            List <Record> stringList = new List <Record>();
            Binary        binary     = new Binary(stream, false);

            binary.ReadInt32();
            int stringOffset = binary.ReadInt32();
            int recordCount  = binary.ReadInt32();
            int data2Offset  = binary.ReadInt32();

            for (int i = 0; i < recordCount; i++)
            {
                Record record = new Record("IIIII");
                list.Add(record);
            }
            for (int i = 0; i < recordCount; i++)
            {
                list[i][0] = binary.ReadInt32();
                list[i][1] = binary.ReadInt32();
            }
            stream.Position = data2Offset;
            for (int i = 0; i < recordCount; i++)
            {
                list[i][2] = binary.ReadInt32();
                list[i][3] = binary.ReadInt32();
            }

            stream.Position = stringOffset;
            int id = 0;

            string[] stringSheetHeaders = { "ID", "Position", "Text", "Use UTF16 Encoding" };
            do
            {
                Record record = new Record("IIXI", stringSheetHeaders);
                record[0] = id;
                record[1] = (int)(stream.Position - stringOffset);
                ushort        c;
                StringBuilder stringBuilder = new StringBuilder();
                while ((c = binary.ReadUInt16()) != 0)
                {
                    stringBuilder.Append((char)c);
                }
                record[2] = stringBuilder.ToString();
                record[3] = 0;

                stringList.Add(record);
                id++;
            } while (stream.Position < stream.Length);

            foreach (Record record in list)
            {
                record[4] = stringList.FindIndex(r => (int)r[1] == (int)record[1]);
            }

            xlsx.AppendRows("jaJp", list);
            xlsx.AppendRows("jaJpStrings", stringList);
        }
示例#4
0
        public static void ReadFile(Stream stream, XlsxWriter xlsx)
        {
            if (xlsx.HasWorksheet("skillBoard") || xlsx.HasWorksheet("skillBoardStrings"))
            {
                return;
            }
            List <Record> list        = new List <Record>();
            List <Record> stringList  = new List <Record>();
            Binary        binary      = new Binary(stream, true);
            int           recordCount = binary.ReadInt32();
            int           strBufLen   = binary.ReadInt32();

            byte[] strBuf = new byte[strBufLen * 2];
            stream.Read(strBuf);

            for (int j = 0; j < recordCount; j++)
            {
                Record record = new Record("iiiiiIII");
                record.Deserialise(stream);

                list.Add(record);
            }

            int stringIndex = 0;
            int i           = 0;

            char getChar()
            {
                char cc = (char)(256 * strBuf[2 * i] + strBuf[2 * i + 1]);

                i++;
                return(cc);
            }

            string[] stringSheetHeaders = { "Position", "ID", "Text" };
            while (i < strBufLen)
            {
                Record record = new Record("IIX", stringSheetHeaders);
                record[0] = i;
                record[1] = stringIndex++;
                StringBuilder sb = new StringBuilder();
                char          c;
                while ((c = getChar()) != 0)
                {
                    sb.Append(c);
                }
                record[2] = sb.ToString();
                stringList.Add(record);
            }

            for (int j = 0; j < recordCount; j++)
            {
                Record strRecord;
                strRecord  = stringList.Find(r => (int)r[0] == (int)list[j][2]);
                list[j][5] = strRecord[1];
                strRecord  = stringList.Find(r => (int)r[0] == (int)list[j][3]);
                list[j][6] = strRecord[1];
                strRecord  = stringList.Find(r => (int)r[0] == (int)list[j][4]);
                list[j][7] = strRecord[1];
            }

            xlsx.AppendRows("skillBoard", list);
            xlsx.AppendRows("skillBoardStrings", stringList);
        }