UltimateZoneBuilder/Source/Core/GZBuilder/GZDoom/ModeldefParserSE.cs
MaxED 15b2adfe30 Texture Browser Form: swapped foreground and background colors of texture size labels.
Fixed, Texture Browser Form: well, I broke "Tab" key functionality again (in previous commit)...
Maintenance: changed curly braces style to match DB2 one (hopefully not breaking anything in the process...).
Maintenance: changed private method names casing to match DB2 one.
2014-12-03 23:15:26 +00:00

58 lines
1.4 KiB
C#

#region ================== Namespaces
using System.IO;
using System.Collections.Generic;
using CodeImp.DoomBuilder.ZDoom;
using CodeImp.DoomBuilder.GZBuilder.Data;
#endregion
//mxd. Modeldef parser used to create ScriptItems for use in script editor's navigator
namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
{
internal sealed class ModeldefParserSE : ZDTextParser
{
private readonly List<ScriptItem> models;
internal List<ScriptItem> Models { get { return models; } }
public ModeldefParserSE()
{
models = new List<ScriptItem>();
}
public override bool Parse(Stream stream, string sourcefilename)
{
base.Parse(stream, sourcefilename);
// Continue until at the end of the stream
while (SkipWhitespace(true))
{
string token = ReadToken();
if (!string.IsNullOrEmpty(token))
{
token = token.ToUpperInvariant();
if(token == "MODEL")
{
int startPos = (int)stream.Position - 6;
SkipWhitespace(true);
string modelName = ReadToken();
SkipWhitespace(true);
token = ReadToken(); //this should be "{"
if (token == "{")
{
ScriptItem i = new ScriptItem(0, modelName, startPos, (int)stream.Position - 2);
models.Add(i);
}
}
}
}
//sort nodes
models.Sort(ScriptItem.SortByName);
return true;
}
}
}