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;
|
|
|
|
|
using SlimDX;
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
|
string token = ReadToken();
|
|
|
|
|
|
2015-06-18 19:45:39 +00:00
|
|
|
|
if(!string.IsNullOrEmpty(token))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
|
token = StripTokenQuotes(token).ToLowerInvariant();
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(token == ",") //previous token was a sprite name
|
|
|
|
|
{
|
2015-03-21 19:41:54 +00:00
|
|
|
|
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
|
2014-01-03 10:33:45 +00:00
|
|
|
|
prevToken = token.ToUpperInvariant();
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if(token == "=") //next token should be a voxel model name
|
|
|
|
|
{
|
2015-03-21 19:41:54 +00:00
|
|
|
|
if(!string.IsNullOrEmpty(prevToken) && !spriteNames.Contains(prevToken)) spriteNames.Add(prevToken);
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
token = ReadToken();
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
2015-12-17 10:07:28 +00:00
|
|
|
|
ReportError("Expected voxel name");
|
|
|
|
|
return false;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modelName = StripTokenQuotes(token).ToLowerInvariant();
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if(token == "{") //read the settings
|
|
|
|
|
{
|
2015-12-17 10:07:28 +00:00
|
|
|
|
ModelData mde = new ModelData { IsVoxel = true };
|
2014-12-22 21:36:49 +00:00
|
|
|
|
float scale = 1.0f;
|
|
|
|
|
float angleoffset = 0;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
while(SkipWhitespace(true))
|
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
|
token = ReadToken();
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(!string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
|
token = StripTokenQuotes(token).ToLowerInvariant();
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(token == "}") //store data
|
|
|
|
|
{
|
|
|
|
|
if(!string.IsNullOrEmpty(modelName) && spriteNames.Count > 0)
|
|
|
|
|
{
|
2014-12-22 21:36:49 +00:00
|
|
|
|
mde.ModelNames.Add(modelName);
|
|
|
|
|
mde.SetTransform(Matrix.RotationZ(Angle2D.DegToRad(angleoffset)), Matrix.Identity, new Vector3(scale));
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
foreach(string s in spriteNames)
|
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
//TODO: is this the proper behaviour?
|
|
|
|
|
entries[s] = mde;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//reset local data
|
|
|
|
|
modelName = string.Empty;
|
|
|
|
|
prevToken = string.Empty;
|
|
|
|
|
spriteNames.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
2015-12-21 14:17:47 +00:00
|
|
|
|
else if(token == "overridepalette")
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2014-12-22 21:36:49 +00:00
|
|
|
|
mde.OverridePalette = true;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
2015-12-21 14:17:47 +00:00
|
|
|
|
else if(token == "angleoffset")
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
if(!NextTokenIs("=")) return false;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
2015-12-21 14:17:47 +00:00
|
|
|
|
if(!ReadSignedFloat(token, ref angleoffset))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
|
// Not numeric!
|
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
|
|
|
|
ReportError("Expected AngleOffset value, but got \"" + token + "\"");
|
2015-12-17 10:07:28 +00:00
|
|
|
|
return false;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else if(token == "scale")
|
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
if(!NextTokenIs("=")) return false;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
|
|
|
|
token = StripTokenQuotes(ReadToken());
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if(!ReadSignedFloat(token, ref scale))
|
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
|
// Not numeric!
|
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
|
|
|
|
ReportError("Expected Scale value, but got \"" + token + "\"");
|
2015-12-17 10:07:28 +00:00
|
|
|
|
return false;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-17 10:07:28 +00:00
|
|
|
|
|
2014-01-03 10:33:45 +00:00
|
|
|
|
prevToken = token.ToUpperInvariant();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
|
prevToken = token.ToUpperInvariant();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return entries.Count > 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|