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
2014-02-26 14:11:06 +00:00
using System ;
2009-04-19 18:07:22 +00:00
using System.Collections.Generic ;
2015-12-27 00:13:31 +00:00
using System.Globalization ;
2009-04-19 18:07:22 +00:00
using System.IO ;
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 ;
2009-04-19 18:07:22 +00:00
#endregion
namespace CodeImp.DoomBuilder.ZDoom
{
public sealed class DecorateParser : ZDTextParser
{
#region = = = = = = = = = = = = = = = = = = Delegates
public delegate void IncludeDelegate ( DecorateParser parser , string includefile ) ;
public IncludeDelegate OnInclude ;
#endregion
#region = = = = = = = = = = = = = = = = = = Constants
#endregion
#region = = = = = = = = = = = = = = = = = = Variables
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. Script type
internal override ScriptType ScriptType { get { return ScriptType . DECORATE ; } }
2009-04-19 18:07:22 +00:00
// These are actors we want to keep
private Dictionary < string , ActorStructure > actors ;
// These are all parsed actors, also those from other games
private Dictionary < string , ActorStructure > archivedactors ;
2015-12-21 14:17:47 +00:00
//mxd. Includes tracking
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
private readonly HashSet < string > parsedlumps ;
//mxd. Custom damagetypes
private readonly HashSet < string > damagetypes ;
2016-02-02 14:29:19 +00:00
//mxd. Disposing. Is that really needed?..
private bool isdisposed ;
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Properties
2009-08-15 08:41:43 +00:00
/// <summary>
/// All actors that are supported by the current game.
/// </summary>
2016-02-02 14:29:19 +00:00
public IEnumerable < ActorStructure > Actors { get { return actors . Values ; } }
2009-08-15 08:41:43 +00:00
/// <summary>
/// All actors defined in the loaded DECORATE structures. This includes actors not supported in the current game.
/// </summary>
public ICollection < ActorStructure > AllActors { get { return archivedactors . Values ; } }
2015-04-14 11:33:57 +00:00
/// <summary>
/// mxd. All actors that are supported by the current game.
/// </summary>
internal Dictionary < string , ActorStructure > ActorsByClass { get { return actors ; } }
/// <summary>
/// mxd. All actors defined in the loaded DECORATE structures. This includes actors not supported in the current game.
/// </summary>
internal Dictionary < string , ActorStructure > AllActorsByClass { get { return archivedactors ; } }
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
/// <summary>
/// mxd. Custom DamageTypes (http://zdoom.org/wiki/Damage_types).
/// </summary>
public IEnumerable < string > DamageTypes { get { return damagetypes ; } }
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Constructor / Disposer
// Constructor
public DecorateParser ( )
{
// Syntax
2013-09-11 09:47:53 +00:00
whitespace = "\n \t\r\u00A0" ; //mxd. non-breaking space is also space :)
2016-04-20 21:55:33 +00:00
specialtokens = ":{}[]()+-\n;," ;
2016-05-13 13:41:09 +00:00
skipregions = false ; //mxd
2009-04-19 18:07:22 +00:00
// Initialize
Fixed, Visual mode: in some cases ceiling glow effect was interfering with Transfer Brightness effect resulting in incorrectly lit sidedef geometry.
Fixed, Visual mode: UDMF sidedef brightness should be ignored when a wall section is affected by Transfer Brightness effect.
Fixed, Visual mode: any custom fog should be rendered regardless of sector brightness.
Fixed, Visual mode: "fogdensity" and "outsidefogdensity" MAPINFO values were processed incorrectly.
Fixed, Visual mode: in some cases Things were rendered twice during a render pass.
Fixed, Visual mode: floor glow effect should affect thing brightness only when applied to floor of the sector thing is in.
Fixed, TEXTURES parser: TEXTURES group was named incorrectly in the Textures Browser window when parsed from a WAD file.
Fixed, MAPINFO, GLDEFS, DECORATE parsers: "//$GZDB_SKIP" special comment was processed incorrectly.
Fixed, MAPINFO parser: "fogdensity" and "outsidefogdensity" properties are now initialized using GZDoom default value (255) instead of 0.
2016-01-25 13:42:53 +00:00
actors = new Dictionary < string , ActorStructure > ( StringComparer . OrdinalIgnoreCase ) ;
archivedactors = new Dictionary < string , ActorStructure > ( StringComparer . OrdinalIgnoreCase ) ;
2015-12-21 14:17:47 +00:00
parsedlumps = new HashSet < string > ( 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
damagetypes = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ; //mxd
2009-04-19 18:07:22 +00:00
}
2010-08-19 15:06:15 +00:00
// Disposer
2016-02-02 14:29:19 +00:00
public void Dispose ( )
2010-08-19 15:06:15 +00:00
{
2016-02-02 14:29:19 +00:00
//mxd. Not already disposed?
2016-02-01 22:04:00 +00:00
if ( ! isdisposed )
{
foreach ( KeyValuePair < string , ActorStructure > a in archivedactors )
a . Value . Dispose ( ) ;
actors = null ;
archivedactors = null ;
2016-02-02 14:29:19 +00:00
isdisposed = true ;
2016-02-01 22:04:00 +00:00
}
2010-08-19 15:06:15 +00:00
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Parsing
// 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 override bool Parse ( TextResourceData data , bool clearerrors )
2009-04-19 18:07:22 +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
//mxd. Already parsed?
if ( ! base . AddTextResource ( data ) )
{
if ( clearerrors ) ClearError ( ) ;
return true ;
}
// Cannot process?
if ( ! base . Parse ( data , clearerrors ) ) return false ;
2016-05-13 13:41:09 +00:00
//mxd. Region-as-category stuff...
List < DecorateCategoryInfo > regions = new List < DecorateCategoryInfo > ( ) ; //mxd
2009-04-19 18:07:22 +00:00
// Keep local data
Stream localstream = datastream ;
string localsourcename = sourcename ;
BinaryReader localreader = datareader ;
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
DataLocation locallocation = datalocation ; //mxd
string localtextresourcepath = textresourcepath ; //mxd
2009-04-19 18:07:22 +00:00
// Continue until at the end of the stream
while ( SkipWhitespace ( true ) )
{
// Read a token
string objdeclaration = ReadToken ( ) ;
2015-06-18 19:45:39 +00:00
if ( ! string . IsNullOrEmpty ( objdeclaration ) )
2009-04-19 18:07:22 +00:00
{
objdeclaration = objdeclaration . ToLowerInvariant ( ) ;
Fixed, Visual mode: in some cases ceiling glow effect was interfering with Transfer Brightness effect resulting in incorrectly lit sidedef geometry.
Fixed, Visual mode: UDMF sidedef brightness should be ignored when a wall section is affected by Transfer Brightness effect.
Fixed, Visual mode: any custom fog should be rendered regardless of sector brightness.
Fixed, Visual mode: "fogdensity" and "outsidefogdensity" MAPINFO values were processed incorrectly.
Fixed, Visual mode: in some cases Things were rendered twice during a render pass.
Fixed, Visual mode: floor glow effect should affect thing brightness only when applied to floor of the sector thing is in.
Fixed, TEXTURES parser: TEXTURES group was named incorrectly in the Textures Browser window when parsed from a WAD file.
Fixed, MAPINFO, GLDEFS, DECORATE parsers: "//$GZDB_SKIP" special comment was processed incorrectly.
Fixed, MAPINFO parser: "fogdensity" and "outsidefogdensity" properties are now initialized using GZDoom default value (255) instead of 0.
2016-01-25 13:42:53 +00:00
if ( objdeclaration = = "$gzdb_skip" ) break ;
2015-12-17 10:07:28 +00:00
switch ( objdeclaration )
2009-04-19 18:07:22 +00:00
{
2015-12-17 10:07:28 +00:00
case "actor" :
2009-04-19 18:07:22 +00:00
{
2015-12-17 10:07:28 +00:00
// Read actor structure
2016-05-13 13:41:09 +00:00
ActorStructure actor = new ActorStructure ( this , ( regions . Count > 0 ? regions [ regions . Count - 1 ] : null ) ) ;
2015-12-17 10:07:28 +00:00
if ( this . HasError ) return false ;
// Add the actor
archivedactors [ actor . ClassName . ToLowerInvariant ( ) ] = actor ;
2009-04-19 18:07:22 +00:00
if ( actor . CheckActorSupported ( ) )
2015-12-17 10:07:28 +00:00
actors [ actor . ClassName . ToLowerInvariant ( ) ] = actor ;
// Replace an actor?
if ( actor . ReplacesClass ! = null )
2009-04-19 18:07:22 +00:00
{
2015-12-17 10:07:28 +00:00
if ( GetArchivedActorByName ( actor . ReplacesClass ) ! = null )
archivedactors [ actor . ReplacesClass . ToLowerInvariant ( ) ] = actor ;
else
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
LogWarning ( "Unable to find \"" + actor . ReplacesClass + "\" class to replace, while parsing \"" + actor . ClassName + "\"" ) ;
2015-12-17 10:07:28 +00:00
if ( actor . CheckActorSupported ( ) & & GetActorByName ( actor . ReplacesClass ) ! = null )
2009-04-19 18:07:22 +00:00
actors [ actor . ReplacesClass . ToLowerInvariant ( ) ] = actor ;
}
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. Add to current text resource
2016-11-24 11:55:11 +00:00
if ( ! scriptresources [ textresourcepath ] . Entries . Contains ( actor . ClassName ) ) scriptresources [ textresourcepath ] . Entries . Add ( actor . ClassName ) ;
2009-04-19 18:07:22 +00:00
}
2015-12-17 10:07:28 +00:00
break ;
case "#include" :
2009-04-19 18:07:22 +00:00
{
2015-12-21 14:17:47 +00:00
//INFO: ZDoom DECORATE include paths can't be relative ("../actor.txt")
//or absolute ("d:/project/actor.txt")
2015-12-27 00:13:31 +00:00
//or have backward slashes ("info\actor.txt")
2015-12-21 14:17:47 +00:00
//include paths are relative to the first parsed entry, not the current one
//also include paths may or may not be quoted
2015-12-17 10:07:28 +00:00
SkipWhitespace ( true ) ;
2016-04-06 22:54:04 +00:00
string filename = StripQuotes ( ReadToken ( false ) ) ; //mxd. Don't skip newline
2015-12-17 10:07:28 +00:00
//mxd. Sanity checks
2015-12-21 14:17:47 +00:00
if ( string . IsNullOrEmpty ( filename ) )
2015-12-17 10:07:28 +00:00
{
2015-12-21 14:17:47 +00:00
ReportError ( "Expected file name to include" ) ;
2015-12-17 10:07:28 +00:00
return false ;
}
2016-01-01 18:10:16 +00:00
//mxd. Check invalid path chars
if ( ! CheckInvalidPathChars ( filename ) ) return false ;
2015-12-21 14:17:47 +00:00
//mxd. Absolute paths are not supported...
if ( Path . IsPathRooted ( filename ) )
{
ReportError ( "Absolute include paths are not supported by ZDoom" ) ;
return false ;
}
2009-04-19 18:07:22 +00:00
2015-12-21 14:17:47 +00:00
//mxd. Relative paths are not supported
if ( filename . StartsWith ( RELATIVE_PATH_MARKER ) | | filename . StartsWith ( CURRENT_FOLDER_PATH_MARKER ) | |
filename . StartsWith ( ALT_RELATIVE_PATH_MARKER ) | | filename . StartsWith ( ALT_CURRENT_FOLDER_PATH_MARKER ) )
2015-12-17 10:07:28 +00:00
{
2015-12-21 14:17:47 +00:00
ReportError ( "Relative include paths are not supported by ZDoom" ) ;
return false ;
}
2015-12-27 00:13:31 +00:00
//mxd. Backward slashes are not supported
if ( filename . Contains ( Path . DirectorySeparatorChar . ToString ( CultureInfo . InvariantCulture ) ) )
2015-12-21 14:17:47 +00:00
{
2015-12-27 00:13:31 +00:00
ReportError ( "Only forward slashes are supported by ZDoom" ) ;
2015-12-21 14:17:47 +00:00
return false ;
}
//mxd. Already parsed?
if ( parsedlumps . Contains ( filename ) )
{
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 ( "Already parsed \"" + filename + "\". Check your include directives" ) ;
2015-12-17 10:07:28 +00:00
return false ;
}
2015-12-21 14:17:47 +00:00
//mxd. Add to collection
parsedlumps . Add ( filename ) ;
2009-04-19 18:07:22 +00:00
// Callback to parse this file now
if ( OnInclude ! = null ) OnInclude ( this , filename ) ;
2015-12-21 14:17:47 +00:00
//mxd. Bail out on error
if ( this . HasError ) return false ;
2009-04-19 18:07:22 +00:00
// Set our buffers back to continue parsing
datastream = localstream ;
datareader = localreader ;
sourcename = localsourcename ;
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
datalocation = locallocation ; //mxd
textresourcepath = localtextresourcepath ; //mxd
2009-04-19 18:07:22 +00:00
}
2015-12-17 10:07:28 +00:00
break ;
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
case "damagetype" : //mxd
// Get DamageType name
SkipWhitespace ( true ) ;
2016-04-06 22:54:04 +00:00
string damagetype = StripQuotes ( ReadToken ( false ) ) ;
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 ( damagetype ) )
{
ReportError ( "Expected DamageType name" ) ;
return false ;
}
// Next should be "{"
SkipWhitespace ( true ) ;
if ( ! NextTokenIs ( "{" ) ) return false ;
// Skip the structure
while ( SkipWhitespace ( true ) )
{
string t = ReadToken ( ) ;
if ( string . IsNullOrEmpty ( t ) | | t = = "}" ) break ;
}
// Add to collection
if ( ! damagetypes . Contains ( damagetype ) ) damagetypes . Add ( damagetype ) ;
break ;
2015-12-17 10:07:28 +00:00
case "enum" :
case "native" :
case "const" :
while ( SkipWhitespace ( true ) )
{
string t = ReadToken ( ) ;
if ( string . IsNullOrEmpty ( t ) | | t = = ";" ) break ;
}
2009-04-19 18:07:22 +00:00
break ;
2015-12-17 10:07:28 +00:00
2016-05-13 13:41:09 +00:00
//mxd. Region-as-category handling
case "#region" :
SkipWhitespace ( false ) ;
string cattitle = ReadLine ( ) ;
if ( ! string . IsNullOrEmpty ( cattitle ) )
{
// Make new category info
string [ ] parts = cattitle . Split ( DataManager . CATEGORY_SPLITTER , StringSplitOptions . RemoveEmptyEntries ) ;
DecorateCategoryInfo info = new DecorateCategoryInfo ( ) ;
if ( regions . Count > 0 )
{
// Preserve nesting
info . Category . AddRange ( regions [ regions . Count - 1 ] . Category ) ;
info . Properties = new Dictionary < string , List < string > > ( regions [ regions . Count - 1 ] . Properties ) ;
}
info . Category . AddRange ( parts ) ;
// Add to collection
regions . Add ( info ) ;
}
break ;
//mxd. Region-as-category handling
case "#endregion" :
if ( regions . Count > 0 )
regions . RemoveAt ( regions . Count - 1 ) ;
else
LogWarning ( "Unexpected #endregion token" ) ;
break ;
2015-12-17 10:07:28 +00:00
default :
2009-04-19 18:07:22 +00:00
{
2016-05-02 19:16:01 +00:00
//mxd. In some special cases (like the whole actor commented using "//") our special comments will be detected here...
if ( objdeclaration . StartsWith ( "$" ) )
{
2016-05-13 13:41:09 +00:00
if ( regions . Count > 0 )
{
// Store region property
regions [ regions . Count - 1 ] . Properties [ objdeclaration ] = new List < string > { ( SkipWhitespace ( false ) ? ReadLine ( ) : "" ) } ;
}
else
{
// Skip the whole line, then carry on
ReadLine ( ) ;
}
2016-05-02 19:16:01 +00:00
break ;
}
2015-12-17 10:07:28 +00:00
// Unknown structure!
// Best we can do now is just find the first { and then
// follow the scopes until the matching } is found
string token2 ;
do
{
if ( ! SkipWhitespace ( true ) ) break ;
token2 = ReadToken ( ) ;
if ( string . IsNullOrEmpty ( token2 ) ) break ;
}
while ( token2 ! = "{" ) ;
int scopelevel = 1 ;
do
{
if ( ! SkipWhitespace ( true ) ) break ;
token2 = ReadToken ( ) ;
if ( string . IsNullOrEmpty ( token2 ) ) break ;
if ( token2 = = "{" ) scopelevel + + ;
if ( token2 = = "}" ) scopelevel - - ;
}
while ( scopelevel > 0 ) ;
2009-04-19 18:07:22 +00:00
}
2015-03-05 08:51:12 +00:00
break ;
}
2009-04-19 18:07:22 +00:00
}
}
// Return true when no errors occurred
return ( ErrorDescription = = null ) ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Methods
2009-08-15 08:41:43 +00:00
/// <summary>
/// This returns a supported actor by name. Returns null when no supported actor with the specified name can be found. This operation is of O(1) complexity.
/// </summary>
2009-04-19 18:07:22 +00:00
public ActorStructure GetActorByName ( string name )
{
name = name . ToLowerInvariant ( ) ;
2015-12-17 10:07:28 +00:00
return actors . ContainsKey ( name ) ? actors [ name ] : null ;
2009-04-19 18:07:22 +00:00
}
2009-08-15 08:41:43 +00:00
/// <summary>
/// This returns a supported actor by DoomEdNum. Returns null when no supported actor with the specified name can be found. Please note that this operation is of O(n) complexity!
/// </summary>
public ActorStructure GetActorByDoomEdNum ( int doomednum )
{
2015-12-17 10:07:28 +00:00
foreach ( ActorStructure a in actors . Values )
if ( a . DoomEdNum = = doomednum ) return a ;
2009-08-15 08:41:43 +00:00
return null ;
}
2009-04-19 18:07:22 +00:00
// This returns an actor by name
// Returns null when actor cannot be found
internal ActorStructure GetArchivedActorByName ( string name )
{
name = name . ToLowerInvariant ( ) ;
2015-03-17 12:28:42 +00:00
return ( archivedactors . ContainsKey ( name ) ? archivedactors [ name ] : null ) ;
2009-04-19 18:07:22 +00:00
}
#endregion
}
}