mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-12-11 04:41:00 +00:00
0f7aa9f827
Added, DECORATE parser: damage types are now parsed. Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads. Added, all text parsers: added #region/#endregion support. Added TERRAIN parser. Added, Script Editor: added special handling for DECORATE special comments. Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value. Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes. Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor. Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser. Cosmetic: changed ' to " in the rest of Error and Warning messages. Internal: added text resource tracking. Updated ZDoom_DECORATE.cfg. Updated documentation ("Game Configuration - Basic Settings" page).
113 lines
3 KiB
C#
113 lines
3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using CodeImp.DoomBuilder.Config;
|
|
using CodeImp.DoomBuilder.Data;
|
|
using CodeImp.DoomBuilder.ZDoom;
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|
{
|
|
internal class ModeldefParser : ZDTextParser
|
|
{
|
|
internal override ScriptType ScriptType { get { return ScriptType.MODELDEF; } }
|
|
|
|
private readonly Dictionary<string, int> actorsbyclass;
|
|
internal Dictionary<string, int> ActorsByClass { get { return actorsbyclass; } }
|
|
|
|
private Dictionary<string, ModelData> entries; //classname, entry
|
|
internal Dictionary<string, ModelData> Entries { get { return entries; } }
|
|
|
|
internal ModeldefParser(Dictionary<string, int> actorsbyclass)
|
|
{
|
|
this.actorsbyclass = actorsbyclass;
|
|
this.entries = new Dictionary<string, ModelData>(StringComparer.Ordinal);
|
|
}
|
|
|
|
//should be called after all decorate actors are parsed
|
|
public override bool Parse(TextResourceData data, bool clearerrors)
|
|
{
|
|
entries = new Dictionary<string, ModelData>(StringComparer.Ordinal);
|
|
|
|
//mxd. Already parsed?
|
|
if(!base.AddTextResource(data))
|
|
{
|
|
if(clearerrors) ClearError();
|
|
return true;
|
|
}
|
|
|
|
// Cannot process?
|
|
if(!base.Parse(data, clearerrors)) return false;
|
|
|
|
// Continue until at the end of the stream
|
|
while(SkipWhitespace(true))
|
|
{
|
|
string token = ReadToken();
|
|
if(!string.IsNullOrEmpty(token))
|
|
{
|
|
token = StripTokenQuotes(token).ToLowerInvariant();
|
|
if(token == "model") //model structure start
|
|
{
|
|
// Find classname
|
|
SkipWhitespace(true);
|
|
string displayclassname = StripTokenQuotes(ReadToken(ActorStructure.ACTOR_CLASS_SPECIAL_TOKENS));
|
|
string classname = displayclassname.ToLowerInvariant();
|
|
|
|
if(!string.IsNullOrEmpty(classname) && !entries.ContainsKey(classname))
|
|
{
|
|
// Now find opening brace
|
|
if(!NextTokenIs("{")) return false;
|
|
|
|
ModeldefStructure mds = new ModeldefStructure();
|
|
if(mds.Parse(this, displayclassname) && mds.ModelData != null)
|
|
{
|
|
entries.Add(classname, mds.ModelData);
|
|
}
|
|
|
|
if(HasError)
|
|
{
|
|
LogError();
|
|
ClearError();
|
|
}
|
|
|
|
// Skip untill current structure end
|
|
if(!mds.ParsingFinished) SkipStructure(1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Unknown structure!
|
|
if(token != "{")
|
|
{
|
|
string token2;
|
|
do
|
|
{
|
|
if(!SkipWhitespace(true)) break;
|
|
token2 = ReadToken();
|
|
if(string.IsNullOrEmpty(token2)) break;
|
|
}
|
|
while(token2 != "{");
|
|
}
|
|
|
|
SkipStructure(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
return entries.Count > 0;
|
|
}
|
|
|
|
// Skips untill current structure end
|
|
private void SkipStructure(int scopelevel)
|
|
{
|
|
do
|
|
{
|
|
if(!SkipWhitespace(true)) break;
|
|
string token = ReadToken();
|
|
if(string.IsNullOrEmpty(token)) break;
|
|
if(token == "{") scopelevel++;
|
|
if(token == "}") scopelevel--;
|
|
}
|
|
while(scopelevel > 0);
|
|
}
|
|
}
|
|
}
|