mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
Removed limitation of 4 models per frame as this limitation is lifted in GZDoom
This commit is contained in:
parent
250b89dc4e
commit
122784f739
2 changed files with 40 additions and 50 deletions
|
@ -214,11 +214,20 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texture name will be empty when skin path is embedded in the model
|
// Texture name will be empty when skin path is embedded in the model
|
||||||
string skinname = (!string.IsNullOrEmpty(mds.SkinNames[fs.ModelIndex]) ? mds.SkinNames[fs.ModelIndex].ToLowerInvariant() : string.Empty);
|
string skinname = mds.SkinNames.ContainsKey(fs.ModelIndex) ? mds.SkinNames[fs.ModelIndex].ToLowerInvariant() : string.Empty;
|
||||||
|
|
||||||
md.SkinNames.Add(skinname);
|
md.SkinNames.Add(skinname);
|
||||||
md.SurfaceSkinNames.Add(mds.SurfaceSkinNames[fs.ModelIndex]);
|
|
||||||
md.ModelNames.Add(mds.ModelNames[fs.ModelIndex].ToLowerInvariant());
|
if (mds.SurfaceSkinNames.ContainsKey(fs.ModelIndex))
|
||||||
|
md.SurfaceSkinNames.Add(mds.SurfaceSkinNames[fs.ModelIndex]);
|
||||||
|
else
|
||||||
|
md.SurfaceSkinNames.Add(new Dictionary<int, string>());
|
||||||
|
|
||||||
|
if (mds.ModelNames.ContainsKey(fs.ModelIndex))
|
||||||
|
md.ModelNames.Add(mds.ModelNames[fs.ModelIndex].ToLowerInvariant());
|
||||||
|
else
|
||||||
|
md.ModelNames.Add(string.Empty);
|
||||||
|
|
||||||
md.FrameNames.Add(fs.FrameName);
|
md.FrameNames.Add(fs.FrameName);
|
||||||
md.FrameIndices.Add(fs.FrameIndex);
|
md.FrameIndices.Add(fs.FrameIndex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||||
using CodeImp.DoomBuilder.Rendering;
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
|
@ -13,12 +14,6 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
{
|
{
|
||||||
internal sealed class ModeldefStructure
|
internal sealed class ModeldefStructure
|
||||||
{
|
{
|
||||||
#region ================== Constants
|
|
||||||
|
|
||||||
private const int MAX_MODELS = 4; //maximum models per modeldef entry, zero-based
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ================== Structs
|
#region ================== Structs
|
||||||
|
|
||||||
internal struct FrameStructure
|
internal struct FrameStructure
|
||||||
|
@ -33,9 +28,9 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
|
|
||||||
#region ================== Variables
|
#region ================== Variables
|
||||||
|
|
||||||
private string[] skinnames;
|
private Dictionary<int, string> skinnames;
|
||||||
private Dictionary<int, string>[] surfaceskinenames;
|
private Dictionary<int, Dictionary<int, string>> surfaceskinenames;
|
||||||
private string[] modelnames;
|
private Dictionary<int, string> modelnames;
|
||||||
private string path;
|
private string path;
|
||||||
private Vector3f scale;
|
private Vector3f scale;
|
||||||
private Vector3f offset;
|
private Vector3f offset;
|
||||||
|
@ -52,9 +47,9 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
|
||||||
public string[] SkinNames { get { return skinnames; } }
|
public Dictionary<int, string> SkinNames { get { return skinnames; } }
|
||||||
public Dictionary<int, string>[] SurfaceSkinNames { get { return surfaceskinenames; } }
|
public Dictionary<int, Dictionary<int, string>> SurfaceSkinNames { get { return surfaceskinenames; } }
|
||||||
public string[] ModelNames { get { return modelnames; } }
|
public Dictionary<int, string> ModelNames { get { return modelnames; } }
|
||||||
public Vector3f Scale { get { return scale; } }
|
public Vector3f Scale { get { return scale; } }
|
||||||
public Vector3f Offset { get { return offset; } }
|
public Vector3f Offset { get { return offset; } }
|
||||||
public float AngleOffset { get { return angleoffset; } }
|
public float AngleOffset { get { return angleoffset; } }
|
||||||
|
@ -74,15 +69,11 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
internal ModeldefStructure()
|
internal ModeldefStructure()
|
||||||
{
|
{
|
||||||
path = string.Empty;
|
path = string.Empty;
|
||||||
skinnames = new string[MAX_MODELS];
|
skinnames = new Dictionary<int, string>();
|
||||||
modelnames = new string[MAX_MODELS];
|
modelnames = new Dictionary<int, string>();
|
||||||
frames = new Dictionary<string, HashSet<FrameStructure>>(StringComparer.OrdinalIgnoreCase);
|
frames = new Dictionary<string, HashSet<FrameStructure>>(StringComparer.OrdinalIgnoreCase);
|
||||||
scale = new Vector3f(1.0f, 1.0f, 1.0f);
|
scale = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||||
surfaceskinenames = new Dictionary<int, string>[MAX_MODELS];
|
surfaceskinenames = new Dictionary<int, Dictionary<int, string>>();
|
||||||
for(int i = 0; i < MAX_MODELS; i++)
|
|
||||||
{
|
|
||||||
surfaceskinenames[i] = new Dictionary<int, string>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -123,10 +114,10 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(index < 0 || index > MAX_MODELS - 1)
|
if(index < 0)
|
||||||
{
|
{
|
||||||
// Out of bounds
|
// Out of bounds
|
||||||
parser.ReportError("Model index must be in [0.." + (MAX_MODELS - 1) + "] range");
|
parser.ReportError("Model index must not be in negative");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,10 +165,10 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(skinindex < 0 || skinindex >= MAX_MODELS)
|
if(skinindex < 0)
|
||||||
{
|
{
|
||||||
// Out of bounds
|
// Out of bounds
|
||||||
parser.ReportError("Skin index must be in [0.." + (MAX_MODELS - 1) + "] range");
|
parser.ReportError("Skin index must not be negative");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,10 +203,10 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modelindex < 0 || modelindex >= MAX_MODELS)
|
if(modelindex < 0)
|
||||||
{
|
{
|
||||||
// Out of bounds
|
// Out of bounds
|
||||||
parser.ReportError("Model index must be in [0.." + (MAX_MODELS - 1) + "] range");
|
parser.ReportError("Model index must not be negative");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,6 +243,9 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
if(!parser.CheckInvalidPathChars(token)) return false;
|
if(!parser.CheckInvalidPathChars(token)) return false;
|
||||||
|
|
||||||
// Store
|
// Store
|
||||||
|
if (!surfaceskinenames.ContainsKey(modelindex))
|
||||||
|
surfaceskinenames[modelindex] = new Dictionary<int, string>();
|
||||||
|
|
||||||
surfaceskinenames[modelindex][surfaceindex] = Path.Combine(path, token).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
surfaceskinenames[modelindex][surfaceindex] = Path.Combine(path, token).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -420,10 +414,10 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
parser.ReportError("Expected model index, but got \"" + token + "\"");
|
parser.ReportError("Expected model index, but got \"" + token + "\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(fimodelindnex < 0 || fimodelindnex > MAX_MODELS - 1)
|
if(fimodelindnex < 0)
|
||||||
{
|
{
|
||||||
// Out of bounds
|
// Out of bounds
|
||||||
parser.ReportError("Model index must be in [0.." + (MAX_MODELS - 1) + "] range");
|
parser.ReportError("Model index must not be negative");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,10 +493,10 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
parser.ReportError("Expected model index, but got \"" + token + "\"");
|
parser.ReportError("Expected model index, but got \"" + token + "\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(modelindnex < 0 || modelindnex > MAX_MODELS - 1)
|
if(modelindnex < 0)
|
||||||
{
|
{
|
||||||
// Out of bounds
|
// Out of bounds
|
||||||
parser.ReportError("Model index must be in [0.." + (MAX_MODELS - 1) + "] range");
|
parser.ReportError("Model index must not be negative");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,37 +545,24 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any models defined?
|
// Any models defined?
|
||||||
bool valid = false;
|
if(modelnames.Count == 0)
|
||||||
for(int i = 0; i < modelnames.Length; i++)
|
|
||||||
{
|
|
||||||
if(!string.IsNullOrEmpty(modelnames[i]))
|
|
||||||
{
|
|
||||||
//INFO: skin may be defined in the model itself, so we don't check it here
|
|
||||||
valid = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!valid)
|
|
||||||
{
|
{
|
||||||
parser.ReportError("Structure doesn't define any models");
|
parser.ReportError("Structure doesn't define any models");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check skin-model associations
|
foreach(int i in skinnames.Keys.OrderBy(k => k))
|
||||||
for(int i = 0; i < skinnames.Length; i++)
|
|
||||||
{
|
{
|
||||||
if(!string.IsNullOrEmpty(skinnames[i]) && string.IsNullOrEmpty(modelnames[i]))
|
if (!string.IsNullOrEmpty(skinnames[i]) && !modelnames.ContainsKey(i))
|
||||||
{
|
{
|
||||||
parser.ReportError("No model is defined for skin " + i + ":\"" + skinnames[i] + "\"");
|
parser.ReportError("No model is defined for skin " + i + ":\"" + skinnames[i] + "\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check surfaceskin-model associations
|
foreach(int i in surfaceskinenames.Keys.OrderBy(k => k))
|
||||||
for(int i = 0; i < surfaceskinenames.Length; i++)
|
|
||||||
{
|
{
|
||||||
if(surfaceskinenames[i].Count > 0 && string.IsNullOrEmpty(modelnames[i]))
|
if (surfaceskinenames[i].Count > 0 && !modelnames.ContainsKey(i))
|
||||||
{
|
{
|
||||||
parser.ReportError("No model is defined for surface skin " + i);
|
parser.ReportError("No model is defined for surface skin " + i);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue