2014-12-03 23:15:26 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
2014-02-26 14:11:06 +00:00
|
|
|
|
using System.Collections.Generic;
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
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).
2016-02-22 12:33:19 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Config;
|
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
2019-08-08 16:24:33 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2014-01-03 10:33:45 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.ZDoom
|
|
|
|
|
{
|
|
|
|
|
public sealed class VoxeldefParser : ZDTextParser
|
|
|
|
|
{
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
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).
2016-02-22 12:33:19 +00:00
|
|
|
|
internal override ScriptType ScriptType { get { return ScriptType.VOXELDEF; } }
|
|
|
|
|
|
2014-01-03 10:33:45 +00:00
|
|
|
|
private Dictionary<string, ModelData> entries; //sprite name, entry
|
|
|
|
|
internal Dictionary<string, ModelData> Entries { get { return entries; } }
|
|
|
|
|
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
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).
2016-02-22 12:33:19 +00:00
|
|
|
|
public override bool Parse(TextResourceData data, bool clearerrors)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2014-02-26 14:11:06 +00:00
|
|
|
|
entries = new Dictionary<string, ModelData>(StringComparer.Ordinal);
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
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).
2016-02-22 12:33:19 +00:00
|
|
|
|
|
|
|
|
|
//mxd. Already parsed?
|
|
|
|
|
if(!base.AddTextResource(data))
|
|
|
|
|
{
|
|
|
|
|
if(clearerrors) ClearError();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cannot process?
|
|
|
|
|
if(!base.Parse(data, clearerrors)) return false;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
|
|
|
|
List<string> spriteNames = new List<string>();
|
|
|
|
|
string modelName = string.Empty;
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
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).
2016-02-22 12:33:19 +00:00
|
|
|
|
string prevToken = string.Empty;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
|
|
|
|
// Continue until at the end of the stream
|
2014-12-03 23:15:26 +00:00
|
|
|
|
while(SkipWhitespace(true))
|
|
|
|
|
{
|
2016-04-06 22:54:04 +00:00
|
|
|
|
string token = ReadToken().ToLowerInvariant();
|
|
|
|
|
if(string.IsNullOrEmpty(token)) continue;
|
|
|
|
|
|
|
|
|
|
if(token == ",") //previous token was a sprite name
|
|
|
|
|
{
|
|
|
|
|
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
|
|
|
|
|
prevToken = StripQuotes(token).ToUpperInvariant();
|
|
|
|
|
}
|
|
|
|
|
else if(token == "=") //next token should be a voxel model name
|
|
|
|
|
{
|
|
|
|
|
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
|
|
|
|
|
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = ReadToken();
|
|
|
|
|
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
ReportError("Expected voxel name");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2016-07-11 22:13:43 +00:00
|
|
|
|
modelName = StripQuotes(token).ToUpperInvariant();
|
2016-04-06 22:54:04 +00:00
|
|
|
|
}
|
|
|
|
|
else if(token == "{") //read the settings
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-04-06 22:54:04 +00:00
|
|
|
|
ModelData mde = new ModelData { IsVoxel = true };
|
|
|
|
|
float scale = 1.0f;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
while(SkipWhitespace(true))
|
|
|
|
|
{
|
|
|
|
|
token = ReadToken().ToLowerInvariant();
|
|
|
|
|
if(string.IsNullOrEmpty(token)) continue;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
if(token == "}") //store data
|
|
|
|
|
{
|
|
|
|
|
if(!string.IsNullOrEmpty(modelName) && spriteNames.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
mde.ModelNames.Add(modelName);
|
2020-01-03 01:22:33 +00:00
|
|
|
|
mde.SetTransform(Matrix.RotationZ(Angle2D.DegToRad(mde.AngleOffset)), Matrix.Identity, new Vector3f(scale));
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
foreach(string s in spriteNames)
|
|
|
|
|
{
|
|
|
|
|
//TODO: is this the proper behaviour?
|
|
|
|
|
entries[s] = mde;
|
|
|
|
|
}
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
//reset local data
|
|
|
|
|
modelName = string.Empty;
|
|
|
|
|
prevToken = string.Empty;
|
|
|
|
|
spriteNames.Clear();
|
|
|
|
|
}
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if(token == "overridepalette")
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-04-06 22:54:04 +00:00
|
|
|
|
mde.OverridePalette = true;
|
|
|
|
|
}
|
|
|
|
|
else if(token == "angleoffset")
|
|
|
|
|
{
|
|
|
|
|
if(!NextTokenIs("=")) return false;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
token = ReadToken();
|
2016-07-11 22:13:43 +00:00
|
|
|
|
if(!ReadSignedFloat(token, ref mde.AngleOffset))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-04-06 22:54:04 +00:00
|
|
|
|
// Not numeric!
|
|
|
|
|
ReportError("Expected AngleOffset value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(token == "scale")
|
|
|
|
|
{
|
|
|
|
|
if(!NextTokenIs("=")) return false;
|
2015-12-17 10:07:28 +00:00
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
token = ReadToken();
|
|
|
|
|
if(!ReadSignedFloat(token, ref scale))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
ReportError("Expected Scale value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-06 22:54:04 +00:00
|
|
|
|
|
|
|
|
|
prevToken = StripQuotes(token).ToUpperInvariant();
|
2014-01-03 10:33:45 +00:00
|
|
|
|
}
|
2016-04-06 22:54:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
prevToken = StripQuotes(token).ToUpperInvariant();
|
2014-01-03 10:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return entries.Count > 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|