UltimateZoneBuilder/Source/Core/Config/ResourceTextureSet.cs
MaxED 0f7aa9f827 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

116 lines
3.4 KiB
C#

#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.Collections.Generic;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.IO;
#endregion
namespace CodeImp.DoomBuilder.Config
{
internal sealed class ResourceTextureSet : TextureSet, IFilledTextureSet
{
#region ================== Constants
#endregion
#region ================== Variables
// Matching textures and flats
private Dictionary<long, ImageData> textures;
private Dictionary<long, ImageData> flats;
private DataLocation location;
#endregion
#region ================== Properties
public ICollection<ImageData> Textures { get { return textures.Values; } }
public ICollection<ImageData> Flats { get { return flats.Values; } }
public DataLocation Location { get { return location; } }
#endregion
#region ================== Constructor / Destructor
// New texture set constructor
public ResourceTextureSet(string name, DataLocation location)
{
this.name = name;
this.location = location;
this.textures = new Dictionary<long, ImageData>();
this.flats = new Dictionary<long, ImageData>();
}
#endregion
#region ================== Methods
// Add a texture
internal void AddTexture(ImageData image)
{
//mxd. Wad duplicates are checked by WadReader
if(location.type != DataLocation.RESOURCE_WAD && textures.ContainsKey(image.LongName) && !image.HasPatchWithSameName)
General.ErrorLogger.Add(ErrorType.Warning, "Texture \"" + image.Name + "\" is double defined in resource \"" + this.Location.location + "\".");
textures[image.LongName] = image;
}
// Add a flat
internal void AddFlat(ImageData image)
{
//mxd. Wad duplicates are checked by WadReader
if(location.type != DataLocation.RESOURCE_WAD && flats.ContainsKey(image.LongName) && (!General.Map.Config.MixTexturesFlats || !image.HasPatchWithSameName))
General.ErrorLogger.Add(ErrorType.Warning, "Flat \"" + image.Name + "\" is double defined in resource \"" + this.Location.location + "\".");
flats[image.LongName] = image;
}
// Check if this set has a texture
internal bool TextureExists(ImageData image)
{
return textures.ContainsKey(image.LongName);
}
// Check if this set has a flat
internal bool FlatExists(ImageData image)
{
return flats.ContainsKey(image.LongName);
}
// Mix the textures and flats
internal void MixTexturesAndFlats()
{
// Make a copy of the flats only
Dictionary<long, ImageData> flatsonly = new Dictionary<long, ImageData>(flats);
// Add textures to flats
foreach(KeyValuePair<long, ImageData> t in textures)
{
if(!flats.ContainsKey(t.Key)) flats.Add(t.Key, t.Value);
}
// Add flats to textures
foreach(KeyValuePair<long, ImageData> f in flatsonly)
{
if(!textures.ContainsKey(f.Key)) textures.Add(f.Key, f.Value);
}
}
#endregion
}
}