2013-04-11 11:04:16 +00:00
|
|
|
|
using System.IO;
|
2012-07-12 22:34:12 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using CodeImp.DoomBuilder.ZDoom;
|
|
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
|
|
|
|
|
|
|
|
|
//mxd. Decorate parser used to create ScriptItems for use in script editor's navigator
|
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
internal sealed class DecorateParserSE : ZDTextParser
|
|
|
|
|
{
|
|
|
|
|
private List<ScriptItem> actors;
|
|
|
|
|
public List<ScriptItem> Actors { get { return actors; } }
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public DecorateParserSE()
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
actors = 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.ToLowerInvariant();
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if (token == "actor")
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
int startPos = (int)stream.Position - 6;
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
|
|
|
|
|
List<string> definition = new List<string>();
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
while ((token = ReadToken()) != "{")
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
definition.Add(token);
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string name = "";
|
2014-12-03 23:15:26 +00:00
|
|
|
|
foreach (string s in definition) name += s + " ";
|
2013-09-11 09:47:53 +00:00
|
|
|
|
actors.Add(new ScriptItem(0, name.TrimEnd(), startPos, (int)stream.Position - 2));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//sort nodes
|
|
|
|
|
actors.Sort(ScriptItem.SortByName);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-12 22:34:12 +00:00
|
|
|
|
}
|