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 ;
2016-01-11 13:00:52 +00:00
using System.Drawing ;
using System.Drawing.Drawing2D ;
using System.Drawing.Imaging ;
2009-04-19 18:07:22 +00:00
using System.IO ;
2016-03-23 14:52:33 +00:00
using System.Linq ;
2016-03-14 00:01:21 +00:00
using System.Runtime.InteropServices ;
2015-11-28 23:31:54 +00:00
using System.Threading ;
2014-03-03 13:40:29 +00:00
using System.Windows.Forms ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.Config ;
2016-11-24 11:55:11 +00:00
using CodeImp.DoomBuilder.Data.Scripting ;
2012-05-21 23:51:32 +00:00
using CodeImp.DoomBuilder.GZBuilder.Data ;
using CodeImp.DoomBuilder.GZBuilder.MD3 ;
2016-01-14 11:39:52 +00:00
using CodeImp.DoomBuilder.Geometry ;
2015-11-28 23:31:54 +00:00
using CodeImp.DoomBuilder.IO ;
using CodeImp.DoomBuilder.Map ;
2016-01-14 11:39:52 +00:00
using CodeImp.DoomBuilder.Rendering ;
2015-11-28 23:31:54 +00:00
using CodeImp.DoomBuilder.Windows ;
using CodeImp.DoomBuilder.ZDoom ;
2019-08-08 16:24:33 +00:00
using Matrix = CodeImp . DoomBuilder . Rendering . Matrix ;
2017-03-02 18:14:24 +00:00
using CodeImp.DoomBuilder.Controls ;
2012-05-21 23:51:32 +00:00
2009-04-19 18:07:22 +00:00
#endregion
namespace CodeImp.DoomBuilder.Data
{
public sealed class DataManager
{
#region = = = = = = = = = = = = = = = = = = Constants
public const string INTERNAL_PREFIX = "internal:" ;
2014-11-25 11:52:01 +00:00
public const int CLASIC_IMAGE_NAME_LENGTH = 8 ; //mxd
2016-03-04 08:10:56 +00:00
private const int MAX_SKYTEXTURE_SIZE = 2048 ; //mxd
2016-05-13 13:41:09 +00:00
internal static readonly char [ ] CATEGORY_SPLITTER = { Path . DirectorySeparatorChar , Path . AltDirectorySeparatorChar } ; //mxd
2016-04-08 14:02:08 +00:00
private long UNKNOWN_THING ; //mxd
private long MISSING_THING ; //mxd
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Variables
// Data containers
private List < DataReader > containers ;
private DataReader currentreader ;
// Palette
private Playpal palette ;
// Textures, Flats and Sprites
private Dictionary < long , ImageData > textures ;
2014-11-25 11:52:01 +00:00
private Dictionary < long , long > texturenamesshorttofull ; //mxd
2009-04-19 18:07:22 +00:00
private List < string > texturenames ;
private Dictionary < long , ImageData > flats ;
2014-11-25 11:52:01 +00:00
private Dictionary < long , long > flatnamesshorttofull ; //mxd
2016-03-23 14:52:33 +00:00
private Dictionary < long , long > flatnamesfulltoshort ; //mxd
2009-04-19 18:07:22 +00:00
private List < string > flatnames ;
private Dictionary < long , ImageData > sprites ;
private List < MatchingTextureSet > texturesets ;
private List < ResourceTextureSet > resourcetextures ;
private AllTextureSet alltextures ;
2012-04-17 19:13:47 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2015-04-14 11:33:57 +00:00
private Dictionary < int , ModelData > modeldefentries ; //Thing.Type, Model entry
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 Dictionary < int , DynamicLightData > gldefsentries ; //Thing.Type, Light entry
2015-04-14 11:33:57 +00:00
private MapInfo mapinfo ;
2015-01-25 23:22:42 +00:00
private Dictionary < string , KeyValuePair < int , int > > reverbs ; //<name, <arg1, arg2>
2015-04-14 11:33:57 +00:00
private Dictionary < long , GlowingFlatData > glowingflats ; // Texture name hash, Glowing Flat Data
2016-01-11 13:00:52 +00:00
private Dictionary < string , SkyboxInfo > skyboxes ;
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 string [ ] soundsequences ;
private string [ ] terrainnames ;
private string [ ] damagetypes ;
2016-03-16 23:26:53 +00:00
private Dictionary < string , PixelColor > knowncolors ; // Colors parsed from X11R6RGB lump. Color names are lowercase without spaces
2016-04-13 14:11:35 +00:00
private CvarsCollection cvars ; // Variables parsed from CVARINFO
2016-07-15 14:07:30 +00:00
private Dictionary < int , PixelColor > lockcolors ; // Lock colors defined in LOCKDEFS
private Dictionary < int , int > lockableactions ; // <Action number, arg referenceing "keys" enum number>
2016-10-05 20:15:38 +00:00
private Dictionary < int , AmbientSoundInfo > ambientsounds ;
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
//mxd. Text resources
2016-11-24 11:55:11 +00:00
private Dictionary < ScriptType , HashSet < ScriptResource > > scriptresources ;
2009-04-19 18:07:22 +00:00
// Background loading
private Queue < ImageData > imageque ;
private Thread backgroundloader ;
private volatile bool updatedusedtextures ;
private bool notifiedbusy ;
// Image previews
private PreviewManager previews ;
// Special images
private ImageData missingtexture3d ;
private ImageData unknowntexture3d ;
2014-01-13 08:06:56 +00:00
private UnknownImage unknownimage ; //mxd
2009-04-19 18:07:22 +00:00
private ImageData hourglass3d ;
private ImageData crosshair ;
private ImageData crosshairbusy ;
2016-04-08 14:02:08 +00:00
private Dictionary < string , long > internalspriteslookup ; //mxd
2009-06-04 20:21:31 +00:00
private ImageData whitetexture ;
2015-12-04 12:29:22 +00:00
private ImageData blacktexture ; //mxd
2016-04-01 10:49:19 +00:00
private ImageData thingtexture ; //mxd
2015-07-14 23:34:31 +00:00
2016-12-22 15:04:40 +00:00
//mxd. Texture Browser images
private ImageData foldertexture ;
private ImageData folderuptexture ;
2016-01-11 13:00:52 +00:00
//mxd. Sky textures
private CubeTexture skybox ; // GZDoom skybox
2015-07-14 23:34:31 +00:00
//mxd. Comment icons
private ImageData [ ] commenttextures ;
2009-04-19 18:07:22 +00:00
// Used images
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 Dictionary < long , bool > usedtextures ; //mxd
private Dictionary < long , bool > usedflats ; //mxd. Used only when MixTextursFlats is disabled
2009-04-19 18:07:22 +00:00
// Things combined with things created from Decorate
2009-08-15 08:41:43 +00:00
private DecorateParser decorate ;
2017-01-15 22:00:45 +00:00
private ZScriptParser zscript ;
2017-01-16 08:20:47 +00:00
private Dictionary < string , ActorStructure > zdoomclasses ;
2009-04-19 18:07:22 +00:00
private List < ThingCategory > thingcategories ;
private Dictionary < int , ThingTypeInfo > thingtypes ;
// Timing
2016-03-14 00:01:21 +00:00
private long loadstarttime ;
private long loadfinishtime ;
2009-04-19 18:07:22 +00:00
// Disposing
2014-02-21 14:42:12 +00:00
private bool isdisposed ;
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Properties
2013-09-11 09:47:53 +00:00
//mxd
2015-04-14 11:33:57 +00:00
internal Dictionary < int , ModelData > ModeldefEntries { get { return modeldefentries ; } }
internal Dictionary < int , DynamicLightData > GldefsEntries { get { return gldefsentries ; } }
public MapInfo MapInfo { get { return mapinfo ; } }
2015-01-25 23:22:42 +00:00
public Dictionary < string , KeyValuePair < int , int > > Reverbs { get { return reverbs ; } }
2015-04-14 11:33:57 +00:00
public Dictionary < long , GlowingFlatData > GlowingFlats { get { return glowingflats ; } }
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 string [ ] SoundSequences { get { return soundsequences ; } }
public string [ ] TerrainNames { get { return terrainnames ; } }
public string [ ] DamageTypes { get { return damagetypes ; } }
2016-03-16 23:26:53 +00:00
public Dictionary < string , PixelColor > KnownColors { get { return knowncolors ; } }
2016-11-24 11:55:11 +00:00
internal Dictionary < ScriptType , HashSet < ScriptResource > > ScriptResources { get { return scriptresources ; } }
2016-04-13 14:11:35 +00:00
internal CvarsCollection CVars { get { return cvars ; } }
2016-07-15 14:07:30 +00:00
public Dictionary < int , PixelColor > LockColors { get { return lockcolors ; } }
public Dictionary < int , int > LockableActions { get { return lockableactions ; } }
2016-10-05 20:15:38 +00:00
public Dictionary < int , AmbientSoundInfo > AmbientSounds { get { return ambientsounds ; } }
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
internal IEnumerable < DataReader > Containers { get { return containers ; } }
2012-04-17 19:13:47 +00:00
2009-04-19 18:07:22 +00:00
public Playpal Palette { get { return palette ; } }
public PreviewManager Previews { get { return previews ; } }
public ICollection < ImageData > Textures { get { return textures . Values ; } }
2013-12-03 10:50:33 +00:00
public ICollection < ImageData > Flats { get { return flats . Values ; } }
2009-04-19 18:07:22 +00:00
public List < string > TextureNames { get { return texturenames ; } }
2013-12-03 10:50:33 +00:00
public List < string > FlatNames { get { return flatnames ; } }
2009-04-19 18:07:22 +00:00
public bool IsDisposed { get { return isdisposed ; } }
public ImageData MissingTexture3D { get { return missingtexture3d ; } }
public ImageData UnknownTexture3D { get { return unknowntexture3d ; } }
2017-04-03 17:40:51 +00:00
public ImageData UnknownImage { get { return unknownimage ; } }
2009-04-19 18:07:22 +00:00
public ImageData Hourglass3D { get { return hourglass3d ; } }
public ImageData Crosshair3D { get { return crosshair ; } }
public ImageData CrosshairBusy3D { get { return crosshairbusy ; } }
2009-06-04 20:21:31 +00:00
public ImageData WhiteTexture { get { return whitetexture ; } }
2015-12-04 12:29:22 +00:00
public ImageData BlackTexture { get { return blacktexture ; } } //mxd
2016-04-01 10:49:19 +00:00
public ImageData ThingTexture { get { return thingtexture ; } } //mxd
2016-12-22 15:04:40 +00:00
internal ImageData FolderTexture { get { return foldertexture ; } } //mxd
internal ImageData FolderUpTexture { get { return folderuptexture ; } } //mxd
2015-07-14 23:34:31 +00:00
public ImageData [ ] CommentTextures { get { return commenttextures ; } } //mxd
2016-01-11 13:00:52 +00:00
internal CubeTexture SkyBox { get { return skybox ; } } //mxd
2009-04-19 18:07:22 +00:00
public List < ThingCategory > ThingCategories { get { return thingcategories ; } }
public ICollection < ThingTypeInfo > ThingTypes { get { return thingtypes . Values ; } }
2009-08-15 08:41:43 +00:00
public DecorateParser Decorate { get { return decorate ; } }
2017-01-15 22:00:45 +00:00
public ZScriptParser ZScript { get { return zscript ; } }
2009-04-19 18:07:22 +00:00
internal ICollection < MatchingTextureSet > TextureSets { get { return texturesets ; } }
internal ICollection < ResourceTextureSet > ResourceTextureSets { get { return resourcetextures ; } }
internal AllTextureSet AllTextureSet { get { return alltextures ; } }
public bool IsLoading
{
get
{
if ( imageque ! = null )
return ( backgroundloader ! = null ) & & backgroundloader . IsAlive & & ( ( imageque . Count > 0 ) | | previews . IsLoading ) ;
2013-07-29 08:50:50 +00:00
return false ;
2009-04-19 18:07:22 +00:00
}
}
2017-08-27 05:09:28 +00:00
internal const float DOOM_PIXEL_RATIO = 1.2f ;
public float VerticalViewStretch
{
get
{
if ( mapinfo = = null )
return DOOM_PIXEL_RATIO ;
return mapinfo . PixelRatio ;
}
}
public float InvertedVerticalViewStretch
{
get
{
return 1.0f / VerticalViewStretch ;
}
}
#endregion
#region = = = = = = = = = = = = = = = = = = Constructor / Disposer
2009-04-19 18:07:22 +00:00
2017-08-27 05:09:28 +00:00
// Constructor
internal DataManager ( )
2009-04-19 18:07:22 +00:00
{
// We have no destructor
GC . SuppressFinalize ( this ) ;
2015-12-30 13:58:58 +00:00
// Load special images (mxd: the rest is loaded in LoadInternalTextures())
2015-12-04 12:29:22 +00:00
whitetexture = new ResourceImage ( "CodeImp.DoomBuilder.Resources.White.png" ) { UseColorCorrection = false } ;
2009-06-04 20:21:31 +00:00
whitetexture . LoadImage ( ) ;
whitetexture . CreateTexture ( ) ;
2015-12-04 12:29:22 +00:00
blacktexture = new ResourceImage ( "CodeImp.DoomBuilder.Resources.Black.png" ) { UseColorCorrection = false } ; //mxd
blacktexture . LoadImage ( ) ; //mxd
blacktexture . CreateTexture ( ) ; //mxd
2014-01-13 08:06:56 +00:00
unknownimage = new UnknownImage ( Properties . Resources . UnknownImage ) ; //mxd. There should be only one!
2015-07-14 23:34:31 +00:00
2016-12-22 15:04:40 +00:00
//mxd. Textures browser images
foldertexture = new ResourceImage ( "CodeImp.DoomBuilder.Resources.Folder96.png" ) { UseColorCorrection = false } ;
foldertexture . LoadImage ( ) ;
folderuptexture = new ResourceImage ( "CodeImp.DoomBuilder.Resources.Folder96Up.png" ) { UseColorCorrection = false } ;
folderuptexture . LoadImage ( ) ;
2015-07-14 23:34:31 +00:00
//mxd. Create comment icons
commenttextures = new ImageData [ ]
{
2016-12-22 15:04:40 +00:00
new ResourceImage ( "CodeImp.DoomBuilder.Resources.CommentRegular.png" ) { UseColorCorrection = false } ,
new ResourceImage ( "CodeImp.DoomBuilder.Resources.CommentInfo.png" ) { UseColorCorrection = false } ,
new ResourceImage ( "CodeImp.DoomBuilder.Resources.CommentQuestion.png" ) { UseColorCorrection = false } ,
new ResourceImage ( "CodeImp.DoomBuilder.Resources.CommentProblem.png" ) { UseColorCorrection = false } ,
new ResourceImage ( "CodeImp.DoomBuilder.Resources.CommentSmile.png" ) { UseColorCorrection = false } ,
2015-07-14 23:34:31 +00:00
} ;
//mxd. Load comment icons
2015-12-28 15:01:53 +00:00
foreach ( ImageData data in commenttextures )
2015-07-14 23:34:31 +00:00
{
data . LoadImage ( ) ;
data . CreateTexture ( ) ;
}
2009-04-19 18:07:22 +00:00
}
2009-06-04 20:21:31 +00:00
2009-04-19 18:07:22 +00:00
// Disposer
internal void Dispose ( )
{
// Not already disposed?
if ( ! isdisposed )
{
// Clean up
Unload ( ) ;
missingtexture3d . Dispose ( ) ;
missingtexture3d = null ;
unknowntexture3d . Dispose ( ) ;
unknowntexture3d = null ;
hourglass3d . Dispose ( ) ;
hourglass3d = null ;
crosshair . Dispose ( ) ;
crosshair = null ;
crosshairbusy . Dispose ( ) ;
crosshairbusy = null ;
2009-06-04 20:21:31 +00:00
whitetexture . Dispose ( ) ;
whitetexture = null ;
2015-12-04 12:29:22 +00:00
blacktexture . Dispose ( ) ; //mxd
blacktexture = null ; //mxd
2016-04-01 10:49:19 +00:00
thingtexture . Dispose ( ) ; //mxd
thingtexture = null ; //mxd
2014-01-13 08:06:56 +00:00
unknownimage . Dispose ( ) ; //mxd
unknownimage = null ; //mxd
2016-12-22 15:04:40 +00:00
foldertexture . Dispose ( ) ; //mxd
foldertexture = null ; //mxd
folderuptexture . Dispose ( ) ; //mxd
folderuptexture = null ; //mxd
2016-01-11 13:00:52 +00:00
for ( int i = 0 ; i < commenttextures . Length ; i + + ) //mxd
{
commenttextures [ i ] . Dispose ( ) ;
commenttextures [ i ] = null ;
}
2015-09-16 12:10:43 +00:00
commenttextures = null ;
2016-01-11 13:00:52 +00:00
if ( skybox ! = null ) //mxd
{
skybox . Dispose ( ) ;
skybox = null ;
}
2009-04-19 18:07:22 +00:00
// Done
isdisposed = true ;
}
}
#endregion
#region = = = = = = = = = = = = = = = = = = Loading / Unloading
// This loads all data resources
internal void Load ( DataLocationList configlist , DataLocationList maplist , DataLocation maplocation )
{
2016-04-29 13:42:52 +00:00
//mxd. Don't modify original lists
DataLocationList configlistcopy = new DataLocationList ( configlist ) ;
DataLocationList maplistcopy = new DataLocationList ( maplist ) ;
2009-04-19 18:07:22 +00:00
2016-04-29 13:42:52 +00:00
//mxd. If maplocation was already added as a resource, make sure it's singular and is the last in the list
configlistcopy . Remove ( maplocation ) ;
maplistcopy . Remove ( maplocation ) ;
maplistcopy . Add ( maplocation ) ;
Load ( configlistcopy , maplistcopy ) ;
2009-04-19 18:07:22 +00:00
}
// This loads all data resources
2016-04-29 13:42:52 +00:00
internal void Load ( DataLocationList configlist , DataLocationList maplist )
2009-04-19 18:07:22 +00:00
{
Dictionary < long , ImageData > texturesonly = new Dictionary < long , ImageData > ( ) ;
2009-05-12 09:50:08 +00:00
Dictionary < long , ImageData > colormapsonly = new Dictionary < long , ImageData > ( ) ;
2009-04-19 18:07:22 +00:00
Dictionary < long , ImageData > flatsonly = new Dictionary < long , ImageData > ( ) ;
2015-12-27 21:54:50 +00:00
2009-04-19 18:07:22 +00:00
// Create collections
containers = new List < DataReader > ( ) ;
textures = new Dictionary < long , ImageData > ( ) ;
flats = new Dictionary < long , ImageData > ( ) ;
sprites = new Dictionary < long , ImageData > ( ) ;
texturenames = new List < string > ( ) ;
flatnames = new List < string > ( ) ;
2014-11-25 11:52:01 +00:00
texturenamesshorttofull = new Dictionary < long , long > ( ) ; //mxd
flatnamesshorttofull = new Dictionary < long , long > ( ) ; //mxd
2016-03-23 14:52:33 +00:00
flatnamesfulltoshort = new Dictionary < long , long > ( ) ; //mxd
2009-04-19 18:07:22 +00:00
imageque = new Queue < ImageData > ( ) ;
previews = new PreviewManager ( ) ;
texturesets = new List < MatchingTextureSet > ( ) ;
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
usedtextures = new Dictionary < long , bool > ( ) ; //mxd
usedflats = new Dictionary < long , bool > ( ) ; //mxd
2009-04-19 18:07:22 +00:00
thingcategories = General . Map . Config . GetThingCategories ( ) ;
thingtypes = General . Map . Config . GetThingTypes ( ) ;
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. Create even more collections!
modeldefentries = new Dictionary < int , ModelData > ( ) ;
gldefsentries = new Dictionary < int , DynamicLightData > ( ) ;
reverbs = new Dictionary < string , KeyValuePair < int , int > > ( StringComparer . Ordinal ) ;
glowingflats = new Dictionary < long , GlowingFlatData > ( ) ;
skyboxes = new Dictionary < string , SkyboxInfo > ( StringComparer . Ordinal ) ;
soundsequences = new string [ 0 ] ;
terrainnames = new string [ 0 ] ;
2016-11-24 11:55:11 +00:00
scriptresources = new Dictionary < ScriptType , HashSet < ScriptResource > > ( ) ;
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 string [ 0 ] ;
2016-03-16 23:26:53 +00:00
knowncolors = new Dictionary < string , PixelColor > ( StringComparer . OrdinalIgnoreCase ) ;
2016-10-05 20:15:38 +00:00
cvars = new CvarsCollection ( ) ;
ambientsounds = new Dictionary < int , AmbientSoundInfo > ( ) ;
2009-04-19 18:07:22 +00:00
// Load texture sets
foreach ( DefinedTextureSet ts in General . Map . ConfigSettings . TextureSets )
texturesets . Add ( new MatchingTextureSet ( ts ) ) ;
// Sort the texture sets
texturesets . Sort ( ) ;
// Special textures sets
alltextures = new AllTextureSet ( ) ;
resourcetextures = new List < ResourceTextureSet > ( ) ;
// Go for all locations
2016-04-29 13:42:52 +00:00
DataLocationList locations = DataLocationList . Combined ( configlist , maplist ) ; //mxd
2016-03-18 11:28:09 +00:00
string prevofficialiwad = string . Empty ; //mxd
2009-04-19 18:07:22 +00:00
foreach ( DataLocation dl in locations )
{
// Nothing chosen yet
2015-12-27 21:54:50 +00:00
DataReader c = null ;
2009-04-19 18:07:22 +00:00
// TODO: Make this work more elegant using reflection.
// Make DataLocation.type of type Type and assign the
// types of the desired reader classes.
try
{
// Choose container type
switch ( dl . type )
{
2016-11-24 11:55:11 +00:00
//mxd. Load resource in read-only mode if:
// 1. UseResourcesInReadonlyMode map option is set.
// 2. OR file has "Read only" flag set.
// 3. OR resource has "Exclude from testing parameters" flag set.
// 4. OR resource is official IWAD.
2009-04-19 18:07:22 +00:00
// WAD file container
case DataLocation . RESOURCE_WAD :
2016-11-24 11:55:11 +00:00
c = new WADReader ( dl , General . Map . Options . UseResourcesInReadonlyMode | | dl . notfortesting | | new FileInfo ( dl . location ) . IsReadOnly ) ;
2016-03-18 11:28:09 +00:00
if ( ( ( WADReader ) c ) . WadFile . IsOfficialIWAD ) //mxd
{
if ( ! string . IsNullOrEmpty ( prevofficialiwad ) )
General . ErrorLogger . Add ( ErrorType . Warning , "Using more than one official IWAD as a resource is not recommended. Consider removing \"" + prevofficialiwad + "\" or \"" + dl . GetDisplayName ( ) + "\"." ) ;
prevofficialiwad = dl . GetDisplayName ( ) ;
}
2009-04-19 18:07:22 +00:00
break ;
// Directory container
case DataLocation . RESOURCE_DIRECTORY :
2016-11-24 11:55:11 +00:00
c = new DirectoryReader ( dl , General . Map . Options . UseResourcesInReadonlyMode | | dl . notfortesting ) ;
2009-04-19 18:07:22 +00:00
break ;
// PK3 file container
case DataLocation . RESOURCE_PK3 :
2016-11-24 11:55:11 +00:00
c = new PK3Reader ( dl , General . Map . Options . UseResourcesInReadonlyMode | | dl . notfortesting | | new FileInfo ( dl . location ) . IsReadOnly ) ;
2009-04-19 18:07:22 +00:00
break ;
}
}
catch ( Exception e )
{
// Unable to load resource
2010-10-03 16:54:38 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Unable to load resources from location \"" + dl . location + "\". Please make sure the location is accessible and not in use by another program. The resources will now be loaded with this location excluded. You may reload the resources to try again.\n" + e . GetType ( ) . Name + " when creating data reader: " + e . Message ) ;
2009-04-19 18:07:22 +00:00
General . WriteLogLine ( e . StackTrace ) ;
continue ;
}
// Add container
if ( c ! = null )
{
containers . Add ( c ) ;
resourcetextures . Add ( c . TextureSet ) ;
}
}
// Load stuff
2016-03-16 23:26:53 +00:00
LoadX11R6RGB ( ) ; //mxd
2009-04-19 18:07:22 +00:00
LoadPalette ( ) ;
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
Dictionary < string , TexturesParser > cachedparsers = new Dictionary < string , TexturesParser > ( ) ; //mxd
int texcount = LoadTextures ( texturesonly , texturenamesshorttofull , cachedparsers ) ;
int flatcount = LoadFlats ( flatsonly , flatnamesshorttofull , cachedparsers ) ;
2015-12-27 21:54:50 +00:00
int colormapcount = LoadColormaps ( colormapsonly ) ;
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
LoadSprites ( cachedparsers ) ;
cachedparsers = null ; //mxd
2015-04-14 11:33:57 +00:00
2016-04-13 14:11:35 +00:00
//mxd. Load MAPINFO and CVARINFO. Should happen before parisng DECORATE
2016-01-18 11:39:59 +00:00
Dictionary < int , string > spawnnums , doomednums ;
2015-04-14 11:33:57 +00:00
LoadMapInfo ( out spawnnums , out doomednums ) ;
2016-04-13 14:11:35 +00:00
LoadCvarInfo ( ) ;
2016-07-14 23:39:48 +00:00
LoadLockDefs ( ) ;
2015-04-14 11:33:57 +00:00
2016-11-24 21:09:24 +00:00
//mxd. Load Script Editor-only stuff...
LoadExtraTextLumps ( ) ;
2017-01-16 00:08:35 +00:00
LoadZScriptThings ( ) ;
LoadDecorateThings ( ) ;
int thingcount = ApplyZDoomThings ( spawnnums , doomednums ) ;
2015-12-27 21:54:50 +00:00
int spritecount = LoadThingSprites ( ) ;
2009-04-19 18:07:22 +00:00
LoadInternalSprites ( ) ;
2015-12-30 13:58:58 +00:00
LoadInternalTextures ( ) ; //mxd
2012-05-21 23:51:32 +00:00
2015-01-25 23:22:42 +00:00
//mxd. Load more stuff
LoadReverbs ( ) ;
2015-05-28 13:45:01 +00:00
LoadSndSeq ( ) ;
2016-05-24 22:11:29 +00:00
LoadSndInfo ( ) ;
2014-12-03 23:15:26 +00:00
LoadVoxels ( ) ;
2013-09-11 09:47:53 +00:00
General . MainWindow . DisplayReady ( ) ;
2009-05-12 09:50:08 +00:00
// Process colormaps (we just put them in as textures)
foreach ( KeyValuePair < long , ImageData > t in colormapsonly )
{
textures . Add ( t . Key , t . Value ) ;
texturenames . Add ( t . Value . Name ) ;
}
2009-04-19 18:07:22 +00:00
// Process textures
foreach ( KeyValuePair < long , ImageData > t in texturesonly )
{
2009-05-14 21:36:25 +00:00
if ( ! textures . ContainsKey ( t . Key ) )
{
textures . Add ( t . Key , t . Value ) ;
2015-09-01 19:44:03 +00:00
//mxd. Add both short and long names?
if ( t . Value . HasLongName ) texturenames . Add ( t . Value . ShortName ) ;
2009-05-14 21:36:25 +00:00
texturenames . Add ( t . Value . Name ) ;
}
2009-04-19 18:07:22 +00:00
}
2013-12-03 10:50:33 +00:00
// Process flats
foreach ( KeyValuePair < long , ImageData > f in flatsonly )
{
flats . Add ( f . Key , f . Value ) ;
2015-09-01 19:44:03 +00:00
//mxd. Add both short and long names?
if ( f . Value . HasLongName ) flatnames . Add ( f . Value . ShortName ) ;
2013-12-03 10:50:33 +00:00
flatnames . Add ( f . Value . Name ) ;
}
2009-04-19 18:07:22 +00:00
// Mixed textures and flats?
2015-09-01 19:44:03 +00:00
if ( General . Map . Config . MixTexturesFlats )
2014-12-03 09:06:05 +00:00
{
2013-12-03 10:50:33 +00:00
// Add textures to flats
foreach ( KeyValuePair < long , ImageData > t in texturesonly )
{
if ( ! flats . ContainsKey ( t . Key ) )
{
flats . Add ( t . Key , t . Value ) ;
2015-09-01 19:44:03 +00:00
//mxd. Add both short and long names?
if ( t . Value . HasLongName ) flatnames . Add ( t . Value . ShortName ) ;
2013-12-03 10:50:33 +00:00
flatnames . Add ( t . Value . Name ) ;
}
2016-03-04 08:10:56 +00:00
else if ( t . Value is TEXTURESImage | | t . Value is SimpleTextureImage ) //mxd. Textures defined in TEXTURES or placed between TX_START and TX_END markers override "regular" flats in ZDoom
2014-07-07 08:42:46 +00:00
{
2014-12-03 09:06:05 +00:00
//TODO: check this!
2014-07-07 08:42:46 +00:00
flats [ t . Key ] = t . Value ;
}
2013-12-03 10:50:33 +00:00
}
2014-12-03 09:06:05 +00:00
//mxd
2015-09-01 19:44:03 +00:00
foreach ( KeyValuePair < long , long > t in texturenamesshorttofull )
if ( ! flatnamesshorttofull . ContainsKey ( t . Key ) ) flatnamesshorttofull . Add ( t . Key , t . Value ) ;
2014-12-03 09:06:05 +00:00
2016-03-23 14:52:33 +00:00
//mxd
flatnamesfulltoshort = flatnamesshorttofull . ToDictionary ( t = > t . Value , t = > t . Key ) ; //flatnamesshorttofull.ToDictionary(kp => kp.Value, kp => kp.Key);
2009-04-19 18:07:22 +00:00
// Add flats to textures
2013-12-03 10:50:33 +00:00
foreach ( KeyValuePair < long , ImageData > f in flatsonly )
{
if ( ! textures . ContainsKey ( f . Key ) )
{
2009-04-19 18:07:22 +00:00
textures . Add ( f . Key , f . Value ) ;
2015-09-01 19:44:03 +00:00
//mxd. Add both short and long names?
if ( f . Value . HasLongName ) texturenames . Add ( f . Value . ShortName ) ;
2009-04-19 18:07:22 +00:00
texturenames . Add ( f . Value . Name ) ;
}
}
2010-08-12 19:59:06 +00:00
2014-12-03 09:06:05 +00:00
//mxd
2015-09-01 19:44:03 +00:00
foreach ( KeyValuePair < long , long > t in flatnamesshorttofull )
if ( ! texturenamesshorttofull . ContainsKey ( t . Key ) ) texturenamesshorttofull . Add ( t . Key , t . Value ) ;
2014-12-03 09:06:05 +00:00
2010-08-12 19:59:06 +00:00
// Do the same on the data readers
2015-09-01 19:44:03 +00:00
foreach ( DataReader dr in containers )
2010-08-12 19:59:06 +00:00
dr . TextureSet . MixTexturesAndFlats ( ) ;
2009-04-19 18:07:22 +00:00
}
2015-04-14 11:33:57 +00:00
//mxd. Should be done after loading textures...
2016-03-04 08:10:56 +00:00
int hirestexcount = LoadHiResTextures ( ) ;
2015-12-18 10:16:53 +00:00
//mxd. Create camera textures. Should be done after loading textures.
LoadAnimdefs ( ) ;
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
LoadTerrain ( ) ;
2009-04-19 18:07:22 +00:00
// Sort names
texturenames . Sort ( ) ;
flatnames . Sort ( ) ;
2019-06-15 15:44:02 +00:00
// biwa. Moved model processing after texture processing, since the model might need one of those textures
Dictionary < string , int > actorsbyclass = CreateActorsByClassList ( ) ;
LoadModeldefs ( actorsbyclass ) ;
foreach ( Thing t in General . Map . Map . Things ) t . UpdateCache ( ) ;
LoadGldefs ( actorsbyclass ) ;
2009-04-19 18:07:22 +00:00
// Sort things
2019-06-15 15:44:02 +00:00
foreach ( ThingCategory tc in thingcategories ) tc . SortIfNeeded ( ) ;
2009-04-19 18:07:22 +00:00
// Update the used textures
General . Map . Data . UpdateUsedTextures ( ) ;
// Add texture names to texture sets
foreach ( KeyValuePair < long , ImageData > img in textures )
{
2013-07-29 08:50:50 +00:00
// Add to all sets
2009-04-19 18:07:22 +00:00
foreach ( MatchingTextureSet ms in texturesets )
2013-07-29 08:50:50 +00:00
ms . AddTexture ( img . Value ) ;
2009-04-19 18:07:22 +00:00
// Add to all
alltextures . AddTexture ( img . Value ) ;
}
// Add flat names to texture sets
foreach ( KeyValuePair < long , ImageData > img in flats )
{
2013-07-29 08:50:50 +00:00
// Add to all sets
2009-04-19 18:07:22 +00:00
foreach ( MatchingTextureSet ms in texturesets )
2013-07-29 08:50:50 +00:00
ms . AddFlat ( img . Value ) ;
2009-04-19 18:07:22 +00:00
// Add to all
alltextures . AddFlat ( img . Value ) ;
}
2016-01-14 22:15:54 +00:00
//mxd. Create skybox texture(s)
SetupSkybox ( ) ;
2017-03-02 18:14:24 +00:00
// [ZZ] clear texture/flat cache in ImageSelectorPanel
ImageSelectorPanel . ClearCachedPreviews ( ) ;
2009-04-19 18:07:22 +00:00
// Start background loading
StartBackgroundLoader ( ) ;
// Output info
2016-03-04 08:10:56 +00:00
General . WriteLogLine ( "Loaded " + texcount + " textures, " + flatcount + " flats, " + hirestexcount + " hires textures, " +
2015-04-14 11:33:57 +00:00
colormapcount + " colormaps, " + spritecount + " sprites, " +
2016-05-04 14:02:13 +00:00
thingcount + " decorate things, " + modeldefentries . Count + " model/voxel definitions, " +
2015-04-14 11:33:57 +00:00
gldefsentries . Count + " dynamic light definitions, " +
2016-01-11 13:00:52 +00:00
glowingflats . Count + " glowing flat definitions, " + skyboxes . Count + " skybox definitions, " +
reverbs . Count + " sound environment definitions" ) ;
2009-04-19 18:07:22 +00:00
}
// This unloads all data
2014-12-03 09:06:05 +00:00
private void Unload ( )
2009-04-19 18:07:22 +00:00
{
// Stop background loader
StopBackgroundLoader ( ) ;
// Dispose preview manager
previews . Dispose ( ) ;
previews = null ;
2010-08-19 15:06:15 +00:00
// Dispose decorate
decorate . Dispose ( ) ;
2009-04-19 18:07:22 +00:00
// Dispose resources
foreach ( KeyValuePair < long , ImageData > i in textures ) i . Value . Dispose ( ) ;
foreach ( KeyValuePair < long , ImageData > i in flats ) i . Value . Dispose ( ) ;
foreach ( KeyValuePair < long , ImageData > i in sprites ) i . Value . Dispose ( ) ;
palette = null ;
2012-05-21 23:51:32 +00:00
2015-09-16 12:10:43 +00:00
//mxd. Dispose models
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
foreach ( ModelData md in modeldefentries . Values ) md . Dispose ( ) ;
2015-09-16 12:10:43 +00:00
2009-04-19 18:07:22 +00:00
// Dispose containers
foreach ( DataReader c in containers ) c . Dispose ( ) ;
containers . Clear ( ) ;
// Trash collections
2010-08-19 15:06:15 +00:00
decorate = null ;
2009-04-19 18:07:22 +00:00
containers = null ;
textures = null ;
flats = null ;
sprites = null ;
2016-02-01 22:04:00 +00:00
modeldefentries = null ; //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
gldefsentries = null ; //mxd
reverbs = null ; //mxd
glowingflats = null ; //mxd
skyboxes = null ; //mxd
soundsequences = null ; //mxd
terrainnames = null ; //mxd
2016-11-24 11:55:11 +00:00
scriptresources = null ; //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 = null ; //mxd
2016-03-16 23:26:53 +00:00
knowncolors = null ; //mxd
2016-04-13 14:11:35 +00:00
cvars = null ; //mxd
2009-04-19 18:07:22 +00:00
texturenames = null ;
flatnames = null ;
imageque = null ;
2015-09-16 12:10:43 +00:00
mapinfo = null ; //mxd
2009-04-19 18:07:22 +00:00
}
2016-11-10 19:18:06 +00:00
//mxd. Called before Clock is reset
internal void OnBeforeClockReset ( )
{
if ( loadstarttime > 0 ) loadstarttime - = Clock . CurrentTime ;
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Suspend / Resume
// This suspends data resources
internal void Suspend ( )
{
// Stop background loader
StopBackgroundLoader ( ) ;
// Go for all containers
foreach ( DataReader d in containers )
{
// Suspend
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 . WriteLogLine ( "Suspended data resource \"" + d . Location . location + "\"" ) ;
2009-04-19 18:07:22 +00:00
d . Suspend ( ) ;
}
}
// This resumes data resources
internal void Resume ( )
{
// Go for all containers
foreach ( DataReader d in containers )
{
try
{
// Resume
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 . WriteLogLine ( "Resumed data resource \"" + d . Location . location + "\"" ) ;
2009-04-19 18:07:22 +00:00
d . Resume ( ) ;
}
catch ( Exception e )
{
// Unable to load resource
2009-05-10 16:02:08 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Unable to load resources from location \"" + d . Location . location + "\". Please make sure the location is accessible and not in use by another program. The resources will now be loaded with this location excluded. You may reload the resources to try again.\n" + e . GetType ( ) . Name + " when resuming data reader: " + e . Message + ")" ) ;
2009-04-19 18:07:22 +00:00
General . WriteLogLine ( e . StackTrace ) ;
}
}
// Start background loading
StartBackgroundLoader ( ) ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Background Loading
// This starts background loading
private void StartBackgroundLoader ( )
{
// Timing
2014-05-20 09:09:28 +00:00
loadstarttime = Clock . CurrentTime ;
2009-04-19 18:07:22 +00:00
loadfinishtime = 0 ;
// If a loader is already running, stop it first
if ( backgroundloader ! = null ) StopBackgroundLoader ( ) ;
// Start a low priority thread to load images in background
General . WriteLogLine ( "Starting background resource loading..." ) ;
2014-01-30 14:52:08 +00:00
backgroundloader = new Thread ( BackgroundLoad ) ;
2009-04-19 18:07:22 +00:00
backgroundloader . Name = "Background Loader" ;
backgroundloader . Priority = ThreadPriority . Lowest ;
backgroundloader . IsBackground = true ;
backgroundloader . Start ( ) ;
}
// This stops background loading
private void StopBackgroundLoader ( )
{
General . WriteLogLine ( "Stopping background resource loading..." ) ;
if ( backgroundloader ! = null )
{
// Stop the thread and wait for it to end
backgroundloader . Interrupt ( ) ;
backgroundloader . Join ( ) ;
// Reset load states on all images in the list
while ( imageque . Count > 0 )
{
2015-12-28 15:01:53 +00:00
ImageData img = imageque . Dequeue ( ) ;
2009-04-19 18:07:22 +00:00
switch ( img . ImageState )
{
case ImageLoadState . Loading :
img . ImageState = ImageLoadState . None ;
break ;
case ImageLoadState . Unloading :
img . ImageState = ImageLoadState . Ready ;
break ;
}
switch ( img . PreviewState )
{
case ImageLoadState . Loading :
img . PreviewState = ImageLoadState . None ;
break ;
case ImageLoadState . Unloading :
img . PreviewState = ImageLoadState . Ready ;
break ;
}
}
// Done
notifiedbusy = false ;
backgroundloader = null ;
2018-04-14 13:55:21 +00:00
General . SendMessage ( General . MainWindow . Handle , ( int ) MainForm . ThreadMessages . UpdateStatus , IntPtr . Zero , IntPtr . Zero ) ;
2009-04-19 18:07:22 +00:00
}
}
// The background loader
private void BackgroundLoad ( )
{
try
{
do
{
// Do we have to update the used-in-map status?
if ( updatedusedtextures ) BackgroundUpdateUsedTextures ( ) ;
// Get next item
ImageData image = null ;
lock ( imageque )
{
// Fetch next image to process
if ( imageque . Count > 0 ) image = imageque . Dequeue ( ) ;
}
// Any image to process?
if ( image ! = null )
{
// Load this image?
if ( image . IsReferenced & & ( image . ImageState ! = ImageLoadState . Ready ) )
{
image . LoadImage ( ) ;
}
// Unload this image?
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
else if ( ! image . IsReferenced & & image . AllowUnload & & ( image . ImageState ! = ImageLoadState . None ) )
2009-04-19 18:07:22 +00:00
{
// Still unreferenced?
image . UnloadImage ( ) ;
}
}
// Doing something?
if ( image ! = null )
{
// Wait a bit and update icon
if ( ! notifiedbusy )
{
notifiedbusy = true ;
2018-04-14 13:55:21 +00:00
General . SendMessage ( General . MainWindow . Handle , ( int ) MainForm . ThreadMessages . UpdateStatus , IntPtr . Zero , IntPtr . Zero ) ;
2009-04-19 18:07:22 +00:00
}
Thread . Sleep ( 0 ) ;
}
else
{
// Process previews only when we don't have images to process
// because these are lower priority than the actual images
if ( previews . BackgroundLoad ( ) )
{
// Wait a bit and update icon
if ( ! notifiedbusy )
{
notifiedbusy = true ;
2018-04-14 13:55:21 +00:00
General . SendMessage ( General . MainWindow . Handle , ( int ) MainForm . ThreadMessages . UpdateStatus , IntPtr . Zero , IntPtr . Zero ) ;
2009-04-19 18:07:22 +00:00
}
Thread . Sleep ( 0 ) ;
}
else
{
// Timing
if ( loadfinishtime = = 0 )
{
2014-10-15 08:36:17 +00:00
//mxd. Release PK3 files
2015-12-28 15:01:53 +00:00
foreach ( DataReader reader in containers )
2014-10-15 08:36:17 +00:00
{
2015-12-28 15:01:53 +00:00
if ( reader is PK3Reader ) ( reader as PK3Reader ) . BathMode = false ;
2014-10-15 08:36:17 +00:00
}
2014-05-20 09:09:28 +00:00
loadfinishtime = Clock . CurrentTime ;
2016-03-14 00:01:21 +00:00
string deltatimesec = ( ( loadfinishtime - loadstarttime ) / 1000.0f ) . ToString ( "########0.00" ) ;
General . WriteLogLine ( "Resources loading took " + deltatimesec + " seconds" ) ;
2016-11-10 19:18:06 +00:00
loadstarttime = 0 ; //mxd
2016-03-14 00:01:21 +00:00
//mxd. Show more detailed message
if ( notifiedbusy )
{
notifiedbusy = false ;
IntPtr strptr = Marshal . StringToCoTaskMemAuto ( deltatimesec ) ;
2018-04-14 13:55:21 +00:00
General . SendMessage ( General . MainWindow . Handle , ( int ) MainForm . ThreadMessages . ResourcesLoaded , strptr , IntPtr . Zero ) ;
2016-03-14 00:01:21 +00:00
}
}
else if ( notifiedbusy ) //mxd. Sould never happen (?)
{
notifiedbusy = false ;
2018-04-14 13:55:21 +00:00
General . SendMessage ( General . MainWindow . Handle , ( int ) MainForm . ThreadMessages . UpdateStatus , IntPtr . Zero , IntPtr . Zero ) ;
2009-04-19 18:07:22 +00:00
}
// Wait longer to release CPU resources
Thread . Sleep ( 50 ) ;
}
}
}
while ( true ) ;
}
2016-03-16 23:26:53 +00:00
catch ( ThreadInterruptedException ) { }
2009-04-19 18:07:22 +00:00
}
// This adds an image for background loading or unloading
internal void ProcessImage ( ImageData img )
{
// Load this image?
if ( ( img . ImageState = = ImageLoadState . None ) & & img . IsReferenced )
{
// Add for loading
img . ImageState = ImageLoadState . Loading ;
lock ( imageque ) { imageque . Enqueue ( img ) ; }
}
// Unload this image?
2010-08-11 20:32:14 +00:00
if ( ( img . ImageState = = ImageLoadState . Ready ) & & ! img . IsReferenced & & img . AllowUnload )
2009-04-19 18:07:22 +00:00
{
// Add for unloading
img . ImageState = ImageLoadState . Unloading ;
lock ( imageque ) { imageque . Enqueue ( img ) ; }
}
// Update icon
2018-04-14 13:55:21 +00:00
General . SendMessage ( General . MainWindow . Handle , ( int ) MainForm . ThreadMessages . UpdateStatus , IntPtr . Zero , IntPtr . Zero ) ;
2009-04-19 18:07:22 +00:00
}
2013-07-29 08:50:50 +00:00
//mxd. This loads a model
2014-12-03 09:06:05 +00:00
internal bool ProcessModel ( int type )
{
2015-04-14 11:33:57 +00:00
if ( modeldefentries [ type ] . LoadState ! = ModelLoadState . None ) return true ;
2013-07-29 08:50:50 +00:00
//create models
2019-08-08 01:19:11 +00:00
ModelReader . Load ( modeldefentries [ type ] , containers ) ;
2013-07-29 08:50:50 +00:00
2015-04-14 11:33:57 +00:00
if ( modeldefentries [ type ] . Model ! = null )
2014-12-03 09:06:05 +00:00
{
2015-04-14 11:33:57 +00:00
modeldefentries [ type ] . LoadState = ModelLoadState . Ready ;
2013-07-30 09:25:27 +00:00
return true ;
2013-07-29 08:50:50 +00:00
}
2013-07-30 09:25:27 +00:00
2015-04-14 11:33:57 +00:00
modeldefentries . Remove ( type ) ;
2013-07-30 09:25:27 +00:00
return false ;
2013-07-29 08:50:50 +00:00
}
2009-04-19 18:07:22 +00:00
// This updates the used-in-map status on all textures and flats
private void BackgroundUpdateUsedTextures ( )
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
if ( General . Map . Config . MixTexturesFlats )
2009-04-19 18:07:22 +00:00
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
lock ( usedtextures )
2009-04-19 18:07:22 +00:00
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
// Set used on all textures
foreach ( KeyValuePair < long , ImageData > i in textures )
{
i . Value . SetUsedInMap ( usedtextures . ContainsKey ( i . Key ) ) ;
if ( i . Value . IsImageLoaded ! = i . Value . IsReferenced ) ProcessImage ( i . Value ) ;
}
// Set used on all flats
foreach ( KeyValuePair < long , ImageData > i in flats )
{
i . Value . SetUsedInMap ( usedtextures . ContainsKey ( i . Key ) ) ;
if ( i . Value . IsImageLoaded ! = i . Value . IsReferenced ) ProcessImage ( i . Value ) ;
}
}
}
//mxd. Use separate collections
else
{
lock ( usedtextures )
{
// Set used on all textures
foreach ( KeyValuePair < long , ImageData > i in textures )
{
i . Value . SetUsedInMap ( usedtextures . ContainsKey ( i . Key ) ) ;
if ( i . Value . IsImageLoaded ! = i . Value . IsReferenced ) ProcessImage ( i . Value ) ;
}
2009-04-19 18:07:22 +00:00
}
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
lock ( usedflats )
2014-12-03 09:06:05 +00:00
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
// Set used on all flats
foreach ( KeyValuePair < long , ImageData > i in flats )
{
i . Value . SetUsedInMap ( usedflats . ContainsKey ( i . Key ) ) ;
if ( i . Value . IsImageLoaded ! = i . Value . IsReferenced ) ProcessImage ( i . Value ) ;
}
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
// Done
updatedusedtextures = false ;
2009-04-19 18:07:22 +00:00
}
#endregion
#region = = = = = = = = = = = = = = = = = = Palette
// This loads the PLAYPAL palette
private void LoadPalette ( )
{
// Go for all opened containers
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
// Load palette
palette = containers [ i ] . LoadPalette ( ) ;
if ( palette ! = null ) break ;
}
// Make empty palette when still no palette found
if ( palette = = null )
{
2009-05-10 16:02:08 +00:00
General . ErrorLogger . Add ( ErrorType . Warning , "None of the loaded resources define a color palette. Did you forget to configure an IWAD for this game configuration?" ) ;
2009-04-19 18:07:22 +00:00
palette = new Playpal ( ) ;
}
}
#endregion
2009-05-12 09:50:08 +00:00
#region = = = = = = = = = = = = = = = = = = Colormaps
// This loads the colormaps
private int LoadColormaps ( Dictionary < long , ImageData > list )
{
int counter = 0 ;
// Go for all opened containers
foreach ( DataReader dr in containers )
{
// Load colormaps
2015-12-28 15:01:53 +00:00
ICollection < ImageData > images = dr . LoadColormaps ( ) ;
2009-05-12 09:50:08 +00:00
if ( images ! = null )
{
// Go for all colormaps
foreach ( ImageData img in images )
{
// Add or replace in flats list
list . Remove ( img . LongName ) ;
list . Add ( img . LongName , img ) ;
counter + + ;
// Add to preview manager
previews . AddImage ( img ) ;
}
}
}
// Output info
return counter ;
}
// This returns a specific colormap stream
internal Stream GetColormapData ( string pname )
{
// Go for all opened containers
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
// This contain provides this flat?
2015-12-28 15:01:53 +00:00
Stream colormap = containers [ i ] . GetColormapData ( pname ) ;
2009-05-12 09:50:08 +00:00
if ( colormap ! = null ) return colormap ;
}
// No such patch found
return null ;
}
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Textures
2009-05-12 09:50:08 +00:00
2009-04-19 18:07:22 +00:00
// 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
private int LoadTextures ( Dictionary < long , ImageData > list , Dictionary < long , long > nametranslation , Dictionary < string , TexturesParser > cachedparsers )
2009-04-19 18:07:22 +00:00
{
PatchNames pnames = new PatchNames ( ) ;
int counter = 0 ;
// Go for all opened containers
foreach ( DataReader dr in containers )
{
// Load PNAMES info
// Note that pnames is NOT set to null in the loop
// because if a container has no pnames, the pnames
// of the previous (higher) container should be used.
2015-12-28 15:01:53 +00:00
PatchNames newpnames = dr . LoadPatchNames ( ) ;
2009-04-19 18:07:22 +00:00
if ( newpnames ! = null ) pnames = newpnames ;
// Load 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
IEnumerable < ImageData > images = dr . LoadTextures ( pnames , cachedparsers ) ;
2009-04-19 18:07:22 +00:00
if ( images ! = null )
{
// Go for all textures
foreach ( ImageData img in images )
{
// Add or replace in textures list
2016-03-04 08:10:56 +00:00
list [ img . LongName ] = img ;
2009-04-19 18:07:22 +00:00
counter + + ;
2014-12-03 09:06:05 +00:00
//mxd. Also add as short name when texture name is longer than 8 chars
// Or remove when a wad image with short name overrides previously added
// resource image with long name
if ( img . HasLongName )
{
long longshortname = Lump . MakeLongName ( Path . GetFileNameWithoutExtension ( img . Name ) , false ) ;
2016-03-04 08:10:56 +00:00
nametranslation [ longshortname ] = img . LongName ;
2014-12-03 09:06:05 +00:00
}
2015-12-18 10:16:53 +00:00
else if ( img is TextureImage & & nametranslation . ContainsKey ( img . LongName ) )
2014-12-03 09:06:05 +00:00
{
nametranslation . Remove ( img . LongName ) ;
}
2009-04-19 18:07:22 +00:00
// Add to preview manager
previews . AddImage ( img ) ;
}
}
}
// Output info
return counter ;
}
// This returns a specific patch stream
2016-03-14 21:53:53 +00:00
internal Stream GetPatchData ( string pname , bool longname , ref string patchlocation )
2009-04-19 18:07:22 +00:00
{
// Go for all opened containers
2013-07-29 08:50:50 +00:00
for ( int i = containers . Count - 1 ; i > - 1 ; i - - )
2009-04-19 18:07:22 +00:00
{
// This contain provides this patch?
2016-03-14 21:53:53 +00:00
Stream patch = containers [ i ] . GetPatchData ( pname , longname , ref patchlocation ) ;
2009-04-19 18:07:22 +00:00
if ( patch ! = null ) return patch ;
}
// No such patch found
return null ;
}
// This returns a specific texture stream
2016-03-14 21:53:53 +00:00
internal Stream GetTextureData ( string pname , bool longname , ref string texturelocation )
2009-04-19 18:07:22 +00:00
{
// Go for all opened containers
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
2016-01-13 09:34:32 +00:00
// This container provides this patch?
2016-03-14 21:53:53 +00:00
Stream patch = containers [ i ] . GetTextureData ( pname , longname , ref texturelocation ) ;
2009-04-19 18:07:22 +00:00
if ( patch ! = null ) return patch ;
}
// No such patch found
return null ;
}
2010-08-12 09:01:22 +00:00
// This checks if a given texture is known
public bool GetTextureExists ( string name )
{
2015-01-16 13:14:57 +00:00
return GetTextureExists ( Lump . MakeLongName ( name ) ) ; //mxd
2010-08-12 09:01:22 +00:00
}
// This checks if a given texture is known
public bool GetTextureExists ( long longname )
{
2014-12-03 09:06:05 +00:00
return textures . ContainsKey ( longname ) | | texturenamesshorttofull . ContainsKey ( longname ) ;
2010-08-12 09:01:22 +00:00
}
2009-04-19 18:07:22 +00:00
// This returns an image by string
public ImageData GetTextureImage ( string name )
{
// Get the long name
long longname = Lump . MakeLongName ( name ) ;
return GetTextureImage ( longname ) ;
}
2010-08-12 09:01:22 +00:00
2009-04-19 18:07:22 +00:00
// This returns an image by long
public ImageData GetTextureImage ( long longname )
{
// Does this texture exist?
2016-03-04 08:10:56 +00:00
if ( textures . ContainsKey ( longname )
& & ( textures [ longname ] is TEXTURESImage | | textures [ longname ] is HiResImage ) )
return textures [ longname ] ; //TEXTURES and HiRes textures should still override regular ones...
2014-12-03 09:06:05 +00:00
if ( texturenamesshorttofull . ContainsKey ( longname ) ) return textures [ texturenamesshorttofull [ longname ] ] ; //mxd
if ( textures . ContainsKey ( longname ) ) return textures [ longname ] ;
2013-07-23 14:25:03 +00:00
// Return null image
2014-01-13 08:06:56 +00:00
return unknownimage ; //mxd
2009-04-19 18:07:22 +00:00
}
2014-11-25 11:52:01 +00:00
2016-01-13 09:34:32 +00:00
//mxd. This tries to find and load any image with given name
2016-03-04 08:10:56 +00:00
internal Bitmap GetTextureBitmap ( string name ) { Vector2D unused = new Vector2D ( ) ; return GetTextureBitmap ( name , out unused ) ; }
internal Bitmap GetTextureBitmap ( string name , out Vector2D scale )
2016-01-13 09:34:32 +00:00
{
// Check the textures first...
ImageData img = GetTextureImage ( name ) ;
if ( img is UnknownImage & & ! General . Map . Config . MixTexturesFlats )
img = GetFlatImage ( name ) ;
if ( ! ( img is UnknownImage ) )
{
if ( ! img . IsImageLoaded ) img . LoadImage ( ) ;
if ( ! img . LoadFailed )
{
2016-03-04 08:10:56 +00:00
// HiResImage will not give us it's actual scale
Bitmap texture = img . GetBitmap ( ) ;
2017-05-09 03:06:07 +00:00
lock ( texture )
{
scale = new Vector2D ( ( float ) img . Width / texture . Width , ( float ) img . Height / texture . Height ) ;
}
2016-03-04 08:10:56 +00:00
return texture ;
2016-01-13 09:34:32 +00:00
}
}
// Try to find any image...
2016-03-04 08:10:56 +00:00
scale = new Vector2D ( 1.0f , 1.0f ) ;
2016-01-13 09:34:32 +00:00
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
// This container has a lump with given name?
if ( containers [ i ] is PK3StructuredReader )
{
2016-01-15 22:19:48 +00:00
string foundname = ( ( PK3StructuredReader ) containers [ i ] ) . FindFirstFile ( name , true ) ;
if ( string . IsNullOrEmpty ( foundname ) ) continue ;
name = foundname ;
2016-01-13 09:34:32 +00:00
}
else if ( ! ( containers [ i ] is WADReader ) )
{
throw new NotImplementedException ( "Unsupported container type!" ) ;
}
if ( ! containers [ i ] . FileExists ( name ) ) continue ;
MemoryStream mem = containers [ i ] . LoadFile ( name ) ;
if ( mem = = null ) continue ;
// Is it an image?
IImageReader reader = ImageDataFormat . GetImageReader ( mem , ImageDataFormat . DOOMPICTURE , General . Map . Data . Palette ) ;
if ( ! ( reader is UnknownImageReader ) )
{
// Load the image
mem . Seek ( 0 , SeekOrigin . Begin ) ;
Bitmap result ;
try { result = reader . ReadAsBitmap ( mem ) ; }
catch ( InvalidDataException )
{
// Data cannot be read!
result = null ;
}
// Found it?
if ( result ! = null ) return result ;
}
}
// No such image found
return null ;
}
2014-11-25 11:52:01 +00:00
//mxd
public string GetFullTextureName ( string name )
{
2016-01-13 09:34:32 +00:00
if ( string . IsNullOrEmpty ( name ) ) return name ;
2015-12-28 15:01:53 +00:00
if ( Path . GetFileNameWithoutExtension ( name ) = = name & & name . Length > CLASIC_IMAGE_NAME_LENGTH )
2014-11-25 11:52:01 +00:00
name = name . Substring ( 0 , CLASIC_IMAGE_NAME_LENGTH ) ;
long hash = MurmurHash2 . Hash ( name . Trim ( ) . ToUpperInvariant ( ) ) ;
2014-12-03 09:06:05 +00:00
2016-03-04 08:10:56 +00:00
if ( textures . ContainsKey ( hash ) & & ( textures [ hash ] is TEXTURESImage | | textures [ hash ] is HiResImage ) )
return textures [ hash ] . Name ; //TEXTURES and HiRes textures should still override regular ones...
2014-11-25 11:52:01 +00:00
if ( texturenamesshorttofull . ContainsKey ( hash ) ) return textures [ texturenamesshorttofull [ hash ] ] . Name ;
2014-12-03 09:06:05 +00:00
if ( textures . ContainsKey ( hash ) ) return textures [ hash ] . Name ;
2014-11-25 11:52:01 +00:00
return name ;
}
2014-12-03 09:06:05 +00:00
//mxd
internal long GetFullLongTextureName ( long hash )
{
2016-03-04 08:10:56 +00:00
if ( textures . ContainsKey ( hash ) & & ( textures [ hash ] is TEXTURESImage | | textures [ hash ] is HiResImage ) )
return hash ; //TEXTURES and HiRes textures should still override regular ones...
2014-12-03 09:06:05 +00:00
return ( General . Map . Config . UseLongTextureNames & & texturenamesshorttofull . ContainsKey ( hash ) ? texturenamesshorttofull [ hash ] : hash ) ;
}
2015-12-30 13:58:58 +00:00
//mxd
private void LoadInternalTextures ( )
{
2016-04-01 10:49:19 +00:00
missingtexture3d = LoadInternalTexture ( "MissingTexture3D.png" ) ;
unknowntexture3d = LoadInternalTexture ( "UnknownTexture3D.png" ) ;
thingtexture = LoadInternalTexture ( "ThingTexture2D.png" ) ;
hourglass3d = LoadInternalTexture ( "Hourglass3D.png" ) ;
crosshair = LoadInternalTexture ( "Crosshair.png" ) ;
crosshairbusy = LoadInternalTexture ( "CrosshairBusy.png" ) ;
thingtexture . UseColorCorrection = false ;
thingtexture . CreateTexture ( ) ;
2015-12-30 13:58:58 +00:00
}
//mxd
private static ImageData LoadInternalTexture ( string name )
{
ImageData result ;
string path = Path . Combine ( General . TexturesPath , name ) ;
if ( File . Exists ( path ) )
{
result = new FileImage ( name , path ) { AllowUnload = false } ;
}
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 , "Unable to load editor texture \"" + name + "\". Using built-in one instead." ) ;
2015-12-30 13:58:58 +00:00
result = new ResourceImage ( "CodeImp.DoomBuilder.Resources." + name ) ;
}
result . LoadImage ( ) ;
return result ;
}
2009-04-19 18:07:22 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Flats
// This loads the flats
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 int LoadFlats ( Dictionary < long , ImageData > list , Dictionary < long , long > nametranslation , Dictionary < string , TexturesParser > cachedparsers )
2009-04-19 18:07:22 +00:00
{
int counter = 0 ;
// Go for all opened containers
foreach ( DataReader dr in containers )
{
// Load flats
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 > images = dr . LoadFlats ( cachedparsers ) ;
2009-04-19 18:07:22 +00:00
if ( images ! = null )
{
// Go for all flats
foreach ( ImageData img in images )
{
// Add or replace in flats list
2016-03-04 08:10:56 +00:00
list [ img . LongName ] = img ; //mxd
2009-04-19 18:07:22 +00:00
counter + + ;
2014-12-03 09:06:05 +00:00
//mxd. Also add as short name when texture name is longer than 8 chars
// Or remove when a wad image with short name overrides previously added
// resource image with long name
2015-12-28 15:01:53 +00:00
if ( img . HasLongName )
2014-12-03 09:06:05 +00:00
{
long longshortname = Lump . MakeLongName ( Path . GetFileNameWithoutExtension ( img . Name ) , false ) ;
2016-03-04 08:10:56 +00:00
nametranslation [ longshortname ] = img . LongName ;
2014-12-03 09:06:05 +00:00
}
else if ( img is FlatImage & & nametranslation . ContainsKey ( img . LongName ) )
{
nametranslation . Remove ( img . LongName ) ;
}
2009-04-19 18:07:22 +00:00
// Add to preview manager
previews . AddImage ( img ) ;
}
}
}
// Output info
return counter ;
}
// This returns a specific flat stream
2016-03-14 21:53:53 +00:00
internal Stream GetFlatData ( string pname , bool longname , ref string flatlocation )
2009-04-19 18:07:22 +00:00
{
// Go for all opened containers
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
// This contain provides this flat?
2016-03-14 21:53:53 +00:00
Stream flat = containers [ i ] . GetFlatData ( pname , longname , ref flatlocation ) ;
2009-04-19 18:07:22 +00:00
if ( flat ! = null ) return flat ;
}
// No such patch found
return null ;
}
2010-08-12 09:01:22 +00:00
// This checks if a flat is known
public bool GetFlatExists ( string name )
{
2015-01-16 13:14:57 +00:00
return GetFlatExists ( Lump . MakeLongName ( name ) ) ; //mxd
2010-08-12 09:01:22 +00:00
}
2017-04-03 17:40:51 +00:00
// This checks if a flat is known
public bool GetFlatExists ( long longname )
{
// [ZZ] return nonexistent name for bad flats.
if ( flats . ContainsKey ( longname ) )
{
// [ZZ] long name is long. a doom flat with a long name is invalid.
ImageData id = flats [ longname ] ;
if ( id is PK3FileImage & & ( ( PK3FileImage ) id ) . IsBadForLongTextureNames )
return false ;
return true ;
}
return flatnamesshorttofull . ContainsKey ( longname ) ;
}
2009-04-19 18:07:22 +00:00
// This returns an image by string
public ImageData GetFlatImage ( string name )
{
// Get the long name
long longname = Lump . MakeLongName ( name ) ;
return GetFlatImage ( longname ) ;
}
// This returns an image by long
public ImageData GetFlatImage ( long longname )
{
2013-12-02 15:02:01 +00:00
// Does this flat exist?
2016-03-04 08:10:56 +00:00
if ( flats . ContainsKey ( longname ) & & ( flats [ longname ] is TEXTURESImage | | flats [ longname ] is HiResImage ) )
return flats [ longname ] ; //TEXTURES and HiRes flats should still override regular ones...
2017-04-03 17:40:51 +00:00
if ( flatnamesshorttofull . ContainsKey ( longname ) )
return flats [ flatnamesshorttofull [ longname ] ] ; //mxd
if ( flats . ContainsKey ( longname ) )
{
// [ZZ] long name is long. a doom flat with a long name is invalid.
ImageData id = flats [ longname ] ;
if ( id is PK3FileImage & & ( ( PK3FileImage ) id ) . IsBadForLongTextureNames )
return unknownimage ;
return id ;
}
2013-12-03 10:50:33 +00:00
2013-07-29 08:50:50 +00:00
// Return null image
2014-01-13 08:06:56 +00:00
return unknownimage ; //mxd
2009-04-19 18:07:22 +00:00
}
2010-08-14 09:30:54 +00:00
// This returns an image by long and doesn't check if it exists
2015-01-23 21:51:11 +00:00
/ * public ImageData GetFlatImageKnown ( long longname )
2010-08-14 09:30:54 +00:00
{
// Return flat
2014-12-03 09:06:05 +00:00
return flatnamesshorttofull . ContainsKey ( longname ) ? flats [ flatnamesshorttofull [ longname ] ] : flats [ longname ] ; //mxd
2015-01-23 21:51:11 +00:00
} * /
2014-11-25 11:52:01 +00:00
//mxd. Gets full flat name by short flat name
public string GetFullFlatName ( string name )
{
if ( Path . GetFileNameWithoutExtension ( name ) = = name & & name . Length > CLASIC_IMAGE_NAME_LENGTH )
name = name . Substring ( 0 , CLASIC_IMAGE_NAME_LENGTH ) ;
long hash = MurmurHash2 . Hash ( name . ToUpperInvariant ( ) ) ;
2014-12-03 09:06:05 +00:00
2016-03-04 08:10:56 +00:00
if ( flats . ContainsKey ( hash ) & & ( flats [ hash ] is TEXTURESImage | | flats [ hash ] is HiResImage ) )
return flats [ hash ] . Name ; //TEXTURES and HiRes flats should still override regular ones...
2014-11-25 11:52:01 +00:00
if ( flatnamesshorttofull . ContainsKey ( hash ) ) return flats [ flatnamesshorttofull [ hash ] ] . Name ;
2014-12-03 09:06:05 +00:00
if ( flats . ContainsKey ( hash ) ) return flats [ hash ] . Name ;
2014-11-25 11:52:01 +00:00
return name ;
}
2014-12-03 09:06:05 +00:00
//mxd
internal long GetFullLongFlatName ( long hash )
{
2016-03-04 08:10:56 +00:00
if ( flats . ContainsKey ( hash ) & & ( flats [ hash ] is TEXTURESImage | | flats [ hash ] is HiResImage ) )
return hash ; //TEXTURES and HiRes flats should still override regular ones...
2014-12-03 09:06:05 +00:00
return ( General . Map . Config . UseLongTextureNames & & flatnamesshorttofull . ContainsKey ( hash ) ? flatnamesshorttofull [ hash ] : hash ) ;
}
2016-03-23 14:52:33 +00:00
//mxd
internal long GetShortLongFlatName ( long hash )
{
return ( flatnamesfulltoshort . ContainsKey ( hash ) ? flatnamesfulltoshort [ hash ] : hash ) ;
}
2009-04-19 18:07:22 +00:00
#endregion
2016-03-04 08:10:56 +00:00
#region = = = = = = = = = = = = = = = = = = mxd . HiRes textures
// This loads the textures
private int LoadHiResTextures ( )
{
int counter = 0 ;
// Go for all opened containers
foreach ( DataReader dr in containers )
{
//mxd. Load HiRes texures
IEnumerable < HiResImage > hiresimages = dr . LoadHiResTextures ( ) ;
if ( hiresimages ! = null )
{
// Go for all textures
foreach ( HiResImage img in hiresimages )
{
2016-03-22 22:24:33 +00:00
// Replace when HiRes image name exactly matches a regular texture name,
// or when regular texture filename is 8 or less chars long
//bool replaced = false;
2016-03-04 08:10:56 +00:00
// Replace texture?
2016-03-22 22:24:33 +00:00
long hash = GetFullLongTextureName ( img . LongName ) ;
if ( textures . ContainsKey ( hash ) & & ( hash = = img . LongName | | Path . GetFileNameWithoutExtension ( textures [ hash ] . Name ) . Length < = CLASIC_IMAGE_NAME_LENGTH ) )
2016-03-04 08:10:56 +00:00
{
HiResImage replacer = new HiResImage ( img ) ;
2016-03-22 22:24:33 +00:00
replacer . ApplySettings ( textures [ hash ] ) ;
2016-03-23 14:52:33 +00:00
textures [ img . LongName ] = replacer ;
2016-03-22 22:24:33 +00:00
//replaced = true;
2016-03-04 08:10:56 +00:00
// Add to preview manager
previews . AddImage ( replacer ) ;
2016-03-22 22:24:33 +00:00
counter + + ;
2016-03-04 08:10:56 +00:00
}
// Replace flat?
2016-03-22 22:24:33 +00:00
hash = GetFullLongFlatName ( img . LongName ) ;
if ( flats . ContainsKey ( hash ) & & ( hash = = img . LongName | | Path . GetFileNameWithoutExtension ( flats [ hash ] . Name ) . Length < = CLASIC_IMAGE_NAME_LENGTH ) )
2016-03-04 08:10:56 +00:00
{
HiResImage replacer = new HiResImage ( img ) ;
2016-03-22 22:24:33 +00:00
replacer . ApplySettings ( flats [ hash ] ) ;
2016-03-23 14:52:33 +00:00
flats [ img . LongName ] = replacer ;
2016-03-22 22:24:33 +00:00
//replaced = true;
2016-03-04 08:10:56 +00:00
// Add to preview manager
previews . AddImage ( replacer ) ;
2016-03-22 22:24:33 +00:00
counter + + ;
2016-03-04 08:10:56 +00:00
}
2016-03-22 22:24:33 +00:00
// Replace sprite?
if ( sprites . ContainsKey ( img . LongName ) )
{
HiResImage replacer = new HiResImage ( img ) ;
replacer . ApplySettings ( sprites [ img . LongName ] ) ;
sprites [ img . LongName ] = replacer ;
//replaced = true;
// Add to preview manager
previews . AddImage ( replacer ) ;
counter + + ;
}
// We don't load any graphics and most of the sprites, so this can result in a ton of false warnings...
/ * if ( ! replaced )
2016-03-04 08:10:56 +00:00
{
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
General . ErrorLogger . Add ( ErrorType . Warning , "HiRes texture \"" + Path . Combine ( dr . Location . GetDisplayName ( ) , img . FilePathName . Replace ( Path . AltDirectorySeparatorChar , Path . DirectorySeparatorChar ) ) + "\" does not override any existing texture or flat." ) ;
2016-03-04 08:10:56 +00:00
dr . TextureSet . AddTexture ( img ) ;
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
// Add to textures and flats
textures [ img . LongName ] = img ;
flats [ img . LongName ] = img ;
// Add to preview manager
previews . AddImage ( img ) ;
2016-03-04 08:10:56 +00:00
}
2016-03-22 22:24:33 +00:00
counter + + ; * /
2016-03-04 08:10:56 +00:00
}
}
}
// Output info
return counter ;
}
//mxd. This returns a specific HiRes texture stream
2016-03-14 21:53:53 +00:00
internal Stream GetHiResTextureData ( string name , ref string hireslocation )
2016-03-04 08:10:56 +00:00
{
// Go for all opened containers
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
// This container provides this texture?
2016-03-14 21:53:53 +00:00
Stream data = containers [ i ] . GetHiResTextureData ( name , ref hireslocation ) ;
2016-03-04 08:10:56 +00:00
if ( data ! = null ) return data ;
}
// No such patch texture
return null ;
}
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Sprites
2010-08-18 09:07:54 +00:00
// This loads the hard defined sprites (not all the lumps, we do that on a need-to-know basis, see LoadThingSprites)
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 int LoadSprites ( Dictionary < string , TexturesParser > cachedparsers )
2010-08-18 09:07:54 +00:00
{
int counter = 0 ;
// Load all defined sprites. Note that we do not use all sprites,
// so we don't add them for previews just yet.
foreach ( DataReader dr in containers )
{
// Load 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
IEnumerable < ImageData > images = dr . LoadSprites ( cachedparsers ) ;
2010-08-18 09:07:54 +00:00
if ( images ! = null )
{
// Add or replace in sprites list
foreach ( ImageData img in images )
{
sprites [ img . LongName ] = img ;
counter + + ;
}
}
}
// Output info
return counter ;
}
// This loads the sprites that we really need for things
private int LoadThingSprites ( )
2009-04-19 18:07:22 +00:00
{
2016-07-11 22:13:43 +00:00
//mxd. Get all sprite names
HashSet < string > spritenames = new HashSet < string > ( StringComparer . Ordinal ) ;
2017-03-01 16:35:15 +00:00
// [ZZ] in order to properly replace different rotation count, we need more complex processing here.
HashSet < string > loadedspritenames = new HashSet < string > ( StringComparer . Ordinal ) ;
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
IEnumerable < string > result = containers [ i ] . GetSpriteNames ( ) ;
if ( result ! = null )
{
// remove old sprites with this name
result = result . Where ( str = > ! loadedspritenames . Contains ( str . Substring ( 0 , 4 ) ) ) ; // only sprites that we still don't have. remember, reverse iteration!
// add new sprites with this name
spritenames . UnionWith ( result ) ;
// remember
foreach ( string spr in result )
loadedspritenames . Add ( spr . Substring ( 0 , 4 ) ) ;
}
}
2016-07-14 14:28:42 +00:00
//mxd. Add sprites from sprites collection (because GetSpriteNames() doesn't return TEXTURES sprites)
foreach ( ImageData data in sprites . Values ) spritenames . Add ( data . Name ) ;
2016-07-11 22:13:43 +00:00
//mxd. Get names of all voxel models, which can be used "as is" (these do not require corresponding sprite to work)
HashSet < string > voxelnames = new HashSet < string > ( StringComparer . Ordinal ) ;
foreach ( DataReader dr in containers )
{
IEnumerable < string > result = dr . GetVoxelNames ( ) ;
if ( result ! = null ) voxelnames . UnionWith ( result ) ;
}
2009-04-19 18:07:22 +00:00
// Go for all things
foreach ( ThingTypeInfo ti in General . Map . Data . ThingTypes )
{
2010-08-18 09:07:54 +00:00
// Valid sprite name?
2014-11-25 11:52:01 +00:00
if ( ti . Sprite . Length = = 0 | | ti . Sprite . Length > CLASIC_IMAGE_NAME_LENGTH ) continue ; //mxd
2010-08-18 09:07:54 +00:00
2016-04-08 14:02:08 +00:00
//mxd. Find all sprite angles
2016-07-11 22:13:43 +00:00
bool isvoxel = ti . SetupSpriteFrame ( spritenames , voxelnames ) ;
2014-01-03 10:33:45 +00:00
2016-07-11 22:13:43 +00:00
//mxd. Create voxel sprite?
if ( isvoxel )
2014-01-03 10:33:45 +00:00
{
2016-07-11 22:13:43 +00:00
if ( ! sprites . ContainsKey ( Lump . MakeLongName ( ti . Sprite ) ) )
{
// Make new voxel image
VoxelImage image = new VoxelImage ( ti . Sprite , ti . Sprite ) ;
// Add to collection
sprites . Add ( image . LongName , image ) ;
// Add to preview manager
previews . AddImage ( image ) ;
}
}
else
{
//mxd. Load all sprites
foreach ( SpriteFrameInfo info in ti . SpriteFrame )
2016-03-14 21:53:53 +00:00
{
2016-07-11 22:13:43 +00:00
ImageData image = null ;
// Sprite not in our collection yet?
if ( ! sprites . ContainsKey ( info . SpriteLongName ) )
2016-03-14 21:53:53 +00:00
{
2016-07-11 22:13:43 +00:00
//mxd. Go for all opened containers
bool spritefound = false ;
if ( ! string . IsNullOrEmpty ( info . Sprite ) )
2016-03-14 21:53:53 +00:00
{
2016-07-11 22:13:43 +00:00
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
2016-04-08 14:02:08 +00:00
{
2016-07-11 22:13:43 +00:00
// This container provides this sprite?
if ( containers [ i ] . GetSpriteExists ( info . Sprite ) )
{
spritefound = true ;
break ;
}
2016-04-08 14:02:08 +00:00
}
2016-03-14 21:53:53 +00:00
}
2016-07-11 22:13:43 +00:00
if ( spritefound )
{
// Make new sprite image
image = new SpriteImage ( info . Sprite ) ;
2014-01-03 10:33:45 +00:00
2016-07-11 22:13:43 +00:00
// Add to collection
sprites . Add ( info . SpriteLongName , image ) ;
}
else
{
2017-03-09 17:09:08 +00:00
if ( ! ti . Optional )
General . ErrorLogger . Add ( ErrorType . Error , "Unable to find sprite lump \"" + info . Sprite + "\" used by actor \"" + ti . Title + "\":" + ti . Index + ". Forgot to include required resources?" ) ;
2016-07-11 22:13:43 +00:00
}
2016-04-08 14:02:08 +00:00
}
else
{
2016-07-11 22:13:43 +00:00
image = sprites [ info . SpriteLongName ] ;
2016-04-08 14:02:08 +00:00
}
2014-01-03 10:33:45 +00:00
2016-07-11 22:13:43 +00:00
// Add to preview manager
if ( image ! = null ) previews . AddImage ( image ) ;
}
2016-04-08 14:02:08 +00:00
}
2009-04-19 18:07:22 +00:00
}
2010-08-18 09:07:54 +00:00
2009-04-19 18:07:22 +00:00
// Output info
return sprites . Count ;
}
2010-08-18 09:07:54 +00:00
2016-04-08 14:02:08 +00:00
// This returns a specific sprite stream
2016-03-14 21:53:53 +00:00
internal Stream GetSpriteData ( string pname , ref string spritelocation )
2009-04-19 18:07:22 +00:00
{
if ( ! string . IsNullOrEmpty ( pname ) )
{
// Go for all opened containers
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
2016-07-11 22:13:43 +00:00
// This container provides this sprite?
2016-03-14 21:53:53 +00:00
Stream spritedata = containers [ i ] . GetSpriteData ( pname , ref spritelocation ) ;
2017-03-01 16:35:15 +00:00
if ( spritedata ! = null )
return spritedata ;
2009-04-19 18:07:22 +00:00
}
}
2016-04-08 14:02:08 +00:00
// No such sprite found
2009-04-19 18:07:22 +00:00
return null ;
}
// This tests if a given sprite can be found
internal bool GetSpriteExists ( string pname )
{
if ( ! string . IsNullOrEmpty ( pname ) )
{
2010-08-18 09:07:54 +00:00
long longname = Lump . MakeLongName ( pname ) ;
2015-01-23 21:51:11 +00:00
if ( sprites . ContainsKey ( longname ) ) return true ;
2010-08-18 09:07:54 +00:00
2009-04-19 18:07:22 +00:00
// Go for all opened containers
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
2016-04-08 14:02:08 +00:00
// This contain provides this sprite?
2009-04-19 18:07:22 +00:00
if ( containers [ i ] . GetSpriteExists ( pname ) ) return true ;
}
}
2016-04-08 14:02:08 +00:00
// No such sprite found
2009-04-19 18:07:22 +00:00
return false ;
}
// This loads the internal sprites
private void LoadInternalSprites ( )
{
// Add sprite icon files from directory
2016-04-08 14:02:08 +00:00
string name ;
2009-04-19 18:07:22 +00:00
string [ ] files = Directory . GetFiles ( General . SpritesPath , "*.png" , SearchOption . TopDirectoryOnly ) ;
2016-04-08 14:02:08 +00:00
internalspriteslookup = new Dictionary < string , long > ( files . Length + 2 ) ; //mxd
2009-04-19 18:07:22 +00:00
foreach ( string spritefile in files )
{
2014-11-25 11:52:01 +00:00
ImageData img = new FileImage ( Path . GetFileNameWithoutExtension ( spritefile ) . ToLowerInvariant ( ) , spritefile ) ;
2009-04-19 18:07:22 +00:00
img . LoadImage ( ) ;
2010-08-11 20:32:14 +00:00
img . AllowUnload = false ;
2016-04-08 14:02:08 +00:00
name = INTERNAL_PREFIX + img . Name ;
long hash = Lump . MakeLongName ( name , true ) ; //mxd
sprites [ hash ] = img ; //mxd
internalspriteslookup [ name ] = hash ; //mxd
2009-04-19 18:07:22 +00:00
}
2016-04-08 14:02:08 +00:00
// Add some internal resources.
// mxd. Doesn't seem to be used anywhere
/ * name = INTERNAL_PREFIX + "nothing" ;
if ( ! internalspriteslookup . ContainsKey ( name ) )
2009-04-19 18:07:22 +00:00
{
2009-08-02 18:21:53 +00:00
ImageData img = new ResourceImage ( "CodeImp.DoomBuilder.Resources.Nothing.png" ) ;
2009-04-19 18:07:22 +00:00
img . LoadImage ( ) ;
2010-08-11 20:32:14 +00:00
img . AllowUnload = false ;
2016-04-08 14:02:08 +00:00
long hash = Lump . MakeLongName ( name , true ) ; //mxd
sprites [ hash ] = img ; //mxd
internalspriteslookup [ name ] = hash ; //mxd
} * /
name = INTERNAL_PREFIX + "unknownthing" ;
UNKNOWN_THING = Lump . MakeLongName ( name , true ) ;
if ( ! internalspriteslookup . ContainsKey ( name ) )
2009-04-19 18:07:22 +00:00
{
2009-08-02 18:21:53 +00:00
ImageData img = new ResourceImage ( "CodeImp.DoomBuilder.Resources.UnknownThing.png" ) ;
2009-04-19 18:07:22 +00:00
img . LoadImage ( ) ;
2010-08-11 20:32:14 +00:00
img . AllowUnload = false ;
2016-04-08 14:02:08 +00:00
sprites [ UNKNOWN_THING ] = img ; //mxd
internalspriteslookup [ name ] = UNKNOWN_THING ; //mxd
2013-08-21 10:45:54 +00:00
}
//mxd
2016-04-08 14:02:08 +00:00
name = INTERNAL_PREFIX + "missingthing" ;
MISSING_THING = Lump . MakeLongName ( name , true ) ;
if ( ! internalspriteslookup . ContainsKey ( name ) )
2014-05-19 13:33:38 +00:00
{
2013-08-21 10:45:54 +00:00
ImageData img = new ResourceImage ( "CodeImp.DoomBuilder.Resources.MissingThing.png" ) ;
img . LoadImage ( ) ;
img . AllowUnload = false ;
2016-04-08 14:02:08 +00:00
sprites [ MISSING_THING ] = img ; //mxd
internalspriteslookup [ name ] = MISSING_THING ; //mxd
2009-04-19 18:07:22 +00:00
}
}
2013-08-21 10:45:54 +00:00
// This returns an image by name
2009-04-19 18:07:22 +00:00
public ImageData GetSpriteImage ( string name )
{
// Is this referring to an internal sprite image?
if ( ( name . Length > INTERNAL_PREFIX . Length ) & & name . ToLowerInvariant ( ) . StartsWith ( INTERNAL_PREFIX ) )
{
// Get the internal sprite
2016-04-08 14:02:08 +00:00
string internalname = name . ToLowerInvariant ( ) ;
if ( internalspriteslookup . ContainsKey ( internalname ) ) //mxd
return sprites [ internalspriteslookup [ internalname ] ] ;
2013-08-21 10:45:54 +00:00
2016-04-08 14:02:08 +00:00
return sprites [ UNKNOWN_THING ] ; //mxd
2009-04-19 18:07:22 +00:00
}
else
{
// Get the long name
long longname = Lump . MakeLongName ( name ) ;
// Sprite already loaded?
if ( sprites . ContainsKey ( longname ) )
{
// Return exiting sprite
return sprites [ longname ] ;
}
else
{
2016-03-14 21:53:53 +00:00
//mxd. Go for all opened containers
bool spritefound = false ;
if ( ! string . IsNullOrEmpty ( name ) )
2009-04-19 18:07:22 +00:00
{
2016-03-14 21:53:53 +00:00
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
// This contain provides this sprite?
if ( containers [ i ] . GetSpriteExists ( name ) )
{
spritefound = true ;
break ;
}
}
2009-04-19 18:07:22 +00:00
}
// Found anything?
2016-03-14 21:53:53 +00:00
if ( spritefound )
2009-04-19 18:07:22 +00:00
{
// Make new sprite image
SpriteImage image = new SpriteImage ( name ) ;
// Add to collection
sprites . Add ( longname , image ) ;
// Return result
return image ;
}
2013-08-21 10:45:54 +00:00
else //mxd
2009-04-19 18:07:22 +00:00
{
2016-04-08 14:02:08 +00:00
ImageData img = string . IsNullOrEmpty ( name ) ? sprites [ UNKNOWN_THING ] : sprites [ MISSING_THING ] ;
2013-08-21 10:45:54 +00:00
// Add to collection
sprites . Add ( longname , img ) ;
2013-09-03 09:34:28 +00:00
// Return image
2013-08-21 10:45:54 +00:00
return img ;
2009-04-19 18:07:22 +00:00
}
}
}
}
2016-04-08 14:02:08 +00:00
//mxd. Returns all sprite names, which start with given string
2016-07-11 22:13:43 +00:00
internal IEnumerable < string > GetSpriteNames ( )
2016-04-08 14:02:08 +00:00
{
HashSet < string > result = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
foreach ( DataReader reader in containers )
2016-07-11 22:13:43 +00:00
result . UnionWith ( reader . GetSpriteNames ( ) ) ;
2016-04-08 14:02:08 +00:00
return result ;
}
2009-04-19 18:07:22 +00:00
#endregion
2016-07-11 22:13:43 +00:00
#region = = = = = = = = = = = = = = = = = = mxd . Voxels
// This returns a specific voxel stream
internal Stream GetVoxelData ( string pname , ref string voxellocation )
{
if ( ! string . IsNullOrEmpty ( pname ) )
{
// Go for all opened containers
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
// This container provides this sprite?
Stream spritedata = containers [ i ] . GetVoxelData ( pname , ref voxellocation ) ;
if ( spritedata ! = null ) return spritedata ;
}
}
// No such voxel found
return null ;
}
#endregion
2009-04-19 18:07:22 +00:00
#region = = = = = = = = = = = = = = = = = = Things
2017-01-16 00:08:35 +00:00
private void LoadZScriptThings ( )
2017-01-15 22:00:45 +00:00
{
// Create new parser
2017-01-17 04:53:20 +00:00
zscript = new ZScriptParser { OnInclude = LoadZScriptFromLocation } ;
2017-01-15 22:00:45 +00:00
// Only load these when the game configuration supports the use of decorate
if ( ! string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) )
{
// Go for all opened containers
foreach ( DataReader dr in containers )
{
// Load Decorate info cumulatively (the last Decorate is added to the previous)
// I'm not sure if this is the right thing to do though.
currentreader = dr ;
IEnumerable < TextResourceData > streams = dr . GetDecorateData ( "ZSCRIPT" ) ;
foreach ( TextResourceData data in streams )
{
// Parse the data
data . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
zscript . Parse ( data , true ) ;
//mxd. DECORATE lumps are interdepandable. Can't carry on...
if ( zscript . HasError )
{
zscript . LogError ( ) ;
break ;
}
}
}
2017-01-16 01:49:58 +00:00
zscript . Finalize ( ) ;
if ( zscript . HasError )
zscript . LogError ( ) ;
2017-01-15 22:00:45 +00:00
//mxd. Add to text resources collection
scriptresources [ zscript . ScriptType ] = new HashSet < ScriptResource > ( zscript . ScriptResources . Values ) ;
currentreader = null ;
}
2017-01-16 00:08:35 +00:00
if ( zscript . HasError )
zscript . ClearActors ( ) ;
2017-01-15 22:00:45 +00:00
}
2009-04-19 18:07:22 +00:00
// This loads the things from Decorate
2017-01-16 00:08:35 +00:00
private void LoadDecorateThings ( )
2009-04-19 18:07:22 +00:00
{
2009-08-15 08:41:43 +00:00
// Create new parser
2017-01-17 04:53:20 +00:00
decorate = new DecorateParser ( zscript . AllActorsByClass ) { OnInclude = LoadDecorateFromLocation } ;
2015-12-17 10:07:28 +00:00
2009-04-19 18:07:22 +00:00
// Only load these when the game configuration supports the use of decorate
if ( ! string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) )
{
// Go for all opened containers
foreach ( DataReader dr in containers )
{
// Load Decorate info cumulatively (the last Decorate is added to the previous)
// I'm not sure if this is the right thing to do though.
currentreader = dr ;
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 < TextResourceData > decostreams = dr . GetDecorateData ( "DECORATE" ) ;
foreach ( TextResourceData data in decostreams )
2009-04-19 18:07:22 +00:00
{
// Parse the data
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
data . Stream . Seek ( 0 , SeekOrigin . Begin ) ;
decorate . Parse ( data , true ) ;
2009-04-19 18:07:22 +00:00
2015-12-17 10:07:28 +00:00
//mxd. DECORATE lumps are interdepandable. Can't carry on...
2009-08-15 08:41:43 +00:00
if ( decorate . HasError )
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
decorate . LogError ( ) ;
2016-11-28 20:01:47 +00:00
break ;
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. Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ decorate . ScriptType ] = new HashSet < ScriptResource > ( decorate . ScriptResources . Values ) ;
2009-04-19 18:07:22 +00:00
currentreader = null ;
2017-01-16 00:08:35 +00:00
}
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
if ( decorate . HasError )
decorate . ClearActors ( ) ;
}
2015-04-14 11:33:57 +00:00
2017-01-16 08:20:47 +00:00
// [ZZ] this retrieves ZDoom actor structure by class name.
public ActorStructure GetZDoomActor ( string classname )
{
classname = classname . ToLowerInvariant ( ) ;
ActorStructure outv ;
if ( ! zdoomclasses . TryGetValue ( classname , out outv ) )
return null ;
return outv ;
}
2017-01-16 00:08:35 +00:00
// [ZZ] this merges in the parsed actor lists from zscript+decorate using the original DECORATE merging code
private int ApplyZDoomThings ( Dictionary < int , string > spawnnumsoverride , Dictionary < int , string > doomednumsoverride )
{
int counter = 0 ;
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
/////////////// ====================== DAMAGETYPES
//mxd. Create DamageTypes list
// Combine damage types from config and decorate
HashSet < string > dtset = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
dtset . UnionWith ( General . Map . Config . DamageTypes ) ;
if ( ! decorate . HasError ) dtset . UnionWith ( decorate . DamageTypes ) ;
// Sort values
List < string > dtypes = new List < string > ( dtset ) ;
dtypes . Sort ( ) ;
// Apply to collection
damagetypes = new string [ dtypes . Count ] ;
dtypes . CopyTo ( damagetypes ) ;
/////////////// ====================== /DAMAGETYPES
// Step 0. Create ThingTypeInfo by classname collection...
Dictionary < string , ThingTypeInfo > thingtypesbyclass = new Dictionary < string , ThingTypeInfo > ( thingtypes . Count , StringComparer . OrdinalIgnoreCase ) ;
foreach ( ThingTypeInfo info in thingtypes . Values )
if ( ! string . IsNullOrEmpty ( info . ClassName ) ) thingtypesbyclass [ info . ClassName ] = info ;
// [ZZ] create combined array of actors to process.
IEnumerable < ActorStructure > mergedActors = zscript . Actors . Union ( decorate . Actors ) ;
IEnumerable < ActorStructure > mergedAllActors = zscript . AllActors . Union ( decorate . AllActors ) ;
2017-01-19 07:16:55 +00:00
Dictionary < string , ActorStructure > mergedActorsByClass = decorate . ActorsByClass . Concat ( zscript . ActorsByClass . Where ( x = > ! decorate . ActorsByClass . ContainsKey ( x . Key ) ) ) . ToDictionary ( k = > k . Key , v = > v . Value ) ;
Dictionary < string , ActorStructure > mergedAllActorsByClass = decorate . AllActorsByClass . Concat ( zscript . AllActorsByClass . Where ( x = > ! decorate . AllActorsByClass . ContainsKey ( x . Key ) ) ) . ToDictionary ( k = > k . Key , v = > v . Value ) ;
2017-01-16 08:20:47 +00:00
zdoomclasses = mergedAllActorsByClass ;
2017-01-16 00:08:35 +00:00
// Step 1. Go for all actors in the decorate to make things or update things
foreach ( ActorStructure actor in mergedActors )
{
//mxd. Apply "replaces" DECORATE override...
if ( ! string . IsNullOrEmpty ( actor . ReplacesClass ) & & thingtypesbyclass . ContainsKey ( actor . ReplacesClass ) )
{
// Update info
thingtypesbyclass [ actor . ReplacesClass ] . ModifyByDecorateActor ( actor , true ) ;
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
// Count
counter + + ;
}
// Check if we want to add this actor
else if ( actor . DoomEdNum > 0 )
{
// Check if we can find this thing in our existing collection
if ( thingtypes . ContainsKey ( actor . DoomEdNum ) )
{
// Update the thing
thingtypes [ actor . DoomEdNum ] . ModifyByDecorateActor ( actor ) ;
}
else
{
// Find the category to put the actor in
ThingCategory cat = GetThingCategory ( null , thingcategories , GetCategoryInfo ( actor ) ) ; //mxd
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
// Add new thing
ThingTypeInfo t = new ThingTypeInfo ( cat , actor ) ;
cat . AddThing ( t ) ;
thingtypes . Add ( t . Index , t ) ;
}
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
// Count
counter + + ;
}
}
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
//mxd. Step 2. Apply DoomEdNum MAPINFO overrides, remove actors disabled in MAPINFO
if ( doomednumsoverride . Count > 0 )
{
List < int > toremove = new List < int > ( ) ;
foreach ( KeyValuePair < int , string > group in doomednumsoverride )
{
// Remove thing from the list?
if ( group . Value = = "none" )
{
toremove . Add ( group . Key ) ;
continue ;
}
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
// Skip if already added.
if ( thingtypes . ContainsKey ( group . Key ) & & thingtypes [ group . Key ] . ClassName . ToLowerInvariant ( ) = = group . Value )
{
continue ;
}
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
// Try to find the actor...
ActorStructure actor = null ;
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
//... in ActorsByClass
if ( mergedActorsByClass . ContainsKey ( group . Value ) )
{
actor = mergedActorsByClass [ group . Value ] ;
}
// Try finding in ArchivedActors
else if ( mergedAllActorsByClass . ContainsKey ( group . Value ) )
{
actor = mergedAllActorsByClass [ group . Value ] ;
}
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
if ( actor ! = null )
{
// Find the category to put the actor in
ThingCategory cat = GetThingCategory ( null , thingcategories , GetCategoryInfo ( actor ) ) ; //mxd
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
// Add a new ThingTypeInfo, replacing already existing one if necessary
ThingTypeInfo info = new ThingTypeInfo ( cat , actor , group . Key ) ;
thingtypes [ group . Key ] = info ;
cat . AddThing ( info ) ;
}
// Check thingtypes...
else if ( thingtypesbyclass . ContainsKey ( group . Value ) )
{
ThingTypeInfo t = new ThingTypeInfo ( group . Key , thingtypesbyclass [ group . Value ] ) ;
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
// Add new thing, replacing already existing one if necessary
t . Category . AddThing ( t ) ;
thingtypes [ group . Key ] = t ;
}
// Loudly give up...
else
{
General . ErrorLogger . Add ( ErrorType . Warning , "Failed to apply MAPINFO DoomEdNum override \"" + group . Key + " = " + group . Value + "\": failed to find corresponding actor class..." ) ;
}
}
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
// Remove items
foreach ( int id in toremove )
{
if ( thingtypes . ContainsKey ( id ) )
{
thingtypes [ id ] . Category . RemoveThing ( thingtypes [ id ] ) ;
thingtypes . Remove ( id ) ;
}
}
}
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
//mxd. Step 3. Gather DECORATE SpawnIDs
Dictionary < int , EnumItem > configspawnnums = new Dictionary < int , EnumItem > ( ) ;
2015-04-14 11:33:57 +00:00
2017-01-16 00:08:35 +00:00
// Update or create the main enums list
if ( General . Map . Config . Enums . ContainsKey ( "spawnthing" ) )
{
foreach ( EnumItem item in General . Map . Config . Enums [ "spawnthing" ] )
configspawnnums . Add ( item . GetIntValue ( ) , item ) ;
}
bool spawnidschanged = false ;
foreach ( ActorStructure actor in mergedActors )
{
int spawnid = actor . GetPropertyValueInt ( "spawnid" , 0 ) ;
if ( spawnid ! = 0 )
{
configspawnnums [ spawnid ] = new EnumItem ( spawnid . ToString ( ) , ( actor . HasPropertyWithValue ( "$title" ) ? actor . GetPropertyAllValues ( "$title" ) : actor . ClassName ) ) ;
spawnidschanged = true ;
}
}
//mxd. Step 4. Update SpawnNums using MAPINFO overrides
if ( spawnnumsoverride . Count > 0 )
{
// Modify by MAPINFO data
foreach ( KeyValuePair < int , string > group in spawnnumsoverride )
configspawnnums [ group . Key ] = new EnumItem ( group . Key . ToString ( ) , ( thingtypes . ContainsKey ( group . Key ) ? thingtypes [ group . Key ] . Title : group . Value ) ) ;
spawnidschanged = true ;
}
if ( spawnidschanged )
{
// Update the main collection
EnumList newenums = new EnumList ( ) ;
newenums . AddRange ( configspawnnums . Values ) ;
newenums . Sort ( ( a , b ) = > a . Title . CompareTo ( b . Title ) ) ;
General . Map . Config . Enums [ "spawnthing" ] = newenums ;
// Update all ArgumentInfos...
foreach ( ThingTypeInfo info in thingtypes . Values )
{
foreach ( ArgumentInfo ai in info . Args )
if ( ai . Enum . Name = = "spawnthing" ) ai . Enum = newenums ;
}
foreach ( LinedefActionInfo info in General . Map . Config . LinedefActions . Values )
{
foreach ( ArgumentInfo ai in info . Args )
if ( ai . Enum . Name = = "spawnthing" ) ai . Enum = newenums ;
}
}
return counter ;
}
//mxd
private static ThingCategory GetThingCategory ( ThingCategory parent , List < ThingCategory > categories , DecorateCategoryInfo catinfo )
2015-04-14 11:33:57 +00:00
{
// Find the category to put the actor in
ThingCategory cat = null ;
2016-05-13 13:41:09 +00:00
string catname = ( catinfo . Category . Count > 0 ? catinfo . Category [ 0 ] . Trim ( ) . ToLowerInvariant ( ) : string . Empty ) ; //catnames[0].ToLowerInvariant().Trim();
2017-01-17 08:39:30 +00:00
if ( string . IsNullOrEmpty ( catname ) ) catname = "custom" ;
2015-06-01 21:46:28 +00:00
// First search by Title...
foreach ( ThingCategory c in categories )
2015-04-14 11:33:57 +00:00
{
2016-05-13 13:41:09 +00:00
if ( string . Equals ( c . Title , catname , StringComparison . OrdinalIgnoreCase ) )
{
cat = c ;
break ;
}
2015-04-14 11:33:57 +00:00
}
2015-06-08 14:37:20 +00:00
// Make full name
if ( parent ! = null ) catname = parent . Name . ToLowerInvariant ( ) + "." + catname ;
2015-06-01 22:10:15 +00:00
//...then - by Name
2015-04-14 11:33:57 +00:00
if ( cat = = null )
{
2015-06-01 21:46:28 +00:00
foreach ( ThingCategory c in categories )
2015-04-14 11:33:57 +00:00
{
2016-05-13 13:41:09 +00:00
if ( string . Equals ( c . Name , catname , StringComparison . OrdinalIgnoreCase ) )
{
cat = c ;
break ;
}
2015-04-14 11:33:57 +00:00
}
}
// Make the category if needed
2015-06-01 21:46:28 +00:00
if ( cat = = null )
{
2016-05-13 13:41:09 +00:00
string cattitle = ( catinfo . Category . Count > 0 ? catinfo . Category [ 0 ] . Trim ( ) : string . Empty ) ;
2017-01-17 08:39:30 +00:00
if ( string . IsNullOrEmpty ( cattitle ) ) cattitle = "User-defined" ;
2016-05-13 13:41:09 +00:00
cat = new ThingCategory ( parent , catname , cattitle , catinfo ) ;
2015-06-01 21:46:28 +00:00
categories . Add ( cat ) ; // ^.^
}
// Still have subcategories?
2016-05-13 13:41:09 +00:00
if ( catinfo . Category . Count > 1 )
2015-04-14 11:33:57 +00:00
{
2016-05-13 13:41:09 +00:00
catinfo . Category . RemoveAt ( 0 ) ;
return GetThingCategory ( cat , cat . Children , catinfo ) ;
2015-04-14 11:33:57 +00:00
}
return cat ;
}
2016-05-13 13:41:09 +00:00
//mxd
private static DecorateCategoryInfo GetCategoryInfo ( ActorStructure actor )
{
string catname = ZDTextParser . StripQuotes ( actor . GetPropertyAllValues ( "$category" ) ) . Trim ( ) ;
DecorateCategoryInfo catinfo = new DecorateCategoryInfo ( ) ;
if ( string . IsNullOrEmpty ( catname ) )
{
if ( actor . CategoryInfo ! = null )
{
catinfo . Category = new List < string > ( actor . CategoryInfo . Category ) ;
catinfo . Properties = new Dictionary < string , List < string > > ( actor . CategoryInfo . Properties ) ;
}
else
{
2017-01-17 08:39:30 +00:00
catinfo . Category = new List < string > { "User-defined" } ;
2016-05-13 13:41:09 +00:00
}
}
else
{
catinfo . Category = catname . Split ( CATEGORY_SPLITTER , StringSplitOptions . RemoveEmptyEntries ) . ToList ( ) ; //mxd
}
return catinfo ;
}
2009-04-19 18:07:22 +00:00
// This loads Decorate data from a specific file or lump name
private void LoadDecorateFromLocation ( DecorateParser parser , string location )
{
//General.WriteLogLine("Including DECORATE resource '" + location + "'...");
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 < TextResourceData > decostreams = currentreader . GetDecorateData ( location ) ;
foreach ( TextResourceData data in decostreams )
2009-04-19 18:07:22 +00:00
{
// Parse this data
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
parser . Parse ( data , false ) ;
2015-12-18 10:16:53 +00:00
//mxd. DECORATE lumps are interdepandable. Can't carry on...
if ( parser . HasError )
{
2016-02-01 22:04:00 +00:00
parser . LogError ( ) ;
2015-12-18 10:16:53 +00:00
return ;
}
2009-04-19 18:07:22 +00:00
}
}
2017-01-15 22:00:45 +00:00
private void LoadZScriptFromLocation ( ZScriptParser parser , string location )
{
IEnumerable < TextResourceData > streams = currentreader . GetZScriptData ( location ) ;
foreach ( TextResourceData data in streams )
{
// Parse this data
parser . Parse ( data , false ) ;
//mxd. DECORATE lumps are interdepandable. Can't carry on...
if ( parser . HasError )
{
parser . LogError ( ) ;
return ;
}
}
}
2018-06-09 14:26:03 +00:00
// This loads MODELDEF data from a specific file or lump name
private void LoadModeldefFromLocation ( ModeldefParser parser , string location )
{
IEnumerable < TextResourceData > streams = currentreader . GetModeldefData ( location ) ;
foreach ( TextResourceData data in streams )
{
// Parse this data
parser . Parse ( data , false ) ;
//mxd. DECORATE lumps are interdepandable. Can't carry on...
if ( parser . HasError )
{
parser . LogError ( ) ;
return ;
}
}
}
2009-04-19 18:07:22 +00:00
// This gets thing information by index
public ThingTypeInfo GetThingInfo ( int thingtype )
{
// Index in config?
if ( thingtypes . ContainsKey ( thingtype ) )
{
// Return from config
return thingtypes [ thingtype ] ;
}
2014-02-21 15:24:54 +00:00
// Create unknown thing info
return new ThingTypeInfo ( thingtype ) ;
2009-04-19 18:07:22 +00:00
}
// This gets thing information by index
// Returns null when thing type info could not be found
public ThingTypeInfo GetThingInfoEx ( int thingtype )
{
// Index in config?
if ( thingtypes . ContainsKey ( thingtype ) )
{
// Return from config
return thingtypes [ thingtype ] ;
}
2014-02-21 15:24:54 +00:00
// No such thing type known
return null ;
2009-04-19 18:07:22 +00:00
}
#endregion
2014-01-03 10:33:45 +00:00
#region = = = = = = = = = = = = = = = = = = mxd . Modeldef , Voxeldef , Gldefs , Mapinfo
2012-05-21 23:51:32 +00:00
2013-09-11 09:47:53 +00:00
//mxd. This creates <Actor Class, Thing.Type> dictionary. Should be called after all DECORATE actors are parsed
2015-12-21 14:17:47 +00:00
private Dictionary < string , int > CreateActorsByClassList ( )
2014-12-03 23:15:26 +00:00
{
2016-01-11 13:00:52 +00:00
Dictionary < string , int > actors = new Dictionary < string , int > ( StringComparer . OrdinalIgnoreCase ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) return actors ;
2012-05-21 23:51:32 +00:00
2013-09-11 09:47:53 +00:00
//read our new shiny ClassNames for default game things
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( KeyValuePair < int , ThingTypeInfo > ti in thingtypes )
2014-12-03 23:15:26 +00:00
{
2015-04-14 11:33:57 +00:00
if ( ! string . IsNullOrEmpty ( ti . Value . ClassName ) )
{
2016-01-11 13:00:52 +00:00
if ( actors . ContainsKey ( ti . Value . ClassName ) & & actors [ ti . Value . ClassName ] ! = ti . Key )
2016-05-24 22:11:29 +00:00
General . ErrorLogger . Add ( ErrorType . Warning , "Actor \"" + ti . Value . ClassName + "\" has several editor numbers (" + actors [ ti . Value . ClassName ] + " and " + ti . Key + "). Only the last one will be used." ) ;
2016-01-11 13:00:52 +00:00
actors [ ti . Value . ClassName ] = ti . Key ;
2015-04-14 11:33:57 +00:00
}
2013-09-11 09:47:53 +00:00
}
2012-06-01 10:17:47 +00:00
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( actors . Count = = 0 )
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 , "Unable to find any DECORATE actor definitions!" ) ;
2013-09-16 14:07:12 +00:00
2013-09-11 09:47:53 +00:00
return actors ;
}
2012-06-01 10:17:47 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2014-12-03 23:15:26 +00:00
public void ReloadModeldef ( )
{
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( modeldefentries ! = null )
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
foreach ( ModelData md in modeldefentries . Values ) md . Dispose ( ) ;
2012-08-05 19:18:05 +00:00
2015-12-18 10:16:53 +00:00
// Bail out when not supported by current game configuration
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) return ;
2013-09-11 09:47:53 +00:00
General . MainWindow . DisplayStatus ( StatusType . Busy , "Reloading model definitions..." ) ;
2014-12-03 23:15:26 +00:00
LoadModeldefs ( CreateActorsByClassList ( ) ) ;
2013-07-29 08:50:50 +00:00
2014-03-03 13:40:29 +00:00
General . MainWindow . DisplayStatus ( StatusType . Busy , "Reloading voxel definitions..." ) ;
2014-12-03 23:15:26 +00:00
LoadVoxels ( ) ;
2014-03-03 13:40:29 +00:00
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
foreach ( Thing t in General . Map . Map . Things ) t . UpdateCache ( ) ;
2012-06-01 10:17:47 +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
// Rebuild geometry if in Visual mode
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( General . Editing . Mode ! = null & & General . Editing . Mode . GetType ( ) . Name = = "BaseVisualMode" )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
General . Editing . Mode . OnReloadResources ( ) ;
}
General . MainWindow . DisplayReady ( ) ;
}
//mxd
2014-12-03 23:15:26 +00:00
public void ReloadGldefs ( )
{
2015-12-18 10:16:53 +00:00
// Bail out when not supported by current game configuration
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) return ;
2013-09-11 09:47:53 +00:00
General . MainWindow . DisplayStatus ( StatusType . Busy , "Reloading GLDEFS..." ) ;
2014-03-03 13:40:29 +00:00
2014-12-03 23:15:26 +00:00
try
{
LoadGldefs ( CreateActorsByClassList ( ) ) ;
}
catch ( ArgumentNullException )
{
2014-03-03 13:40:29 +00:00
MessageBox . Show ( "GLDEFS reload failed. Try using 'Reload Resources' instead.\nCheck 'Errors and Warnings' window for more details." ) ;
General . MainWindow . DisplayReady ( ) ;
return ;
}
2013-09-11 09:47:53 +00:00
2016-01-14 22:15:54 +00:00
// Rebuild skybox texture
SetupSkybox ( ) ;
2016-01-11 13:00:52 +00:00
// Rebuild geometry if in Visual mode
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( General . Editing . Mode ! = null & & General . Editing . Mode . GetType ( ) . Name = = "BaseVisualMode" )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
General . Editing . Mode . OnReloadResources ( ) ;
}
General . MainWindow . DisplayReady ( ) ;
}
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
//mxd. This parses modeldefs. Should be called after all DECORATE actors are parsed
2015-12-21 14:17:47 +00:00
private void LoadModeldefs ( Dictionary < string , int > actorsbyclass )
2014-12-03 23:15:26 +00:00
{
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
// Abort if no classnames are defined in DECORATE or game config...
2015-12-21 14:17:47 +00:00
if ( actorsbyclass . Count = = 0 ) return ;
2013-09-11 09:47:53 +00:00
2018-06-09 14:26:03 +00:00
ModeldefParser parser = new ModeldefParser ( actorsbyclass ) { OnInclude = LoadModeldefFromLocation } ;
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
foreach ( DataReader dr in containers )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . MODELDEF , false , true ) ;
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 ( TextResourceData data in streams )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
// Parse the data
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
parser . Parse ( data , true ) ;
2015-12-17 10:07:28 +00:00
// Modeldefs are independable, so parsing fail in one file should not affect the others
2015-12-18 10:16:53 +00:00
if ( parser . HasError ) parser . LogError ( ) ;
2013-09-11 09:47:53 +00:00
}
}
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
// Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2013-09-11 09:47:53 +00:00
currentreader = null ;
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
foreach ( KeyValuePair < string , ModelData > e in parser . Entries )
2014-12-03 23:15:26 +00:00
{
2015-12-21 14:17:47 +00:00
if ( actorsbyclass . ContainsKey ( e . Key ) )
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
modeldefentries [ actorsbyclass [ e . Key ] ] = parser . Entries [ e . Key ] ;
2015-04-14 11:33:57 +00:00
else if ( ! decorate . ActorsByClass . ContainsKey ( e . Key ) )
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 , "MODELDEF model \"" + e . Key + "\" doesn't match any Decorate actor class" ) ;
2013-09-11 09:47:53 +00:00
}
}
2012-06-01 10:17:47 +00:00
2014-01-03 10:33:45 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void LoadVoxels ( )
{
2015-12-18 10:16:53 +00:00
// Bail out when not supported by current game configuration
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) return ;
2014-01-03 10:33:45 +00:00
// Go for all things
2016-07-11 22:13:43 +00:00
Dictionary < string , List < int > > allsprites = new Dictionary < string , List < int > > ( StringComparer . Ordinal ) ;
2014-12-03 23:15:26 +00:00
foreach ( ThingTypeInfo ti in thingtypes . Values )
{
2014-01-03 10:33:45 +00:00
// Valid sprite name?
2016-07-11 22:13:43 +00:00
if ( string . IsNullOrEmpty ( ti . Sprite ) | | ti . Sprite . Length > CLASIC_IMAGE_NAME_LENGTH ) continue ;
if ( ! allsprites . ContainsKey ( ti . Sprite ) ) allsprites . Add ( ti . Sprite , new List < int > ( ) ) ;
allsprites [ ti . Sprite ] . Add ( ti . Index ) ;
2014-01-03 10:33:45 +00:00
}
VoxeldefParser parser = new VoxeldefParser ( ) ;
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
HashSet < string > processed = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
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
// Parse VOXLEDEF
2014-12-03 23:15:26 +00:00
foreach ( DataReader dr in containers )
{
2014-01-03 10:33:45 +00:00
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . VOXELDEF , false , 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
foreach ( TextResourceData data in streams )
2014-12-03 23:15:26 +00:00
{
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
if ( parser . Parse ( data , true ) )
2014-12-03 23:15:26 +00:00
{
2015-12-17 10:07:28 +00:00
foreach ( KeyValuePair < string , ModelData > entry in parser . Entries )
2014-12-03 23:15:26 +00:00
{
2016-07-11 22:13:43 +00:00
foreach ( KeyValuePair < string , List < int > > sc in allsprites )
2014-12-03 23:15:26 +00:00
{
2016-07-11 22:13:43 +00:00
if ( sc . Key . StartsWith ( entry . Key , StringComparison . OrdinalIgnoreCase ) )
2015-12-17 10:07:28 +00:00
{
2016-07-11 22:13:43 +00:00
foreach ( int id in sc . Value ) modeldefentries [ id ] = entry . Value ;
processed . Add ( sc . Key ) ;
// Create preview image if it doesn't exist...
ImageData sprite = GetSpriteImage ( sc . Key ) ;
if ( sprite = = null )
{
// Make new voxel image
sprite = new VoxelImage ( sc . Key , entry . Value . ModelNames [ 0 ] ) ;
// Add to collection
sprites . Add ( sprite . LongName , sprite ) ;
// Add to preview manager
previews . AddImage ( sprite ) ;
}
// Apply VOXELDEF settings to the preview image...
VoxelImage vi = sprite as VoxelImage ;
if ( vi ! = null )
{
vi . AngleOffset = ( int ) Math . Round ( entry . Value . AngleOffset ) ;
vi . OverridePalette = entry . Value . OverridePalette ;
}
2015-12-17 10:07:28 +00:00
}
2014-01-03 10:33:45 +00:00
}
}
}
2015-12-17 10:07:28 +00:00
// Report errors?
2015-12-18 10:16:53 +00:00
if ( parser . HasError ) parser . LogError ( ) ;
2014-01-03 10:33:45 +00:00
}
}
Sectors, Linedefs, Things modes: optimized text label rendering.
Fixed, Things mode: in some cases selection labels were not updated after editing a thing.
Fixed, Things mode: selection labels were positioned incorrectly on things with FixedSize setting.
Fixed, Sectors mode: fixed a crash when selecting self-referencing sector when selection labels were enabled.
Fixed, Visual mode: in some cases Auto-align texture actions were not working when "use long texture names" Map Options setting was enabled.
Fixed, MD2/MD3 loader: available animation frames upper bound check was performed incorrectly, which would cause a crash in some very special cases.
Fixed, Game configurations: most Hexen/ZDoom teleport actions use TeleportDests as teleport targets, not MapSpots.
2016-04-05 22:24:36 +00:00
// Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2014-01-03 10:33:45 +00:00
currentreader = null ;
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
// Get voxel models
2016-07-11 22:13:43 +00:00
foreach ( KeyValuePair < string , List < int > > sc in allsprites )
2014-12-03 23:15:26 +00:00
{
2016-07-11 22:13:43 +00:00
if ( processed . Contains ( sc . Key ) ) continue ;
VoxelImage vi = GetSpriteImage ( sc . Key ) as VoxelImage ;
if ( vi ! = null )
2014-12-03 23:15:26 +00:00
{
2016-07-11 22:13:43 +00:00
// It's a model without a definition, and it corresponds to a sprite we can display, so let's add it
ModelData data = new ModelData { IsVoxel = true } ;
data . ModelNames . Add ( vi . VoxelName ) ;
2014-01-03 10:33:45 +00:00
2016-07-11 22:13:43 +00:00
foreach ( int id in sc . Value ) modeldefentries [ id ] = data ;
2014-01-03 10:33:45 +00:00
}
}
}
2015-12-21 14:17:47 +00:00
//mxd. This parses gldefs. Should be called after all DECORATE actors are parsed
private void LoadGldefs ( Dictionary < string , int > actorsbyclass )
2014-12-03 23:15:26 +00:00
{
2016-01-11 13:00:52 +00:00
// Skip if no actors defined in DECORATE or game config...
2015-12-21 14:17:47 +00:00
if ( actorsbyclass . Count = = 0 ) return ;
2013-09-11 09:47:53 +00:00
2015-04-14 11:33:57 +00:00
GldefsParser parser = new GldefsParser { OnInclude = ParseFromLocation } ;
2013-09-11 09:47:53 +00:00
2015-12-17 10:07:28 +00:00
// Load gldefs from resources
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( DataReader dr in containers )
2014-12-03 23:15:26 +00:00
{
2016-11-28 20:01:47 +00:00
if ( parser . HasError ) break ;
2013-09-11 09:47:53 +00:00
currentreader = dr ;
2015-01-20 12:20:35 +00:00
parser . ClearIncludesList ( ) ;
2016-07-14 23:39:48 +00:00
IEnumerable < TextResourceData > streams = dr . GetGldefsData ( General . Map . Config . 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
foreach ( TextResourceData data in streams )
2015-12-17 10:07:28 +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
parser . Parse ( data , false ) ;
2015-12-17 10:07:28 +00:00
// Gldefs can be interdependable. Can't carry on
if ( parser . HasError )
{
parser . LogError ( ) ;
2016-11-28 20:01:47 +00:00
break ;
2015-12-17 10:07:28 +00:00
}
}
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
//mxd. Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
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
currentreader = null ;
2016-11-28 20:01:47 +00:00
//mxd. Abort on errors, but after adding parsed text resources
if ( parser . HasError ) return ;
2016-01-11 13:00:52 +00:00
// Create Gldefs Entries dictionary
2015-12-21 14:17:47 +00:00
foreach ( KeyValuePair < string , string > e in parser . Objects ) //<ClassName, Light name>
2016-04-06 22:54:04 +00:00
{
// Check if we have decorate actor and light definition for given ClassName
//INFO: objects without corresponding actors are already reported by the parser
if ( actorsbyclass . ContainsKey ( e . Key ) )
{
if ( parser . LightsByName . ContainsKey ( e . Value ) )
{
gldefsentries [ actorsbyclass [ e . Key ] ] = parser . LightsByName [ e . Value ] ;
}
else
{
//INFO: Lights CAN be defiend after Objects, so we can't perform any object->light matching checks while parsing
General . ErrorLogger . Add ( ErrorType . Error , "GLDEFS object \"" + e . Key + "\" references undefined light \"" + e . Value + "\"" ) ;
}
}
2013-09-11 09:47:53 +00:00
}
2015-04-14 11:33:57 +00:00
2016-04-20 21:55:33 +00:00
// Apply dynamic lights defined using Light() state expression
foreach ( ThingTypeInfo info in thingtypes . Values )
{
if ( string . IsNullOrEmpty ( info . LightName ) ) continue ;
if ( parser . LightsByName . ContainsKey ( info . LightName ) )
gldefsentries [ info . Index ] = parser . LightsByName [ info . LightName ] ;
else
General . ErrorLogger . Add ( ErrorType . Error , "Actor \"" + info . Title + "\":" + info . Index + " references undefined light \"" + info . LightName + "\"" ) ;
}
2015-04-14 11:33:57 +00:00
// Grab them glowy flats!
glowingflats = parser . GlowingFlats ;
2016-01-11 13:00:52 +00:00
// And skyboxes
skyboxes = parser . Skyboxes ;
2013-09-11 09:47:53 +00:00
}
2016-01-18 11:39:59 +00:00
//mxd. This updates mapinfo class only
internal void ReloadMapInfoPartial ( )
{
Dictionary < int , string > spawnnums , doomednums ;
LoadMapInfo ( out spawnnums , out doomednums ) ;
}
2013-09-11 09:47:53 +00:00
//mxd. This loads (Z)MAPINFO
2015-04-14 11:33:57 +00:00
private void LoadMapInfo ( out Dictionary < int , string > spawnnums , out Dictionary < int , string > doomednums )
2014-12-03 23:15:26 +00:00
{
2015-04-14 11:33:57 +00:00
MapinfoParser parser = new MapinfoParser { OnInclude = ParseFromLocation } ;
2016-01-11 13:00:52 +00:00
// Parse mapinfo
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
foreach ( DataReader dr in containers )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
currentreader = dr ;
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 < TextResourceData > streams = dr . GetMapinfoData ( ) ;
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
foreach ( TextResourceData data in streams )
2014-12-03 23:15:26 +00:00
{
2013-09-11 09:47:53 +00:00
// Parse the data
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
parser . Parse ( data , General . Map . Options . LevelName , false ) ;
2015-12-17 10:07:28 +00:00
//MAPINFO lumps are interdependable. Can't carry on...
if ( parser . HasError )
{
parser . LogError ( ) ;
2016-01-11 13:00:52 +00:00
break ;
2015-12-17 10:07:28 +00:00
}
2013-09-11 09:47:53 +00:00
}
}
2016-01-11 13:00:52 +00:00
if ( ! parser . HasError )
{
// Store parsed data
spawnnums = parser . SpawnNums ;
doomednums = parser . DoomEdNums ;
mapinfo = parser . MapInfo ;
}
else
{
// No nulls allowed!
spawnnums = new Dictionary < int , string > ( ) ;
doomednums = new Dictionary < int , string > ( ) ;
mapinfo = new 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
//mxd. Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2013-09-11 09:47:53 +00:00
currentreader = null ;
}
2015-12-18 10:16:53 +00:00
private void ParseFromLocation ( ZDTextParser parser , string location , bool clearerrors )
2014-12-03 23:15:26 +00:00
{
2015-04-14 11:33:57 +00:00
if ( currentreader . 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
parser . Parse ( new TextResourceData ( currentreader , currentreader . LoadFile ( location ) , location , true ) , clearerrors ) ;
2013-09-11 09:47:53 +00:00
}
2015-01-25 23:22:42 +00:00
//mxd. This loads REVERBS
private void LoadReverbs ( )
{
reverbs . Clear ( ) ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
2015-12-18 10:16:53 +00:00
// Bail out when not supported by current game configuration
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) return ;
ReverbsParser parser = new ReverbsParser ( ) ;
2015-01-25 23:22:42 +00:00
foreach ( DataReader dr in containers )
{
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . REVERBS , false , 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
foreach ( TextResourceData data in streams )
2015-01-25 23:22:42 +00:00
{
// Parse the data
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
parser . Parse ( data , true ) ;
2015-12-17 10:07:28 +00:00
// Report errors?
2015-12-18 10:16:53 +00:00
if ( parser . HasError ) parser . LogError ( ) ;
2015-01-25 23:22:42 +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. Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2015-01-25 23:22:42 +00:00
currentreader = null ;
reverbs = parser . GetReverbs ( ) ;
}
2016-05-24 22:11:29 +00:00
//mxd. This loads SNDINFO
private void LoadSndInfo ( )
{
// Bail out when not supported by current game configuration
if ( string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) return ;
SndInfoParser parser = new SndInfoParser ( ) ;
foreach ( DataReader dr in containers )
{
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . SNDINFO , false , false ) ;
2016-05-24 22:11:29 +00:00
// Parse the data
foreach ( TextResourceData data in streams )
{
parser . Parse ( data , true ) ;
// Report errors?
if ( parser . HasError ) parser . LogError ( ) ;
}
}
// Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2016-05-24 22:11:29 +00:00
currentreader = null ;
// Anything to do?
2016-10-03 11:42:12 +00:00
parser . FinishSetup ( ) ;
2016-05-24 22:11:29 +00:00
if ( parser . AmbientSounds . Count > 0 )
{
// Update or create the main enums list
Dictionary < int , EnumItem > configenums = new Dictionary < int , EnumItem > ( ) ;
if ( General . Map . Config . Enums . ContainsKey ( "ambient_sounds" ) )
{
foreach ( EnumItem item in General . Map . Config . Enums [ "ambient_sounds" ] )
configenums . Add ( item . GetIntValue ( ) , item ) ;
}
if ( configenums . ContainsKey ( 0 ) ) configenums . Remove ( 0 ) ;
2016-10-03 11:42:12 +00:00
foreach ( KeyValuePair < int , AmbientSoundInfo > group in parser . AmbientSounds )
2016-05-24 22:11:29 +00:00
{
2016-10-03 11:42:12 +00:00
configenums [ group . Key ] = new EnumItem ( group . Key . ToString ( ) , group . Value . SoundName ) ;
2016-05-24 22:11:29 +00:00
}
// Store results in "ambient_sounds" enum
EnumList newenums = new EnumList ( ) ;
newenums . AddRange ( configenums . Values ) ;
newenums . Sort ( ( a , b ) = > a . Title . CompareTo ( b . Title ) ) ; // Sort by title
newenums . Insert ( 0 , new EnumItem ( "0" , "None" ) ) ; // Add "None" value
General . Map . Config . Enums [ "ambient_sounds" ] = newenums ;
// Update all ArgumentInfos...
foreach ( ThingTypeInfo info in thingtypes . Values )
{
foreach ( ArgumentInfo ai in info . Args )
if ( ai . Enum . Name = = "ambient_sounds" ) ai . Enum = newenums ;
}
foreach ( LinedefActionInfo info in General . Map . Config . LinedefActions . Values )
{
foreach ( ArgumentInfo ai in info . Args )
if ( ai . Enum . Name = = "ambient_sounds" ) ai . Enum = newenums ;
}
// Update "Ambient Sound XX" thing names. Hardcoded for things 14001 - 14064 for now...
for ( int i = 14001 ; i < 14065 ; i + + )
{
int ambsoundindex = i - 14000 ;
2016-10-03 11:42:12 +00:00
// Attach AmbientSoundInfo
if ( parser . AmbientSounds . ContainsKey ( ambsoundindex ) )
thingtypes [ i ] . AmbientSound = parser . AmbientSounds [ ambsoundindex ] ;
2016-05-24 22:11:29 +00:00
// Update title
2016-10-03 11:42:12 +00:00
if ( configenums . ContainsKey ( ambsoundindex ) & & thingtypes . ContainsKey ( i ) & & string . IsNullOrEmpty ( thingtypes [ i ] . ClassName ) )
thingtypes [ i ] . Title + = " (" + configenums [ ambsoundindex ] + ")" ;
2016-05-24 22:11:29 +00:00
}
}
2016-10-05 20:15:38 +00:00
// Store collection
ambientsounds = parser . AmbientSounds ;
2016-05-24 22:11:29 +00:00
}
2015-05-28 13:45:01 +00:00
//mxd. This loads SNDSEQ
private void LoadSndSeq ( )
{
2015-12-18 10:16:53 +00:00
// Bail out when not supported by current game configuration
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
if ( string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) return ;
SndSeqParser parser = new SndSeqParser ( ) ;
2015-05-28 13:45:01 +00:00
foreach ( DataReader dr in containers )
{
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . SNDSEQ , false , false ) ;
2015-05-28 13:45:01 +00:00
// Parse the data
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 ( TextResourceData data in streams )
2015-05-28 13:45:01 +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
parser . Parse ( data , true ) ;
2015-12-17 10:07:28 +00:00
// Report errors?
2015-12-18 10:16:53 +00:00
if ( parser . HasError ) parser . LogError ( ) ;
}
}
2016-05-24 22:11:29 +00:00
// Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2015-12-18 10:16:53 +00:00
currentreader = null ;
soundsequences = parser . GetSoundSequences ( ) ;
}
//mxd. This loads cameratextures from ANIMDEFS
private void LoadAnimdefs ( )
{
// Bail out when not supported by current game configuration
if ( string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) return ;
AnimdefsParser parser = new AnimdefsParser ( ) ;
foreach ( DataReader dr in containers )
{
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . ANIMDEFS , false , false ) ;
2015-12-18 10:16:53 +00:00
// Parse the data
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 ( TextResourceData data in streams )
2015-12-18 10:16:53 +00:00
{
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
parser . Parse ( data , true ) ;
2015-12-18 10:16:53 +00:00
// Report errors?
if ( parser . HasError ) parser . LogError ( ) ;
// Create images
foreach ( var g in parser . CameraTextures )
2015-12-17 10:07:28 +00:00
{
2015-12-18 10:16:53 +00:00
// Grab a local copy
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
CameraTextureData camtexdata = g . Value ;
2015-12-18 10:16:53 +00:00
// Apply texture size override?
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 ( ! camtexdata . FitTexture )
2015-12-18 10:16:53 +00:00
{
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
long longname = Lump . MakeLongName ( camtexdata . Name ) ;
2015-12-18 10:16:53 +00:00
if ( textures . ContainsKey ( longname ) )
{
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
camtexdata . ScaleX = ( float ) textures [ longname ] . Width / camtexdata . Width ;
camtexdata . ScaleY = ( float ) textures [ longname ] . Height / camtexdata . Height ;
2015-12-18 10:16:53 +00:00
}
else if ( flats . ContainsKey ( longname ) )
{
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
camtexdata . ScaleX = ( float ) flats [ longname ] . Width / camtexdata . Width ;
camtexdata . ScaleY = ( float ) flats [ longname ] . Height / camtexdata . Height ;
2015-12-18 10:16:53 +00:00
}
}
// Create texture
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
CameraTextureImage camteximage = new CameraTextureImage ( camtexdata ) ;
2015-12-18 10:16:53 +00:00
// Add to flats and textures
texturenames . Add ( camteximage . Name ) ;
flatnames . Add ( camteximage . Name ) ;
//TODO: Do cameratextures override stuff like this?..
textures [ camteximage . LongName ] = camteximage ;
flats [ camteximage . LongName ] = camteximage ;
// Add to preview manager
previews . AddImage ( camteximage ) ;
// Add to container's texture set
currentreader . TextureSet . AddFlat ( camteximage ) ;
currentreader . TextureSet . AddTexture ( camteximage ) ;
2015-12-17 10:07:28 +00:00
}
2015-05-28 13:45:01 +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. Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
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
currentreader = null ;
}
//mxd. This loads TERRAIN
private void LoadTerrain ( )
{
// Bail out when not supported by current game configuration
if ( string . IsNullOrEmpty ( General . Map . Config . DecorateGames ) ) return ;
TerrainParser parser = new TerrainParser ( ) ;
foreach ( DataReader dr in containers )
{
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . TERRAIN , false , 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
// Parse the data
foreach ( TextResourceData data in streams )
{
parser . Parse ( data , true ) ;
// Report errors?
if ( parser . HasError ) parser . LogError ( ) ;
}
}
// Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2015-05-28 13:45:01 +00:00
currentreader = null ;
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
// Sort
List < string > names = new List < string > ( parser . TerrainNames ) ;
names . Sort ( ) ;
// Set as collection
terrainnames = names . ToArray ( ) ;
2015-05-28 13:45:01 +00:00
}
2016-03-16 23:26:53 +00:00
//mxd. This loads X11R6RGB
private void LoadX11R6RGB ( )
{
X11R6RGBParser parser = new X11R6RGBParser ( ) ;
foreach ( DataReader dr in containers )
{
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . X11R6RGB , true , false ) ;
2016-03-16 23:26:53 +00:00
// Parse the data
foreach ( TextResourceData data in streams )
{
parser . Parse ( data , true ) ;
// Report errors?
if ( parser . HasError ) parser . LogError ( ) ;
}
}
// Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2016-03-16 23:26:53 +00:00
currentreader = null ;
// Set as collection
knowncolors = parser . KnownColors ;
}
2016-04-13 14:11:35 +00:00
//mxd. This loads CVARINFO lumps
private void LoadCvarInfo ( )
{
CvarInfoParser parser = new CvarInfoParser ( ) ;
foreach ( DataReader dr in containers )
{
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . CVARINFO , false , false ) ;
2016-04-13 14:11:35 +00:00
// Parse the data
foreach ( TextResourceData data in streams )
{
parser . Parse ( data , true ) ;
// Report errors?
if ( parser . HasError ) parser . LogError ( ) ;
}
}
// Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2016-04-13 14:11:35 +00:00
currentreader = null ;
// Set as collection
cvars = parser . Cvars ;
}
2016-07-14 23:39:48 +00:00
//mxd. This loads LOCKDEFS lumps
private void LoadLockDefs ( )
{
LockDefsParser parser = new LockDefsParser ( ) ;
foreach ( DataReader dr in containers )
{
currentreader = dr ;
2016-12-12 12:35:18 +00:00
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( ScriptType . LOCKDEFS , false , false ) ;
2016-07-14 23:39:48 +00:00
// Parse the data
foreach ( TextResourceData data in streams )
{
parser . Parse ( data , true ) ;
// Report errors?
if ( parser . HasError ) parser . LogError ( ) ;
}
}
// Add to text resources collection
2016-11-24 11:55:11 +00:00
scriptresources [ parser . ScriptType ] = new HashSet < ScriptResource > ( parser . ScriptResources . Values ) ;
2016-07-14 23:39:48 +00:00
currentreader = null ;
// Apply to the enums list?
EnumList keys = parser . GetLockDefs ( ) ;
2016-07-15 14:07:30 +00:00
lockableactions = new Dictionary < int , int > ( ) ;
2016-07-14 23:39:48 +00:00
if ( keys . Count > 0 )
{
2016-07-17 00:00:29 +00:00
keys . Sort ( ( a , b ) = > a . Title . CompareTo ( b . Title ) ) ;
2016-07-14 23:39:48 +00:00
keys . Insert ( 0 , new EnumItem ( "0" , "None" ) ) ;
General . Map . Config . Enums [ "keys" ] = keys ;
// Update all ArgumentInfos...
foreach ( ThingTypeInfo info in thingtypes . Values )
{
foreach ( ArgumentInfo ai in info . Args )
if ( ai . Enum . Name = = "keys" ) ai . Enum = General . Map . Config . Enums [ "keys" ] ;
}
foreach ( LinedefActionInfo info in General . Map . Config . LinedefActions . Values )
{
2016-07-15 14:07:30 +00:00
for ( int i = 0 ; i < info . Args . Length ; i + + )
{
if ( info . Args [ i ] . Enum . Name = = "keys" )
{
info . Args [ i ] . Enum = General . Map . Config . Enums [ "keys" ] ;
lockableactions [ info . Index ] = i ;
}
}
2016-07-14 23:39:48 +00:00
}
2016-07-15 14:07:30 +00:00
// Also store lock colors
lockcolors = parser . MapColors ;
}
else
{
lockcolors = new Dictionary < int , PixelColor > ( ) ;
2016-07-14 23:39:48 +00:00
}
}
2016-11-24 21:09:24 +00:00
//mxd. This collects ZDoom text lumps, which are not used by the editor anywhere outside the Script Editor
private void LoadExtraTextLumps ( )
{
2016-12-12 12:35:18 +00:00
Dictionary < ScriptType , bool > extralumptypes = new Dictionary < ScriptType , bool > // <script type, singular>
2016-11-24 21:09:24 +00:00
{
2016-12-12 12:35:18 +00:00
{ ScriptType . MENUDEF , true } ,
{ ScriptType . SBARINFO , true } , //TODO: SBARINFO supports #include
{ ScriptType . GAMEINFO , true } ,
{ ScriptType . KEYCONF , true } ,
{ ScriptType . FONTDEFS , true } ,
//TODO: load/create SCRIPTS and DIALOG here?
} ;
2016-11-24 21:09:24 +00:00
2016-12-12 12:35:18 +00:00
foreach ( KeyValuePair < ScriptType , bool > group in extralumptypes )
2016-11-24 21:09:24 +00:00
{
2016-12-12 12:35:18 +00:00
HashSet < ScriptResource > resources = new HashSet < ScriptResource > ( ) ;
foreach ( DataReader dr in containers )
{
currentreader = dr ;
IEnumerable < TextResourceData > streams = dr . GetTextLumpData ( group . Key , group . Value , false ) ;
2016-11-24 21:09:24 +00:00
2016-12-12 12:35:18 +00:00
// Add text tesources
foreach ( TextResourceData data in streams ) resources . Add ( new ScriptResource ( data , group . Key ) ) ;
}
2016-11-24 21:09:24 +00:00
2016-12-12 12:35:18 +00:00
// Add to collection
if ( resources . Count > 0 ) scriptresources [ group . Key ] = resources ;
}
2016-11-24 21:09:24 +00:00
}
2013-09-11 09:47:53 +00:00
//mxd
2016-02-28 22:15:17 +00:00
internal TextResourceData GetTextResourceData ( string name )
2014-12-03 23:15:26 +00:00
{
2015-12-21 14:17:47 +00:00
// Filesystem path?
if ( Path . IsPathRooted ( name ) )
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 ( File . Exists ( name ) )
{
DataLocation location = new DataLocation { location = name , type = DataLocation . RESOURCE_DIRECTORY } ;
2016-11-24 21:09:24 +00:00
return new TextResourceData ( File . OpenRead ( name ) , location , name ) ;
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
}
2015-12-21 14:17:47 +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 null ;
}
// Search in resources
for ( int i = containers . Count - 1 ; i > = 0 ; i - - )
{
if ( containers [ i ] . FileExists ( name ) )
2016-11-24 21:09:24 +00:00
return new TextResourceData ( containers [ i ] , containers [ i ] . LoadFile ( name ) , name , true ) ;
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
}
2015-12-21 14:17:47 +00:00
2013-09-11 09:47:53 +00:00
return null ;
}
#endregion
#region = = = = = = = = = = = = = = = = = = Tools
// This finds the first IWAD resource
2009-04-19 18:07:22 +00:00
// Returns false when not found
2012-06-01 19:53:14 +00:00
public bool FindFirstIWAD ( out DataLocation result )
2009-04-19 18:07:22 +00:00
{
// Go for all data containers
foreach ( DataReader dr in containers )
{
// Container is a WAD file?
if ( dr is WADReader )
{
// Check if it is an IWAD
WADReader wr = dr as WADReader ;
if ( wr . IsIWAD )
{
// Return location!
result = wr . Location ;
return true ;
}
}
}
// No IWAD found
result = new DataLocation ( ) ;
return false ;
}
// This signals the background thread to update the
// used-in-map status on all textures and flats
public void UpdateUsedTextures ( )
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
if ( General . Map . Config . MixTexturesFlats )
2009-04-19 18:07:22 +00:00
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
lock ( usedtextures )
{
usedtextures . Clear ( ) ;
2009-04-19 18:07:22 +00:00
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
// Go through the map to find the used textures
foreach ( Sidedef sd in General . Map . Map . Sidedefs )
{
// Add used textures to dictionary
2016-03-23 14:52:33 +00:00
if ( sd . LongHighTexture ! = MapSet . EmptyLongName )
{
usedtextures [ sd . LongHighTexture ] = true ;
//mxd. Part of long name support shennanigans
if ( texturenamesshorttofull . ContainsKey ( sd . LongHighTexture ) )
usedtextures [ texturenamesshorttofull [ sd . LongHighTexture ] ] = true ;
}
if ( sd . LongMiddleTexture ! = MapSet . EmptyLongName )
{
usedtextures [ sd . LongMiddleTexture ] = true ;
//mxd. Part of long name support shennanigans
if ( texturenamesshorttofull . ContainsKey ( sd . LongMiddleTexture ) )
usedtextures [ texturenamesshorttofull [ sd . LongMiddleTexture ] ] = true ;
}
if ( sd . LongLowTexture ! = MapSet . EmptyLongName )
{
usedtextures [ sd . LongLowTexture ] = true ;
//mxd. Part of long name support shennanigans
if ( texturenamesshorttofull . ContainsKey ( sd . LongLowTexture ) )
usedtextures [ texturenamesshorttofull [ sd . LongLowTexture ] ] = true ;
}
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
}
// Go through the map to find the used flats
foreach ( Sector s in General . Map . Map . Sectors )
{
// Add used flats to dictionary
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
usedtextures [ s . LongFloorTexture ] = false ;
usedtextures [ s . LongCeilTexture ] = false ;
2016-03-23 14:52:33 +00:00
//mxd. Part of long name support shennanigans
if ( flatnamesshorttofull . ContainsKey ( s . LongFloorTexture ) )
usedtextures [ flatnamesshorttofull [ s . LongFloorTexture ] ] = false ;
if ( flatnamesshorttofull . ContainsKey ( s . LongCeilTexture ) )
usedtextures [ flatnamesshorttofull [ s . LongCeilTexture ] ] = false ;
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
}
}
}
//mxd. Use separate collections
else
{
lock ( usedtextures )
2009-04-19 18:07:22 +00:00
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
usedtextures . Clear ( ) ;
// Go through the map to find the used textures
foreach ( Sidedef sd in General . Map . Map . Sidedefs )
{
// Add used textures to dictionary
2016-03-23 14:52:33 +00:00
if ( sd . LongHighTexture ! = MapSet . EmptyLongName )
{
usedtextures [ sd . LongHighTexture ] = true ;
//mxd. Part of long name support shennanigans
if ( texturenamesshorttofull . ContainsKey ( sd . LongHighTexture ) )
usedtextures [ texturenamesshorttofull [ sd . LongHighTexture ] ] = true ;
}
if ( sd . LongMiddleTexture ! = MapSet . EmptyLongName )
{
usedtextures [ sd . LongMiddleTexture ] = true ;
//mxd. Part of long name support shennanigans
if ( texturenamesshorttofull . ContainsKey ( sd . LongMiddleTexture ) )
usedtextures [ texturenamesshorttofull [ sd . LongMiddleTexture ] ] = true ;
}
if ( sd . LongLowTexture ! = MapSet . EmptyLongName )
{
usedtextures [ sd . LongLowTexture ] = true ;
//mxd. Part of long name support shennanigans
if ( texturenamesshorttofull . ContainsKey ( sd . LongLowTexture ) )
usedtextures [ texturenamesshorttofull [ sd . LongLowTexture ] ] = true ;
}
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
}
2009-04-19 18:07:22 +00:00
}
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
lock ( usedflats )
2009-04-19 18:07:22 +00:00
{
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
usedflats . Clear ( ) ;
// Go through the map to find the used flats
foreach ( Sector s in General . Map . Map . Sectors )
{
// Add used flats to dictionary
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
usedflats [ s . LongFloorTexture ] = false ;
usedflats [ s . LongCeilTexture ] = false ;
2016-03-23 14:52:33 +00:00
//mxd. Part of long name support shennanigans
if ( flatnamesshorttofull . ContainsKey ( s . LongFloorTexture ) )
usedflats [ flatnamesshorttofull [ s . LongFloorTexture ] ] = false ;
if ( flatnamesshorttofull . ContainsKey ( s . LongCeilTexture ) )
usedflats [ flatnamesshorttofull [ s . LongCeilTexture ] ] = false ;
Removed "Paste Properties Options" action.
Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action.
Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them.
Changed, Paste Properties Special window: only options relevant to current map format are now displayed.
Changed, Paste Properties Special window, UDMF: all UI-managed options are now available.
Fixed: MAPINFO parser was unable to process "include" directives.
Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection.
Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode.
Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time.
Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map.
Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled.
Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category.
Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll.
Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format.
Internal: merged methods from UDMFTools into UniFields, removed UDMFTools.
Updated Inno Setup script (added VC++ 2008 SP1 distributive).
Updated ZDoom_DECORATE.cfg (A_CheckBlock).
Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
}
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
// Notify the background thread that it needs to update the images
updatedusedtextures = true ;
2009-04-19 18:07:22 +00:00
}
2016-01-11 13:00:52 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = mxd . Skybox Making
2016-01-15 18:20:47 +00:00
internal void SetupSkybox ( )
2016-01-11 13:00:52 +00:00
{
// Get rid of old texture
if ( skybox ! = null ) skybox . Dispose ( ) ; skybox = null ;
// Determine which texture name to use
string skytex = string . Empty ;
if ( ! string . IsNullOrEmpty ( mapinfo . Sky1 ) )
{
skytex = mapinfo . Sky1 ;
}
// Use vanilla sky only when current map doesn't have a MAPINFO entry
else if ( ! mapinfo . IsDefined )
{
if ( General . Map . Config . DefaultSkyTextures . ContainsKey ( General . Map . Options . CurrentName ) )
skytex = General . Map . Config . DefaultSkyTextures [ General . Map . Options . CurrentName ] ;
else
skytex = General . GetByIndex ( General . Map . Config . DefaultSkyTextures , 0 ) . Value ;
}
// Create sky texture
if ( ! string . IsNullOrEmpty ( skytex ) )
{
if ( skyboxes . ContainsKey ( skytex ) )
{
// Create cubemap texture
skybox = ( skyboxes [ skytex ] . Textures . Count = = 6 ? MakeSkyBox6 ( skyboxes [ skytex ] ) : MakeSkyBox3 ( skyboxes [ skytex ] ) ) ;
}
else
{
// Create classic texture
2016-03-04 08:10:56 +00:00
Vector2D scale ;
2016-03-08 23:31:32 +00:00
Bitmap sky1 = GetTextureBitmap ( skytex , out scale ) ;
if ( sky1 ! = null )
2016-01-11 13:00:52 +00:00
{
2016-03-08 23:31:32 +00:00
// Double skies?
if ( mapinfo . DoubleSky )
{
Bitmap sky2 = GetTextureBitmap ( mapinfo . Sky2 ) ;
if ( sky2 ! = null )
{
// Resize if needed
if ( sky2 . Width ! = sky1 . Width | | sky2 . Height ! = sky1 . Height )
ResizeImage ( sky2 , sky1 . Width , sky1 . Height ) ;
// Combine both textures. Sky2 is below Sky1
using ( Graphics g = Graphics . FromImage ( sky2 ) )
g . DrawImageUnscaled ( sky1 , 0 , 0 ) ;
// Use the composite one
sky1 = sky2 ;
}
}
skybox = MakeClassicSkyBox ( sky1 , scale ) ;
2016-01-11 13:00:52 +00:00
}
}
}
// Sky texture will be missing in ZDoom. Use internal texture
if ( skybox = = null )
{
2016-01-15 22:19:48 +00:00
// Whine and moan
if ( string . IsNullOrEmpty ( skytex ) )
General . ErrorLogger . Add ( ErrorType . Warning , "Skybox creation failed: Sky1 property is missing from the MAPINFO map definition" ) ;
else
2016-12-10 21:33:59 +00:00
General . ErrorLogger . Add ( ErrorType . Warning , "Skybox creation failed: unable to load texture \"" + skytex + "\"" ) ;
2016-01-15 22:19:48 +00:00
// Use the built-in texture
2019-08-08 01:19:11 +00:00
ImageData tex = LoadInternalTexture ( "MissingSky3D.png" ) ;
tex . CreateTexture ( ) ;
Bitmap bmp = tex . GetBitmap ( ) ;
Bitmap sky ;
lock ( bmp )
{
sky = new Bitmap ( bmp ) ;
}
sky . RotateFlip ( RotateFlipType . RotateNoneFlipX ) ; // We don't want our built-in image mirrored...
skybox = MakeClassicSkyBox ( sky ) ;
tex . Dispose ( ) ;
2016-01-11 13:00:52 +00:00
}
}
2016-01-14 11:39:52 +00:00
//INFO: 1. Looks like GZDoom tries to tile a sky texture into a 1024 pixel width texture.
//INFO: 2. If sky texture width <= height, it will be tiled to fit into 512 pixel height texture vertically.
2016-03-04 08:10:56 +00:00
private static CubeTexture MakeClassicSkyBox ( Bitmap img ) { return MakeClassicSkyBox ( img , new Vector2D ( 1.0f , 1.0f ) ) ; }
private static CubeTexture MakeClassicSkyBox ( Bitmap img , Vector2D scale )
2016-01-11 13:00:52 +00:00
{
2016-01-14 11:39:52 +00:00
// Get averaged top and bottom colors from the original image
int tr = 0 , tg = 0 , tb = 0 , br = 0 , bg = 0 , bb = 0 ;
2016-03-04 08:10:56 +00:00
int defaultcolorsampleheight = ( int ) Math . Round ( 28 / scale . x ) ;
2016-01-18 11:02:03 +00:00
int colorsampleheight = Math . Max ( 1 , Math . Min ( defaultcolorsampleheight , img . Height / 2 ) ) ; // TODO: is this value calculated from the image's height?
2016-03-04 08:10:56 +00:00
int scaledwidth = ( int ) Math . Round ( img . Width * scale . x ) ;
int scaledheight = ( int ) Math . Round ( img . Height * scale . y ) ;
2016-01-18 11:02:03 +00:00
bool dogradients = colorsampleheight < img . Height / 2 ;
2016-01-14 11:39:52 +00:00
for ( int w = 0 ; w < img . Width ; w + + )
2016-01-11 13:00:52 +00:00
{
2016-01-14 11:39:52 +00:00
for ( int h = 0 ; h < colorsampleheight ; h + + )
2016-01-11 13:00:52 +00:00
{
2016-01-14 11:39:52 +00:00
Color c = img . GetPixel ( w , h ) ;
2016-01-11 13:00:52 +00:00
tr + = c . R ;
tg + = c . G ;
tb + = c . B ;
2016-01-14 11:39:52 +00:00
c = img . GetPixel ( w , img . Height - 1 - h ) ;
2016-01-11 13:00:52 +00:00
br + = c . R ;
bg + = c . G ;
bb + = c . B ;
}
}
2016-01-14 11:39:52 +00:00
int pixelscount = img . Width * colorsampleheight ;
Color topcolor = Color . FromArgb ( 255 , tr / pixelscount , tg / pixelscount , tb / pixelscount ) ;
Color bottomcolor = Color . FromArgb ( 255 , br / pixelscount , bg / pixelscount , bb / pixelscount ) ;
2016-01-11 13:00:52 +00:00
2016-03-04 08:10:56 +00:00
// Make tiling image. Take custom scale into account
int horiztiles = ( int ) Math . Ceiling ( 1024.0f / scaledwidth ) ;
int verttiles = scaledheight > 256 ? 1 : 2 ;
2016-01-11 13:00:52 +00:00
2016-03-04 08:10:56 +00:00
Bitmap skyimage = new Bitmap ( ( int ) Math . Round ( 1024 / scale . x ) , img . Height * verttiles , img . PixelFormat ) ;
2016-01-11 13:00:52 +00:00
2016-01-14 11:39:52 +00:00
// Draw original image
using ( Graphics g = Graphics . FromImage ( skyimage ) )
2016-01-11 13:00:52 +00:00
{
2016-01-14 11:39:52 +00:00
for ( int w = 0 ; w < horiztiles ; w + + )
2016-01-11 13:00:52 +00:00
{
2016-01-14 11:39:52 +00:00
for ( int h = 0 ; h < verttiles ; h + + )
{
g . DrawImage ( img , img . Width * w , img . Height * h ) ;
}
2016-01-11 13:00:52 +00:00
}
}
// Make top and bottom images
2016-03-04 08:10:56 +00:00
int capsimgsize = ( int ) Math . Round ( 16 / scale . x ) ;
2016-01-14 11:39:52 +00:00
Bitmap topimg = new Bitmap ( capsimgsize , capsimgsize ) ;
using ( Graphics g = Graphics . FromImage ( topimg ) )
2016-01-11 13:00:52 +00:00
{
using ( SolidBrush b = new SolidBrush ( topcolor ) )
2016-01-14 11:39:52 +00:00
g . FillRectangle ( b , 0 , 0 , capsimgsize , capsimgsize ) ;
2016-01-11 13:00:52 +00:00
}
2016-01-14 11:39:52 +00:00
Bitmap bottomimg = new Bitmap ( capsimgsize , capsimgsize ) ;
using ( Graphics g = Graphics . FromImage ( bottomimg ) )
2016-01-11 13:00:52 +00:00
{
using ( SolidBrush b = new SolidBrush ( bottomcolor ) )
2016-01-14 11:39:52 +00:00
g . FillRectangle ( b , 0 , 0 , capsimgsize , capsimgsize ) ;
2016-01-11 13:00:52 +00:00
}
// Apply top/bottom gradients
2016-01-18 11:02:03 +00:00
if ( dogradients )
2016-01-11 13:00:52 +00:00
{
2016-01-18 11:02:03 +00:00
using ( Graphics g = Graphics . FromImage ( skyimage ) )
2016-01-11 13:00:52 +00:00
{
2016-01-18 11:02:03 +00:00
Rectangle area = new Rectangle ( 0 , 0 , skyimage . Width , colorsampleheight ) ;
using ( LinearGradientBrush b = new LinearGradientBrush ( area , topcolor , Color . FromArgb ( 0 , topcolor ) , 90f ) )
{
g . FillRectangle ( b , area ) ;
}
2016-01-11 13:00:52 +00:00
2016-01-18 11:02:03 +00:00
area = new Rectangle ( 0 , skyimage . Height - colorsampleheight , skyimage . Width , colorsampleheight ) ;
using ( LinearGradientBrush b = new LinearGradientBrush ( area , Color . FromArgb ( 0 , bottomcolor ) , bottomcolor , 90f ) )
{
area . Y + = 1 ;
g . FillRectangle ( b , area ) ;
}
2016-01-11 13:00:52 +00:00
}
}
2016-03-04 08:10:56 +00:00
// Rendering errors occure when image size exceeds MAX_SKYTEXTURE_SIZE...
if ( skyimage . Width > MAX_SKYTEXTURE_SIZE | | skyimage . Height > MAX_SKYTEXTURE_SIZE )
{
float scaler = ( float ) MAX_SKYTEXTURE_SIZE / Math . Max ( skyimage . Width , skyimage . Height ) ;
skyimage = ResizeImage ( skyimage , ( int ) Math . Round ( skyimage . Width * scaler ) , ( int ) Math . Round ( skyimage . Height * scaler ) ) ;
}
2016-01-14 22:15:54 +00:00
// Get Device and shader...
2016-01-14 11:39:52 +00:00
World3DShader effect = General . Map . Graphics . Shaders . World3D ;
2016-01-14 22:15:54 +00:00
// Make custom rendertarget
const int cubemaptexsize = 1024 ;
2019-08-09 21:15:48 +00:00
Texture rendertarget = new Texture ( cubemaptexsize , cubemaptexsize ) ;
2016-01-14 22:15:54 +00:00
2019-08-08 01:19:11 +00:00
// Start rendering
General . Map . Graphics . StartRendering ( true , new Color4 ( ) , rendertarget , true ) ;
2016-01-14 22:15:54 +00:00
// Load the skysphere model...
2016-01-14 11:39:52 +00:00
BoundingBoxSizes bbs = new BoundingBoxSizes ( ) ;
Stream modeldata = General . ThisAssembly . GetManifestResourceStream ( "CodeImp.DoomBuilder.Resources.SkySphere.md3" ) ;
2019-08-08 01:19:11 +00:00
ModelReader . MD3LoadResult meshes = ModelReader . ReadMD3Model ( ref bbs , new Dictionary < int , string > ( ) , modeldata , 0 ) ;
2016-03-04 08:10:56 +00:00
if ( meshes . Meshes . Count ! = 3 ) throw new Exception ( "Skybox creation failed: "
+ ( string . IsNullOrEmpty ( meshes . Errors ) ? "skybox model must contain 3 surfaces" : meshes . Errors ) ) ;
2016-01-14 11:39:52 +00:00
// Make skysphere textures...
2019-08-08 01:19:11 +00:00
Texture texside = TextureFromBitmap ( skyimage ) ;
Texture textop = TextureFromBitmap ( topimg ) ;
Texture texbottom = TextureFromBitmap ( bottomimg ) ;
2016-01-14 11:39:52 +00:00
// Calculate model scaling (gl.skydone.cpp:RenderDome() in GZDoom)
float yscale ;
2016-03-04 08:10:56 +00:00
if ( scaledheight < 128 ) yscale = 128 / 230.0f ;
else if ( scaledheight < 200 ) yscale = scaledheight / 230.0f ;
else if ( scaledheight < 241 ) yscale = 1.0f + ( ( scaledheight - 200.0f ) / 200.0f ) * 1.17f ;
2016-01-14 11:39:52 +00:00
else yscale = 1.2f * 1.17f ;
2016-01-15 18:20:47 +00:00
// I guess my sky model doesn't exactly match the one GZDoom generates...
yscale * = 1.65f ;
2016-01-11 13:00:52 +00:00
// Make cubemap texture
2019-08-09 21:15:48 +00:00
CubeTexture cubemap = new CubeTexture ( cubemaptexsize ) ;
2019-08-08 01:19:11 +00:00
// Set render settings...
General . Map . Graphics . SetRenderState ( RenderState . ZEnable , false ) ;
General . Map . Graphics . SetRenderState ( RenderState . CullMode , Cull . None ) ;
General . Map . Graphics . SetSamplerState ( 0 , SamplerState . AddressU , TextureAddress . Clamp ) ;
General . Map . Graphics . SetSamplerState ( 0 , SamplerState . AddressV , TextureAddress . Clamp ) ;
2016-01-14 22:15:54 +00:00
2016-01-14 11:39:52 +00:00
// Setup matrices
Vector3 offset = new Vector3 ( 0f , 0f , - 1.8f ) ; // Sphere size is 10 mu
Matrix mworld = Matrix . Multiply ( Matrix . Identity , Matrix . Translation ( offset ) * Matrix . Scaling ( 1.0f , 1.0f , yscale ) ) ;
Matrix mprojection = Matrix . PerspectiveFovLH ( Angle2D . PIHALF , 1.0f , 0.5f , 100.0f ) ;
2016-01-11 13:00:52 +00:00
2016-01-14 11:39:52 +00:00
// Place camera at origin
effect . CameraPosition = new Vector4 ( ) ;
2016-01-11 13:00:52 +00:00
2016-01-14 22:15:54 +00:00
// Begin fullbright shaderpass
2016-01-14 11:39:52 +00:00
effect . Begin ( ) ;
2016-01-14 22:15:54 +00:00
effect . BeginPass ( 1 ) ;
2016-01-14 11:39:52 +00:00
// Render to the six faces of the cube map
for ( int i = 0 ; i < 6 ; i + + )
{
Matrix faceview = GetCubeMapViewMatrix ( ( CubeMapFace ) i ) ;
effect . WorldViewProj = mworld * faceview * mprojection ;
// Render the skysphere meshes
2016-01-14 22:15:54 +00:00
for ( int j = 0 ; j < meshes . Meshes . Count ; j + + )
2016-01-14 11:39:52 +00:00
{
// Set appropriate texture
2016-01-14 22:15:54 +00:00
switch ( meshes . Skins [ j ] )
2016-01-14 11:39:52 +00:00
{
case "top.png" : effect . Texture1 = textop ; break ;
case "bottom.png" : effect . Texture1 = texbottom ; break ;
case "side.png" : effect . Texture1 = texside ; break ;
default : throw new Exception ( "Unexpected skin!" ) ;
}
// Commit changes
effect . ApplySettings ( ) ;
// Render mesh
2016-01-14 22:15:54 +00:00
meshes . Meshes [ j ] . DrawSubset ( 0 ) ;
2016-01-14 11:39:52 +00:00
}
2019-08-08 01:19:11 +00:00
General . Map . Graphics . CopyTexture ( rendertarget , cubemap , ( CubeMapFace ) i ) ;
2016-01-14 11:39:52 +00:00
}
// End rendering
effect . EndPass ( ) ;
effect . End ( ) ;
2016-01-14 22:15:54 +00:00
General . Map . Graphics . FinishRendering ( ) ;
2016-01-14 11:39:52 +00:00
// Dispose unneeded stuff
rendertarget . Dispose ( ) ;
textop . Dispose ( ) ;
texside . Dispose ( ) ;
texbottom . Dispose ( ) ;
// Dispose skybox meshes
2016-01-14 22:15:54 +00:00
foreach ( Mesh m in meshes . Meshes ) m . Dispose ( ) ;
2016-01-11 13:00:52 +00:00
// All done...
return cubemap ;
}
// Makes CubeTexture from 6 images
private CubeTexture MakeSkyBox6 ( SkyboxInfo info )
{
// Gather images. They should be defined in this order: North, East, South, West, Top, Bottom
Bitmap [ ] sides = new Bitmap [ 6 ] ;
int targetsize = 0 ;
for ( int i = 0 ; i < info . Textures . Count ; i + + )
{
2016-01-13 09:34:32 +00:00
sides [ i ] = GetTextureBitmap ( info . Textures [ i ] ) ;
if ( sides [ i ] ! = null )
2016-01-11 13:00:52 +00:00
{
2016-01-13 09:34:32 +00:00
targetsize = Math . Max ( targetsize , Math . Max ( sides [ i ] . Width , sides [ i ] . Height ) ) ;
2016-01-11 13:00:52 +00:00
}
2016-01-13 09:34:32 +00:00
else
2016-01-11 13:00:52 +00:00
{
General . ErrorLogger . Add ( ErrorType . Error , "Unable to create \"" + info . Name + "\" skybox: unable to find \"" + info . Textures [ i ] + "\" texture" ) ;
return null ;
}
}
// All images must be square and have the same size
if ( targetsize = = 0 )
{
General . ErrorLogger . Add ( ErrorType . Error , "Unable to create \"" + info . Name + "\" skybox: invalid texture size" ) ;
return null ;
}
// Make it Po2
2016-03-04 08:10:56 +00:00
targetsize = Math . Min ( General . NextPowerOf2 ( targetsize ) , MAX_SKYTEXTURE_SIZE ) ;
2016-01-11 13:00:52 +00:00
for ( int i = 0 ; i < sides . Length ; i + + )
{
if ( sides [ i ] . Width ! = targetsize | | sides [ i ] . Height ! = targetsize )
sides [ i ] = ResizeImage ( sides [ i ] , targetsize , targetsize ) ;
}
// Return cubemap texture
return MakeSkyBox ( sides , targetsize , info . FlipTop ) ;
}
// Makes CubeTexture from 3 images
private CubeTexture MakeSkyBox3 ( SkyboxInfo info )
{
// Gather images. They should be defined in this order: Sides, Top, Bottom
Bitmap [ ] sides = new Bitmap [ 6 ] ;
int targetsize = 0 ;
// Create NWSE images from the side texture
2016-01-13 09:34:32 +00:00
Bitmap sideimg = GetTextureBitmap ( info . Textures [ 0 ] ) ;
if ( sideimg ! = null )
2016-01-11 13:00:52 +00:00
{
2016-01-13 09:34:32 +00:00
// This should be 4x1 format image. If it's not, we'll need to resize it
targetsize = Math . Max ( sideimg . Width / 4 , sideimg . Height ) ;
if ( targetsize = = 0 )
2016-01-11 13:00:52 +00:00
{
2016-01-13 09:34:32 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Unable to create \"" + info . Name + "\" skybox: invalid texture size" ) ;
return null ;
}
2016-01-11 13:00:52 +00:00
2016-01-13 09:34:32 +00:00
// Make it Po2
2016-03-04 08:10:56 +00:00
targetsize = Math . Min ( General . NextPowerOf2 ( targetsize ) , MAX_SKYTEXTURE_SIZE ) ;
2016-01-11 13:00:52 +00:00
2016-01-13 09:34:32 +00:00
// Resize if needed
if ( sideimg . Width ! = targetsize * 4 | | sideimg . Height ! = targetsize )
{
sideimg = ResizeImage ( sideimg , targetsize * 4 , targetsize ) ;
}
2016-01-11 13:00:52 +00:00
2016-01-13 09:34:32 +00:00
// Chop into tiny pieces
for ( int i = 0 ; i < 4 ; i + + )
{
// Create square image
Bitmap img = new Bitmap ( targetsize , targetsize ) ;
using ( Graphics g = Graphics . FromImage ( img ) )
2016-01-11 13:00:52 +00:00
{
2016-01-13 09:34:32 +00:00
// Copy area from the side image
g . DrawImage ( sideimg , 0 , 0 , new Rectangle ( targetsize * i , 0 , targetsize , targetsize ) , GraphicsUnit . Pixel ) ;
2016-01-11 13:00:52 +00:00
}
2016-01-13 09:34:32 +00:00
// Add to collection
sides [ i ] = img ;
2016-01-11 13:00:52 +00:00
}
}
// Sanity check...
if ( sides [ 0 ] = = null | | sides [ 1 ] = = null | | sides [ 2 ] = = null | | sides [ 3 ] = = null )
{
General . ErrorLogger . Add ( ErrorType . Error , "Unable to create \"" + info . Name + "\" skybox: unable to find \"" + info . Textures [ 0 ] + "\" texture" ) ;
return null ;
}
// Create top
2016-01-13 09:34:32 +00:00
Bitmap topimg = GetTextureBitmap ( info . Textures [ 1 ] ) ;
if ( topimg ! = null )
2016-01-11 13:00:52 +00:00
{
2016-01-13 09:34:32 +00:00
// Resize if needed
if ( topimg . Width ! = targetsize | | topimg . Height ! = targetsize )
topimg = ResizeImage ( topimg , targetsize , targetsize ) ;
2016-01-11 13:00:52 +00:00
2016-01-13 09:34:32 +00:00
// Add to collection
sides [ 4 ] = topimg ;
2016-01-11 13:00:52 +00:00
}
2016-01-13 09:34:32 +00:00
else
2016-01-11 13:00:52 +00:00
{
General . ErrorLogger . Add ( ErrorType . Error , "Unable to create \"" + info . Name + "\" skybox: unable to find \"" + info . Textures [ 1 ] + "\" texture" ) ;
return null ;
}
// Create bottom
2016-01-13 09:34:32 +00:00
Bitmap bottomimg = GetTextureBitmap ( info . Textures [ 2 ] ) ;
if ( bottomimg ! = null )
2016-01-11 13:00:52 +00:00
{
2016-01-13 09:34:32 +00:00
// Resize if needed
if ( bottomimg . Width ! = targetsize | | bottomimg . Height ! = targetsize )
bottomimg = ResizeImage ( bottomimg , targetsize , targetsize ) ;
2016-01-11 13:00:52 +00:00
2016-01-13 09:34:32 +00:00
// Add to collection
sides [ 5 ] = bottomimg ;
2016-01-11 13:00:52 +00:00
}
2016-01-13 09:34:32 +00:00
else
2016-01-11 13:00:52 +00:00
{
General . ErrorLogger . Add ( ErrorType . Error , "Unable to create \"" + info . Name + "\" skybox: unable to find \"" + info . Textures [ 2 ] + "\" texture" ) ;
return null ;
}
// Return cubemap texture
return MakeSkyBox ( sides , targetsize , info . FlipTop ) ;
}
// Makes CubeTexture from 6 images.
// sides[] must contain 6 square Po2 images in this order: North, East, South, West, Top, Bottom
private static CubeTexture MakeSkyBox ( Bitmap [ ] sides , int targetsize , bool fliptop )
{
2019-08-09 21:15:48 +00:00
CubeTexture cubemap = new CubeTexture ( targetsize ) ;
2016-01-11 13:00:52 +00:00
// Draw faces
2016-12-08 13:11:11 +00:00
sides [ 3 ] . RotateFlip ( RotateFlipType . Rotate90FlipNone ) ;
2016-01-11 13:00:52 +00:00
DrawCubemapFace ( cubemap , CubeMapFace . NegativeX , sides [ 3 ] ) ; // West
DrawCubemapFace ( cubemap , CubeMapFace . NegativeY , sides [ 0 ] ) ; // North
2016-12-08 13:11:11 +00:00
sides [ 1 ] . RotateFlip ( RotateFlipType . Rotate270FlipNone ) ;
2016-01-11 13:00:52 +00:00
DrawCubemapFace ( cubemap , CubeMapFace . PositiveX , sides [ 1 ] ) ; // East
2016-12-08 13:11:11 +00:00
sides [ 2 ] . RotateFlip ( RotateFlipType . Rotate180FlipNone ) ;
2016-01-11 13:00:52 +00:00
DrawCubemapFace ( cubemap , CubeMapFace . PositiveY , sides [ 2 ] ) ; // South
2016-12-08 13:11:11 +00:00
if ( ! fliptop ) sides [ 4 ] . RotateFlip ( RotateFlipType . Rotate180FlipX ) ;
2016-01-11 13:00:52 +00:00
DrawCubemapFace ( cubemap , CubeMapFace . PositiveZ , sides [ 4 ] ) ; // Top
2016-12-08 13:11:11 +00:00
sides [ 5 ] . RotateFlip ( RotateFlipType . Rotate180FlipNone ) ;
2016-01-11 13:00:52 +00:00
DrawCubemapFace ( cubemap , CubeMapFace . NegativeZ , sides [ 5 ] ) ; // Bottom
// All done...
return cubemap ;
}
private static void DrawCubemapFace ( CubeTexture texture , CubeMapFace face , Bitmap image )
{
2019-08-08 05:10:35 +00:00
texture . SetPixels ( face , image ) ;
2016-01-11 13:00:52 +00:00
}
private static Bitmap ResizeImage ( Image image , int width , int height )
{
var destrect = new Rectangle ( 0 , 0 , width , height ) ;
var destimage = new Bitmap ( width , height ) ;
destimage . SetResolution ( image . HorizontalResolution , image . VerticalResolution ) ;
using ( var graphics = Graphics . FromImage ( destimage ) )
{
graphics . CompositingMode = CompositingMode . SourceCopy ;
graphics . CompositingQuality = CompositingQuality . HighQuality ;
graphics . InterpolationMode = InterpolationMode . HighQualityBicubic ;
graphics . SmoothingMode = SmoothingMode . HighQuality ;
graphics . PixelOffsetMode = PixelOffsetMode . HighQuality ;
using ( var wrapmode = new ImageAttributes ( ) )
{
wrapmode . SetWrapMode ( WrapMode . TileFlipXY ) ;
graphics . DrawImage ( image , destrect , 0 , 0 , image . Width , image . Height , GraphicsUnit . Pixel , wrapmode ) ;
}
}
return destimage ;
}
2016-01-14 11:39:52 +00:00
private static Matrix GetCubeMapViewMatrix ( CubeMapFace face )
{
Vector3 lookdir , updir ;
switch ( face )
{
case CubeMapFace . PositiveX :
lookdir = new Vector3 ( 1.0f , 0.0f , 0.0f ) ;
updir = new Vector3 ( 0.0f , 1.0f , 0.0f ) ;
break ;
case CubeMapFace . NegativeX :
lookdir = new Vector3 ( - 1.0f , 0.0f , 0.0f ) ;
updir = new Vector3 ( 0.0f , 1.0f , 0.0f ) ;
break ;
case CubeMapFace . PositiveY :
lookdir = new Vector3 ( 0.0f , 1.0f , 0.0f ) ;
updir = new Vector3 ( 0.0f , 0.0f , - 1.0f ) ;
break ;
case CubeMapFace . NegativeY :
lookdir = new Vector3 ( 0.0f , - 1.0f , 0.0f ) ;
updir = new Vector3 ( 0.0f , 0.0f , 1.0f ) ;
break ;
case CubeMapFace . PositiveZ :
lookdir = new Vector3 ( 0.0f , 0.0f , 1.0f ) ;
updir = new Vector3 ( 0.0f , 1.0f , 0.0f ) ;
break ;
case CubeMapFace . NegativeZ :
lookdir = new Vector3 ( 0.0f , 0.0f , - 1.0f ) ;
updir = new Vector3 ( 0.0f , 1.0f , 0.0f ) ;
break ;
default :
throw new Exception ( "Unknown CubeMapFace!" ) ;
}
Vector3 eye = new Vector3 ( ) ;
return Matrix . LookAtLH ( eye , lookdir , updir ) ;
}
2019-08-08 01:19:11 +00:00
private static Texture TextureFromBitmap ( Image image )
2016-01-14 11:39:52 +00:00
{
2019-08-09 21:15:48 +00:00
using ( var bitmap = new Bitmap ( image ) )
{
return new Texture ( bitmap ) ;
}
2016-01-14 11:39:52 +00:00
}
2009-04-19 18:07:22 +00:00
#endregion
}
}