Files
systemrevivalserver/Services/Admin/Pages/DungeonBuilder/Tiles.cshtml
T
2026-01-10 11:20:06 -05:00

180 lines
7.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@page "/admin/dungeonbuilder/tiles"
@model DungeonBuilder.TilesModel
@using DataServer.Data.Entities
@{
ViewData["Title"] = "Tile Templates";
var categories = Enum.GetValues<TileTemplateCategory>();
}
<div class="mb-4">
<a href="/admin/dungeonbuilder" class="text-blue-400 hover:text-blue-300 text-sm">&larr; Back to Dungeon Builder</a>
</div>
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-6">
<div>
<h1 class="text-2xl font-bold text-white">Tile Templates</h1>
<p class="text-gray-400 text-sm mt-1">Reusable floor, wall, and door patterns (@Model.TotalCount total)</p>
</div>
<a href="/admin/dungeonbuilder/tiles/edit" class="btn btn-primary">+ New Template</a>
</div>
@if (!string.IsNullOrEmpty(Model.Message))
{
<div class="mb-4 p-3 rounded @(Model.IsError ? "bg-red-900/50 text-red-300" : "bg-green-900/50 text-green-300")">
@Model.Message
</div>
}
<!-- Filters -->
<div class="card p-4 mb-4">
<form method="get" class="flex flex-wrap gap-3">
<div class="flex-1 min-w-[150px]">
<input type="text" name="search" value="@Model.Search"
class="input w-full text-sm" placeholder="Search by name or tags..." />
</div>
<select name="category" class="input text-sm">
<option value="">All Categories</option>
@foreach (var c in categories)
{
<option value="@((int)c)" selected="@(Model.CategoryFilter == (int)c)">@c</option>
}
</select>
<select name="biome" class="input text-sm">
<option value="">All Biomes</option>
@foreach (var b in Model.Biomes)
{
<option value="@b" selected="@(Model.BiomeFilter == b)">@b</option>
}
</select>
<select name="sheetId" class="input text-sm">
<option value="">All Sheets</option>
@foreach (var s in Model.TileSheets)
{
<option value="@s.Id" selected="@(Model.SheetFilter == s.Id)">@s.Name</option>
}
</select>
<button type="submit" class="btn btn-secondary text-sm">Filter</button>
<a href="/admin/dungeonbuilder/tiles" class="btn btn-ghost text-sm">Clear</a>
</form>
</div>
<!-- Templates Grid -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
@foreach (var tile in Model.Tiles)
{
var tileInfo = Model.GetTileDisplayInfo(tile);
<div class="card p-4 hover:border-blue-500/50 transition-colors">
<div class="flex items-start gap-3">
<!-- Preview - Using TilesJson data -->
<div class="w-16 h-16 bg-gray-900 rounded flex items-center justify-center flex-shrink-0" style="image-rendering: pixelated;">
@if (tileInfo != null)
{
<div style="width: @(tileInfo.TileWidth * 2)px; height: @(tileInfo.TileHeight * 2)px;
background: url('@tileInfo.ImageUrl') @(tileInfo.BgX * 2)px @(tileInfo.BgY * 2)px no-repeat;
background-size: @(tileInfo.SheetWidth * 2)px @(tileInfo.SheetHeight * 2)px;
image-rendering: pixelated;"></div>
}
else
{
<span class="text-gray-600 text-2xl">🧱</span>
}
</div>
<!-- Info -->
<div class="flex-1 min-w-0">
<h3 class="font-semibold text-white truncate">@tile.Name</h3>
<div class="text-xs text-gray-400 mt-1">
<span class="@GetCategoryColor(tile.Category)">@tile.Category</span>
@if (!string.IsNullOrEmpty(tile.Biome))
{
<span class="ml-2">@tile.Biome</span>
}
</div>
<!-- Tags -->
@if (!string.IsNullOrEmpty(tile.Tags))
{
<div class="text-xs text-gray-500 mt-1 truncate">@tile.Tags</div>
}
<!-- Size & Flags -->
<div class="flex flex-wrap gap-1 mt-2">
@if (tile.Width > 1 || tile.Height > 1)
{
<span class="px-1.5 py-0.5 bg-gray-700 text-gray-400 rounded text-xs">@tile.Width×@tile.Height</span>
}
@if (!tile.IsWalkable)
{
<span class="px-1.5 py-0.5 bg-red-500/20 text-red-400 rounded text-xs">Solid</span>
}
@if (tile.BlocksLineOfSight)
{
<span class="px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded text-xs">Blocks LoS</span>
}
</div>
</div>
</div>
<div class="flex items-center justify-between mt-3 pt-3 border-t border-gray-700">
<span class="text-xs text-gray-500">Weight: @tile.Weight</span>
<div class="flex gap-2">
<a href="/admin/dungeonbuilder/tiles/edit?id=@tile.Id" class="text-blue-400 hover:text-blue-300 text-sm">Edit</a>
<form method="post" asp-page-handler="Delete" class="inline" onsubmit="return confirm('Delete this template?');">
<input type="hidden" name="id" value="@tile.Id" />
<button type="submit" class="text-red-400 hover:text-red-300 text-sm">Delete</button>
</form>
</div>
</div>
</div>
}
@if (!Model.Tiles.Any())
{
<div class="col-span-full card p-8 text-center text-gray-500">
No tile templates found. <a href="/admin/dungeonbuilder/tiles/edit" class="text-blue-400 hover:underline">Create one</a>!
</div>
}
</div>
<!-- Pagination -->
@if (Model.TotalPages > 1)
{
<div class="flex items-center justify-center gap-2 mt-6">
@if (Model.Page > 1)
{
<a href="@Model.GetPageUrl(1)" class="btn btn-ghost text-sm">First</a>
<a href="@Model.GetPageUrl(Model.Page - 1)" class="btn btn-ghost text-sm">&larr; Prev</a>
}
@for (int i = Math.Max(1, Model.Page - 2); i <= Math.Min(Model.TotalPages, Model.Page + 2); i++)
{
<a href="@Model.GetPageUrl(i)" class="btn @(i == Model.Page ? "btn-primary" : "btn-ghost") text-sm">@i</a>
}
@if (Model.Page < Model.TotalPages)
{
<a href="@Model.GetPageUrl(Model.Page + 1)" class="btn btn-ghost text-sm">Next &rarr;</a>
<a href="@Model.GetPageUrl(Model.TotalPages)" class="btn btn-ghost text-sm">Last</a>
}
<span class="text-gray-500 text-sm ml-4">Page @Model.Page of @Model.TotalPages</span>
</div>
}
@functions {
string GetCategoryColor(TileTemplateCategory category)
{
return category switch
{
TileTemplateCategory.Floor => "text-green-400",
TileTemplateCategory.Wall => "text-red-400",
TileTemplateCategory.Door => "text-purple-400",
TileTemplateCategory.Window => "text-cyan-400",
TileTemplateCategory.Stairs => "text-yellow-400",
TileTemplateCategory.Water => "text-blue-400",
TileTemplateCategory.Lava => "text-orange-400",
_ => "text-gray-400"
};
}
}