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
using System ;
using System.Collections.Generic ;
using System.IO ;
2016-07-14 23:39:48 +00:00
using CodeImp.DoomBuilder.Config ;
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.ZDoom ;
2009-04-19 18:07:22 +00:00
#endregion
namespace CodeImp.DoomBuilder.Data
{
internal abstract class PK3StructuredReader : DataReader
{
#region = = = = = = = = = = = = = = = = = = Constants
protected const string PATCHES_DIR = "patches" ;
protected const string TEXTURES_DIR = "textures" ;
protected const string FLATS_DIR = "flats" ;
protected const string HIRES_DIR = "hires" ;
protected const string SPRITES_DIR = "sprites" ;
2009-05-12 09:50:08 +00:00
protected const string COLORMAPS_DIR = "colormaps" ;
2013-12-20 09:24:43 +00:00
protected const string GRAPHICS_DIR = "graphics" ; //mxd
2014-01-03 10:33:45 +00:00
protected const string VOXELS_DIR = "voxels" ; //mxd
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Variables
// Source
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 bool roottextures ;
protected readonly bool rootflats ;
2009-04-19 18:07:22 +00:00
// WAD files that must be loaded as well
protected List < WADReader > wads ;
#endregion
#region = = = = = = = = = = = = = = = = = = Properties
2014-10-07 09:56:36 +00:00
protected readonly string [ ] PatchLocations = { PATCHES_DIR , TEXTURES_DIR , FLATS_DIR , SPRITES_DIR , GRAPHICS_DIR } ; //mxd. Because ZDoom looks for patches and sprites in this order
2016-11-24 11:55:11 +00:00
internal List < WADReader > Wads { get { return wads ; } } //mxd
2013-07-29 08:50:50 +00:00
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Constructor / Disposer
// Constructor
2016-04-29 13:42:52 +00:00
protected PK3StructuredReader ( DataLocation dl , bool asreadonly ) : base ( dl , asreadonly )
2009-04-19 18:07:22 +00:00
{
// Initialize
this . roottextures = dl . option1 ;
this . rootflats = dl . option2 ;
}
// Call this to initialize this class
protected virtual void Initialize ( )
{
2017-01-21 01:13:36 +00:00
// [ZZ] we can have wad files already. dispose if any.
if ( wads ! = null ) foreach ( WADReader wr in wads ) wr . Dispose ( ) ;
// Load all WAD files in the root as WAD resources
string [ ] wadfiles = GetWadFiles ( ) ;
2009-04-19 18:07:22 +00:00
wads = new List < WADReader > ( wadfiles . Length ) ;
foreach ( string w in wadfiles )
{
string tempfile = CreateTempFile ( w ) ;
2016-03-14 21:53:53 +00:00
DataLocation wdl = new DataLocation ( DataLocation . RESOURCE_WAD , tempfile , Path . Combine ( location . GetDisplayName ( ) , Path . GetFileName ( w ) ) , false , false , true ) ;
2016-11-24 11:55:11 +00:00
wads . Add ( new WADReader ( wdl , location . type ! = DataLocation . RESOURCE_DIRECTORY ) { ParentResource = this } ) ;
2009-04-19 18:07:22 +00:00
}
}
// Disposer
public override void Dispose ( )
{
// Not already disposed?
if ( ! isdisposed )
{
// Clean up
foreach ( WADReader wr in wads ) wr . Dispose ( ) ;
// Done
base . Dispose ( ) ;
}
}
#endregion
#region = = = = = = = = = = = = = = = = = = Management
// This suspends use of this resource
public override void Suspend ( )
{
foreach ( WADReader wr in wads ) wr . Suspend ( ) ;
base . Suspend ( ) ;
}
// This resumes use of this resource
public override void Resume ( )
{
foreach ( WADReader wr in wads ) wr . Resume ( ) ;
base . Resume ( ) ;
}
2017-01-21 01:13:36 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Palette
// This loads the PLAYPAL palette
public override Playpal LoadPalette ( )
2009-04-19 18:07:22 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Palette from wad(s)
Playpal palette = null ;
foreach ( WADReader wr in wads )
{
Playpal wadpalette = wr . LoadPalette ( ) ;
if ( wadpalette ! = null ) return wadpalette ;
}
// Find in root directory
string foundfile = FindFirstFile ( "PLAYPAL" , false ) ;
if ( ( foundfile ! = null ) & & FileExists ( foundfile ) )
{
MemoryStream stream = LoadFile ( foundfile ) ;
2012-08-24 01:18:25 +00:00
2015-01-25 23:22:42 +00:00
if ( stream . Length > 767 ) //mxd
2012-08-24 01:18:25 +00:00
palette = new Playpal ( stream ) ;
2015-01-25 23:22:42 +00:00
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
General . ErrorLogger . Add ( ErrorType . Warning , "Warning: invalid palette \"" + foundfile + "\"" ) ;
2009-04-19 18:07:22 +00:00
stream . Dispose ( ) ;
}
// Done
return palette ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Textures
// This loads the textures
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 IEnumerable < ImageData > LoadTextures ( PatchNames pnames , Dictionary < string , TexturesParser > cachedparsers )
2009-04-19 18:07:22 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2015-12-29 18:22:08 +00:00
Dictionary < long , ImageData > images = new Dictionary < long , ImageData > ( ) ;
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
IEnumerable < ImageData > collection ;
2009-04-19 18:07:22 +00:00
// Load from wad files (NOTE: backward order, because the last wad's images have priority)
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
{
2013-03-18 13:52:27 +00:00
PatchNames wadpnames = wads [ i ] . LoadPatchNames ( ) ; //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
collection = wads [ i ] . LoadTextures ( ( wadpnames ! = null & & wadpnames . Length > 0 ) ? wadpnames : pnames , cachedparsers ) ; //mxd
2009-04-19 18:07:22 +00:00
AddImagesToList ( images , collection ) ;
}
// Should we load the images in this directory as textures?
if ( roottextures )
{
2009-05-12 09:50:08 +00:00
collection = LoadDirectoryImages ( "" , ImageDataFormat . DOOMPICTURE , false ) ;
2009-04-19 18:07:22 +00:00
AddImagesToList ( images , collection ) ;
}
// Load TEXTURE1 lump file
2015-12-29 18:22:08 +00:00
List < ImageData > imgset = new List < ImageData > ( ) ;
2009-04-19 18:07:22 +00:00
string texture1file = FindFirstFile ( "TEXTURE1" , false ) ;
if ( ( texture1file ! = null ) & & FileExists ( texture1file ) )
{
MemoryStream filedata = LoadFile ( texture1file ) ;
WADReader . LoadTextureSet ( "TEXTURE1" , filedata , ref imgset , pnames ) ;
filedata . Dispose ( ) ;
}
// Load TEXTURE2 lump file
string texture2file = FindFirstFile ( "TEXTURE2" , false ) ;
if ( ( texture2file ! = null ) & & FileExists ( texture2file ) )
{
MemoryStream filedata = LoadFile ( texture2file ) ;
WADReader . LoadTextureSet ( "TEXTURE2" , filedata , ref imgset , pnames ) ;
filedata . Dispose ( ) ;
}
2010-08-13 15:19:51 +00:00
2009-04-19 18:07:22 +00:00
// Add images from TEXTURE1 and TEXTURE2 lump files
AddImagesToList ( images , imgset ) ;
2010-08-13 15:19:51 +00:00
2012-08-05 19:18:05 +00:00
// Load TEXTURES lump files
2009-04-19 18:07:22 +00:00
imgset . Clear ( ) ;
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 [ ] alltexturefiles = GetAllFilesWhichTitleStartsWith ( "" , "TEXTURES" , false ) ; //mxd
2010-08-13 15:19:51 +00:00
foreach ( string texturesfile in alltexturefiles )
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. Added TexturesParser caching
string fullpath = Path . Combine ( this . location . location , texturesfile ) ;
if ( cachedparsers . ContainsKey ( fullpath ) )
{
// Make the textures
foreach ( TextureStructure t in cachedparsers [ fullpath ] . Textures )
imgset . Add ( t . MakeImage ( ) ) ;
}
else
{
MemoryStream filedata = LoadFile ( texturesfile ) ;
TextResourceData data = new TextResourceData ( this , filedata , texturesfile , true ) ; //mxd
2016-03-04 08:10:56 +00:00
cachedparsers . Add ( fullpath , WADReader . LoadTEXTURESTextures ( data , ref imgset ) ) ; //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
filedata . Dispose ( ) ;
}
2009-04-19 18:07:22 +00:00
}
2010-08-13 15:19:51 +00:00
2009-04-19 18:07:22 +00:00
// Add images from TEXTURES lump file
AddImagesToList ( images , imgset ) ;
2012-08-05 19:18:05 +00:00
//mxd. Add images from texture directory. Textures defined in TEXTURES override ones in "textures" folder
collection = LoadDirectoryImages ( TEXTURES_DIR , ImageDataFormat . DOOMPICTURE , true ) ;
AddImagesToList ( images , collection ) ;
2009-04-19 18:07:22 +00:00
// Add images to the container-specific texture set
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
foreach ( ImageData img in images . Values ) textureset . AddTexture ( img ) ;
2009-04-19 18:07:22 +00:00
return new List < ImageData > ( images . Values ) ;
}
2016-03-04 08:10:56 +00:00
//mxd
public override IEnumerable < HiResImage > LoadHiResTextures ( )
{
// Go for all files
2016-03-22 22:24:33 +00:00
string [ ] files = GetAllFiles ( HIRES_DIR , true ) ;
2016-03-04 08:10:56 +00:00
List < HiResImage > result = new List < HiResImage > ( files . Length ) ;
foreach ( string f in files )
{
Changed, Select Similar Sectors action: when "Effect" option is enabled, all sectors with at least one matching generalized/predefined effect will be selected.
Added, Tag Explorer plugin: a separate category for each generalized/predefined effect is now created when "Sort by action special" sort mode is used.
Added, Edit Effect window: normal and generalized effects can now be set at the same time.
Fixed, Edit Action window: in some cases Generalized actions were incorrectly processed.
Fixed, Edit Effect window: in some cases Generalized effects were incorrectly processed.
Fixed, Select Similar window: Tab control was incorrectly anchored.
Fixed, Nodes Viewer mode, cosmetic: segs angles were calculated incorrectly when showing nodes in classic format.
Fixed: HiRes textures, which didn't override any texture or flat were not loaded.
Fixed, Tag Explorer plugin: linedef action categories were missing title when "Sort by action special" sort mode was used.
Cosmetic: renamed "Grid Setup" action to "Grid and Backdrop Setup".
2016-03-21 15:19:14 +00:00
if ( string . IsNullOrEmpty ( Path . GetFileNameWithoutExtension ( f ) ) )
2016-03-04 08:10:56 +00:00
{
// Can't load image without name
2016-03-22 22:24:33 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Can't load an unnamed HiRes texture from \"" + Path . Combine ( this . location . GetDisplayName ( ) , HIRES_DIR ) + "\". Please consider giving names to your resources." ) ;
2016-03-04 08:10:56 +00:00
}
else
{
// Add image to list
Changed, Select Similar Sectors action: when "Effect" option is enabled, all sectors with at least one matching generalized/predefined effect will be selected.
Added, Tag Explorer plugin: a separate category for each generalized/predefined effect is now created when "Sort by action special" sort mode is used.
Added, Edit Effect window: normal and generalized effects can now be set at the same time.
Fixed, Edit Action window: in some cases Generalized actions were incorrectly processed.
Fixed, Edit Effect window: in some cases Generalized effects were incorrectly processed.
Fixed, Select Similar window: Tab control was incorrectly anchored.
Fixed, Nodes Viewer mode, cosmetic: segs angles were calculated incorrectly when showing nodes in classic format.
Fixed: HiRes textures, which didn't override any texture or flat were not loaded.
Fixed, Tag Explorer plugin: linedef action categories were missing title when "Sort by action special" sort mode was used.
Cosmetic: renamed "Grid Setup" action to "Grid and Backdrop Setup".
2016-03-21 15:19:14 +00:00
result . Add ( new HiResImage ( f ) ) ;
2016-03-04 08:10:56 +00:00
}
}
return result ;
}
2009-04-19 18:07:22 +00:00
// This returns the patch names from the PNAMES lump
// A directory resource does not support this lump, but the wads in the directory may contain this lump
public override PatchNames LoadPatchNames ( )
{
PatchNames pnames ;
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Load from wad files
// Note the backward order, because the last wad's images have priority
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
{
pnames = wads [ i ] . LoadPatchNames ( ) ;
if ( pnames ! = null ) return pnames ;
}
// If none of the wads provides patch names, let's see if we can
string pnamesfile = FindFirstFile ( "PNAMES" , false ) ;
if ( ( pnamesfile ! = null ) & & FileExists ( pnamesfile ) )
{
MemoryStream pnamesdata = LoadFile ( pnamesfile ) ;
pnames = new PatchNames ( pnamesdata ) ;
pnamesdata . Dispose ( ) ;
return pnames ;
}
return null ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Flats
// This loads the textures
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 IEnumerable < ImageData > LoadFlats ( Dictionary < string , TexturesParser > cachedparsers )
2009-04-19 18:07:22 +00:00
{
Dictionary < long , ImageData > images = new Dictionary < long , ImageData > ( ) ;
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
IEnumerable < ImageData > collection ;
2010-08-18 05:49:15 +00:00
List < ImageData > imgset = new List < ImageData > ( ) ;
2009-04-19 18:07:22 +00:00
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Load from wad files
// Note the backward order, because the last wad's images have priority
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
{
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
collection = wads [ i ] . LoadFlats ( cachedparsers ) ;
2009-04-19 18:07:22 +00:00
AddImagesToList ( images , collection ) ;
}
// Should we load the images in this directory as flats?
if ( rootflats )
{
2009-05-12 09:50:08 +00:00
collection = LoadDirectoryImages ( "" , ImageDataFormat . DOOMFLAT , false ) ;
2009-04-19 18:07:22 +00:00
AddImagesToList ( images , collection ) ;
}
2014-10-07 09:56:36 +00:00
2014-10-13 09:32:55 +00:00
// Add images from flats directory
collection = LoadDirectoryImages ( FLATS_DIR , ImageDataFormat . DOOMFLAT , true ) ;
AddImagesToList ( images , collection ) ;
2009-04-19 18:07:22 +00:00
2010-08-18 05:49:15 +00:00
// Load TEXTURES lump file
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 [ ] alltexturefiles = GetAllFilesWhichTitleStartsWith ( "" , "TEXTURES" , false ) ; //mxd
2010-08-18 05:49:15 +00:00
foreach ( string texturesfile in alltexturefiles )
{
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. Added TexturesParser caching
string fullpath = Path . Combine ( this . location . location , texturesfile ) ;
if ( cachedparsers . ContainsKey ( fullpath ) )
{
// Make the textures
foreach ( TextureStructure t in cachedparsers [ fullpath ] . Flats )
imgset . Add ( t . MakeImage ( ) ) ;
}
else
{
MemoryStream filedata = LoadFile ( texturesfile ) ;
TextResourceData data = new TextResourceData ( this , filedata , texturesfile , true ) ; //mxd
2016-03-04 08:10:56 +00:00
cachedparsers . Add ( fullpath , WADReader . LoadTEXTURESFlats ( data , ref imgset ) ) ; //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
filedata . Dispose ( ) ;
}
2010-08-18 05:49:15 +00:00
}
// Add images from TEXTURES lump file
AddImagesToList ( images , imgset ) ;
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
// Add images to the container-specific texture set
foreach ( ImageData img in images . Values )
textureset . AddFlat ( img ) ;
2010-08-18 05:49:15 +00:00
2009-04-19 18:07:22 +00:00
return new List < ImageData > ( images . Values ) ;
}
2013-07-29 08:50:50 +00:00
//mxd.
2016-03-14 21:53:53 +00:00
public override Stream GetFlatData ( string pname , bool longname , ref string flatlocation )
2014-11-25 11:52:01 +00:00
{
2013-07-29 08:50:50 +00:00
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
// Find in any of the wad files
// Note the backward order, because the last wad's images have priority
2014-11-25 11:52:01 +00:00
if ( ! longname ) //mxd. Flats with long names can't be in wads
{
2015-12-28 15:01:53 +00:00
for ( int i = wads . Count - 1 ; i > - 1 ; i - - )
2014-11-25 11:52:01 +00:00
{
2016-03-14 21:53:53 +00:00
Stream data = wads [ i ] . GetFlatData ( pname , false , ref flatlocation ) ;
2015-12-28 15:01:53 +00:00
if ( data ! = null ) return data ;
2014-11-25 11:52:01 +00:00
}
2013-07-29 08:50:50 +00:00
}
// Nothing found
return null ;
}
2009-04-19 18:07:22 +00:00
#endregion
2010-08-18 09:07:54 +00:00
#region = = = = = = = = = = = = = = = = = = Sprites
2016-04-08 14:02:08 +00:00
// This loads the sprites
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 IEnumerable < ImageData > LoadSprites ( Dictionary < string , TexturesParser > cachedparsers )
2010-08-18 09:07:54 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2016-04-08 14:02:08 +00:00
Dictionary < long , ImageData > images = new Dictionary < long , ImageData > ( ) ;
List < ImageData > imgset = new List < ImageData > ( ) ;
2010-08-18 09:07:54 +00:00
// Load from wad files
// Note the backward order, because the last wad's images have priority
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
{
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
IEnumerable < ImageData > collection = wads [ i ] . LoadSprites ( cachedparsers ) ;
2010-08-18 09:07:54 +00:00
AddImagesToList ( images , collection ) ;
}
// Load TEXTURES lump file
imgset . Clear ( ) ;
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 [ ] alltexturefiles = GetAllFilesWhichTitleStartsWith ( "" , "TEXTURES" , false ) ; //mxd
2010-08-18 09:07:54 +00:00
foreach ( string texturesfile in alltexturefiles )
{
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. Added TexturesParser caching
string fullpath = Path . Combine ( this . location . location , texturesfile ) ;
if ( cachedparsers . ContainsKey ( fullpath ) )
{
// Make the textures
foreach ( TextureStructure t in cachedparsers [ fullpath ] . Sprites )
imgset . Add ( t . MakeImage ( ) ) ;
}
else
{
MemoryStream filedata = LoadFile ( texturesfile ) ;
TextResourceData data = new TextResourceData ( this , filedata , texturesfile , true ) ; //mxd
2016-03-04 08:10:56 +00:00
cachedparsers . Add ( fullpath , WADReader . LoadTEXTURESSprites ( data , ref imgset ) ) ; //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
filedata . Dispose ( ) ;
}
2010-08-18 09:07:54 +00:00
}
// Add images from TEXTURES lump file
AddImagesToList ( images , imgset ) ;
return new List < ImageData > ( images . Values ) ;
}
2016-04-08 14:02:08 +00:00
2016-07-11 22:13:43 +00:00
//mxd. This returns all sprite names
public override HashSet < string > GetSpriteNames ( )
2016-04-08 14:02:08 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
HashSet < string > result = new HashSet < string > ( ) ;
// Load from wad files
// Note the backward order, because the last wad's images have priority
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
{
2016-07-11 22:13:43 +00:00
result . UnionWith ( wads [ i ] . GetSpriteNames ( ) ) ;
2016-04-08 14:02:08 +00:00
}
// Load from out own files
2016-07-11 22:13:43 +00:00
string [ ] files = GetAllFiles ( SPRITES_DIR , true ) ;
2016-04-08 14:02:08 +00:00
foreach ( string file in files )
{
2016-06-26 22:42:24 +00:00
// Some users tend to place all manner of graphics into the "Sprites" folder...
string spritename = Path . GetFileNameWithoutExtension ( file ) . ToUpperInvariant ( ) ;
if ( WADReader . IsValidSpriteName ( spritename ) ) result . Add ( spritename ) ;
2016-04-08 14:02:08 +00:00
}
return result ;
}
2010-08-18 09:07:54 +00:00
#endregion
2009-05-12 09:50:08 +00:00
#region = = = = = = = = = = = = = = = = = = Colormaps
// This loads the textures
public override ICollection < ImageData > LoadColormaps ( )
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2016-04-08 14:02:08 +00:00
Dictionary < long , ImageData > images = new Dictionary < long , ImageData > ( ) ;
ICollection < ImageData > collection ;
2009-05-12 09:50:08 +00:00
// Load from wad files
// Note the backward order, because the last wad's images have priority
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
{
collection = wads [ i ] . LoadColormaps ( ) ;
AddImagesToList ( images , collection ) ;
}
// Add images from flats directory
collection = LoadDirectoryImages ( COLORMAPS_DIR , ImageDataFormat . DOOMCOLORMAP , true ) ;
AddImagesToList ( images , collection ) ;
// Add images to the container-specific texture set
2016-04-08 14:02:08 +00:00
foreach ( ImageData img in images . Values ) textureset . AddFlat ( img ) ;
2009-05-12 09:50:08 +00:00
return new List < ImageData > ( images . Values ) ;
}
#endregion
2015-12-18 10:16:53 +00:00
#region = = = = = = = = = = = = = = = = = = DECORATE
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
// This finds and returns DECORATE streams
public override IEnumerable < TextResourceData > GetDecorateData ( string pname )
2009-04-19 18:07:22 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
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
List < TextResourceData > result = new List < TextResourceData > ( ) ;
string [ ] allfilenames ;
2010-08-12 10:03:29 +00:00
2009-04-19 18:07:22 +00:00
// Find in root directory
string filename = Path . GetFileName ( pname ) ;
string pathname = Path . GetDirectoryName ( pname ) ;
2010-08-15 13:45:43 +00:00
if ( filename . IndexOf ( '.' ) > - 1 )
{
2020-07-29 07:57:42 +00:00
allfilenames = GetFileAtPath ( filename , pathname , "DECORATE" ) ;
2010-08-15 13:45:43 +00:00
}
else
allfilenames = GetAllFilesWithTitle ( pathname , filename , false ) ;
2010-08-13 15:19:51 +00:00
foreach ( string foundfile in allfilenames )
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
result . Add ( new TextResourceData ( this , LoadFile ( foundfile ) , foundfile , true ) ) ;
2010-08-12 10:03:29 +00:00
// Find in any of the wad files
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
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
result . AddRange ( wads [ i ] . GetDecorateData ( pname ) ) ;
2014-10-23 12:48:31 +00:00
return result ;
2009-04-19 18:07:22 +00:00
}
2017-01-15 22:00:45 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = ZSCRIPT
// This finds and returns ZSCRIPT streams
public override IEnumerable < TextResourceData > GetZScriptData ( string pname )
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
List < TextResourceData > result = new List < TextResourceData > ( ) ;
string [ ] allfilenames ;
// Find in root directory
string filename = Path . GetFileName ( pname ) ;
string pathname = Path . GetDirectoryName ( pname ) ;
if ( filename . IndexOf ( '.' ) > - 1 )
{
2020-07-29 07:57:42 +00:00
allfilenames = GetFileAtPath ( filename , pathname , "ZSCRIPT" ) ;
2017-01-15 22:00:45 +00:00
}
else
allfilenames = GetAllFilesWithTitle ( pathname , filename , false ) ;
foreach ( string foundfile in allfilenames )
result . Add ( new TextResourceData ( this , LoadFile ( foundfile ) , foundfile , true ) ) ;
// Find in any of the wad files
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
result . AddRange ( wads [ i ] . GetZScriptData ( pname ) ) ;
return result ;
}
#endregion
2018-06-09 14:26:03 +00:00
#region = = = = = = = = = = = = = = = = = = MODELDEF
// This finds and returns MODELDEF streams
public override IEnumerable < TextResourceData > GetModeldefData ( string pname )
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
List < TextResourceData > result = new List < TextResourceData > ( ) ;
string [ ] allfilenames ;
// Find in root directory
string filename = Path . GetFileName ( pname ) ;
string pathname = Path . GetDirectoryName ( pname ) ;
if ( filename . IndexOf ( '.' ) > - 1 )
{
2020-07-29 07:57:42 +00:00
allfilenames = GetFileAtPath ( filename , pathname , "MODELDEF" ) ;
2018-06-09 14:26:03 +00:00
}
else
allfilenames = GetAllFilesWithTitle ( pathname , filename , false ) ;
foreach ( string foundfile in allfilenames )
result . Add ( new TextResourceData ( this , LoadFile ( foundfile ) , foundfile , true ) ) ;
// Find in any of the wad files
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
result . AddRange ( wads [ i ] . GetModeldefData ( pname ) ) ;
return result ;
}
#endregion
2017-01-15 22:00:45 +00:00
#region = = = = = = = = = = = = = = = = = = VOXELDEF ( mxd )
//mxd. This returns the list of voxels, which can be used without VOXELDEF definition
public override HashSet < string > GetVoxelNames ( )
2014-11-25 11:52:01 +00:00
{
2014-01-03 10:33:45 +00:00
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2016-07-11 22:13:43 +00:00
HashSet < string > result = new HashSet < string > ( ) ;
2014-01-03 10:33:45 +00:00
2016-07-11 22:13:43 +00:00
// Load from wad files
// Note the backward order, because the last wad's images have priority
for ( int i = wads . Count - 1 ; i > = 0 ; i - - )
{
result . UnionWith ( wads [ i ] . GetVoxelNames ( ) ) ;
}
// Load from out own files
string [ ] files = GetAllFiles ( "voxels" , false ) ;
2015-12-28 15:01:53 +00:00
foreach ( string t in files )
2014-11-25 11:52:01 +00:00
{
string s = Path . GetFileNameWithoutExtension ( t ) . ToUpperInvariant ( ) ;
2016-07-11 22:13:43 +00:00
if ( WADReader . IsValidVoxelName ( s ) ) result . Add ( s ) ;
2014-01-03 10:33:45 +00:00
}
2016-07-11 22:13:43 +00:00
return result ;
2014-01-03 10:33:45 +00:00
}
2013-09-11 09:47:53 +00:00
#endregion
2014-01-03 10:33:45 +00:00
#region = = = = = = = = = = = = = = = = = = ( Z ) MAPINFO ( mxd )
2013-09-11 09:47:53 +00:00
//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
public override IEnumerable < TextResourceData > GetMapinfoData ( )
2014-11-25 11:52:01 +00:00
{
2013-09-11 09:47:53 +00:00
// Error when suspended
2015-12-28 15:01:53 +00:00
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2013-09-11 09:47:53 +00:00
2016-01-11 13:00:52 +00:00
// Mapinfo should be in root folder
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
List < TextResourceData > result = new List < TextResourceData > ( ) ;
2013-09-11 09:47:53 +00:00
2016-01-11 13:00:52 +00:00
// Try to find (z)mapinfo
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 [ ] files = GetAllFilesWithTitle ( "" , "ZMAPINFO" , false ) ;
if ( files . Length = = 0 ) files = GetAllFilesWithTitle ( "" , "MAPINFO" , false ) ;
2016-04-23 23:15:43 +00:00
// Add to collection
foreach ( string s in files )
result . Add ( new TextResourceData ( this , LoadFile ( s ) , s , true ) ) ;
2013-09-11 09:47:53 +00:00
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
// Find in any of the wad files
foreach ( WADReader wr in wads ) result . AddRange ( wr . GetMapinfoData ( ) ) ;
return result ;
2013-09-11 09:47:53 +00:00
}
#endregion
2014-01-03 10:33:45 +00:00
#region = = = = = = = = = = = = = = = = = = GLDEFS ( mxd )
2013-09-11 09:47:53 +00:00
//mxd
2016-07-14 23:39:48 +00:00
public override IEnumerable < TextResourceData > GetGldefsData ( string basegame )
2014-11-25 11:52:01 +00:00
{
2013-09-11 09:47:53 +00:00
// Error when suspended
2015-12-18 10:16:53 +00:00
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
2013-09-11 09:47:53 +00:00
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
List < TextResourceData > result = new List < TextResourceData > ( ) ;
2014-01-03 10:33:45 +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
// At least one of gldefs should be in the root folder
List < string > files = new List < string > ( ) ;
2013-09-11 09:47:53 +00:00
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
// Try to load game specific GLDEFS first
2016-07-14 23:39:48 +00:00
if ( basegame ! = GameType . UNKNOWN )
2014-11-25 11:52:01 +00:00
{
2016-07-14 23:39:48 +00:00
string lumpname = GameType . GldefsLumpsPerGame [ basegame ] ;
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
files . AddRange ( GetAllFilesWhichTitleStartsWith ( "" , lumpname , false ) ) ;
2013-09-11 09:47:53 +00:00
}
2014-11-25 11:52:01 +00:00
// Can be several entries
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
files . AddRange ( GetAllFilesWhichTitleStartsWith ( "" , "GLDEFS" , false ) ) ;
// Add to collection
2015-12-18 10:16:53 +00:00
foreach ( string s in files )
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
result . Add ( new TextResourceData ( this , LoadFile ( s ) , s , true ) ) ;
// Find in any of the wad files
2016-07-14 23:39:48 +00:00
foreach ( WADReader wr in wads ) result . AddRange ( wr . GetGldefsData ( basegame ) ) ;
2013-09-11 09:47:53 +00:00
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
return result ;
2013-09-11 09:47:53 +00:00
}
#endregion
2016-12-12 12:35:18 +00:00
#region = = = = = = = = = = = = = = = = = = Generic text lumps loading ( mxd )
2015-01-25 23:22:42 +00:00
2016-12-12 12:35:18 +00:00
public override IEnumerable < TextResourceData > GetTextLumpData ( ScriptType scripttype , bool singular , bool partialtitlematch )
2015-01-25 23:22:42 +00:00
{
// Error when suspended
if ( issuspended ) throw new Exception ( "Data reader is suspended" ) ;
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
List < TextResourceData > result = new List < TextResourceData > ( ) ;
2016-12-12 12:35:18 +00:00
List < string > files = new List < string > ( ) ;
string lumpname = Enum . GetName ( typeof ( ScriptType ) , scripttype ) . ToUpperInvariant ( ) ;
2016-07-14 23:39:48 +00:00
2016-12-12 12:35:18 +00:00
if ( singular )
{
string file = FindFirstFile ( lumpname , false ) ;
if ( ! string . IsNullOrEmpty ( file ) ) files . Add ( file ) ;
}
else
{
files = new List < string > ( partialtitlematch ?
GetAllFilesWhichTitleStartsWith ( "" , lumpname , false ) :
GetAllFilesWithTitle ( "" , lumpname , false ) ) ;
}
2016-07-14 23:39:48 +00:00
// Add to collection
foreach ( string s in files )
result . Add ( new TextResourceData ( this , LoadFile ( s ) , s , true ) ) ;
// Find in any of the wad files
2016-12-12 12:35:18 +00:00
foreach ( WADReader wr in wads )
result . AddRange ( wr . GetTextLumpData ( scripttype , singular , partialtitlematch ) ) ;
2016-11-24 21:09:24 +00:00
return result ;
}
#endregion
2013-09-11 09:47:53 +00:00
#region = = = = = = = = = = = = = = = = = = Methods
// This loads the images in this directory
2009-05-12 09:50:08 +00:00
private ICollection < ImageData > LoadDirectoryImages ( string path , int imagetype , bool includesubdirs )
2009-04-19 18:07:22 +00:00
{
List < ImageData > images = new List < ImageData > ( ) ;
// Go for all files
2014-05-19 13:33:38 +00:00
string [ ] files = GetAllFiles ( path , includesubdirs ) ;
2009-04-19 18:07:22 +00:00
foreach ( string f in files )
{
2014-11-25 11:52:01 +00:00
if ( string . IsNullOrEmpty ( Path . GetFileNameWithoutExtension ( f ) ) )
2009-04-19 18:07:22 +00:00
{
// Can't load image without name
2009-05-10 16:02:08 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Can't load an unnamed texture from \"" + path + "\". Please consider giving names to your resources." ) ;
2014-05-19 13:33:38 +00:00
}
else
{
// Add image to list
2014-11-25 11:52:01 +00:00
images . Add ( CreateImage ( f , imagetype ) ) ;
2009-04-19 18:07:22 +00:00
}
}
// Return result
return images ;
}
2020-07-29 07:57:42 +00:00
2020-07-29 20:05:12 +00:00
/// <summary>
/// Gets a correctly cased file from a path/file. This is required for case sensitive file systems.
/// </summary>
/// <param name="filename">File name without path</param>
/// <param name="pathname">Path to the file</param>
/// <param name="type">Type of file (i.e. everything before the first dot)</param>
/// <returns>Array with one element on success, array with no elements on failure</returns>
2020-07-29 07:57:42 +00:00
protected string [ ] GetFileAtPath ( string filename , string pathname , string type )
{
string fullname = Path . Combine ( pathname , filename ) ;
2020-07-29 20:05:12 +00:00
2020-07-29 07:57:42 +00:00
if ( FileExists ( fullname ) )
{
2020-07-29 21:30:17 +00:00
return new string [ 1 ] { fullname } ;
2020-07-29 07:57:42 +00:00
}
else
{
General . ErrorLogger . Add ( ErrorType . Warning , "Unable to load " + type + " file \"" + fullname + "\"" ) ;
2020-07-29 20:05:12 +00:00
return new string [ 0 ] ;
2020-07-29 07:57:42 +00:00
}
}
2009-04-19 18:07:22 +00:00
// This copies images from a collection unless they already exist in the list
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 static void AddImagesToList ( Dictionary < long , ImageData > targetlist , IEnumerable < ImageData > sourcelist )
2009-04-19 18:07:22 +00:00
{
// Go for all source images
foreach ( ImageData src in sourcelist )
{
// Check if exists in target list
if ( ! targetlist . ContainsKey ( src . LongName ) )
targetlist . Add ( src . LongName , src ) ;
}
}
// This must create an image
2014-11-25 11:52:01 +00:00
protected abstract ImageData CreateImage ( string filename , int imagetype ) ;
2009-04-19 18:07:22 +00:00
// This must return all files in a given directory
protected abstract string [ ] GetAllFiles ( string path , bool subfolders ) ;
2010-08-13 15:19:51 +00:00
// This must return all files in a given directory that have the given file title
protected abstract string [ ] GetAllFilesWithTitle ( string path , string title , bool subfolders ) ;
2013-09-11 09:47:53 +00:00
//mxd. This must return all files in a given directory which title starts with given title
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 abstract string [ ] GetAllFilesWhichTitleStartsWith ( string path , string title , bool subfolders ) ;
2012-08-05 19:18:05 +00:00
2009-04-19 18:07:22 +00:00
// This must return all files in a given directory that match the given extension
2016-11-24 21:09:24 +00:00
internal abstract string [ ] GetFilesWithExt ( string path , string extension , bool subfolders ) ;
2009-04-19 18:07:22 +00:00
2016-04-23 23:15:43 +00:00
//mxd. This must return wad files in the root directory
protected abstract string [ ] GetWadFiles ( ) ;
2009-04-19 18:07:22 +00:00
// This must find the first file that has the specific name, regardless of file extension
2016-01-13 09:34:32 +00:00
internal abstract string FindFirstFile ( string beginswith , bool subfolders ) ;
2009-04-19 18:07:22 +00:00
// This must find the first file that has the specific name, regardless of file extension
protected abstract string FindFirstFile ( string path , string beginswith , bool subfolders ) ;
// This must find the first file that has the specific name
protected abstract string FindFirstFileWithExt ( string path , string beginswith , bool subfolders ) ;
2012-07-23 21:28:23 +00:00
2009-04-19 18:07:22 +00:00
// This must create a temp file for the speciied file and return the absolute path to the temp file
// NOTE: Callers are responsible for removing the temp file when done!
protected abstract string CreateTempFile ( string filename ) ;
// This makes the path relative to the directory, if needed
protected virtual string MakeRelativePath ( string anypath )
{
if ( Path . IsPathRooted ( anypath ) )
{
// Make relative
string lowpath = anypath . ToLowerInvariant ( ) ;
string lowlocation = location . location . ToLowerInvariant ( ) ;
if ( ( lowpath . Length > ( lowlocation . Length + 1 ) ) & & lowpath . StartsWith ( lowlocation ) )
return anypath . Substring ( lowlocation . Length + 1 ) ;
else
return anypath ;
}
else
{
// Path is already relative
return anypath ;
}
}
2016-04-29 13:42:52 +00:00
2020-07-29 20:05:12 +00:00
/// <summary>
/// Returns the correctly cased file from a path/file. This is required for case sensitive file systems. For PK3s the input will already have the correct case.
/// </summary>
/// <param name="filepathname">File name get the the correctly cased name from</param>
/// <returns></returns>
2020-07-29 07:57:42 +00:00
protected virtual string GetCorrectCaseForFile ( string filepathname )
{
return filepathname ;
}
2016-04-29 13:42:52 +00:00
//mxd. Archives and Folders don't have lump indices
internal override MemoryStream LoadFile ( string name , int unused )
{
return LoadFile ( name ) ;
}
2009-04-19 18:07:22 +00:00
#endregion
}
}