-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathRTextParser.cs
85 lines (72 loc) · 2.06 KB
/
RTextParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Syroot.BinaryData;
namespace PDTools.RText;
public class RTextParser
{
public RTextBase RText { get; set; }
public string LocaleCode { get; set; }
public static readonly Dictionary<string, string> Locales = new()
{
{ "BP", "Portuguese (Brazillian)" },
{ "CN", "Chinese (China)" },
{ "CZ", "Czech" },
{ "DK", "Danish" }, // Stubbed in GT6
{ "DE", "German" },
{ "EL", "Greek" },
{ "ES", "Spanish" },
{ "FI", "Finnish" }, // Stubbed in GT6
{ "FR", "French" },
{ "GB", "British" },
{ "HU", "Magyar (Hungary)" },
{ "IT", "Italian" },
{ "JP", "Japanese" },
{ "KR", "Korean" },
{ "MS", "Spanish (Mexican)" },
{ "NO", "Norwegian" },
{ "NL", "Dutch" },
{ "PL", "Polish" },
{ "PT", "Portuguese" },
{ "RU", "Russian" },
{ "SE", "Swedish" },
{ "TR", "Turkish" },
{ "TW", "Chinese (Taiwan)" },
{ "US", "American" }
};
public RTextParser()
{
}
public void Read(byte[] data)
{
using var ms = new MemoryStream(data);
using var reader = new BinaryStream(ms);
switch (reader.ReadUInt32())
{
case 0x35305450: // RT03
RText = new RT03();
break;
case 0x35305451: // RT04
RText = new RT04();
break;
case 0x35305452: // RT05
RText = new RT05();
break;
case 0x52543035: // 50TR
try
{
RText = new _50TR();
RText.Read(data);
return;
}
catch { }
// Failed, try GT7
RText = new _50TR(gt7: true);
break;
default:
throw new InvalidDataException("Unknown header magic.");
}
RText.Read(data);
}
}