2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
2014-11-25 11:52:01 +00:00
|
|
|
using System.IO;
|
2009-04-19 18:07:22 +00:00
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2013-03-18 13:52:27 +00:00
|
|
|
using CodeImp.DoomBuilder.ZDoom;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Data
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
public enum TexturePathRenderStyle
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2016-03-16 23:26:53 +00:00
|
|
|
COPY,
|
|
|
|
BLEND,
|
|
|
|
ADD,
|
|
|
|
SUBTRACT,
|
|
|
|
REVERSE_SUBTRACT,
|
|
|
|
MODULATE,
|
|
|
|
COPY_ALPHA,
|
|
|
|
COPY_NEW_ALPHA, //mxd
|
|
|
|
OVERLAY, //mxd
|
2013-03-18 13:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public enum TexturePathBlendStyle //mxd
|
|
|
|
{
|
2016-03-16 23:26:53 +00:00
|
|
|
NONE,
|
|
|
|
BLEND,
|
|
|
|
TINT
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
internal struct TexturePatch
|
|
|
|
{
|
2016-03-16 23:26:53 +00:00
|
|
|
public readonly string LumpName;
|
|
|
|
public readonly int X;
|
|
|
|
public readonly int Y;
|
|
|
|
public readonly bool FlipX;
|
|
|
|
public readonly bool FlipY;
|
|
|
|
public readonly bool HasLongName; //mxd
|
|
|
|
public readonly int Rotate;
|
|
|
|
public PixelColor BlendColor;
|
|
|
|
public readonly float Alpha;
|
|
|
|
public readonly TexturePathRenderStyle RenderStyle;
|
|
|
|
public readonly TexturePathBlendStyle BlendStyle; //mxd
|
|
|
|
public readonly bool Skip; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Constructor for simple patches
|
|
|
|
public TexturePatch(string lumpname, int x, int y)
|
|
|
|
{
|
|
|
|
// Initialize
|
2016-03-16 23:26:53 +00:00
|
|
|
this.LumpName = lumpname;
|
|
|
|
this.X = x;
|
|
|
|
this.Y = y;
|
|
|
|
this.FlipX = false;
|
|
|
|
this.FlipY = false;
|
|
|
|
this.Rotate = 0;
|
|
|
|
this.BlendColor = new PixelColor(0, 0, 0, 0);
|
|
|
|
this.Alpha = 1.0f;
|
|
|
|
this.RenderStyle = TexturePathRenderStyle.COPY;
|
|
|
|
this.BlendStyle = TexturePathBlendStyle.NONE;//mxd
|
|
|
|
this.HasLongName = false; //mxd
|
|
|
|
this.Skip = false; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
//mxd. Constructor for hires patches
|
2014-12-03 23:15:26 +00:00
|
|
|
public TexturePatch(PatchStructure patch)
|
|
|
|
{
|
2009-04-19 18:07:22 +00:00
|
|
|
// Initialize
|
2016-03-16 23:26:53 +00:00
|
|
|
this.LumpName = patch.Name.ToUpperInvariant();
|
|
|
|
this.X = patch.OffsetX;
|
|
|
|
this.Y = patch.OffsetY;
|
|
|
|
this.FlipX = patch.FlipX;
|
|
|
|
this.FlipY = patch.FlipY;
|
|
|
|
this.Rotate = patch.Rotation;
|
|
|
|
this.BlendColor = patch.BlendColor;
|
|
|
|
this.Alpha = patch.Alpha;
|
|
|
|
this.RenderStyle = patch.RenderStyle;
|
|
|
|
this.BlendStyle = patch.BlendStyle;
|
|
|
|
this.HasLongName = (Path.GetFileNameWithoutExtension(this.LumpName) != this.LumpName);
|
|
|
|
this.Skip = patch.Skip;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
|
|
//mxd. Check data so we don't perform unneeded operations later on
|
2016-03-16 23:26:53 +00:00
|
|
|
if(this.Alpha == 1.0f)
|
2014-11-25 11:52:01 +00:00
|
|
|
{
|
2016-03-16 23:26:53 +00:00
|
|
|
switch(this.RenderStyle)
|
2015-12-04 12:29:22 +00:00
|
|
|
{
|
2016-03-16 23:26:53 +00:00
|
|
|
case TexturePathRenderStyle.BLEND:
|
|
|
|
case TexturePathRenderStyle.COPY_ALPHA:
|
|
|
|
case TexturePathRenderStyle.COPY_NEW_ALPHA:
|
|
|
|
case TexturePathRenderStyle.OVERLAY:
|
|
|
|
this.RenderStyle = TexturePathRenderStyle.COPY;
|
2015-12-04 12:29:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-03-18 13:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. and get rid of render styles we don't support
|
2016-03-16 23:26:53 +00:00
|
|
|
if(this.RenderStyle == TexturePathRenderStyle.OVERLAY) this.RenderStyle = TexturePathRenderStyle.COPY;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|