mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-15 15:09:29 +00:00
fd8eead241
* Ensure that location of PNG is resolved relative to the JSON file directory in TexturePacker processor * Bump version to 5.0.2 * Update tests
34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
// Copyright (c) Craftwork Games. All rights reserved.
|
|
// Licensed under the MIT license.
|
|
// See LICENSE file in the project root for full license information.
|
|
|
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
|
using MonoGame.Extended.Content.TexturePacker;
|
|
|
|
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
|
|
{
|
|
[ContentImporter(".json", DefaultProcessor = "TexturePackerProcessor", DisplayName = "TexturePacker JSON Importer - MonoGame.Extended")]
|
|
public class TexturePackerJsonImporter : ContentImporter<ContentImporterResult<TexturePackerFileContent>>
|
|
{
|
|
public override ContentImporterResult<TexturePackerFileContent> Import(string filename, ContentImporterContext context)
|
|
{
|
|
var tpFile = TexturePackerFileReader.Read(filename);
|
|
|
|
if (tpFile.Meta.Image != null)
|
|
{
|
|
context.AddDependency(tpFile.Meta.Image);
|
|
}
|
|
else if (tpFile.Meta.DataFormat == "monogame-extended")
|
|
{
|
|
// new format: textures are in the textures array
|
|
foreach (var texture in tpFile.Textures)
|
|
{
|
|
context.AddDependency(texture.FileName);
|
|
}
|
|
}
|
|
|
|
return new ContentImporterResult<TexturePackerFileContent>(filename, tpFile);
|
|
}
|
|
}
|
|
}
|