@page "/admin/tilemaps/edit" @model TileMaps.EditModel @using DataServer.Data.Entities @{ ViewData["Title"] = Model.Sheet.Id == 0 ? "New TileMap Sheet" : $"Edit: {Model.Sheet.Name}"; var tileTypes = Enum.GetValues(); // Build image URL - handle both with and without /downloads/ path var imageUrl = Model.Sheet.CdnPath; if (!string.IsNullOrEmpty(imageUrl)) { if (!imageUrl.StartsWith("http")) { // Ensure proper CDN URL construction var baseUrl = Model.CdnBaseUrl.TrimEnd('/'); if (!baseUrl.EndsWith("/downloads")) { baseUrl += "/downloads"; } imageUrl = $"{baseUrl}/{imageUrl.TrimStart('/')}"; } } }
← Back to TileMap Sheets
@if (!string.IsNullOrEmpty(Model.Message)) {
@Model.Message
}

TileMap Sheet Settings

@Html.AntiForgeryToken()

Preview

@if (!string.IsNullOrEmpty(Model.Sheet.CdnPath)) {
@Model.Sheet.Name

Grid: @Model.Sheet.Columns × @Model.Sheet.Rows = @Model.Sheet.TotalTiles tiles

URL: @imageUrl

} else {
Select a CDN path to preview the tilemap
}
@if (Model.Sheet.Id > 0) {

Tile Definitions

Click on a tile to define its properties. Defined: @Model.TileDefinitions.Count / @Model.Sheet.TotalTiles

@if (!string.IsNullOrEmpty(Model.Sheet.CdnPath)) { @Model.Sheet.Name
@for (int row = 0; row < Model.Sheet.Rows; row++) { @for (int col = 0; col < Model.Sheet.Columns; col++) { var frameIndex = row * Model.Sheet.Columns + col; var tileDef = Model.TileDefinitions.FirstOrDefault(t => t.FrameIndex == frameIndex); var hasDefinition = tileDef != null; var tileColor = hasDefinition ? GetTileTypeColor(tileDef!.Type) : "transparent";
} }
}
Legend: Floor Wall Door Water Lava Spawn
@if (Model.TileDefinitions.Count > 0) {

Defined Tiles (@Model.TileDefinitions.Count)

@foreach (var tile in Model.TileDefinitions.Take(50)) { var col = tile.FrameIndex % Model.Sheet.Columns; var row = tile.FrameIndex / Model.Sheet.Columns; }
# Preview Name Type Tags Props Actions
@tile.FrameIndex
@(tile.Name ?? "-") @tile.Type @(tile.Tags ?? "-") @if (tile.IsWalkable) { W } @if (tile.BlocksProjectiles) { P } @if (tile.BlocksLineOfSight) { L }
@if (Model.TileDefinitions.Count > 50) {

Showing first 50 of @Model.TileDefinitions.Count tiles

}
}
} @section Scripts { } @functions { string GetTileTypeColor(TileType type) { return type switch { TileType.Floor => "rgba(34, 197, 94, 0.3)", TileType.Wall => "rgba(239, 68, 68, 0.3)", TileType.Door => "rgba(168, 85, 247, 0.3)", TileType.Water => "rgba(59, 130, 246, 0.3)", TileType.Lava => "rgba(249, 115, 22, 0.3)", TileType.Pit => "rgba(31, 41, 55, 0.5)", TileType.Stairs => "rgba(236, 72, 153, 0.3)", TileType.PlayerSpawn => "rgba(234, 179, 8, 0.4)", TileType.MobSpawn => "rgba(234, 179, 8, 0.3)", TileType.BossSpawn => "rgba(220, 38, 38, 0.4)", TileType.ChestSpawn => "rgba(251, 191, 36, 0.4)", TileType.Trigger => "rgba(139, 92, 246, 0.3)", TileType.Transition => "rgba(14, 165, 233, 0.3)", TileType.Secret => "rgba(163, 163, 163, 0.3)", TileType.Trap => "rgba(239, 68, 68, 0.4)", TileType.FloorDecor => "rgba(34, 197, 94, 0.2)", TileType.WallDecor => "rgba(239, 68, 68, 0.2)", _ => "transparent" }; } }