mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 20:12:23 +00:00
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System;
|
|
using System.IO;
|
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
|
using MonoGame.Extended.BitmapFonts;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace MonoGame.Extended.Content.Pipeline.BitmapFonts
|
|
{
|
|
[ContentProcessor(DisplayName = "BMFont Processor - MonoGame.Extended")]
|
|
public class BitmapFontProcessor : ContentProcessor<BitmapFontFile, BitmapFontProcessorResult>
|
|
{
|
|
public override BitmapFontProcessorResult Process(BitmapFontFile input, ContentProcessorContext context)
|
|
{
|
|
try
|
|
{
|
|
context.Logger.LogMessage("Processing BMFont");
|
|
var json = JsonConvert.SerializeObject(input);
|
|
var output = new BitmapFontProcessorResult(json);
|
|
|
|
foreach (var fontPage in input.Pages)
|
|
{
|
|
var assetName = Path.GetFileNameWithoutExtension(fontPage.File);
|
|
context.Logger.LogMessage("Expected texture asset: {0}", assetName);
|
|
output.TextureAssets.Add(assetName);
|
|
}
|
|
|
|
return output;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
context.Logger.LogMessage("Error {0}", ex);
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
} |