98 lines
4.5 KiB
Plaintext
98 lines
4.5 KiB
Plaintext
@page "/admin/tilemaps"
|
||
@model TileMaps.IndexModel
|
||
@{
|
||
ViewData["Title"] = "TileMap Sheets";
|
||
}
|
||
|
||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4 md:mb-6">
|
||
<div>
|
||
<h1 class="text-xl md:text-2xl font-bold text-white">TileMap Sheets</h1>
|
||
<p class="text-gray-400 text-sm">Manage tilemap sprite sheets for dungeon generation</p>
|
||
</div>
|
||
<a href="/admin/tilemaps/edit" class="btn btn-primary text-sm">+ New TileMap Sheet</a>
|
||
</div>
|
||
|
||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 md:gap-4">
|
||
@foreach (var sheet in Model.Sheets)
|
||
{
|
||
var imageUrl = sheet.CdnPath;
|
||
if (!string.IsNullOrEmpty(imageUrl) && !imageUrl.StartsWith("http"))
|
||
{
|
||
var baseUrl = Model.CdnBaseUrl.TrimEnd('/');
|
||
if (!baseUrl.EndsWith("/downloads")) { baseUrl += "/downloads"; }
|
||
imageUrl = $"{baseUrl}/{imageUrl.TrimStart('/')}";
|
||
}
|
||
|
||
<div class="card p-4">
|
||
<div class="flex justify-between items-start mb-3">
|
||
<div class="min-w-0 flex-1">
|
||
<h3 class="text-base md:text-lg font-semibold text-white truncate">@sheet.Name</h3>
|
||
<p class="text-xs md:text-sm text-gray-400 truncate">@sheet.CdnPath</p>
|
||
</div>
|
||
<span class="px-2 py-0.5 text-xs rounded flex-shrink-0 ml-2 @(sheet.IsEnabled ? "bg-green-900 text-green-300" : "bg-red-900 text-red-300")">
|
||
@(sheet.IsEnabled ? "On" : "Off")
|
||
</span>
|
||
</div>
|
||
|
||
<!-- Preview -->
|
||
<div class="mb-3 bg-gray-900 rounded-lg p-2 flex justify-center h-24 md:h-32 overflow-hidden">
|
||
<img src="@imageUrl"
|
||
alt="@sheet.Name"
|
||
class="max-h-full object-contain"
|
||
style="image-rendering: pixelated;"
|
||
onerror="this.src='data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><rect fill=%22%23374151%22 width=%22100%22 height=%22100%22/><text x=%2250%22 y=%2255%22 text-anchor=%22middle%22 fill=%22%239ca3af%22 font-size=%2212%22>No Image</text></svg>';" />
|
||
</div>
|
||
|
||
<div class="grid grid-cols-2 gap-1 text-xs md:text-sm mb-3">
|
||
<div>
|
||
<span class="text-gray-500">Sheet:</span>
|
||
<span class="text-gray-300">@sheet.SheetWidth×@sheet.SheetHeight</span>
|
||
</div>
|
||
<div>
|
||
<span class="text-gray-500">Tile:</span>
|
||
<span class="text-gray-300">@sheet.TileWidth×@sheet.TileHeight</span>
|
||
</div>
|
||
<div>
|
||
<span class="text-gray-500">Grid:</span>
|
||
<span class="text-gray-300">@sheet.Columns×@sheet.Rows</span>
|
||
</div>
|
||
<div>
|
||
<span class="text-gray-500">Defined:</span>
|
||
<span class="text-gray-300">@(sheet.Tiles?.Count ?? 0)/@sheet.TotalTiles</span>
|
||
</div>
|
||
</div>
|
||
|
||
@if (!string.IsNullOrEmpty(sheet.Tags))
|
||
{
|
||
<div class="flex flex-wrap gap-1 mb-3">
|
||
@foreach (var tag in sheet.Tags.Split(',', StringSplitOptions.RemoveEmptyEntries).Take(3))
|
||
{
|
||
<span class="px-1.5 py-0.5 bg-blue-900/50 text-blue-300 text-xs rounded">@tag.Trim()</span>
|
||
}
|
||
@if (sheet.Tags.Split(',').Length > 3)
|
||
{
|
||
<span class="text-gray-500 text-xs">+@(sheet.Tags.Split(',').Length - 3)</span>
|
||
}
|
||
</div>
|
||
}
|
||
|
||
<div class="flex gap-2">
|
||
<a href="/admin/tilemaps/edit?id=@sheet.Id" class="btn btn-secondary flex-1 text-center text-sm py-1.5">Edit</a>
|
||
<form method="post" asp-page-handler="Delete" class="flex-1">
|
||
<input type="hidden" name="id" value="@sheet.Id" />
|
||
<button type="submit" class="btn bg-red-600 hover:bg-red-700 w-full text-sm py-1.5"
|
||
onclick="return confirm('Delete this tilemap sheet?')">Delete</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
}
|
||
</div>
|
||
|
||
@if (Model.Sheets.Count == 0)
|
||
{
|
||
<div class="card p-8 md:p-12 text-center">
|
||
<p class="text-gray-400 mb-4">No tilemap sheets yet.</p>
|
||
<a href="/admin/tilemaps/edit" class="btn btn-primary">Create Your First TileMap Sheet</a>
|
||
</div>
|
||
}
|