2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
|
|
|
using System;
|
2016-01-11 13:00:52 +00:00
|
|
|
using System.Collections.Generic;
|
2009-04-19 18:07:22 +00:00
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
|
|
|
using System.IO;
|
2015-11-28 23:31:54 +00:00
|
|
|
using CodeImp.DoomBuilder.Compilers;
|
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-21 14:17:47 +00:00
|
|
|
using CodeImp.DoomBuilder.Data;
|
2016-11-24 11:55:11 +00:00
|
|
|
using CodeImp.DoomBuilder.Data.Scripting;
|
2016-03-16 23:26:53 +00:00
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.ZDoom
|
|
|
|
{
|
2016-02-02 14:29:19 +00:00
|
|
|
public abstract class ZDTextParser
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
2015-12-21 14:17:47 +00:00
|
|
|
|
|
|
|
protected static readonly string RELATIVE_PATH_MARKER = ".." + Path.DirectorySeparatorChar;
|
|
|
|
protected static readonly string CURRENT_FOLDER_PATH_MARKER = "." + Path.DirectorySeparatorChar;
|
|
|
|
protected static readonly string ALT_RELATIVE_PATH_MARKER = ".." + Path.AltDirectorySeparatorChar;
|
|
|
|
protected static readonly string ALT_CURRENT_FOLDER_PATH_MARKER = "." + Path.AltDirectorySeparatorChar;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Parsing
|
2013-11-18 12:36:42 +00:00
|
|
|
protected string whitespace = "\n \t\r\u00A0\0"; //mxd. non-breaking space is also space :)
|
2009-04-19 18:07:22 +00:00
|
|
|
protected string specialtokens = ":{}+-\n;";
|
2016-05-13 13:41:09 +00:00
|
|
|
protected bool skipregions; //mxd
|
2016-06-05 22:06:56 +00:00
|
|
|
protected bool skipeditorcomments; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Input data stream
|
|
|
|
protected Stream datastream;
|
|
|
|
protected BinaryReader datareader;
|
|
|
|
protected string sourcename;
|
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
|
|
|
protected int sourcelumpindex; //mxd
|
|
|
|
protected DataLocation datalocation; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Error report
|
|
|
|
private int errorline;
|
|
|
|
private string errordesc;
|
2016-03-07 20:01:13 +00:00
|
|
|
private string errorsource; // Rooted path to the troubling file
|
|
|
|
private string shorterrorsource; //mxd. Resource name + filename
|
2017-01-15 22:00:45 +00:00
|
|
|
protected long prevstreamposition; //mxd. Text stream position storted before performing ReadToken.
|
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. Text lumps
|
|
|
|
protected string textresourcepath;
|
2016-11-24 11:55:11 +00:00
|
|
|
protected readonly Dictionary<string, ScriptResource> scriptresources;
|
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
|
|
|
protected readonly HashSet<string> untrackedtextresources;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
internal Stream DataStream { get { return datastream; } }
|
|
|
|
internal BinaryReader DataReader { get { return datareader; } }
|
|
|
|
public int ErrorLine { get { return errorline; } }
|
|
|
|
public string ErrorDescription { get { return errordesc; } }
|
|
|
|
public string ErrorSource { get { return errorsource; } }
|
|
|
|
public bool HasError { get { return (errordesc != null); } }
|
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 abstract ScriptType ScriptType { get; } //mxd
|
2016-11-24 11:55:11 +00:00
|
|
|
internal Dictionary<string, ScriptResource> ScriptResources { get { return scriptresources; } } //mxd
|
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
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
protected ZDTextParser()
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
errordesc = null;
|
2016-11-24 11:55:11 +00:00
|
|
|
scriptresources = new Dictionary<string, ScriptResource>(StringComparer.OrdinalIgnoreCase); //mxd
|
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
|
|
|
untrackedtextresources = new HashSet<string>(StringComparer.OrdinalIgnoreCase); //mxd
|
2016-05-13 13:41:09 +00:00
|
|
|
skipregions = true; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Parsing
|
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
//mxd. This parses the given decorate stream. Returns false on errors
|
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 virtual bool Parse(TextResourceData parsedata, bool clearerrors)
|
2014-10-23 12:48:31 +00:00
|
|
|
{
|
2016-03-25 14:06:00 +00:00
|
|
|
// Clear error status?
|
2015-12-18 10:16:53 +00:00
|
|
|
if(clearerrors) ClearError();
|
2016-03-25 14:06:00 +00:00
|
|
|
|
|
|
|
// Integrity checks
|
|
|
|
// INFO: MapManager.CompileLump() prepends lumpname with "?" to distinguish between temporary files and files compiled in place
|
|
|
|
// We don't want this to show up in error messages
|
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
|
|
|
if(parsedata.Stream == null)
|
2014-10-23 12:48:31 +00:00
|
|
|
{
|
2016-03-25 14:06:00 +00:00
|
|
|
ReportError("Unable to load \"" + parsedata.Filename.Replace("?", "") + "\"");
|
2015-12-18 10:16:53 +00:00
|
|
|
return false;
|
2014-10-23 12:48:31 +00:00
|
|
|
}
|
2016-01-11 13:00:52 +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
|
|
|
if(parsedata.Stream.Length == 0)
|
2016-01-11 13:00:52 +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
|
|
|
if(!string.IsNullOrEmpty(sourcename) && sourcename != parsedata.Filename)
|
2016-01-20 17:54:56 +00:00
|
|
|
{
|
2016-03-25 14:06:00 +00:00
|
|
|
LogWarning("Include file \"" + parsedata.Filename.Replace("?", "") + "\" is empty");
|
2016-01-20 17:54:56 +00:00
|
|
|
}
|
2016-01-11 13:00:52 +00:00
|
|
|
else
|
2016-01-20 17:54:56 +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
|
|
|
sourcename = parsedata.Filename; // LogWarning() needs "sourcename" property to properly log the warning...
|
2016-01-11 13:00:52 +00:00
|
|
|
LogWarning("File is empty");
|
2016-01-20 17:54:56 +00:00
|
|
|
}
|
2016-01-11 13:00:52 +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
|
|
|
|
|
|
|
datastream = parsedata.Stream;
|
|
|
|
datareader = new BinaryReader(parsedata.Stream, Encoding.ASCII);
|
|
|
|
sourcename = parsedata.Filename;
|
2016-03-25 14:06:00 +00:00
|
|
|
sourcelumpindex = parsedata.LumpIndex;
|
|
|
|
datalocation = parsedata.SourceLocation;
|
2009-04-19 18:07:22 +00:00
|
|
|
datastream.Seek(0, SeekOrigin.Begin);
|
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
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
|
|
|
protected bool AddTextResource(TextResourceData parsedata)
|
|
|
|
{
|
|
|
|
// Script Editor resources don't have actual path and should always be parsed
|
|
|
|
if(string.IsNullOrEmpty(parsedata.SourceLocation.location))
|
|
|
|
{
|
|
|
|
if(parsedata.Trackable) throw new NotSupportedException("Trackable TextResource must have a valid path.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
string path = Path.Combine(parsedata.SourceLocation.location, parsedata.Filename + (parsedata.LumpIndex != -1 ? "#" + parsedata.LumpIndex : ""));
|
2016-11-24 11:55:11 +00:00
|
|
|
if(scriptresources.ContainsKey(path) || untrackedtextresources.Contains(path))
|
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
|
|
|
return false;
|
|
|
|
|
|
|
|
//mxd. Create TextResource for this file
|
|
|
|
if(parsedata.Trackable)
|
|
|
|
{
|
|
|
|
textresourcepath = path;
|
2016-11-24 11:55:11 +00:00
|
|
|
ScriptResource res = new ScriptResource(parsedata, this.ScriptType);
|
|
|
|
scriptresources.Add(textresourcepath, res);
|
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
|
|
|
}
|
|
|
|
// Track the untrackable!
|
|
|
|
else
|
|
|
|
{
|
|
|
|
untrackedtextresources.Add(path);
|
|
|
|
textresourcepath = string.Empty;
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This returns true if the given character is whitespace
|
2015-02-04 18:02:03 +00:00
|
|
|
private bool IsWhitespace(char c)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
return (whitespace.IndexOf(c) > -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This returns true if the given character is a special token
|
2015-02-04 18:02:03 +00:00
|
|
|
private bool IsSpecialToken(char c)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
return (specialtokens.IndexOf(c) > -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This returns true if the given character is a special token
|
2009-08-15 08:41:43 +00:00
|
|
|
protected internal bool IsSpecialToken(string s)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
if(s.Length > 0) return (specialtokens.IndexOf(s[0]) > -1);
|
|
|
|
return false;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2015-02-04 18:02:03 +00:00
|
|
|
|
|
|
|
//mxd. This removes beginning and ending quotes from a token
|
|
|
|
protected internal string StripTokenQuotes(string token)
|
|
|
|
{
|
|
|
|
return StripQuotes(token);
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// This removes beginning and ending quotes from a token
|
2015-02-04 18:02:03 +00:00
|
|
|
internal static string StripQuotes(string token)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Remove first character, if it is a quote
|
|
|
|
if(!string.IsNullOrEmpty(token) && (token[0] == '"'))
|
|
|
|
token = token.Substring(1);
|
|
|
|
|
|
|
|
// Remove last character, if it is a quote
|
|
|
|
if(!string.IsNullOrEmpty(token) && (token[token.Length - 1] == '"'))
|
|
|
|
token = token.Substring(0, token.Length - 1);
|
|
|
|
|
|
|
|
return token;
|
|
|
|
}
|
2016-11-09 10:07:21 +00:00
|
|
|
|
|
|
|
//mxd
|
|
|
|
internal bool ReadTextureName(out string name) { return ReadTextureName(out name, "texture"); }
|
|
|
|
internal bool ReadTextureName(out string name, string elementname)
|
|
|
|
{
|
|
|
|
string token = ReadToken(false);
|
|
|
|
name = StripQuotes(token);
|
|
|
|
|
|
|
|
if(!string.IsNullOrEmpty(name)
|
|
|
|
&& name.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH
|
|
|
|
&& name.Length == token.Length)
|
|
|
|
{
|
|
|
|
ReportError("Long " + elementname + " names must be quoted. See \"" + token + "\"");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// This skips whitespace on the stream, placing the read
|
|
|
|
// position right before the first non-whitespace character
|
|
|
|
// Returns false when the end of the stream is reached
|
2009-08-15 08:41:43 +00:00
|
|
|
protected internal bool SkipWhitespace(bool skipnewline)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
int offset = skipnewline ? 0 : 1;
|
|
|
|
char c;
|
2015-08-28 13:36:36 +00:00
|
|
|
prevstreamposition = datastream.Position; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if(datastream.Position == datastream.Length) return false;
|
|
|
|
c = (char)datareader.ReadByte();
|
|
|
|
|
|
|
|
// Check if this is comment
|
|
|
|
if(c == '/')
|
|
|
|
{
|
|
|
|
if(datastream.Position == datastream.Length) return false;
|
|
|
|
char c2 = (char)datareader.ReadByte();
|
|
|
|
if(c2 == '/')
|
|
|
|
{
|
|
|
|
// Check if not a special comment with a token
|
|
|
|
if(datastream.Position == datastream.Length) return false;
|
|
|
|
char c3 = (char)datareader.ReadByte();
|
2016-06-05 22:06:56 +00:00
|
|
|
if(skipeditorcomments || c3 != '$') //mxd. Added skipeditorcomments
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Skip entire line
|
|
|
|
char c4 = ' ';
|
|
|
|
while((c4 != '\n') && (datastream.Position < datastream.Length)) { c4 = (char)datareader.ReadByte(); }
|
2010-08-01 20:08:29 +00:00
|
|
|
c = c4;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Not a comment
|
|
|
|
c = c3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(c2 == '*')
|
|
|
|
{
|
|
|
|
// Skip until */
|
|
|
|
char c4, c3 = '\0';
|
2015-08-28 13:36:36 +00:00
|
|
|
prevstreamposition = datastream.Position; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
do
|
|
|
|
{
|
2015-06-24 07:46:08 +00:00
|
|
|
if(datastream.Position == datastream.Length) //mxd
|
|
|
|
{
|
|
|
|
// ZDoom doesn't give even a warning message about this, so we shouldn't report error or fail parsing.
|
2016-11-26 00:02:56 +00:00
|
|
|
string message = ScriptType + " warning in \"" + sourcename + "\", line " + GetCurrentLineNumber() + ". Block comment is not closed.";
|
|
|
|
TextResourceErrorItem error = new TextResourceErrorItem(ErrorType.Warning, ScriptType, datalocation, sourcename, sourcelumpindex, GetCurrentLineNumber(), message);
|
|
|
|
General.ErrorLogger.Add(error);
|
2015-08-28 13:36:36 +00:00
|
|
|
return false;
|
2015-06-24 07:46:08 +00:00
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
c4 = c3;
|
|
|
|
c3 = (char)datareader.ReadByte();
|
|
|
|
}
|
|
|
|
while((c4 != '*') || (c3 != '/'));
|
|
|
|
c = ' ';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Not a comment, rewind from reading c2
|
|
|
|
datastream.Seek(-1, SeekOrigin.Current);
|
|
|
|
}
|
|
|
|
}
|
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. Region/endregion handling
|
2016-05-13 13:41:09 +00:00
|
|
|
else if(skipregions && c == '#')
|
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
|
|
|
{
|
2016-08-31 15:14:55 +00:00
|
|
|
long startpos = datastream.Position - 1;
|
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 s = ReadToken(false).ToLowerInvariant();
|
|
|
|
if(s == "region" || s == "endregion")
|
|
|
|
{
|
|
|
|
// Skip entire line
|
|
|
|
char ch = ' ';
|
|
|
|
while((ch != '\n') && (datastream.Position < datastream.Length)) { ch = (char)datareader.ReadByte(); }
|
|
|
|
c = ch;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Rewind so this structure can be read again
|
2016-08-31 15:14:55 +00:00
|
|
|
DataStream.Seek(startpos, SeekOrigin.Begin);
|
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
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
while(whitespace.IndexOf(c, offset) > -1);
|
|
|
|
|
|
|
|
// Go one character back so we can read this non-whitespace character again
|
|
|
|
datastream.Seek(-1, SeekOrigin.Current);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This reads a token (all sequential non-whitespace characters or a single character)
|
|
|
|
// Returns null when the end of the stream has been reached
|
2015-12-17 10:07:28 +00:00
|
|
|
protected internal string ReadToken() { return ReadToken(true); } //mxd. Added "multiline" param
|
|
|
|
protected internal string ReadToken(bool multiline)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2015-06-18 19:45:39 +00:00
|
|
|
//mxd. Return empty string when the end of the stream has been reached
|
|
|
|
if(datastream.Position == datastream.Length) return string.Empty;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
|
|
|
//mxd. Store starting position
|
|
|
|
prevstreamposition = datastream.Position;
|
|
|
|
|
2014-01-03 10:33:45 +00:00
|
|
|
string token = "";
|
|
|
|
bool quotedstring = false;
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Start reading
|
|
|
|
char c = (char)datareader.ReadByte();
|
|
|
|
while(!IsWhitespace(c) || quotedstring || IsSpecialToken(c))
|
|
|
|
{
|
2015-12-17 10:07:28 +00:00
|
|
|
//mxd. Break at newline?
|
|
|
|
if(!multiline && c == '\r')
|
|
|
|
{
|
|
|
|
// Go one character back so line number is correct
|
|
|
|
datastream.Seek(-1, SeekOrigin.Current);
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Special token?
|
|
|
|
if(!quotedstring && IsSpecialToken(c))
|
|
|
|
{
|
|
|
|
// Not reading a token yet?
|
|
|
|
if(token.Length == 0)
|
|
|
|
{
|
|
|
|
// This is our whole token
|
|
|
|
token += c;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// This is a new token and shouldn't be read now
|
|
|
|
// Go one character back so we can read this token again
|
|
|
|
datastream.Seek(-1, SeekOrigin.Current);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Quote?
|
|
|
|
if(c == '"')
|
|
|
|
{
|
|
|
|
// Quote to end the string?
|
|
|
|
if(quotedstring) quotedstring = false;
|
|
|
|
|
|
|
|
// First character is a quote?
|
|
|
|
if(token.Length == 0) quotedstring = true;
|
|
|
|
|
|
|
|
token += c;
|
2016-07-14 14:28:42 +00:00
|
|
|
|
|
|
|
//mxd. Break after closing quote
|
|
|
|
if(!quotedstring) break;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
// Potential comment?
|
2010-08-17 10:02:07 +00:00
|
|
|
else if((c == '/') && !quotedstring)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Check the next byte
|
|
|
|
if(datastream.Position == datastream.Length) return token;
|
|
|
|
char c2 = (char)datareader.ReadByte();
|
|
|
|
if((c2 == '/') || (c2 == '*'))
|
|
|
|
{
|
|
|
|
// This is a comment start, so the token ends here
|
|
|
|
// Go two characters back so we can read this comment again
|
|
|
|
datastream.Seek(-2, SeekOrigin.Current);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Not a comment
|
|
|
|
// Go one character back so we can read this char again
|
|
|
|
datastream.Seek(-1, SeekOrigin.Current);
|
|
|
|
token += c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
token += c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Next character
|
|
|
|
if(datastream.Position < datastream.Length)
|
|
|
|
c = (char)datareader.Read();
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2014-01-03 10:33:45 +00:00
|
|
|
// This reads a token (all sequential non-whitespace characters or a single character) using custom set of special tokens
|
|
|
|
// Returns null when the end of the stream has been reached (mxd)
|
2014-12-03 23:15:26 +00:00
|
|
|
protected internal string ReadToken(string specialTokens)
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
// Return null when the end of the stream has been reached
|
|
|
|
if(datastream.Position == datastream.Length) return null;
|
Added, Visual mode, GLDEFS, GLOOME: subtractive glow is now supported.
Changed, Visual mode: changed thing fog calculation logic. Should be closer to GZDoom now.
Fixed, GLDEFS parser: "height" texture parameter was not treated as optional.
Fixed, text lump parsers: in some cases incorrect line number was displayed in error and warning messages.
Fixed, Visual mode: glow effect was not applied to sectors with 3 sidedefs.
Fixed, Visual mode: in some cases glow effect was not updated when replacing textures.
Fixed, general interface: "Full Brightness" button state was not updated during map loading.
Fixed, Drag Linedefs/Vertices/Sectors/Things modes: positions of line length labels were not updated while panning the view.
Cosmetic: added a bunch of new icons.
Cosmetic: changed Visual mode crosshair.
2015-08-27 20:46:49 +00:00
|
|
|
|
|
|
|
//mxd. Store starting position
|
|
|
|
prevstreamposition = datastream.Position;
|
2014-01-03 10:33:45 +00:00
|
|
|
|
|
|
|
string token = "";
|
|
|
|
bool quotedstring = false;
|
|
|
|
|
|
|
|
// Start reading
|
|
|
|
char c = (char)datareader.ReadByte();
|
2014-12-03 23:15:26 +00:00
|
|
|
while(!IsWhitespace(c) || quotedstring || specialTokens.IndexOf(c) != -1)
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
// Special token?
|
2014-12-03 23:15:26 +00:00
|
|
|
if(!quotedstring && specialTokens.IndexOf(c) != -1)
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
// Not reading a token yet?
|
2014-12-03 23:15:26 +00:00
|
|
|
if(token.Length == 0)
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
// This is our whole token
|
|
|
|
token += c;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is a new token and shouldn't be read now
|
|
|
|
// Go one character back so we can read this token again
|
|
|
|
datastream.Seek(-1, SeekOrigin.Current);
|
|
|
|
break;
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
// Quote?
|
2014-12-03 23:15:26 +00:00
|
|
|
if(c == '"')
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
// Quote to end the string?
|
|
|
|
if(quotedstring) quotedstring = false;
|
|
|
|
|
|
|
|
// First character is a quote?
|
|
|
|
if(token.Length == 0) quotedstring = true;
|
|
|
|
|
|
|
|
token += c;
|
2016-07-14 14:28:42 +00:00
|
|
|
|
|
|
|
//mxd. Break after closing quote
|
|
|
|
if(!quotedstring) break;
|
2014-01-03 10:33:45 +00:00
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
// Potential comment?
|
|
|
|
else if((c == '/') && !quotedstring)
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
// Check the next byte
|
|
|
|
if(datastream.Position == datastream.Length) return token;
|
|
|
|
char c2 = (char)datareader.ReadByte();
|
2014-12-03 23:15:26 +00:00
|
|
|
if((c2 == '/') || (c2 == '*'))
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
// This is a comment start, so the token ends here
|
|
|
|
// Go two characters back so we can read this comment again
|
|
|
|
datastream.Seek(-2, SeekOrigin.Current);
|
|
|
|
break;
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
// Not a comment
|
|
|
|
// Go one character back so we can read this char again
|
|
|
|
datastream.Seek(-1, SeekOrigin.Current);
|
|
|
|
token += c;
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-03 10:33:45 +00:00
|
|
|
token += c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Next character
|
|
|
|
if(datastream.Position < datastream.Length)
|
|
|
|
c = (char)datareader.Read();
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// This reads the rest of the line
|
|
|
|
// Returns null when the end of the stream has been reached
|
2009-08-15 08:41:43 +00:00
|
|
|
protected internal string ReadLine()
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
string token = "";
|
|
|
|
|
|
|
|
// Return null when the end of the stream has been reached
|
|
|
|
if(datastream.Position == datastream.Length) return null;
|
|
|
|
|
|
|
|
// Start reading
|
|
|
|
char c = (char)datareader.ReadByte();
|
|
|
|
while(c != '\n')
|
|
|
|
{
|
|
|
|
token += c;
|
|
|
|
|
|
|
|
// Next character
|
|
|
|
if(datastream.Position < datastream.Length)
|
|
|
|
c = (char)datareader.Read();
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return token.Trim();
|
|
|
|
}
|
2012-06-01 10:17:47 +00:00
|
|
|
|
2015-04-13 09:50:17 +00:00
|
|
|
//mxd
|
2015-12-21 14:17:47 +00:00
|
|
|
internal bool NextTokenIs(string expectedtoken)
|
2015-04-13 09:50:17 +00:00
|
|
|
{
|
|
|
|
return NextTokenIs(expectedtoken, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
2015-12-21 14:17:47 +00:00
|
|
|
internal bool NextTokenIs(string expectedtoken, bool reporterror)
|
2015-04-13 09:50:17 +00:00
|
|
|
{
|
2016-04-20 21:55:33 +00:00
|
|
|
if(!SkipWhitespace(true))
|
|
|
|
{
|
|
|
|
if(reporterror) ReportError("Unexpected end of the structure");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-04-13 09:50:17 +00:00
|
|
|
string token = ReadToken();
|
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
if(string.Compare(token, expectedtoken, true) != 0)
|
2015-04-13 09:50:17 +00:00
|
|
|
{
|
2016-02-08 21:51:03 +00:00
|
|
|
if(reporterror) ReportError("Expected \"" + expectedtoken + "\", but got \"" + token + "\"");
|
2015-04-13 09:50:17 +00:00
|
|
|
|
|
|
|
// Rewind so this structure can be read again
|
|
|
|
DataStream.Seek(-token.Length - 1, SeekOrigin.Current);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
2016-04-06 22:54:04 +00:00
|
|
|
protected internal bool ReadSignedFloat(ref float value) { return ReadSignedFloat(ReadToken(false), ref value); }
|
2014-12-03 23:15:26 +00:00
|
|
|
protected internal bool ReadSignedFloat(string token, ref float value)
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
int sign = 1;
|
2015-12-18 10:16:53 +00:00
|
|
|
if(token == "-")
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
sign = -1;
|
2016-04-06 22:54:04 +00:00
|
|
|
token = ReadToken(false);
|
2013-09-11 09:47:53 +00:00
|
|
|
}
|
2012-06-01 10:17:47 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
float val;
|
|
|
|
bool success = float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out val);
|
2015-12-18 10:16:53 +00:00
|
|
|
if(success) value = val * sign;
|
2013-09-11 09:47:53 +00:00
|
|
|
return success;
|
|
|
|
}
|
2012-06-01 10:17:47 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
2016-04-06 22:54:04 +00:00
|
|
|
protected internal bool ReadSignedInt(ref int value) { return ReadSignedInt(ReadToken(false), ref value); }
|
2015-04-13 09:50:17 +00:00
|
|
|
protected internal bool ReadSignedInt(string token, ref int value)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
int sign = 1;
|
2015-12-18 10:16:53 +00:00
|
|
|
if(token == "-")
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
sign = -1;
|
2016-04-06 22:54:04 +00:00
|
|
|
token = ReadToken(false);
|
2013-09-11 09:47:53 +00:00
|
|
|
}
|
2012-06-01 10:17:47 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
int val;
|
|
|
|
bool success = int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out val);
|
2015-12-18 10:16:53 +00:00
|
|
|
if(success) value = val * sign;
|
2013-09-11 09:47:53 +00:00
|
|
|
return success;
|
|
|
|
}
|
2016-01-11 13:00:52 +00:00
|
|
|
|
2016-03-16 23:26:53 +00:00
|
|
|
//mxd
|
2016-04-06 22:54:04 +00:00
|
|
|
protected internal bool ReadByte(ref byte value) { return ReadByte(ReadToken(false), ref value); }
|
2016-03-16 23:26:53 +00:00
|
|
|
protected internal bool ReadByte(string token, ref byte value)
|
|
|
|
{
|
|
|
|
if(token == "-") return false;
|
|
|
|
|
|
|
|
int result;
|
|
|
|
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out result) || result < 0 || result > 255)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = (byte)result;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. This replicates ZDoom's V_GetColorFromString method
|
|
|
|
public static bool GetColorFromString(string name, ref PixelColor color)
|
|
|
|
{
|
|
|
|
name = StripQuotes(name.Replace(" ", ""));
|
|
|
|
|
|
|
|
// Check for HTML-style #RRGGBB or #RGB color string
|
|
|
|
bool ishtmlcolor = false;
|
|
|
|
if(name.StartsWith("#"))
|
|
|
|
{
|
|
|
|
ishtmlcolor = true;
|
|
|
|
name = name.Remove(0, 1);
|
|
|
|
|
|
|
|
// Expand RGB to RRGGBB
|
|
|
|
if(name.Length == 3)
|
|
|
|
{
|
|
|
|
name = name[0].ToString() + name[0] + name[1] + name[1] + name[2] + name[2];
|
|
|
|
}
|
|
|
|
else if(name.Length != 6)
|
|
|
|
{
|
|
|
|
// Bad HTML-style; pretend it's black.
|
|
|
|
color = new PixelColor();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Probably it's a hex color (like FFCC11)?
|
|
|
|
int ci;
|
|
|
|
if(int.TryParse(name, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ci))
|
|
|
|
{
|
|
|
|
color = PixelColor.FromInt(ci).WithAlpha(255);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Probably it's a color name?
|
|
|
|
if(!ishtmlcolor && General.Map.Data.KnownColors.ContainsKey(name))
|
|
|
|
{
|
|
|
|
color = General.Map.Data.KnownColors[name];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
//mxd
|
|
|
|
protected void SkipStructure() { SkipStructure(new HashSet<string>()); }
|
|
|
|
protected void SkipStructure(HashSet<string> breakat)
|
|
|
|
{
|
2016-01-17 21:53:29 +00:00
|
|
|
// We need it to be case-insensitive
|
|
|
|
if(breakat.Count > 0) breakat = new HashSet<string>(breakat, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
2016-01-11 13:00:52 +00:00
|
|
|
string token;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if(!SkipWhitespace(true)) break;
|
|
|
|
token = ReadToken();
|
|
|
|
if(string.IsNullOrEmpty(token)) break;
|
|
|
|
if(breakat.Contains(token))
|
|
|
|
{
|
|
|
|
DataStream.Seek(-token.Length - 1, SeekOrigin.Current);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while(token != "{");
|
|
|
|
int scopelevel = 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if(!SkipWhitespace(true)) break;
|
|
|
|
token = ReadToken();
|
|
|
|
if(string.IsNullOrEmpty(token)) break;
|
|
|
|
if(token == "{") scopelevel++;
|
|
|
|
if(token == "}") scopelevel--;
|
|
|
|
}
|
|
|
|
while(scopelevel > 0);
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// This reports an error
|
2009-08-15 08:41:43 +00:00
|
|
|
protected internal void ReportError(string message)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Set error information
|
|
|
|
errordesc = message;
|
2015-11-28 23:31:54 +00:00
|
|
|
errorline = (datastream != null ? GetCurrentLineNumber() : CompilerError.NO_LINE_NUMBER); //mxd
|
2016-03-07 20:01:13 +00:00
|
|
|
|
|
|
|
//mxd
|
|
|
|
if(ScriptType == ScriptType.ACS && sourcename.StartsWith("?"))
|
|
|
|
{
|
2016-03-25 14:06:00 +00:00
|
|
|
shorterrorsource = sourcename.Substring(1);
|
2016-03-07 20:01:13 +00:00
|
|
|
errorsource = sourcename;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-06 22:54:04 +00:00
|
|
|
shorterrorsource = Path.Combine(datalocation.GetDisplayName(), sourcename).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
2016-03-07 20:01:13 +00:00
|
|
|
errorsource = Path.Combine(datalocation.location, sourcename);
|
|
|
|
}
|
|
|
|
|
2016-11-19 20:43:42 +00:00
|
|
|
if(sourcelumpindex != -1) //mxd
|
|
|
|
{
|
|
|
|
errorsource += ":" + sourcelumpindex;
|
|
|
|
shorterrorsource += ":" + sourcelumpindex;
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2012-05-21 23:51:32 +00:00
|
|
|
|
2015-12-17 10:07:28 +00:00
|
|
|
//mxd. This adds a warning to the ErrorLogger
|
2016-11-26 00:02:56 +00:00
|
|
|
protected internal void LogWarning(string message) { LogWarning(message, CompilerError.NO_LINE_NUMBER); }
|
|
|
|
protected internal void LogWarning(string message, int linenumber)
|
2015-09-28 19:49:15 +00:00
|
|
|
{
|
|
|
|
// Add a warning
|
2016-11-26 00:02:56 +00:00
|
|
|
int errline = (linenumber != CompilerError.NO_LINE_NUMBER
|
|
|
|
? linenumber
|
|
|
|
: (datastream != null ? GetCurrentLineNumber() : CompilerError.NO_LINE_NUMBER));
|
2016-03-14 21:53:53 +00:00
|
|
|
string errsource = (ScriptType == ScriptType.ACS && sourcename.StartsWith("?") ? sourcename.Substring(1) : Path.Combine(datalocation.GetDisplayName(), sourcename));
|
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
|
|
|
if(sourcelumpindex != -1) errsource += ":" + sourcelumpindex;
|
2016-11-26 00:02:56 +00:00
|
|
|
|
|
|
|
message = ScriptType + " warning in \"" + errsource
|
|
|
|
+ (errline != CompilerError.NO_LINE_NUMBER ? "\", line " + (errline + 1) : "\"") + ". "
|
|
|
|
+ message + ".";
|
|
|
|
|
|
|
|
TextResourceErrorItem error = new TextResourceErrorItem(ErrorType.Warning,
|
|
|
|
ScriptType, datalocation,
|
|
|
|
(sourcename.StartsWith("?") ? sourcename.Substring(1) : sourcename),
|
|
|
|
sourcelumpindex, errline, message);
|
|
|
|
|
|
|
|
General.ErrorLogger.Add(error);
|
2015-12-17 10:07:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. This adds an error to the ErrorLogger
|
|
|
|
public void LogError()
|
|
|
|
{
|
2016-11-26 00:02:56 +00:00
|
|
|
string message = ScriptType + " error in \"" + shorterrorsource
|
|
|
|
+ (errorline != CompilerError.NO_LINE_NUMBER ? "\", line " + (errorline + 1) : "\"") + ". "
|
|
|
|
+ errordesc + ".";
|
|
|
|
|
2016-11-26 20:03:59 +00:00
|
|
|
TextResourceErrorItem error = new TextResourceErrorItem(ErrorType.Error,
|
2016-11-26 00:02:56 +00:00
|
|
|
ScriptType, datalocation,
|
|
|
|
(sourcename.StartsWith("?") ? sourcename.Substring(1) : sourcename),
|
|
|
|
sourcelumpindex, errorline, message);
|
|
|
|
|
|
|
|
General.ErrorLogger.Add(error);
|
2015-12-17 10:07:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
2015-12-18 10:16:53 +00:00
|
|
|
protected void ClearError()
|
2015-12-17 10:07:28 +00:00
|
|
|
{
|
|
|
|
errordesc = null;
|
|
|
|
errorsource = null;
|
2016-03-07 20:01:13 +00:00
|
|
|
shorterrorsource = null;
|
2015-12-18 10:16:53 +00:00
|
|
|
errorline = CompilerError.NO_LINE_NUMBER;
|
2015-09-28 19:49:15 +00:00
|
|
|
}
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
2015-12-17 10:07:28 +00:00
|
|
|
protected int GetCurrentLineNumber()
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2015-09-28 19:49:15 +00:00
|
|
|
long pos = datastream.Position;
|
2017-01-15 22:00:45 +00:00
|
|
|
long finishpos = (prevstreamposition >= 0 ? Math.Min(prevstreamposition, pos) : pos);
|
2013-09-11 09:47:53 +00:00
|
|
|
long readpos = 0;
|
2015-12-17 10:07:28 +00:00
|
|
|
int linenumber = -1;
|
2012-05-21 23:51:32 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
// Find the line on which we found this error
|
|
|
|
datastream.Seek(0, SeekOrigin.Begin);
|
|
|
|
StreamReader textreader = new StreamReader(datastream, Encoding.ASCII);
|
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
|
|
|
while(readpos < finishpos + 1)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
string line = textreader.ReadLine();
|
2015-09-28 19:49:15 +00:00
|
|
|
if(line == null) break;
|
2013-09-11 09:47:53 +00:00
|
|
|
readpos += line.Length + 2;
|
|
|
|
linenumber++;
|
|
|
|
}
|
2012-05-21 23:51:32 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
// Return to original position
|
2015-09-28 19:49:15 +00:00
|
|
|
datastream.Seek(pos, SeekOrigin.Begin);
|
2012-05-21 23:51:32 +00:00
|
|
|
|
2015-12-17 10:07:28 +00:00
|
|
|
return Math.Max(linenumber, 0);
|
2013-09-11 09:47:53 +00:00
|
|
|
}
|
2015-12-17 10:07:28 +00:00
|
|
|
|
2015-12-21 14:17:47 +00:00
|
|
|
//mxd. This converts given path to be relative to "filename"
|
|
|
|
protected string GetRootedPath(string filename, string includefilename)
|
|
|
|
{
|
|
|
|
// Construct root-relative path...
|
|
|
|
filename = filename.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
|
|
|
|
|
|
|
// Filename absolute? Try to convert it to resource-rooted
|
|
|
|
if(Path.IsPathRooted(filename))
|
|
|
|
{
|
|
|
|
foreach(DataReader reader in General.Map.Data.Containers)
|
|
|
|
{
|
2016-02-01 22:04:00 +00:00
|
|
|
if(reader is DirectoryReader && filename.StartsWith(reader.Location.location, StringComparison.OrdinalIgnoreCase))
|
2015-12-21 14:17:47 +00:00
|
|
|
{
|
|
|
|
filename = filename.Substring(reader.Location.location.Length + 1, filename.Length - reader.Location.location.Length - 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string filepath = Path.GetDirectoryName(filename);
|
|
|
|
string result = includefilename.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
|
|
|
|
|
|
|
if(result.StartsWith(RELATIVE_PATH_MARKER) && !string.IsNullOrEmpty(filepath))
|
|
|
|
{
|
|
|
|
string[] parts = filepath.Split(Path.DirectorySeparatorChar);
|
|
|
|
int index = parts.Length - 1;
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
// Count & trim relative path markers
|
|
|
|
while((pos = result.LastIndexOf(RELATIVE_PATH_MARKER, StringComparison.Ordinal)) != -1)
|
|
|
|
{
|
|
|
|
// includefilename references something above the root?
|
|
|
|
if(index-- < 0)
|
|
|
|
{
|
2016-02-08 21:51:03 +00:00
|
|
|
ReportError("Unable to construct rooted path from \"" + includefilename + "\"");
|
2015-12-21 14:17:47 +00:00
|
|
|
return string.Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
string start = result.Substring(0, pos);
|
|
|
|
string end = result.Substring(pos + RELATIVE_PATH_MARKER.Length, result.Length - pos - RELATIVE_PATH_MARKER.Length);
|
|
|
|
result = start + end;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct absolute path relative to current filename
|
|
|
|
while(index > -1)
|
|
|
|
{
|
|
|
|
result = parts[index--] + Path.DirectorySeparatorChar + result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Trim "this folder" marker
|
|
|
|
if(result.StartsWith(CURRENT_FOLDER_PATH_MARKER))
|
|
|
|
result = result.TrimStart(CURRENT_FOLDER_PATH_MARKER.ToCharArray());
|
|
|
|
|
|
|
|
// Treat as relative path
|
|
|
|
if(!string.IsNullOrEmpty(filepath))
|
|
|
|
result = Path.Combine(filepath, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-01-01 18:10:16 +00:00
|
|
|
//mxd. This replicates System.IO.Path.CheckInvalidPathChars() internal function
|
|
|
|
public bool CheckInvalidPathChars(string path)
|
|
|
|
{
|
|
|
|
foreach(char c in path)
|
|
|
|
{
|
|
|
|
int num = c;
|
|
|
|
switch(num)
|
|
|
|
{
|
|
|
|
case 34: case 60: case 62: case 124:
|
2016-01-11 13:00:52 +00:00
|
|
|
ReportError("Unsupported character \"" + c + "\" in path \"" + path + "\"");
|
2016-01-01 18:10:16 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if(num >= 32) continue;
|
|
|
|
goto case 34;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|