TEXTURES parser: "optional" texture definition keyword was not supported.

TEXTURES parser: part of a TEXTURES filename is now used as a path in Image Browser. For example, textures from "textures.stuff" will be located in "[TEXTURES]/stuff" in the Image Browser.
TEXTURES parser: added "//$GZDB_SKIP" special comment. Parsing of the file is stopped after this comment is encountered.
Updated documentation.
This commit is contained in:
MaxED 2015-03-04 09:37:30 +00:00
parent 8357a96ac8
commit 518d3db5ae
5 changed files with 44 additions and 26 deletions

View file

@ -18,7 +18,7 @@
<body>
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="keyword" value="Template">
<param name="keyword" value="faq">
</object>
<div id="gz_title"><h1>Frequently asked questions</h1></div>

View file

@ -6,24 +6,23 @@
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="../../../default.css" media="screen" title="Default" />
<style type="text/css">
<!--
.style1 {color: #990000}
-->
</style>
</head>
<body>
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="keyword" value="Template">
<param name="keyword" value="textures">
</object>
<div id="gz_title"><h1>TEXTURES support</h1></div>
<div id="contents">
<p>GZDoom Builder adds support for the following TEXTURES parameters:</p>
<p><strong>GZDoom Builder adds support for the following TEXTURES parameters:</strong></p>
<ul><li>FlipX, FlipY, Rotate and Blend (both styles) patch parameters.</li>
<li>&quot;Add&quot;, &quot;Modulate&quot;, &quot;Subtract&quot;, &quot;ReverseSubtract&quot; and &quot;Translucent&quot; patch Translucency Styles.</li>
</ul>
<p><strong>GZDoom Builder supports the following special comments:</strong></p>
<ul>
<li><strong>//$GZDB_SKIP</strong> - skip the rest of the current file. Useful if you don't want textures from certain files or parts of files to show up in the <a href="w_imagesbrowser.html">Image Browser</a> or want to increase resource loading speed.</li>
</ul>
</div>
</body>

View file

@ -40,7 +40,7 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Constructor / Disposer
// Constructor
public HighResImage(string name, int width, int height, float scalex, float scaley, bool worldpanning, bool isflat)
public HighResImage(string name, string virtualpath, int width, int height, float scalex, float scaley, bool worldpanning, bool isflat)
{
// Initialize
this.width = width;
@ -52,6 +52,7 @@ namespace CodeImp.DoomBuilder.Data
//mxd
SetName(name);
this.virtualname = "[TEXTURES]/" + (!string.IsNullOrEmpty(virtualpath) ? virtualpath + "/" : "") + this.name;
this.isFlat = isflat;
// We have no destructor
@ -74,7 +75,6 @@ namespace CodeImp.DoomBuilder.Data
base.SetName(name);
this.virtualname = "[TEXTURES]/" + this.name;
if(General.Settings.CapitalizeTextureNames && !string.IsNullOrEmpty(this.displayname))
{
this.displayname = this.displayname.ToUpperInvariant();

View file

@ -36,20 +36,21 @@ namespace CodeImp.DoomBuilder.ZDoom
#region ================== Variables
// Declaration
private string typename;
private string name;
private int width;
private int height;
private readonly string typename;
private readonly string name;
private readonly string virtualpath; //mxd
private readonly int width;
private readonly int height;
// Properties
private float xscale;
private float yscale;
private int xoffset;
private int yoffset;
private bool worldpanning;
private readonly float xscale;
private readonly float yscale;
private readonly int xoffset;
private readonly int yoffset;
private readonly bool worldpanning;
// Patches
private List<PatchStructure> patches;
private readonly List<PatchStructure> patches;
#endregion
@ -71,10 +72,11 @@ namespace CodeImp.DoomBuilder.ZDoom
#region ================== Constructor / Disposer
// Constructor
internal TextureStructure(TexturesParser parser, string typename)
internal TextureStructure(TexturesParser parser, string typename, string virtualpath)
{
// Initialize
this.typename = typename;
this.virtualpath = virtualpath;
patches = new List<PatchStructure>(4);
xscale = 0.0f;
yscale = 0.0f;
@ -85,6 +87,14 @@ namespace CodeImp.DoomBuilder.ZDoom
// First token is the class name
parser.SkipWhitespace(true);
name = parser.StripTokenQuotes(parser.ReadToken());
//mxd. It can also be "optional" keyword.
if(name.ToLowerInvariant() == "optional")
{
parser.SkipWhitespace(true);
name = parser.StripTokenQuotes(parser.ReadToken());
}
if(string.IsNullOrEmpty(name))
{
parser.ReportError("Expected texture or sprite name");
@ -270,7 +280,7 @@ namespace CodeImp.DoomBuilder.ZDoom
if(yscale == 0.0f) scaley = defaultscale; else scaley = 1f / yscale;
// Make texture
HighResImage tex = new HighResImage(name, width, height, scalex, scaley, worldpanning, typename == "flat");
HighResImage tex = new HighResImage(name, virtualpath, width, height, scalex, scaley, worldpanning, typename == "flat");
// Add patches
foreach(PatchStructure p in patches)

View file

@ -40,6 +40,7 @@ namespace CodeImp.DoomBuilder.ZDoom
private readonly Dictionary<string, TextureStructure> textures;
private readonly Dictionary<string, TextureStructure> flats;
private readonly Dictionary<string, TextureStructure> sprites;
private readonly char[] pathtrimchars = new[] {'_', '.', ' ', '-'}; //mxd
#endregion
@ -75,6 +76,10 @@ namespace CodeImp.DoomBuilder.ZDoom
public override bool Parse(Stream stream, string sourcefilename)
{
base.Parse(stream, sourcefilename);
//mxd. Make vitrual path from filename
string virtualpath = sourcefilename.Substring(8).TrimStart(pathtrimchars);
if(virtualpath.ToLowerInvariant() == "txt") virtualpath = string.Empty;
// Continue until at the end of the stream
while(SkipWhitespace(true))
@ -87,7 +92,7 @@ namespace CodeImp.DoomBuilder.ZDoom
if(objdeclaration == "texture")
{
// Read texture structure
TextureStructure tx = new TextureStructure(this, "texture");
TextureStructure tx = new TextureStructure(this, "texture", virtualpath);
if(this.HasError) break;
// if a limit for the texture name length is set make sure that it's not exceeded
@ -105,7 +110,7 @@ namespace CodeImp.DoomBuilder.ZDoom
else if(objdeclaration == "sprite")
{
// Read sprite structure
TextureStructure tx = new TextureStructure(this, "sprite");
TextureStructure tx = new TextureStructure(this, "sprite", virtualpath);
if(this.HasError) break;
// if a limit for the sprite name length is set make sure that it's not exceeded
@ -122,7 +127,7 @@ namespace CodeImp.DoomBuilder.ZDoom
else if(objdeclaration == "walltexture")
{
// Read walltexture structure
TextureStructure tx = new TextureStructure(this, "walltexture");
TextureStructure tx = new TextureStructure(this, "walltexture", virtualpath);
if(this.HasError) break;
// if a limit for the walltexture name length is set make sure that it's not exceeded
@ -140,7 +145,7 @@ namespace CodeImp.DoomBuilder.ZDoom
else if(objdeclaration == "flat")
{
// Read flat structure
TextureStructure tx = new TextureStructure(this, "flat");
TextureStructure tx = new TextureStructure(this, "flat", virtualpath);
if(this.HasError) break;
// if a limit for the flat name length is set make sure that it's not exceeded
@ -155,6 +160,10 @@ namespace CodeImp.DoomBuilder.ZDoom
flats[tx.Name] = tx;
}
}
else if(objdeclaration == "$gzdb_skip") //mxd
{
break;
}
else
{
// Unknown structure!