mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
Added ANIMDEFS CAMERATEXTURE support.
Some internal changes in text parsers logic.
This commit is contained in:
parent
dbcc57b7a6
commit
b9eba267db
23 changed files with 524 additions and 155 deletions
|
@ -792,6 +792,7 @@
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Data\BitmapImage.cs" />
|
<Compile Include="Data\BitmapImage.cs" />
|
||||||
|
<Compile Include="Data\CameraTextureImage.cs" />
|
||||||
<Compile Include="Data\ColorImage.cs" />
|
<Compile Include="Data\ColorImage.cs" />
|
||||||
<Compile Include="Data\ColormapImage.cs" />
|
<Compile Include="Data\ColormapImage.cs" />
|
||||||
<Compile Include="Data\HighResImage.cs" />
|
<Compile Include="Data\HighResImage.cs" />
|
||||||
|
@ -996,6 +997,7 @@
|
||||||
<DependentUpon>VertexEditForm.cs</DependentUpon>
|
<DependentUpon>VertexEditForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ZDoom\ActorStructure.cs" />
|
<Compile Include="ZDoom\ActorStructure.cs" />
|
||||||
|
<Compile Include="ZDoom\AnimdefsParser.cs" />
|
||||||
<Compile Include="ZDoom\PatchStructure.cs" />
|
<Compile Include="ZDoom\PatchStructure.cs" />
|
||||||
<Compile Include="ZDoom\ReverbsParser.cs" />
|
<Compile Include="ZDoom\ReverbsParser.cs" />
|
||||||
<Compile Include="ZDoom\SndSeqParser.cs" />
|
<Compile Include="ZDoom\SndSeqParser.cs" />
|
||||||
|
|
|
@ -426,7 +426,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
navigator.Items.Clear();
|
navigator.Items.Clear();
|
||||||
|
|
||||||
DecorateParserSE parser = new DecorateParserSE();
|
DecorateParserSE parser = new DecorateParserSE();
|
||||||
if(parser.Parse(stream, "DECORATE"))
|
if(parser.Parse(stream, "DECORATE", false))
|
||||||
{
|
{
|
||||||
navigator.Items.AddRange(parser.Actors.ToArray());
|
navigator.Items.AddRange(parser.Actors.ToArray());
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
navigator.Items.Clear();
|
navigator.Items.Clear();
|
||||||
|
|
||||||
ModeldefParserSE parser = new ModeldefParserSE();
|
ModeldefParserSE parser = new ModeldefParserSE();
|
||||||
if(parser.Parse(stream, "MODELDEF"))
|
if(parser.Parse(stream, "MODELDEF", false))
|
||||||
{
|
{
|
||||||
navigator.Items.AddRange(parser.Models.ToArray());
|
navigator.Items.AddRange(parser.Models.ToArray());
|
||||||
}
|
}
|
||||||
|
@ -462,7 +462,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
navigator.Items.Clear();
|
navigator.Items.Clear();
|
||||||
|
|
||||||
AcsParserSE parser = new AcsParserSE { AddArgumentsToScriptNames = true, IsMapScriptsLump = this is ScriptLumpDocumentTab };
|
AcsParserSE parser = new AcsParserSE { AddArgumentsToScriptNames = true, IsMapScriptsLump = this is ScriptLumpDocumentTab };
|
||||||
if(parser.Parse(stream, "SCRIPTS"))
|
if(parser.Parse(stream, "SCRIPTS", false))
|
||||||
{
|
{
|
||||||
navigator.Items.AddRange(parser.NamedScripts.ToArray());
|
navigator.Items.AddRange(parser.NamedScripts.ToArray());
|
||||||
navigator.Items.AddRange(parser.NumberedScripts.ToArray());
|
navigator.Items.AddRange(parser.NumberedScripts.ToArray());
|
||||||
|
@ -479,7 +479,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
internal ScriptType VerifyScriptType()
|
internal ScriptType VerifyScriptType()
|
||||||
{
|
{
|
||||||
ScriptTypeParserSE parser = new ScriptTypeParserSE();
|
ScriptTypeParserSE parser = new ScriptTypeParserSE();
|
||||||
if(parser.Parse(new MemoryStream(editor.GetText()), config.Description))
|
if(parser.Parse(new MemoryStream(editor.GetText()), config.Description, false))
|
||||||
{
|
{
|
||||||
if(parser.ScriptType != ScriptType.UNKNOWN && config.ScriptType != parser.ScriptType)
|
if(parser.ScriptType != ScriptType.UNKNOWN && config.ScriptType != parser.ScriptType)
|
||||||
return parser.ScriptType;
|
return parser.ScriptType;
|
||||||
|
|
|
@ -172,10 +172,10 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preprocess the file
|
// Preprocess the file
|
||||||
AcsParserSE parser = new AcsParserSE { OnInclude = (se, path) => se.Parse(General.Map.Data.LoadFile(path), path, true, true) };
|
AcsParserSE parser = new AcsParserSE { OnInclude = (se, path) => se.Parse(General.Map.Data.LoadFile(path), path, true, true, false) };
|
||||||
using(FileStream stream = File.OpenRead(filepathname))
|
using(FileStream stream = File.OpenRead(filepathname))
|
||||||
{
|
{
|
||||||
if(!parser.Parse(stream, filepathname, scriptconfig.Compiler.Files, true, false))
|
if(!parser.Parse(stream, filepathname, scriptconfig.Compiler.Files, true, false, false))
|
||||||
{
|
{
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if(parser.HasError)
|
if(parser.HasError)
|
||||||
|
|
120
Source/Core/Data/CameraTextureImage.cs
Normal file
120
Source/Core/Data/CameraTextureImage.cs
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
#region ================== Namespaces
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using CodeImp.DoomBuilder.ZDoom;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.Data
|
||||||
|
{
|
||||||
|
public class CameraTextureImage : ImageData
|
||||||
|
{
|
||||||
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public CameraTextureImage(CameraTextureData data)
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
this.UseColorCorrection = false;
|
||||||
|
this.worldpanning = data.WorldPanning;
|
||||||
|
SetName(data.Name);
|
||||||
|
|
||||||
|
// Get width and height from image
|
||||||
|
this.width = data.Width;
|
||||||
|
this.height = data.Height;
|
||||||
|
scale.x = data.ScaleX;
|
||||||
|
scale.y = data.ScaleY;
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Methods
|
||||||
|
|
||||||
|
// This loads the image
|
||||||
|
protected override void LocalLoadImage()
|
||||||
|
{
|
||||||
|
// Leave when already loaded
|
||||||
|
if(this.IsImageLoaded) return;
|
||||||
|
|
||||||
|
lock(this)
|
||||||
|
{
|
||||||
|
bitmap = new Bitmap(width, height);
|
||||||
|
|
||||||
|
int w = Math.Max(2, Math.Min(width, height) / 24); // line width
|
||||||
|
int o = w / 2; // line center offset
|
||||||
|
int l = w * 3; // line length
|
||||||
|
name = name.ToUpperInvariant();
|
||||||
|
|
||||||
|
using(Graphics g = Graphics.FromImage(bitmap))
|
||||||
|
{
|
||||||
|
// Fill bg
|
||||||
|
g.FillRectangle(Brushes.Black, 0, 0, width, height);
|
||||||
|
|
||||||
|
// Draw corners
|
||||||
|
Color color = General.Colors.BrightColors[General.Random(0, General.Colors.BrightColors.Length - 1)].ToColor();
|
||||||
|
using(var pen = new Pen(color, w))
|
||||||
|
{
|
||||||
|
g.DrawLines(pen, new[] { new Point(l, o), new Point(o, o), new Point(o, l) }); // TL
|
||||||
|
g.DrawLines(pen, new[] { new Point(width - l, o), new Point(width - o, o), new Point(width - o, l) }); // TR
|
||||||
|
g.DrawLines(pen, new[] { new Point(l, height - o), new Point(o, height - o), new Point(o, height - l) }); // BL
|
||||||
|
g.DrawLines(pen, new[] { new Point(width - l, height - o), new Point(width - o, height - o), new Point(width - o, height - l) }); // BR
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate required font size
|
||||||
|
const string rec = "\u25CFREC";
|
||||||
|
float targetwidth = Math.Max(l * 2, 22);
|
||||||
|
SizeF fontsize = g.MeasureString(rec, General.MainWindow.Font);
|
||||||
|
float scaleratio = Math.Min(targetwidth / fontsize.Height, targetwidth / fontsize.Width);
|
||||||
|
|
||||||
|
// Draw "REC" text
|
||||||
|
using(Font font = new Font(General.MainWindow.Font.FontFamily, General.MainWindow.Font.Size * scaleratio))
|
||||||
|
{
|
||||||
|
using(var brush = new SolidBrush(Color.Red))
|
||||||
|
{
|
||||||
|
g.DrawString(rec, font, brush, new RectangleF(l / 2, l / 2 - w / 2, fontsize.Width * scaleratio, fontsize.Height * scaleratio));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate required font size
|
||||||
|
targetwidth = Math.Min(width, height);
|
||||||
|
targetwidth -= targetwidth / 6;
|
||||||
|
fontsize = g.MeasureString(name, General.MainWindow.Font);
|
||||||
|
scaleratio = Math.Min(targetwidth / fontsize.Height, targetwidth / fontsize.Width);
|
||||||
|
|
||||||
|
// Draw texture name
|
||||||
|
using(Font font = new Font(General.MainWindow.Font.FontFamily, General.MainWindow.Font.Size * scaleratio))
|
||||||
|
{
|
||||||
|
using(var brush = new SolidBrush(color))
|
||||||
|
{
|
||||||
|
StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
|
||||||
|
g.DrawString(name, font, brush, new RectangleF(0, 0, width, height), sf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass on to base
|
||||||
|
base.LocalLoadImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//mxd
|
||||||
|
protected override void SetName(string name)
|
||||||
|
{
|
||||||
|
if(!General.Map.Config.UseLongTextureNames)
|
||||||
|
{
|
||||||
|
if(name.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH) name = name.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH);
|
||||||
|
name = name.ToUpperInvariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
base.SetName(name);
|
||||||
|
this.virtualname = "[CAMERA TEXTURES]" + Path.AltDirectorySeparatorChar + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,6 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using CodeImp.DoomBuilder.Compilers;
|
|
||||||
using CodeImp.DoomBuilder.Config;
|
using CodeImp.DoomBuilder.Config;
|
||||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||||
using CodeImp.DoomBuilder.GZBuilder.GZDoom;
|
using CodeImp.DoomBuilder.GZBuilder.GZDoom;
|
||||||
|
@ -452,6 +451,9 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
//mxd. Should be done after loading textures...
|
//mxd. Should be done after loading textures...
|
||||||
LoadGldefs(actorsbyclass);
|
LoadGldefs(actorsbyclass);
|
||||||
|
|
||||||
|
//mxd. Create camera textures. Should be done after loading textures.
|
||||||
|
LoadAnimdefs();
|
||||||
|
|
||||||
// Sort names
|
// Sort names
|
||||||
texturenames.Sort();
|
texturenames.Sort();
|
||||||
flatnames.Sort();
|
flatnames.Sort();
|
||||||
|
@ -1672,7 +1674,14 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
foreach(KeyValuePair<string, Stream> group in decostreams)
|
foreach(KeyValuePair<string, Stream> group in decostreams)
|
||||||
{
|
{
|
||||||
// Parse this data
|
// Parse this data
|
||||||
parser.Parse(group.Value, Path.Combine(currentreader.Location.location, group.Key));
|
parser.Parse(group.Value, Path.Combine(currentreader.Location.location, group.Key), false);
|
||||||
|
|
||||||
|
//mxd. DECORATE lumps are interdepandable. Can't carry on...
|
||||||
|
if(parser.HasError)
|
||||||
|
{
|
||||||
|
decorate.LogError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1741,7 +1750,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
group.Value.Dispose();
|
group.Value.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bail out when not supported by currect game configuration
|
// Bail out when not supported by current game configuration
|
||||||
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
||||||
|
|
||||||
General.MainWindow.DisplayStatus(StatusType.Busy, "Reloading model definitions...");
|
General.MainWindow.DisplayStatus(StatusType.Busy, "Reloading model definitions...");
|
||||||
|
@ -1764,7 +1773,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
//mxd
|
//mxd
|
||||||
public void ReloadGldefs()
|
public void ReloadGldefs()
|
||||||
{
|
{
|
||||||
// Bail out when not supported by currect game configuration
|
// Bail out when not supported by current game configuration
|
||||||
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
||||||
|
|
||||||
General.MainWindow.DisplayStatus(StatusType.Busy, "Reloading GLDEFS...");
|
General.MainWindow.DisplayStatus(StatusType.Busy, "Reloading GLDEFS...");
|
||||||
|
@ -1806,7 +1815,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
foreach(KeyValuePair<string, Stream> group in streams)
|
foreach(KeyValuePair<string, Stream> group in streams)
|
||||||
{
|
{
|
||||||
// Parse the data
|
// Parse the data
|
||||||
if(parser.Parse(group.Value, currentreader.Location.location + "\\" + group.Key))
|
if(parser.Parse(group.Value, currentreader.Location.location + "\\" + group.Key, true))
|
||||||
{
|
{
|
||||||
foreach(KeyValuePair<string, ModelData> g in parser.Entries)
|
foreach(KeyValuePair<string, ModelData> g in parser.Entries)
|
||||||
{
|
{
|
||||||
|
@ -1823,11 +1832,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modeldefs are independable, so parsing fail in one file should not affect the others
|
// Modeldefs are independable, so parsing fail in one file should not affect the others
|
||||||
if(parser.HasError)
|
if(parser.HasError) parser.LogError();
|
||||||
{
|
|
||||||
parser.LogError();
|
|
||||||
parser.ClearError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1849,7 +1854,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
//mxd
|
//mxd
|
||||||
private void LoadVoxels()
|
private void LoadVoxels()
|
||||||
{
|
{
|
||||||
// Bail out when not supported by currect game configuration
|
// Bail out when not supported by current game configuration
|
||||||
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
||||||
|
|
||||||
//Get names of all voxel models, which can be used "as is"
|
//Get names of all voxel models, which can be used "as is"
|
||||||
|
@ -1859,7 +1864,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
{
|
{
|
||||||
currentreader = dr;
|
currentreader = dr;
|
||||||
|
|
||||||
string[] result = dr.GetVoxelNames();
|
IEnumerable<string> result = dr.GetVoxelNames();
|
||||||
if(result == null) continue;
|
if(result == null) continue;
|
||||||
|
|
||||||
foreach(string s in result)
|
foreach(string s in result)
|
||||||
|
@ -1902,7 +1907,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
KeyValuePair<string, Stream> group = dr.GetVoxeldefData();
|
KeyValuePair<string, Stream> group = dr.GetVoxeldefData();
|
||||||
if(group.Value != null)
|
if(group.Value != null)
|
||||||
{
|
{
|
||||||
if(parser.Parse(group.Value, group.Key))
|
if(parser.Parse(group.Value, group.Key, true))
|
||||||
{
|
{
|
||||||
foreach(KeyValuePair<string, ModelData> entry in parser.Entries)
|
foreach(KeyValuePair<string, ModelData> entry in parser.Entries)
|
||||||
{
|
{
|
||||||
|
@ -1918,11 +1923,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report errors?
|
// Report errors?
|
||||||
if(parser.HasError)
|
if(parser.HasError) parser.LogError();
|
||||||
{
|
|
||||||
parser.LogError();
|
|
||||||
parser.ClearError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1963,7 +1964,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
foreach(KeyValuePair<string, Stream> group in streams)
|
foreach(KeyValuePair<string, Stream> group in streams)
|
||||||
{
|
{
|
||||||
parser.Parse(group.Value, group.Key);
|
parser.Parse(group.Value, group.Key, false);
|
||||||
|
|
||||||
// Gldefs can be interdependable. Can't carry on
|
// Gldefs can be interdependable. Can't carry on
|
||||||
if(parser.HasError)
|
if(parser.HasError)
|
||||||
|
@ -2006,7 +2007,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
foreach(KeyValuePair<string, Stream> group in streams)
|
foreach(KeyValuePair<string, Stream> group in streams)
|
||||||
{
|
{
|
||||||
// Parse the data
|
// Parse the data
|
||||||
parser.Parse(group.Value, Path.Combine(currentreader.Location.location, group.Key), General.Map.Options.LevelName);
|
parser.Parse(group.Value, Path.Combine(currentreader.Location.location, group.Key), General.Map.Options.LevelName, false);
|
||||||
|
|
||||||
//MAPINFO lumps are interdependable. Can't carry on...
|
//MAPINFO lumps are interdependable. Can't carry on...
|
||||||
if(parser.HasError)
|
if(parser.HasError)
|
||||||
|
@ -2032,11 +2033,10 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
mapinfo = parser.MapInfo ?? new MapInfo();
|
mapinfo = parser.MapInfo ?? new MapInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseFromLocation(ZDTextParser parser, string location)
|
private void ParseFromLocation(ZDTextParser parser, string location, bool clearerrors)
|
||||||
{
|
{
|
||||||
if(currentreader.IsSuspended) throw new Exception("Data reader is suspended");
|
if(currentreader.IsSuspended) throw new Exception("Data reader is suspended");
|
||||||
Stream s = currentreader.LoadFile(location);
|
parser.Parse(currentreader.LoadFile(location), location, clearerrors);
|
||||||
if(s != null) parser.Parse(s, location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd. This loads REVERBS
|
//mxd. This loads REVERBS
|
||||||
|
@ -2044,7 +2044,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
{
|
{
|
||||||
reverbs.Clear();
|
reverbs.Clear();
|
||||||
|
|
||||||
// Bail out when not supported by currect game configuration
|
// Bail out when not supported by current game configuration
|
||||||
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
||||||
|
|
||||||
ReverbsParser parser = new ReverbsParser();
|
ReverbsParser parser = new ReverbsParser();
|
||||||
|
@ -2055,14 +2055,10 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
foreach(KeyValuePair<string, Stream> group in streams)
|
foreach(KeyValuePair<string, Stream> group in streams)
|
||||||
{
|
{
|
||||||
// Parse the data
|
// Parse the data
|
||||||
parser.Parse(group.Value, group.Key);
|
parser.Parse(group.Value, group.Key, true);
|
||||||
|
|
||||||
// Report errors?
|
// Report errors?
|
||||||
if(parser.HasError)
|
if(parser.HasError) parser.LogError();
|
||||||
{
|
|
||||||
parser.LogError();
|
|
||||||
parser.ClearError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2075,26 +2071,22 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
{
|
{
|
||||||
soundsequences.Clear();
|
soundsequences.Clear();
|
||||||
|
|
||||||
// Bail out when not supported by currect game configuration
|
// Bail out when not supported by current game configuration
|
||||||
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
if(string.IsNullOrEmpty(General.Map.Config.DecorateGames)) return;
|
||||||
|
|
||||||
SndSeqParser parser = new SndSeqParser();
|
SndSeqParser parser = new SndSeqParser();
|
||||||
foreach(DataReader dr in containers)
|
foreach(DataReader dr in containers)
|
||||||
{
|
{
|
||||||
currentreader = dr;
|
currentreader = dr;
|
||||||
List<Stream> streams = dr.GetSndSeqData();
|
Dictionary<string, Stream> streams = dr.GetSndSeqData();
|
||||||
|
|
||||||
// Parse the data
|
// Parse the data
|
||||||
foreach(Stream s in streams)
|
foreach(KeyValuePair<string, Stream> group in streams)
|
||||||
{
|
{
|
||||||
if(s != null) parser.Parse(s, "SNDSEQ");
|
parser.Parse(group.Value, group.Key, true);
|
||||||
|
|
||||||
// Report errors?
|
// Report errors?
|
||||||
if(parser.HasError)
|
if(parser.HasError) parser.LogError();
|
||||||
{
|
|
||||||
parser.LogError();
|
|
||||||
parser.ClearError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2102,6 +2094,73 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
soundsequences = parser.GetSoundSequences();
|
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;
|
||||||
|
Dictionary<string, Stream> streams = dr.GetAnimdefsData();
|
||||||
|
|
||||||
|
// Parse the data
|
||||||
|
foreach(KeyValuePair<string, Stream> group in streams)
|
||||||
|
{
|
||||||
|
parser.Parse(group.Value, group.Key, true);
|
||||||
|
|
||||||
|
// Report errors?
|
||||||
|
if(parser.HasError) parser.LogError();
|
||||||
|
|
||||||
|
// Create images
|
||||||
|
foreach(var g in parser.CameraTextures)
|
||||||
|
{
|
||||||
|
// Grab a local copy
|
||||||
|
CameraTextureData data = g.Value;
|
||||||
|
|
||||||
|
// Apply texture size override?
|
||||||
|
if(!data.FitTexture)
|
||||||
|
{
|
||||||
|
long longname = Lump.MakeLongName(data.Name);
|
||||||
|
|
||||||
|
if(textures.ContainsKey(longname))
|
||||||
|
{
|
||||||
|
data.ScaleX = (float)textures[longname].Width / data.Width;
|
||||||
|
data.ScaleY = (float)textures[longname].Height / data.Height;
|
||||||
|
}
|
||||||
|
else if(flats.ContainsKey(longname))
|
||||||
|
{
|
||||||
|
data.ScaleX = (float)flats[longname].Width / data.Width;
|
||||||
|
data.ScaleY = (float)flats[longname].Height / data.Height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create texture
|
||||||
|
CameraTextureImage camteximage = new CameraTextureImage(data);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentreader = null;
|
||||||
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
internal MemoryStream LoadFile(string name)
|
internal MemoryStream LoadFile(string name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,36 +152,39 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
#region ================== Decorate, Modeldef, Mapinfo, Gldefs, etc...
|
#region ================== Decorate, Modeldef, Mapinfo, Gldefs, etc...
|
||||||
|
|
||||||
// When implemented, this returns the decorate lump
|
// When implemented, this returns the DECORATE lump
|
||||||
public virtual Dictionary<string, Stream> GetDecorateData(string pname) { return new Dictionary<string, Stream>(); }
|
public abstract Dictionary<string, Stream> GetDecorateData(string pname); // { return new Dictionary<string, Stream>(); }
|
||||||
|
|
||||||
//mxd. When implemented, this returns the Modeldef lump
|
//mxd. When implemented, this returns the MODELDEF lump
|
||||||
public virtual Dictionary<string, Stream> GetModeldefData() { return new Dictionary<string, Stream>(); }
|
public abstract Dictionary<string, Stream> GetModeldefData(); // { return new Dictionary<string, Stream>(); }
|
||||||
|
|
||||||
//mxd. When implemented, this returns the Mapinfo lump
|
//mxd. When implemented, this returns the MAPINFO lump
|
||||||
public virtual Dictionary<string, Stream> GetMapinfoData() { return new Dictionary<string, Stream>(); }
|
public abstract Dictionary<string, Stream> GetMapinfoData(); // { return new Dictionary<string, Stream>(); }
|
||||||
|
|
||||||
//mxd. When implemented, this returns the Gldefs lump
|
//mxd. When implemented, this returns the GLDEFS lump
|
||||||
public virtual Dictionary<string, Stream> GetGldefsData(GameType gameType) { return new Dictionary<string, Stream>(); }
|
public abstract Dictionary<string, Stream> GetGldefsData(GameType gametype); // { return new Dictionary<string, Stream>(); }
|
||||||
|
|
||||||
//mxd. When implemented, this returns the Reverbs lump
|
//mxd. When implemented, this returns the REVERBS lump
|
||||||
public virtual Dictionary<string, Stream> GetReverbsData() { return new Dictionary<string, Stream>(); }
|
public abstract Dictionary<string, Stream> GetReverbsData(); // { return new Dictionary<string, Stream>(); }
|
||||||
|
|
||||||
|
//mxd. When implemented, this returns the VOXELDEF lump
|
||||||
|
public abstract KeyValuePair<string, Stream> GetVoxeldefData(); // { return new KeyValuePair<string, Stream>(); }
|
||||||
|
|
||||||
|
//mxd. When implemented, this returns the SNDSEQ lump
|
||||||
|
public abstract Dictionary<string, Stream> GetSndSeqData(); // { return new Dictionary<string, Stream>(); }
|
||||||
|
|
||||||
|
//mxd. When implemented, this returns the ANIMDEFS lump
|
||||||
|
public abstract Dictionary<string, Stream> GetAnimdefsData();
|
||||||
|
|
||||||
//mxd. When implemented, this returns the list of voxel model names
|
//mxd. When implemented, this returns the list of voxel model names
|
||||||
public virtual string[] GetVoxelNames() { return null; }
|
public abstract IEnumerable<string> GetVoxelNames(); // { return null; }
|
||||||
|
|
||||||
//mxd. When implemented, this returns the voxel lump
|
//mxd. When implemented, this returns the voxel lump
|
||||||
public virtual Stream GetVoxelData(string name) { return null; }
|
public abstract Stream GetVoxelData(string name); // { return null; }
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
public virtual KeyValuePair<string, Stream> GetVoxeldefData() { return new KeyValuePair<string,Stream>(); }
|
internal abstract MemoryStream LoadFile(string name);// { return null; }
|
||||||
|
internal abstract bool FileExists(string filename);// { return false; }
|
||||||
//mxd. When implemented, this returns the SndSeq lump
|
|
||||||
public virtual List<Stream> GetSndSeqData() { return new List<Stream>(); }
|
|
||||||
|
|
||||||
//mxd
|
|
||||||
internal virtual MemoryStream LoadFile(string name) { return null; }
|
|
||||||
internal virtual bool FileExists(string filename) { return false; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,7 +409,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Decorate
|
#region ================== DECORATE
|
||||||
|
|
||||||
// This finds and returns a sprite stream
|
// This finds and returns a sprite stream
|
||||||
public override Dictionary<string, Stream> GetDecorateData(string pname)
|
public override Dictionary<string, Stream> GetDecorateData(string pname)
|
||||||
|
@ -461,7 +461,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Modeldef (mxd)
|
#region ================== MODELDEF (mxd)
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
public override Dictionary<string, Stream> GetModeldefData()
|
public override Dictionary<string, Stream> GetModeldefData()
|
||||||
|
@ -484,10 +484,10 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Voxeldef (mxd)
|
#region ================== VOXELDEF (mxd)
|
||||||
|
|
||||||
//mxd. This returns the list of voxels, which can be used without VOXELDEF definition
|
//mxd. This returns the list of voxels, which can be used without VOXELDEF definition
|
||||||
public override string[] GetVoxelNames()
|
public override IEnumerable<string> GetVoxelNames()
|
||||||
{
|
{
|
||||||
// Error when suspended
|
// Error when suspended
|
||||||
if(issuspended) throw new Exception("Data reader is suspended");
|
if(issuspended) throw new Exception("Data reader is suspended");
|
||||||
|
@ -587,7 +587,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Reverbs
|
#region ================== REVERBS (mxd)
|
||||||
|
|
||||||
public override Dictionary<string, Stream> GetReverbsData()
|
public override Dictionary<string, Stream> GetReverbsData()
|
||||||
{
|
{
|
||||||
|
@ -616,27 +616,58 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== SndSeq
|
#region ================== SNDSEQ (mxd)
|
||||||
|
|
||||||
public override List<Stream> GetSndSeqData()
|
public override Dictionary<string, Stream> GetSndSeqData()
|
||||||
{
|
{
|
||||||
// Error when suspended
|
// Error when suspended
|
||||||
if(issuspended) throw new Exception("Data reader is suspended");
|
if(issuspended) throw new Exception("Data reader is suspended");
|
||||||
|
|
||||||
List<Stream> streams = new List<Stream>();
|
Dictionary<string, Stream> streams = new Dictionary<string, Stream>();
|
||||||
|
|
||||||
// Get from wads first
|
// Get from wads first
|
||||||
//TODO: is this the correct order?..
|
//TODO: is this the correct order?..
|
||||||
foreach(WADReader wr in wads)
|
foreach(WADReader wr in wads)
|
||||||
{
|
{
|
||||||
streams.AddRange(wr.GetSndSeqData());
|
Dictionary<string, Stream> wadstreams = wr.GetSndSeqData();
|
||||||
|
foreach(KeyValuePair<string, Stream> pair in wadstreams) streams.Add(pair.Key, pair.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then from our own files
|
// Then from our own files
|
||||||
string foundfile = FindFirstFile("sndseq", false);
|
string foundfile = FindFirstFile("sndseq", false);
|
||||||
if(!string.IsNullOrEmpty(foundfile) && FileExists(foundfile))
|
if(!string.IsNullOrEmpty(foundfile) && FileExists(foundfile))
|
||||||
{
|
{
|
||||||
streams.Add(LoadFile(foundfile));
|
streams.Add(foundfile, LoadFile(foundfile));
|
||||||
|
}
|
||||||
|
|
||||||
|
return streams;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== ANIMDEFS (mxd)
|
||||||
|
|
||||||
|
public override Dictionary<string, Stream> GetAnimdefsData()
|
||||||
|
{
|
||||||
|
// Error when suspended
|
||||||
|
if(issuspended) throw new Exception("Data reader is suspended");
|
||||||
|
|
||||||
|
Dictionary<string, Stream> streams = new Dictionary<string, Stream>();
|
||||||
|
|
||||||
|
// Get from wads first
|
||||||
|
//TODO: is this the correct order?..
|
||||||
|
foreach(WADReader wr in wads)
|
||||||
|
{
|
||||||
|
Dictionary<string, Stream> wadstreams = wr.GetAnimdefsData();
|
||||||
|
foreach(KeyValuePair<string, Stream> pair in wadstreams)
|
||||||
|
streams.Add(pair.Key, pair.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then from our own files
|
||||||
|
string foundfile = FindFirstFile("animdefs", false);
|
||||||
|
if(!string.IsNullOrEmpty(foundfile) && FileExists(foundfile))
|
||||||
|
{
|
||||||
|
streams.Add(foundfile, LoadFile(foundfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
return streams;
|
return streams;
|
||||||
|
|
|
@ -407,7 +407,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
{
|
{
|
||||||
// Parse the data
|
// Parse the data
|
||||||
TexturesParser parser = new TexturesParser();
|
TexturesParser parser = new TexturesParser();
|
||||||
parser.Parse(stream, filename);
|
parser.Parse(stream, filename, false);
|
||||||
if(parser.HasError) parser.LogError(); //mxd
|
if(parser.HasError) parser.LogError(); //mxd
|
||||||
|
|
||||||
// Make the textures
|
// Make the textures
|
||||||
|
@ -647,7 +647,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
{
|
{
|
||||||
// Parse the data
|
// Parse the data
|
||||||
TexturesParser parser = new TexturesParser();
|
TexturesParser parser = new TexturesParser();
|
||||||
parser.Parse(stream, filename);
|
parser.Parse(stream, filename, false);
|
||||||
if(parser.HasError) parser.LogError(); //mxd
|
if(parser.HasError) parser.LogError(); //mxd
|
||||||
|
|
||||||
// Make the textures
|
// Make the textures
|
||||||
|
@ -710,7 +710,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
{
|
{
|
||||||
// Parse the data
|
// Parse the data
|
||||||
TexturesParser parser = new TexturesParser();
|
TexturesParser parser = new TexturesParser();
|
||||||
parser.Parse(stream, filename);
|
parser.Parse(stream, filename, false);
|
||||||
if(parser.HasError) parser.LogError(); //mxd
|
if(parser.HasError) parser.LogError(); //mxd
|
||||||
|
|
||||||
// Make the textures
|
// Make the textures
|
||||||
|
@ -763,7 +763,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
#region ================== Voxels (mxd)
|
#region ================== Voxels (mxd)
|
||||||
|
|
||||||
//mxd. This returns the list of voxels, which can be used without VOXELDEF definition
|
//mxd. This returns the list of voxels, which can be used without VOXELDEF definition
|
||||||
public override string[] GetVoxelNames()
|
public override IEnumerable<string> GetVoxelNames()
|
||||||
{
|
{
|
||||||
// Error when suspended
|
// Error when suspended
|
||||||
if(issuspended) throw new Exception("Data reader is suspended");
|
if(issuspended) throw new Exception("Data reader is suspended");
|
||||||
|
@ -908,13 +908,24 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
public override List<Stream> GetSndSeqData()
|
public override Dictionary<string, Stream> GetSndSeqData()
|
||||||
{
|
{
|
||||||
if(issuspended) throw new Exception("Data reader is suspended");
|
if(issuspended) throw new Exception("Data reader is suspended");
|
||||||
|
|
||||||
List<Stream> result = new List<Stream>();
|
Dictionary<string, Stream> result = new Dictionary<string, Stream>();
|
||||||
Lump lump = file.FindLump("SNDSEQ");
|
Lump lump = file.FindLump("SNDSEQ");
|
||||||
if(lump != null) result.Add(lump.Stream);
|
if(lump != null) result.Add(Path.Combine(location.location, "SNDSEQ"), lump.Stream);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//mxd
|
||||||
|
public override Dictionary<string, Stream> GetAnimdefsData()
|
||||||
|
{
|
||||||
|
if(issuspended) throw new Exception("Data reader is suspended");
|
||||||
|
|
||||||
|
Dictionary<string, Stream> result = new Dictionary<string, Stream>();
|
||||||
|
Lump lump = file.FindLump("ANIMDEFS");
|
||||||
|
if(lump != null) result.Add(Path.Combine(location.location, "ANIMDEFS"), lump.Stream);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,18 +42,23 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
specialtokens += "(,)";
|
specialtokens += "(,)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
return Parse(stream, sourcefilename, new List<string>(), false, false);
|
return Parse(stream, sourcefilename, new List<string>(), false, false, clearerrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Parse(Stream stream, string sourcefilename, bool processincludes, bool isinclude)
|
public bool Parse(Stream stream, string sourcefilename, bool processincludes, bool isinclude, bool clearerrors)
|
||||||
{
|
{
|
||||||
return Parse(stream, sourcefilename, includestoskip, processincludes, isinclude);
|
return Parse(stream, sourcefilename, includestoskip, processincludes, isinclude, clearerrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Parse(Stream stream, string sourcefilename, List<string> configincludes, bool processincludes, bool isinclude)
|
public bool Parse(Stream stream, string sourcefilename, List<string> configincludes, bool processincludes, bool isinclude, bool clearerrors)
|
||||||
{
|
{
|
||||||
|
parsedlumps.Add(sourcefilename);
|
||||||
|
if(isinclude && !includes.Contains(sourcefilename)) includes.Add(sourcefilename);
|
||||||
|
includestoskip = configincludes;
|
||||||
|
int bracelevel = 0;
|
||||||
|
|
||||||
// Integrity check
|
// Integrity check
|
||||||
if(stream == null || stream.Length == 0)
|
if(stream == null || stream.Length == 0)
|
||||||
{
|
{
|
||||||
|
@ -61,12 +66,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Parse(stream, sourcefilename);
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
parsedlumps.Add(sourcefilename);
|
|
||||||
if(isinclude && !includes.Contains(sourcefilename)) includes.Add(sourcefilename);
|
|
||||||
includestoskip = configincludes;
|
|
||||||
int bracelevel = 0;
|
|
||||||
|
|
||||||
// Keep local data
|
// Keep local data
|
||||||
Stream localstream = datastream;
|
Stream localstream = datastream;
|
||||||
|
|
|
@ -17,9 +17,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
actors = new List<ScriptItem>();
|
actors = new List<ScriptItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
// Continue until at the end of the stream
|
// Continue until at the end of the stream
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
|
|
||||||
#region ================== Delegates
|
#region ================== Delegates
|
||||||
|
|
||||||
public delegate void IncludeDelegate(GldefsParser parser, string includefile);
|
public delegate void IncludeDelegate(GldefsParser parser, string includefile, bool clearerrors);
|
||||||
public IncludeDelegate OnInclude;
|
public IncludeDelegate OnInclude;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -79,10 +79,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
|
|
||||||
#region ================== Parsing
|
#region ================== Parsing
|
||||||
|
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
|
||||||
parsedlumps.Add(sourcefilename);
|
parsedlumps.Add(sourcefilename);
|
||||||
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
// Keep local data
|
// Keep local data
|
||||||
Stream localstream = datastream;
|
Stream localstream = datastream;
|
||||||
|
@ -652,7 +652,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback to parse this file
|
// Callback to parse this file
|
||||||
if(OnInclude != null) OnInclude(this, includelump);
|
if(OnInclude != null) OnInclude(this, includelump, clearerrors);
|
||||||
|
|
||||||
// Set our buffers back to continue parsing
|
// Set our buffers back to continue parsing
|
||||||
datastream = localstream;
|
datastream = localstream;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
{
|
{
|
||||||
#region ================== Delegates
|
#region ================== Delegates
|
||||||
|
|
||||||
public delegate void IncludeDelegate(MapinfoParser parser, string includefile);
|
public delegate void IncludeDelegate(MapinfoParser parser, string includefile, bool clearerror);
|
||||||
public IncludeDelegate OnInclude;
|
public IncludeDelegate OnInclude;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -59,17 +59,17 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
#region ================== Parsing
|
#region ================== Parsing
|
||||||
|
|
||||||
|
|
||||||
override public bool Parse(Stream stream, string sourcefilename)
|
override public bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(mapname)) throw new NotSupportedException("MapName is required!");
|
if(string.IsNullOrEmpty(mapname)) throw new NotSupportedException("MapName is required!");
|
||||||
return Parse(stream, sourcefilename, mapname);
|
return Parse(stream, sourcefilename, mapname, clearerrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Parse(Stream stream, string sourcefilename, string mapname)
|
public bool Parse(Stream stream, string sourcefilename, string mapname, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
|
||||||
this.mapname = mapname.ToLowerInvariant();
|
this.mapname = mapname.ToLowerInvariant();
|
||||||
parsedlumps.Add(sourcefilename);
|
parsedlumps.Add(sourcefilename);
|
||||||
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
if(!string.IsNullOrEmpty(token))
|
if(!string.IsNullOrEmpty(token))
|
||||||
{
|
{
|
||||||
token = token.ToLowerInvariant();
|
token = token.ToLowerInvariant();
|
||||||
if(ParseBlock(token)) break;
|
if(ParseBlock(token, clearerrors)) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns true if parsing is finished
|
//returns true if parsing is finished
|
||||||
private bool ParseBlock(string token)
|
private bool ParseBlock(string token, bool clearerrors)
|
||||||
{
|
{
|
||||||
// Keep local data
|
// Keep local data
|
||||||
Stream localstream = datastream;
|
Stream localstream = datastream;
|
||||||
|
@ -333,7 +333,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
//block end
|
//block end
|
||||||
else if(token == "}")
|
else if(token == "}")
|
||||||
{
|
{
|
||||||
return ParseBlock(token);
|
return ParseBlock(token, clearerrors);
|
||||||
}
|
}
|
||||||
//child block
|
//child block
|
||||||
else if(token == "{")
|
else if(token == "{")
|
||||||
|
@ -362,7 +362,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
{
|
{
|
||||||
// Callback to parse this file
|
// Callback to parse this file
|
||||||
if(OnInclude != null)
|
if(OnInclude != null)
|
||||||
OnInclude(this, includelump.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar));
|
OnInclude(this, includelump.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar), clearerrors);
|
||||||
|
|
||||||
// Set our buffers back to continue parsing
|
// Set our buffers back to continue parsing
|
||||||
datastream = localstream;
|
datastream = localstream;
|
||||||
|
|
|
@ -17,10 +17,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
}
|
}
|
||||||
|
|
||||||
//should be called after all decorate actors are parsed
|
//should be called after all decorate actors are parsed
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
|
||||||
entries = new Dictionary<string, ModelData>(StringComparer.Ordinal);
|
entries = new Dictionary<string, ModelData>(StringComparer.Ordinal);
|
||||||
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
// Continue until at the end of the stream
|
// Continue until at the end of the stream
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
|
|
|
@ -21,9 +21,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
models = new List<ScriptItem>();
|
models = new List<ScriptItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
// Continue until at the end of the stream
|
// Continue until at the end of the stream
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
|
|
|
@ -19,9 +19,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
||||||
scriptType = ScriptType.UNKNOWN;
|
scriptType = ScriptType.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
// Continue until at the end of the stream
|
// Continue until at the end of the stream
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
|
|
|
@ -1928,10 +1928,10 @@ namespace CodeImp.DoomBuilder
|
||||||
if(stream != null && stream.Length > 0 && scriptconfig != null && scriptconfig.Compiler != null)
|
if(stream != null && stream.Length > 0 && scriptconfig != null && scriptconfig.Compiler != null)
|
||||||
{
|
{
|
||||||
// Get script names
|
// Get script names
|
||||||
AcsParserSE parser = new AcsParserSE { OnInclude = (se, path) => se.Parse(General.Map.Data.LoadFile(path), path, true, true) };
|
AcsParserSE parser = new AcsParserSE { OnInclude = (se, path) => se.Parse(General.Map.Data.LoadFile(path), path, true, true, false) };
|
||||||
|
|
||||||
//INFO: CompileLump() prepends lumpname with "?" to distinguish between temporary files and files compiled in place
|
//INFO: CompileLump() prepends lumpname with "?" to distinguish between temporary files and files compiled in place
|
||||||
if(parser.Parse(stream, "?SCRIPTS", scriptconfig.Compiler.Files, true, false))
|
if(parser.Parse(stream, "?SCRIPTS", scriptconfig.Compiler.Files, true, false, false))
|
||||||
{
|
{
|
||||||
// Add them to arrays
|
// Add them to arrays
|
||||||
namedscriptslist.AddRange(parser.NamedScripts);
|
namedscriptslist.AddRange(parser.NamedScripts);
|
||||||
|
|
147
Source/Core/ZDoom/AnimdefsParser.cs
Normal file
147
Source/Core/ZDoom/AnimdefsParser.cs
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
#region ================== Namespaces
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.ZDoom
|
||||||
|
{
|
||||||
|
public struct CameraTextureData
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public int Width;
|
||||||
|
public int Height;
|
||||||
|
public float ScaleX;
|
||||||
|
public float ScaleY;
|
||||||
|
public bool WorldPanning;
|
||||||
|
public bool FitTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
//mxd. Currently this only parses cameratextures
|
||||||
|
internal sealed class AnimdefsParser : ZDTextParser
|
||||||
|
{
|
||||||
|
#region ================== Variables
|
||||||
|
|
||||||
|
private readonly Dictionary<string, CameraTextureData> cameratextures;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Properties
|
||||||
|
|
||||||
|
public Dictionary<string, CameraTextureData> CameraTextures { get { return cameratextures; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Constructor
|
||||||
|
|
||||||
|
internal AnimdefsParser()
|
||||||
|
{
|
||||||
|
cameratextures = new Dictionary<string, CameraTextureData>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Parsing
|
||||||
|
|
||||||
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
|
{
|
||||||
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
|
// Continue until at the end of the stream
|
||||||
|
while(SkipWhitespace(true))
|
||||||
|
{
|
||||||
|
string token = ReadToken();
|
||||||
|
if(string.IsNullOrEmpty(token) || string.Compare(token, "CAMERATEXTURE", true) != 0) continue;
|
||||||
|
|
||||||
|
// Texture name
|
||||||
|
string texturename = StripTokenQuotes(ReadToken(false));
|
||||||
|
if(string.IsNullOrEmpty(texturename))
|
||||||
|
{
|
||||||
|
ReportError("Expected camera texture name");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Width
|
||||||
|
int width = -1;
|
||||||
|
SkipWhitespace(true);
|
||||||
|
if(!ReadSignedInt(ref width) || width < 1)
|
||||||
|
{
|
||||||
|
ReportError("Expected camera texture width");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Height
|
||||||
|
int height = -1;
|
||||||
|
SkipWhitespace(true);
|
||||||
|
if(!ReadSignedInt(ref height) || height < 1)
|
||||||
|
{
|
||||||
|
ReportError("Expected camera texture height");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// "Fit" keyword?
|
||||||
|
bool worldpanning = false;
|
||||||
|
bool fit = false;
|
||||||
|
float scalex = 1.0f;
|
||||||
|
float scaley = 1.0f;
|
||||||
|
|
||||||
|
if(NextTokenIs("fit", false))
|
||||||
|
{
|
||||||
|
fit = true;
|
||||||
|
int fitwidth = width;
|
||||||
|
int fitheight = height;
|
||||||
|
|
||||||
|
// Fit width
|
||||||
|
SkipWhitespace(true);
|
||||||
|
if(!ReadSignedInt(ref fitwidth) || fitwidth < 1)
|
||||||
|
{
|
||||||
|
ReportError("Expected camera texture fit width");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fit height
|
||||||
|
SkipWhitespace(true);
|
||||||
|
if(!ReadSignedInt(ref fitheight) || fitheight < 1)
|
||||||
|
{
|
||||||
|
ReportError("Expected camera texture fit height");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update scale
|
||||||
|
scalex = (float)fitwidth / width;
|
||||||
|
scaley = (float)fitheight / height;
|
||||||
|
|
||||||
|
// WorldPanning
|
||||||
|
worldpanning = NextTokenIs("worldpanning", false);
|
||||||
|
}
|
||||||
|
else if(NextTokenIs("worldpanning", false))
|
||||||
|
{
|
||||||
|
worldpanning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check results
|
||||||
|
if(cameratextures.ContainsKey(texturename.ToUpperInvariant()))
|
||||||
|
{
|
||||||
|
ReportError("Camera texture '" + texturename + "' is defined more than once");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store results
|
||||||
|
texturename = texturename.ToUpperInvariant();
|
||||||
|
cameratextures[texturename] = new CameraTextureData { Name = texturename, Width = width, Height = height,
|
||||||
|
ScaleX = scalex, ScaleY = scaley,
|
||||||
|
WorldPanning = worldpanning, FitTexture = fit };
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string GetLanguageType()
|
||||||
|
{
|
||||||
|
return "ANIMDEFS";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -104,7 +104,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
// Returns false on errors
|
// Returns false on errors
|
||||||
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename, clearerrors);
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
// Keep local data
|
// Keep local data
|
||||||
Stream localstream = datastream;
|
Stream localstream = datastream;
|
||||||
|
|
|
@ -20,9 +20,9 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
combinedargs = new List<int>();
|
combinedargs = new List<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
// Continue until at the end of the stream
|
// Continue until at the end of the stream
|
||||||
while(SkipWhitespace(true))
|
while(SkipWhitespace(true))
|
||||||
|
|
|
@ -31,9 +31,9 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
|
|
||||||
#region ================== Parsing
|
#region ================== Parsing
|
||||||
|
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
char[] dots = new[] { ':' };
|
char[] dots = new[] { ':' };
|
||||||
char[] brace = new[] { '[' };
|
char[] brace = new[] { '[' };
|
||||||
|
|
|
@ -73,9 +73,9 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
|
|
||||||
// This parses the given stream
|
// This parses the given stream
|
||||||
// Returns false on errors
|
// Returns false on errors
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
|
|
||||||
//mxd. Make vitrual path from filename
|
//mxd. Make vitrual path from filename
|
||||||
string virtualpath = sourcefilename.Substring(8).TrimStart(pathtrimchars);
|
string virtualpath = sourcefilename.Substring(8).TrimStart(pathtrimchars);
|
||||||
|
|
|
@ -16,10 +16,10 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
private Dictionary<string, ModelData> entries; //sprite name, entry
|
private Dictionary<string, ModelData> entries; //sprite name, entry
|
||||||
internal Dictionary<string, ModelData> Entries { get { return entries; } }
|
internal Dictionary<string, ModelData> Entries { get { return entries; } }
|
||||||
|
|
||||||
public override bool Parse(Stream stream, string sourcefilename)
|
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
base.Parse(stream, sourcefilename);
|
|
||||||
entries = new Dictionary<string, ModelData>(StringComparer.Ordinal);
|
entries = new Dictionary<string, ModelData>(StringComparer.Ordinal);
|
||||||
|
if(!base.Parse(stream, sourcefilename, clearerrors)) return false;
|
||||||
string prevToken = string.Empty;
|
string prevToken = string.Empty;
|
||||||
|
|
||||||
List<string> spriteNames = new List<string>();
|
List<string> spriteNames = new List<string>();
|
||||||
|
|
|
@ -75,23 +75,17 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
|
|
||||||
#region ================== Parsing
|
#region ================== Parsing
|
||||||
|
|
||||||
// This parses the given decorate stream
|
//mxd. This parses the given decorate stream. Returns false on errors
|
||||||
// Returns false on errors
|
|
||||||
public virtual bool Parse(Stream stream, string sourcefilename)
|
|
||||||
{
|
|
||||||
return Parse(stream, sourcefilename, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This parses the given decorate stream (mxd)
|
|
||||||
// Returns false on errors
|
|
||||||
public virtual bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
public virtual bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||||
{
|
{
|
||||||
// Clear error status (mxd)
|
//mxd. Clear error status?
|
||||||
if(clearerrors)
|
if(clearerrors) ClearError();
|
||||||
|
|
||||||
|
//mxd. Integrity check
|
||||||
|
if(stream == null || stream.Length == 0)
|
||||||
{
|
{
|
||||||
errordesc = null;
|
ReportError("Unable to load '" + sourcefilename + "'!");
|
||||||
errorsource = null;
|
return false;
|
||||||
errorline = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
datastream = stream;
|
datastream = stream;
|
||||||
|
@ -425,7 +419,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
if(!SkipWhitespace(true)) return false;
|
if(!SkipWhitespace(true)) return false;
|
||||||
string token = ReadToken();
|
string token = ReadToken();
|
||||||
|
|
||||||
if(token != expectedtoken)
|
if(string.Compare(token, expectedtoken, true) != 0)
|
||||||
{
|
{
|
||||||
if(reporterror) ReportError("expected '" + expectedtoken + "', but got '" + token + "'");
|
if(reporterror) ReportError("expected '" + expectedtoken + "', but got '" + token + "'");
|
||||||
|
|
||||||
|
@ -438,13 +432,14 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
|
protected internal bool ReadSignedFloat(ref float value) { return ReadSignedFloat(StripTokenQuotes(ReadToken(false)), ref value); }
|
||||||
protected internal bool ReadSignedFloat(string token, ref float value)
|
protected internal bool ReadSignedFloat(string token, ref float value)
|
||||||
{
|
{
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
if(token == "-")
|
if(token == "-")
|
||||||
{
|
{
|
||||||
sign = -1;
|
sign = -1;
|
||||||
token = StripTokenQuotes(ReadToken());
|
token = StripTokenQuotes(ReadToken(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
float val;
|
float val;
|
||||||
|
@ -454,13 +449,14 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
|
protected internal bool ReadSignedInt(ref int value) { return ReadSignedInt(StripTokenQuotes(ReadToken(false)), ref value); }
|
||||||
protected internal bool ReadSignedInt(string token, ref int value)
|
protected internal bool ReadSignedInt(string token, ref int value)
|
||||||
{
|
{
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
if(token == "-")
|
if(token == "-")
|
||||||
{
|
{
|
||||||
sign = -1;
|
sign = -1;
|
||||||
token = StripTokenQuotes(ReadToken());
|
token = StripTokenQuotes(ReadToken(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
int val;
|
int val;
|
||||||
|
@ -497,11 +493,11 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
internal void ClearError()
|
protected void ClearError()
|
||||||
{
|
{
|
||||||
errorline = 0;
|
|
||||||
errordesc = null;
|
errordesc = null;
|
||||||
errorsource = null;
|
errorsource = null;
|
||||||
|
errorline = CompilerError.NO_LINE_NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
|
|
Loading…
Reference in a new issue