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
|
|
|
|
|
{
|
2015-03-21 19:41:54 +00:00
|
|
|
|
private readonly List<ScriptItem> actors;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
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
|
|
|
|
SkipWhitespace(true);
|
2015-01-22 19:03:21 +00:00
|
|
|
|
int startPos = (int)stream.Position;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
|
|
|
|
List<string> definition = new List<string>();
|
|
|
|
|
|
2015-03-21 19:41:54 +00:00
|
|
|
|
do
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-03-21 19:41:54 +00:00
|
|
|
|
token = ReadToken();
|
|
|
|
|
if(string.IsNullOrEmpty(token) || token == "{") break;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
definition.Add(token);
|
2015-03-21 19:41:54 +00:00
|
|
|
|
} while(SkipWhitespace(true));
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
|
|
|
|
string name = "";
|
2014-12-03 23:15:26 +00:00
|
|
|
|
foreach (string s in definition) name += s + " ";
|
2015-07-27 09:02:28 +00:00
|
|
|
|
actors.Add(new ScriptItem(name.TrimEnd(), startPos, false));
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//sort nodes
|
|
|
|
|
actors.Sort(ScriptItem.SortByName);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-12 22:34:12 +00:00
|
|
|
|
}
|