Rewrite sequence linting / missing file handling.
- Distinguish between missing sequences and missing sprites - Lint default sequences as well as maps - Improved performance - Correctly handle null images
This commit is contained in:
@@ -41,7 +41,6 @@ namespace OpenRA.Graphics
|
||||
|
||||
public interface ISpriteSequenceLoader
|
||||
{
|
||||
Action<string> OnMissingSpriteError { get; set; }
|
||||
IReadOnlyDictionary<string, ISpriteSequence> ParseSequences(ModData modData, TileSet tileSet, SpriteCache cache, MiniYamlNode node);
|
||||
}
|
||||
|
||||
@@ -79,6 +78,8 @@ namespace OpenRA.Graphics
|
||||
return seq;
|
||||
}
|
||||
|
||||
public IEnumerable<string> Images { get { return sequences.Value.Keys; } }
|
||||
|
||||
public bool HasSequence(string unitName)
|
||||
{
|
||||
return sequences.Value.ContainsKey(unitName);
|
||||
@@ -104,10 +105,11 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var nodes = MiniYaml.Load(fileSystem, modData.Manifest.Sequences, additionalSequences);
|
||||
var items = new Dictionary<string, UnitSequences>();
|
||||
foreach (var n in nodes)
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
// Work around the loop closure issue in older versions of C#
|
||||
var node = n;
|
||||
// Nodes starting with ^ are inheritable but never loaded directly
|
||||
if (node.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal))
|
||||
continue;
|
||||
|
||||
var key = node.Value.ToLines(node.Key).JoinWith("|");
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ namespace OpenRA
|
||||
throw new InvalidOperationException("Unable to find a sequence loader for type '{0}'.".F(sequenceFormat.Type));
|
||||
|
||||
SpriteSequenceLoader = (ISpriteSequenceLoader)sequenceCtor.Invoke(new[] { this });
|
||||
SpriteSequenceLoader.OnMissingSpriteError = s => Log.Write("debug", s);
|
||||
|
||||
var modelFormat = Manifest.Get<ModelSequenceFormat>();
|
||||
var modelLoader = ObjectCreator.FindType(modelFormat.Type + "Loader");
|
||||
|
||||
@@ -31,12 +31,13 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public readonly string ImageReference; // The field name in the same trait info that contains the image name.
|
||||
public readonly bool Prefix;
|
||||
public readonly bool ActorNameFallback;
|
||||
public SequenceReferenceAttribute(string imageReference = null, bool prefix = false, bool actorNameFallback = false)
|
||||
public readonly bool AllowNullImage;
|
||||
|
||||
public SequenceReferenceAttribute(string imageReference = null, bool prefix = false, bool allowNullImage = false)
|
||||
{
|
||||
ImageReference = imageReference;
|
||||
Prefix = prefix;
|
||||
ActorNameFallback = actorNameFallback;
|
||||
AllowNullImage = allowNullImage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user