Last active
January 22, 2017 18:11
-
-
Save synctam/d335b3197d448fc49842282cfe3967ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private const int HeaderLength = 16 * 2; | |
public List<LoadingScreenEntry> Items { get; } = new List<LoadingScreenEntry>(); | |
public void Read(string path) | |
{ | |
if (!File.Exists(path)) | |
{ | |
throw new FileNotFoundException(path); | |
} | |
Encoding enc = Encoding.UTF8; | |
using (BinaryReader binaryReader = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read))) | |
{ | |
//// header の読み込み | |
byte[] header = binaryReader.ReadBytes(HeaderLength); | |
byte[] tips = binaryReader.ReadBytes(4 + 8); | |
byte[] picture = binaryReader.ReadBytes(4 + 8); | |
byte[] version = binaryReader.ReadBytes(4 + 8); | |
float showMinTime = binaryReader.ReadSingle(); | |
int spliteCount = binaryReader.ReadInt32(); | |
Splite[] splite = new Splite[spliteCount]; | |
for (int i = 0; i < splite.Length; i++) | |
{ | |
splite[i].Data1 = binaryReader.ReadInt32(); | |
splite[i].Data2 = binaryReader.ReadInt64(); | |
} | |
int stringCount = binaryReader.ReadInt32(); | |
for (int i = 0; i < stringCount; i++) | |
{ | |
int length = binaryReader.ReadInt32(); | |
byte[] buff = binaryReader.ReadBytes(length); | |
string text = Encoding.UTF8.GetString(buff); | |
//// DWORD境界以外の場合はパディングをスキップする。 | |
int padLength = length % 4; | |
if (padLength != 0) | |
{ | |
byte[] pad = binaryReader.ReadBytes(4 - padLength); | |
} | |
LoadingScreenEntry entry = new LoadingScreenEntry(i, text, string.Empty); | |
this.Items.Add(entry); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment