private static ObjectManager.StaticObject LoadTextualX(string FileName, string Text, System.Text.Encoding Encoding, ObjectManager.ObjectLoadMode LoadMode, bool ForceTextureRepeatX, bool ForceTextureRepeatY) {
// load
string[] Lines = Text.Replace("\u000D\u000A", "\u2028").Split(new char[] { '\u000A', '\u000C', '\u000D', '\u0085', '\u2028', '\u2029' }, StringSplitOptions.None);
// strip away comments
bool Quote = false;
for (int i = 0; i < Lines.Length; i++) {
for (int j = 0; j < Lines[i].Length; j++) {
if (Lines[i][j] == '"') Quote = !Quote;
if (!Quote) {
if (Lines[i][j] == '#' || j < Lines[i].Length - 1 && Lines[i].Substring(j, 2) == "//") {
Lines[i] = Lines[i].Substring(0, j);
break;
}
}
}
}
// strip away header
if (Lines.Length == 0 || Lines[0].Length < 16) {
Interface.AddMessage(Interface.MessageType.Error, false, "The textual X object file is invalid at line 1 in " + FileName);
return null;
}
Lines[0] = Lines[0].Substring(16);
// join lines
System.Text.StringBuilder Builder = new System.Text.StringBuilder();
for (int i = 0; i < Lines.Length; i++) {
Builder.Append(Lines[i]);
}
string Content = Builder.ToString();
// parse file
int Position = 0;
Structure Structure;
if (!ReadTextualTemplate(FileName, Content, ref Position, new Template("", new string[] { "[...]" }), false, out Structure)) {
return null;
}
// process structure
ObjectManager.StaticObject Object;
if (!ProcessStructure(FileName, Structure, out Object, LoadMode, ForceTextureRepeatX, ForceTextureRepeatY)) {
return null;
}
return Object;
}