public bool Load(string fileName, bool clear)
{
if(clear == true)
{
Clear();
}
byte[] data = idE.FileSystem.ReadFile(fileName);
if(data == null)
{
// let whoever called us deal with the failure (so sys_lang can be reset)
return false;
}
idLexer lexer = new idLexer(LexerOptions.NoFatalErrors | LexerOptions.NoStringConcatination | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination);
lexer.LoadMemory(Encoding.UTF8.GetString(data), fileName);
if(lexer.IsLoaded == false)
{
return false;
}
idToken token, token2;
lexer.ExpectTokenString("{");
while((token = lexer.ReadToken()) != null)
{
if(token.ToString() == "}")
{
break;
}
else if((token2 = lexer.ReadToken()) != null)
{
if(token2.ToString() == "}")
{
break;
}
_regexReplaceIndex = 0;
// stock d3 language files contain sprintf formatters, we need to replace them
string val = token2.ToString();
val = Regex.Replace(val, "%s|%d|%x", new MatchEvaluator(ReplaceHandler));
_elements.Add(token.ToString(), val);
}
}
idConsole.WriteLine("{0} strings read from {1}", _elements.Count, fileName);
return true;
}
#endregion