Editor helper defining TileBrushEditorTemplate and a static lookup of templates for different BrushType values. It stores UI metadata like title, description, texture path, grid layout, slot count and labels for manual, 2x2 edge and 3x3 complex brush templates.
using Saandy.Tilemapper;
using System;
namespace Saandy.Editor.Tilemapper;
public sealed class TileBrushEditorTemplate
{
public BrushType BrushType { get; init; }
public string Title { get; init; }
public string Description { get; init; }
public string TemplateTexturePath { get; init; }
public int SlotCount { get; init; }
public int Columns { get; init; } = 4;
public int Rows { get; init; } = 4;
// How the template texture should be sliced into placeholder images.
// This can differ from Columns/Rows if your visual reference image is laid out differently from the editor grid.
public int TemplateSourceColumns { get; init; } = 4;
public int TemplateSourceRows { get; init; } = 4;
public string[] Labels { get; init; } = Array.Empty<string>();
public bool HasTemplate => SlotCount > 0;
public string GetLabel( int index )
{
if ( index >= 0 && Labels != null && index < Labels.Length && !string.IsNullOrWhiteSpace( Labels[index] ) )
return Labels[index];
return $"Slot {index}";
}
}
public static class TileBrushEditorTemplates
{
public static TileBrushEditorTemplate Get( BrushType brushType )
{
return brushType switch
{
BrushType.Manual => Manual,
BrushType.Edge2x2 => Edge2x2,
BrushType.Complex3x3 => Complex3x3,
_ => null
};
}
private static readonly TileBrushEditorTemplate Manual = new()
{
BrushType = BrushType.Manual,
Title = "Manual Rects",
Description = "Manual brush does not use an autotile order template. You can still define source rects here.",
SlotCount = 0,
Columns = 1,
Rows = 1,
TemplateSourceColumns = 1,
TemplateSourceRows = 1,
Labels = Array.Empty<string>()
};
private static readonly TileBrushEditorTemplate Edge2x2 = new()
{
BrushType = BrushType.Edge2x2,
Title = "2x2 Edge Order Template",
Description = "2x2 Edge order: 16 compact edge/blob sprites. This is the old 3x3 simple brush renamed.",
TemplateTexturePath = "textures/guides/2x2edge_template.png",
SlotCount = 16,
Columns = 4,
Rows = 4,
TemplateSourceColumns = 8,
TemplateSourceRows = 2,
Labels = new[]
{
"Full",
"Edge Left",
"Edge Up",
"Edge Right",
"Edge Down",
"Horizontal",
"Vertical",
"Outer Top-Right",
"Outer Top-Left",
"Outer Bottom-Left",
"Outer Bottom-Right",
"Inner Top-Left",
"Inner Top-Right",
"Inner Bottom-Right",
"Inner Bottom-Left",
"Isolated"
}
};
private static readonly TileBrushEditorTemplate Complex3x3 = new()
{
BrushType = BrushType.Complex3x3,
Title = "3x3 Complex Order Template",
Description = "3x3 Complex order: 47 blob sprites. Tile 0 is fully surrounded. Tile 46 is isolated / 1x1 island.",
TemplateTexturePath = "textures/guides/3x3complex_template.png",
SlotCount = 47,
Columns = 7,
Rows = 7,
TemplateSourceColumns = 7,
TemplateSourceRows = 7,
Labels = new[]
{
"Full",
"Complex 01", "Complex 02", "Complex 03", "Complex 04", "Complex 05", "Complex 06", "Complex 07",
"Complex 08", "Complex 09", "Complex 10", "Complex 11", "Complex 12", "Complex 13", "Complex 14", "Complex 15",
"Complex 16", "Complex 17", "Complex 18", "Complex 19", "Complex 20", "Complex 21", "Complex 22", "Complex 23",
"Complex 24", "Complex 25", "Complex 26", "Complex 27", "Complex 28", "Complex 29", "Complex 30", "Complex 31",
"Complex 32", "Complex 33", "Complex 34", "Complex 35", "Complex 36", "Complex 37", "Complex 38", "Complex 39",
"Complex 40", "Complex 41", "Complex 42", "Complex 43", "Complex 44", "Complex 45",
"Isolated"
}
};
}