mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 03:56:31 +00:00
e962cec448
* mostly restored the tiled importer unit tests * code cleanup * code cleanup * almost got tiled maps serialization independent of the content pipeline * refactored the tiled map content importer so that tiled maps can be loaded at runtime * code cleanup * removed nuspec files * experimenting with an XML based GUI markup parser * a few more markup parser features * finally got a working open file dialog * experimenting with markup bindings * attached properties * working on the gui stuff again * working on a better textbox * multiline textboxing * new text box is really coming along * removed the content explorer experiment * restored the old gui demo back to the way it was before (for now)
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using Microsoft.Xna.Framework.Content.Pipeline;
|
|
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
|
|
using System;
|
|
|
|
namespace MonoGame.Extended.Content.Pipeline.Tiled
|
|
{
|
|
[ContentProcessor(DisplayName = "Tiled Map Tileset Processor - MonoGame.Extended")]
|
|
public class TiledMapTilesetProcessor : ContentProcessor<TiledMapTilesetContentItem, TiledMapTilesetContentItem>
|
|
{
|
|
public override TiledMapTilesetContentItem Process(TiledMapTilesetContentItem contentItem, ContentProcessorContext context)
|
|
{
|
|
try
|
|
{
|
|
var tileset = contentItem.Data;
|
|
|
|
ContentLogger.Logger = context.Logger;
|
|
ContentLogger.Log($"Processing tileset '{tileset.Name}'");
|
|
|
|
// Build the Texture2D asset and load it as it will be saved as part of this tileset file.
|
|
//var externalReference = new ExternalReference<Texture2DContent>(tileset.Image.Source);
|
|
var parameters = new OpaqueDataDictionary
|
|
{
|
|
{ "ColorKeyColor", tileset.Image.TransparentColor },
|
|
{ "ColorKeyEnabled", true }
|
|
};
|
|
//tileset.Image.ContentRef = context.BuildAsset<Texture2DContent, Texture2DContent>(externalReference, "", parameters, "", "");
|
|
contentItem.BuildExternalReference<Texture2DContent>(context, tileset.Image.Source, parameters);
|
|
|
|
foreach (var tile in tileset.Tiles)
|
|
{
|
|
foreach (var obj in tile.Objects)
|
|
{
|
|
TiledMapContentHelper.Process(obj, context);
|
|
}
|
|
}
|
|
|
|
ContentLogger.Log($"Processed tileset '{tileset.Name}'");
|
|
|
|
return contentItem;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
context.Logger.LogImportantMessage(ex.Message);
|
|
throw ex;
|
|
}
|
|
}
|
|
}
|
|
}
|