2014-12-03 23:15:26 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
2016-04-06 11:44:38 +00:00
|
|
|
|
using System.Collections.Generic;
|
2012-06-01 10:17:47 +00:00
|
|
|
|
using System.IO;
|
2021-03-11 20:06:34 +00:00
|
|
|
|
using System.Linq;
|
2012-05-21 23:51:32 +00:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
2019-08-08 16:24:33 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2012-05-21 23:51:32 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2016-04-27 09:13:07 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.ZDoom
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-04-06 11:44:38 +00:00
|
|
|
|
internal sealed class ModeldefStructure
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-04-06 11:44:38 +00:00
|
|
|
|
#region ================== Structs
|
2015-12-17 10:07:28 +00:00
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
internal struct FrameStructure
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-04-06 11:44:38 +00:00
|
|
|
|
public string SpriteName; // Stays here for HashSet duplicate checks
|
|
|
|
|
public int ModelIndex;
|
|
|
|
|
public int FrameIndex;
|
|
|
|
|
public string FrameName;
|
|
|
|
|
}
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
#endregion
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
#region ================== Variables
|
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
|
|
|
|
|
2021-03-11 20:06:34 +00:00
|
|
|
|
private Dictionary<int, string> skinnames;
|
|
|
|
|
private Dictionary<int, Dictionary<int, string>> surfaceskinenames;
|
|
|
|
|
private Dictionary<int, string> modelnames;
|
2016-04-06 11:44:38 +00:00
|
|
|
|
private string path;
|
2020-01-03 01:22:33 +00:00
|
|
|
|
private Vector3f scale;
|
|
|
|
|
private Vector3f offset;
|
2016-04-06 11:44:38 +00:00
|
|
|
|
private float angleoffset;
|
|
|
|
|
private float pitchoffset;
|
|
|
|
|
private float rolloffset;
|
|
|
|
|
private bool inheritactorpitch;
|
2016-07-17 00:00:29 +00:00
|
|
|
|
private bool useactorpitch;
|
|
|
|
|
private bool useactorroll;
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
private Dictionary<string, HashSet<FrameStructure>> frames;
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
#endregion
|
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
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
#region ================== Properties
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2021-03-11 20:06:34 +00:00
|
|
|
|
public Dictionary<int, string> SkinNames { get { return skinnames; } }
|
|
|
|
|
public Dictionary<int, Dictionary<int, string>> SurfaceSkinNames { get { return surfaceskinenames; } }
|
|
|
|
|
public Dictionary<int, string> ModelNames { get { return modelnames; } }
|
2020-01-03 01:22:33 +00:00
|
|
|
|
public Vector3f Scale { get { return scale; } }
|
|
|
|
|
public Vector3f Offset { get { return offset; } }
|
2016-04-06 11:44:38 +00:00
|
|
|
|
public float AngleOffset { get { return angleoffset; } }
|
|
|
|
|
public float PitchOffset { get { return pitchoffset; } }
|
|
|
|
|
public float RollOffset { get { return rolloffset; } }
|
|
|
|
|
public bool InheritActorPitch { get { return inheritactorpitch; } }
|
2016-07-17 00:00:29 +00:00
|
|
|
|
public bool UseActorPitch { get { return useactorpitch; } }
|
|
|
|
|
public bool UseActorRoll { get { return useactorroll; } }
|
2019-06-16 16:40:10 +00:00
|
|
|
|
public string DataPath { get { return path; } } // biwa
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
public Dictionary<string, HashSet<FrameStructure>> Frames { get { return frames; } }
|
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
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
#endregion
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
#region ================== Constructor
|
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
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
internal ModeldefStructure()
|
|
|
|
|
{
|
2016-07-20 21:04:52 +00:00
|
|
|
|
path = string.Empty;
|
2021-03-11 20:06:34 +00:00
|
|
|
|
skinnames = new Dictionary<int, string>();
|
|
|
|
|
modelnames = new Dictionary<int, string>();
|
2016-04-06 11:44:38 +00:00
|
|
|
|
frames = new Dictionary<string, HashSet<FrameStructure>>(StringComparer.OrdinalIgnoreCase);
|
2020-01-03 01:22:33 +00:00
|
|
|
|
scale = new Vector3f(1.0f, 1.0f, 1.0f);
|
2021-03-11 20:06:34 +00:00
|
|
|
|
surfaceskinenames = new Dictionary<int, Dictionary<int, string>>();
|
2016-04-06 11:44:38 +00:00
|
|
|
|
}
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
#endregion
|
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
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
#region ================== Parsing
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
internal bool Parse(ModeldefParser parser)
|
|
|
|
|
{
|
|
|
|
|
// Read modeldef structure contents
|
|
|
|
|
bool parsingfinished = false;
|
|
|
|
|
while(!parsingfinished && parser.SkipWhitespace(true))
|
|
|
|
|
{
|
2016-04-06 22:54:04 +00:00
|
|
|
|
string token = parser.ReadToken().ToLowerInvariant();
|
2016-04-06 11:44:38 +00:00
|
|
|
|
if(string.IsNullOrEmpty(token)) continue;
|
2015-11-17 12:22:49 +00:00
|
|
|
|
|
2016-04-06 22:54:04 +00:00
|
|
|
|
switch(token)
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
|
|
|
|
case "path":
|
|
|
|
|
parser.SkipWhitespace(true);
|
2020-07-29 07:57:42 +00:00
|
|
|
|
path = parser.StripTokenQuotes(parser.ReadToken(false)).Replace("\\", "/"); // Don't skip newline
|
2016-04-06 11:44:38 +00:00
|
|
|
|
if(string.IsNullOrEmpty(path))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Expected model path");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "model":
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
|
|
|
|
|
// Model index
|
2016-05-04 11:16:17 +00:00
|
|
|
|
int index = 0;
|
2016-04-06 11:44:38 +00:00
|
|
|
|
token = parser.ReadToken();
|
2016-05-04 11:16:17 +00:00
|
|
|
|
if(!parser.ReadSignedInt(token, ref index))
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected model index, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-11 20:06:34 +00:00
|
|
|
|
if(index < 0)
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
2016-05-04 11:16:17 +00:00
|
|
|
|
// Out of bounds
|
2021-03-11 20:06:34 +00:00
|
|
|
|
parser.ReportError("Model index must not be in negative");
|
2016-04-06 11:44:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
|
|
|
|
|
// Model path
|
|
|
|
|
token = parser.StripTokenQuotes(parser.ReadToken(false)).ToLowerInvariant(); // Don't skip newline
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Expected model name");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check invalid path chars
|
|
|
|
|
if(!parser.CheckInvalidPathChars(token)) return false;
|
|
|
|
|
|
|
|
|
|
// Check extension
|
|
|
|
|
string modelext = Path.GetExtension(token);
|
|
|
|
|
if(string.IsNullOrEmpty(modelext))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Model \"" + token + "\" won't be loaded. Models without extension are not supported by GZDoom");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-15 15:44:02 +00:00
|
|
|
|
if(modelext != ".md3" && modelext != ".md2" && modelext != ".3d" && modelext != ".obj")
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
2019-06-15 15:44:02 +00:00
|
|
|
|
parser.ReportError("Model \"" + token + "\" won't be loaded. Only Unreal 3D, MD2, MD3, and OBJ models are supported");
|
2016-04-06 11:44:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GZDoom allows models with identical index, it uses the last one encountered
|
2016-07-20 21:04:52 +00:00
|
|
|
|
modelnames[index] = Path.Combine(path, token).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
2016-04-06 11:44:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "skin":
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
|
|
|
|
|
// Skin index
|
2016-05-04 11:16:17 +00:00
|
|
|
|
int skinindex = 0;
|
2016-04-06 11:44:38 +00:00
|
|
|
|
token = parser.ReadToken();
|
2016-05-04 11:16:17 +00:00
|
|
|
|
if(!parser.ReadSignedInt(token, ref skinindex))
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected skin index, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-11 20:06:34 +00:00
|
|
|
|
if(skinindex < 0)
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
2016-05-04 11:16:17 +00:00
|
|
|
|
// Out of bounds
|
2021-03-11 20:06:34 +00:00
|
|
|
|
parser.ReportError("Skin index must not be negative");
|
2016-04-06 11:44:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
|
|
|
|
|
// Skin path
|
|
|
|
|
token = parser.StripTokenQuotes(parser.ReadToken(false)).ToLowerInvariant(); // Don't skip newline
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Expected skin path");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check invalid path chars
|
|
|
|
|
if(!parser.CheckInvalidPathChars(token)) return false;
|
|
|
|
|
|
|
|
|
|
// GZDoom allows skins with identical index, it uses the last one encountered
|
2019-06-15 15:44:02 +00:00
|
|
|
|
skinnames[skinindex] = Path.Combine(path, token);
|
2016-07-18 12:05:19 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// SurfaceSkin <int modelindex> <int surfaceindex> <string skinfile>
|
|
|
|
|
case "surfaceskin":
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
|
|
|
|
|
// Model index
|
|
|
|
|
int modelindex = 0;
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedInt(token, ref modelindex))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected model index, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-11 20:06:34 +00:00
|
|
|
|
if(modelindex < 0)
|
2016-07-18 12:05:19 +00:00
|
|
|
|
{
|
|
|
|
|
// Out of bounds
|
2021-03-11 20:06:34 +00:00
|
|
|
|
parser.ReportError("Model index must not be negative");
|
2016-07-18 12:05:19 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
|
|
|
|
|
// Surfaceindex index
|
|
|
|
|
int surfaceindex = 0;
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedInt(token, ref surfaceindex))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected surface index, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(surfaceindex < 0)
|
|
|
|
|
{
|
|
|
|
|
// Out of bounds
|
|
|
|
|
parser.ReportError("Surface index must be positive integer");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
|
|
|
|
|
// Skin path
|
|
|
|
|
token = parser.StripTokenQuotes(parser.ReadToken(false)).ToLowerInvariant(); // Don't skip newline
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Expected skin path");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check invalid path chars
|
|
|
|
|
if(!parser.CheckInvalidPathChars(token)) return false;
|
|
|
|
|
|
|
|
|
|
// Store
|
2021-03-11 20:06:34 +00:00
|
|
|
|
if (!surfaceskinenames.ContainsKey(modelindex))
|
|
|
|
|
surfaceskinenames[modelindex] = new Dictionary<int, string>();
|
|
|
|
|
|
2016-07-20 21:04:52 +00:00
|
|
|
|
surfaceskinenames[modelindex][surfaceindex] = Path.Combine(path, token).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
2016-04-06 11:44:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "scale":
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref scale.Y))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected Scale X value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref scale.X))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected Scale Y value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref scale.Z))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected Scale Z value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "offset":
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref offset.X))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected Offset X value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref offset.Y))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected Offset Y value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref offset.Z))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected Offset Z value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "zoffset":
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref offset.Z))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected ZOffset value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "angleoffset":
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref angleoffset))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected AngleOffset value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "pitchoffset":
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref pitchoffset))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected PitchOffset value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "rolloffset":
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(!parser.ReadSignedFloat(token, ref rolloffset))
|
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected RollOffset value, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2016-07-17 00:00:29 +00:00
|
|
|
|
case "useactorpitch":
|
|
|
|
|
inheritactorpitch = false;
|
|
|
|
|
useactorpitch = true;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "useactorroll":
|
|
|
|
|
useactorroll = true;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "inheritactorpitch":
|
|
|
|
|
inheritactorpitch = true;
|
|
|
|
|
useactorpitch = false;
|
|
|
|
|
parser.LogWarning("INHERITACTORPITCH flag is deprecated. Consider using USEACTORPITCH flag instead");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "inheritactorroll":
|
|
|
|
|
useactorroll = true;
|
|
|
|
|
parser.LogWarning("INHERITACTORROLL flag is deprecated. Consider using USEACTORROLL flag instead");
|
|
|
|
|
break;
|
2016-04-06 11:44:38 +00:00
|
|
|
|
|
|
|
|
|
//FrameIndex <XXXX> <X> <model index> <frame number>
|
|
|
|
|
case "frameindex":
|
|
|
|
|
// Sprite name
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
string fispritename = parser.ReadToken();
|
|
|
|
|
if(string.IsNullOrEmpty(fispritename))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Expected sprite name");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(fispritename.Length != 4)
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Sprite name must be 4 characters long");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sprite frame
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Expected sprite frame");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(token.Length != 1)
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Sprite frame must be 1 character long");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make full name
|
|
|
|
|
fispritename += token;
|
|
|
|
|
|
|
|
|
|
// Model index
|
|
|
|
|
parser.SkipWhitespace(true);
|
2016-05-04 11:16:17 +00:00
|
|
|
|
int fimodelindnex = 0;
|
2016-04-06 11:44:38 +00:00
|
|
|
|
token = parser.ReadToken();
|
2016-05-04 11:16:17 +00:00
|
|
|
|
if(!parser.ReadSignedInt(token, ref fimodelindnex))
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected model index, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-03-11 20:06:34 +00:00
|
|
|
|
if(fimodelindnex < 0)
|
2016-04-21 21:00:58 +00:00
|
|
|
|
{
|
|
|
|
|
// Out of bounds
|
2021-03-11 20:06:34 +00:00
|
|
|
|
parser.ReportError("Model index must not be negative");
|
2016-04-21 21:00:58 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-04-06 11:44:38 +00:00
|
|
|
|
|
|
|
|
|
// Frame number
|
|
|
|
|
parser.SkipWhitespace(true);
|
2016-05-04 11:16:17 +00:00
|
|
|
|
int fiframeindnex = 0;
|
2016-04-06 11:44:38 +00:00
|
|
|
|
token = parser.ReadToken();
|
2016-05-04 11:16:17 +00:00
|
|
|
|
//INFO: setting frame index to a negative number disables model rendering in GZDoom
|
|
|
|
|
if(!parser.ReadSignedInt(token, ref fiframeindnex))
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected frame index, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add to collection
|
|
|
|
|
FrameStructure fifs = new FrameStructure { FrameIndex = fiframeindnex, ModelIndex = fimodelindnex, SpriteName = fispritename };
|
|
|
|
|
if(!frames.ContainsKey(fispritename))
|
|
|
|
|
{
|
|
|
|
|
frames.Add(fispritename, new HashSet<FrameStructure>());
|
|
|
|
|
frames[fispritename].Add(fifs);
|
|
|
|
|
}
|
|
|
|
|
else if(frames[fispritename].Contains(fifs))
|
|
|
|
|
{
|
|
|
|
|
parser.LogWarning("Duplicate FrameIndex definition");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
frames[fispritename].Add(fifs);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//Frame <XXXX> <X> <model index> <"frame name">
|
|
|
|
|
case "frame":
|
|
|
|
|
// Sprite name
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
string spritename = parser.ReadToken();
|
|
|
|
|
if(string.IsNullOrEmpty(spritename))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Expected sprite name");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(spritename.Length != 4)
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Sprite name must be 4 characters long");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sprite frame
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
token = parser.ReadToken();
|
|
|
|
|
if(string.IsNullOrEmpty(token))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Expected sprite frame");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(token.Length != 1)
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Sprite frame must be 1 character long");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make full name
|
|
|
|
|
spritename += token;
|
|
|
|
|
|
|
|
|
|
// Model index
|
|
|
|
|
parser.SkipWhitespace(true);
|
2016-05-04 11:16:17 +00:00
|
|
|
|
int modelindnex = 0;
|
2016-04-06 11:44:38 +00:00
|
|
|
|
token = parser.ReadToken();
|
2016-05-04 11:16:17 +00:00
|
|
|
|
if(!parser.ReadSignedInt(token, ref modelindnex))
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
|
|
|
|
// Not numeric!
|
|
|
|
|
parser.ReportError("Expected model index, but got \"" + token + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-03-11 20:06:34 +00:00
|
|
|
|
if(modelindnex < 0)
|
2016-04-21 21:00:58 +00:00
|
|
|
|
{
|
|
|
|
|
// Out of bounds
|
2021-03-11 20:06:34 +00:00
|
|
|
|
parser.ReportError("Model index must not be negative");
|
2016-04-21 21:00:58 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-04-06 11:44:38 +00:00
|
|
|
|
|
|
|
|
|
// Frame name
|
|
|
|
|
parser.SkipWhitespace(true);
|
|
|
|
|
string framename = parser.StripTokenQuotes(parser.ReadToken());
|
|
|
|
|
if(string.IsNullOrEmpty(framename))
|
|
|
|
|
{
|
|
|
|
|
parser.ReportError("Expected frame name");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add to collection
|
|
|
|
|
FrameStructure fs = new FrameStructure { FrameName = framename, ModelIndex = modelindnex, SpriteName = spritename };
|
|
|
|
|
if(!frames.ContainsKey(spritename))
|
|
|
|
|
{
|
|
|
|
|
frames.Add(spritename, new HashSet<FrameStructure>());
|
|
|
|
|
frames[spritename].Add(fs);
|
|
|
|
|
}
|
|
|
|
|
else if(frames[spritename].Contains(fs))
|
|
|
|
|
{
|
|
|
|
|
parser.LogWarning("Duplicate Frame definition");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
frames[spritename].Add(fs);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "{":
|
|
|
|
|
parser.ReportError("Unexpected scope start");
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Structure ends here
|
|
|
|
|
case "}":
|
|
|
|
|
parsingfinished = true;
|
|
|
|
|
break;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-06 11:44:38 +00:00
|
|
|
|
// Perform some integrity checks
|
|
|
|
|
if(!parsingfinished)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-04-06 11:44:38 +00:00
|
|
|
|
parser.ReportError("Unclosed structure scope");
|
2015-12-17 10:07:28 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-04-06 11:44:38 +00:00
|
|
|
|
|
|
|
|
|
// Any models defined?
|
2021-03-11 20:06:34 +00:00
|
|
|
|
if(modelnames.Count == 0)
|
2015-12-17 10:07:28 +00:00
|
|
|
|
{
|
2016-04-06 11:44:38 +00:00
|
|
|
|
parser.ReportError("Structure doesn't define any models");
|
2015-12-17 10:07:28 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-11 20:06:34 +00:00
|
|
|
|
foreach(int i in skinnames.Keys.OrderBy(k => k))
|
2016-07-18 12:05:19 +00:00
|
|
|
|
{
|
2021-03-11 20:06:34 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(skinnames[i]) && !modelnames.ContainsKey(i))
|
2016-07-18 12:05:19 +00:00
|
|
|
|
{
|
|
|
|
|
parser.ReportError("No model is defined for skin " + i + ":\"" + skinnames[i] + "\"");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-11 20:06:34 +00:00
|
|
|
|
foreach(int i in surfaceskinenames.Keys.OrderBy(k => k))
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
2021-03-11 20:06:34 +00:00
|
|
|
|
if (surfaceskinenames[i].Count > 0 && !modelnames.ContainsKey(i))
|
2016-04-06 11:44:38 +00:00
|
|
|
|
{
|
2016-07-18 12:05:19 +00:00
|
|
|
|
parser.ReportError("No model is defined for surface skin " + i);
|
2016-04-06 11:44:38 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-17 10:07:28 +00:00
|
|
|
|
return true;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2016-04-06 11:44:38 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2012-05-21 23:51:32 +00:00
|
|
|
|
}
|