2014-12-03 23:15:26 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System.IO;
|
2012-07-12 22:34:12 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using CodeImp.DoomBuilder.ZDoom;
|
|
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2012-07-12 22:34:12 +00:00
|
|
|
|
//mxd. Modeldef parser used to create ScriptItems for use in script editor's navigator
|
2014-12-03 23:15:26 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|
|
|
|
{
|
|
|
|
|
internal sealed class ModeldefParserSE : ZDTextParser
|
|
|
|
|
{
|
|
|
|
|
private readonly List<ScriptItem> models;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
internal List<ScriptItem> Models { get { return models; } }
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public ModeldefParserSE()
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
models = new List<ScriptItem>();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public override bool Parse(Stream stream, string sourcefilename)
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
base.Parse(stream, sourcefilename);
|
|
|
|
|
|
|
|
|
|
// Continue until at the end of the stream
|
2014-12-03 23:15:26 +00:00
|
|
|
|
while (SkipWhitespace(true))
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
string token = ReadToken();
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
token = token.ToUpperInvariant();
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(token == "MODEL")
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
SkipWhitespace(true);
|
2015-01-22 19:03:21 +00:00
|
|
|
|
int startPos = (int)stream.Position;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
string modelName = ReadToken();
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = ReadToken(); //this should be "{"
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if (token == "{")
|
|
|
|
|
{
|
2015-07-27 09:02:28 +00:00
|
|
|
|
ScriptItem i = new ScriptItem(modelName, startPos, false);
|
2013-09-11 09:47:53 +00:00
|
|
|
|
models.Add(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//sort nodes
|
|
|
|
|
models.Sort(ScriptItem.SortByName);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-12 22:34:12 +00:00
|
|
|
|
}
|