2015-12-18 10:16:53 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
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;
|
2015-12-19 00:05:34 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
2015-12-18 10:16:53 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.ZDoom
|
|
|
|
|
{
|
|
|
|
|
public struct CameraTextureData
|
|
|
|
|
{
|
|
|
|
|
public string Name;
|
|
|
|
|
public int Width;
|
|
|
|
|
public int Height;
|
|
|
|
|
public float ScaleX;
|
|
|
|
|
public float ScaleY;
|
|
|
|
|
public bool WorldPanning;
|
|
|
|
|
public bool FitTexture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//mxd. Currently this only parses cameratextures
|
|
|
|
|
internal sealed class AnimdefsParser : ZDTextParser
|
|
|
|
|
{
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
|
|
private readonly Dictionary<string, CameraTextureData> cameratextures;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
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.ANIMDEFS; } }
|
|
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
|
public Dictionary<string, CameraTextureData> CameraTextures { get { return cameratextures; } }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor
|
|
|
|
|
|
|
|
|
|
internal AnimdefsParser()
|
|
|
|
|
{
|
|
|
|
|
cameratextures = new Dictionary<string, CameraTextureData>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Parsing
|
|
|
|
|
|
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)
|
2015-12-18 10:16:53 +00:00
|
|
|
|
{
|
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
|
|
|
|
// Already parsed?
|
|
|
|
|
if(!base.AddTextResource(data))
|
|
|
|
|
{
|
|
|
|
|
if(clearerrors) ClearError();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cannot process?
|
|
|
|
|
if(!base.Parse(data, clearerrors)) return false;
|
2015-12-18 10:16:53 +00:00
|
|
|
|
|
|
|
|
|
// Continue until at the end of the stream
|
|
|
|
|
while(SkipWhitespace(true))
|
|
|
|
|
{
|
|
|
|
|
string token = ReadToken();
|
|
|
|
|
if(string.IsNullOrEmpty(token) || string.Compare(token, "CAMERATEXTURE", true) != 0) continue;
|
|
|
|
|
|
|
|
|
|
// Texture name
|
2015-12-28 21:56:10 +00:00
|
|
|
|
SkipWhitespace(true);
|
2016-04-06 22:54:04 +00:00
|
|
|
|
string texturename = StripQuotes(ReadToken(false));
|
2015-12-18 10:16:53 +00:00
|
|
|
|
if(string.IsNullOrEmpty(texturename))
|
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
ReportError("Expected camera texture name");
|
2015-12-19 00:05:34 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Camera texture names are limited to 8 chars
|
|
|
|
|
if(texturename.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
|
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
ReportError("Camera texture names must be no longer than " + DataManager.CLASIC_IMAGE_NAME_LENGTH + " chars");
|
2015-12-19 00:05:34 +00:00
|
|
|
|
return false;
|
2015-12-18 10:16:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Width
|
|
|
|
|
int width = -1;
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
if(!ReadSignedInt(ref width) || width < 1)
|
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
ReportError("Expected camera texture width");
|
2015-12-19 00:05:34 +00:00
|
|
|
|
return false;
|
2015-12-18 10:16:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Height
|
|
|
|
|
int height = -1;
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
if(!ReadSignedInt(ref height) || height < 1)
|
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
ReportError("Expected camera texture height");
|
2015-12-19 00:05:34 +00:00
|
|
|
|
return false;
|
2015-12-18 10:16:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// "Fit" keyword?
|
|
|
|
|
bool worldpanning = false;
|
|
|
|
|
bool fit = false;
|
|
|
|
|
float scalex = 1.0f;
|
|
|
|
|
float scaley = 1.0f;
|
|
|
|
|
|
|
|
|
|
if(NextTokenIs("fit", false))
|
|
|
|
|
{
|
|
|
|
|
fit = true;
|
|
|
|
|
int fitwidth = width;
|
|
|
|
|
int fitheight = height;
|
|
|
|
|
|
|
|
|
|
// Fit width
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
if(!ReadSignedInt(ref fitwidth) || fitwidth < 1)
|
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
ReportError("Expected camera texture fit width");
|
2015-12-19 00:05:34 +00:00
|
|
|
|
return false;
|
2015-12-18 10:16:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fit height
|
|
|
|
|
SkipWhitespace(true);
|
|
|
|
|
if(!ReadSignedInt(ref fitheight) || fitheight < 1)
|
|
|
|
|
{
|
2015-12-21 14:17:47 +00:00
|
|
|
|
ReportError("Expected camera texture fit height");
|
2015-12-19 00:05:34 +00:00
|
|
|
|
return false;
|
2015-12-18 10:16:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update scale
|
|
|
|
|
scalex = (float)fitwidth / width;
|
|
|
|
|
scaley = (float)fitheight / height;
|
|
|
|
|
|
|
|
|
|
// WorldPanning
|
|
|
|
|
worldpanning = NextTokenIs("worldpanning", false);
|
|
|
|
|
}
|
|
|
|
|
else if(NextTokenIs("worldpanning", false))
|
|
|
|
|
{
|
|
|
|
|
worldpanning = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check results
|
|
|
|
|
if(cameratextures.ContainsKey(texturename.ToUpperInvariant()))
|
|
|
|
|
{
|
2016-03-08 20:41:06 +00:00
|
|
|
|
ReportError("Camera texture \"" + texturename + "\" is defined more than once");
|
2015-12-19 00:05:34 +00:00
|
|
|
|
return false;
|
2015-12-18 10:16:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Store results
|
|
|
|
|
texturename = texturename.ToUpperInvariant();
|
|
|
|
|
cameratextures[texturename] = new CameraTextureData { Name = texturename, Width = width, Height = height,
|
|
|
|
|
ScaleX = scalex, ScaleY = scaley,
|
|
|
|
|
WorldPanning = worldpanning, FitTexture = fit };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|