Files
systemrevivalserver/Services/Admin/Pages/DungeonBuilder/Tiles.cshtml
T
2026-01-03 15:41:01 -05:00

149 lines
6.5 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</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..." />
</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>
<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)
{
<div class="card p-4 hover:border-blue-500/50 transition-colors">
<div class="flex items-start gap-3">
<!-- Preview -->
<div class="w-16 h-16 bg-gray-900 rounded flex items-center justify-center flex-shrink-0">
@if (tile.PrimaryTileDefinition?.TileMapSheet != null)
{
var sheet = tile.PrimaryTileDefinition.TileMapSheet;
var cols = sheet.TileWidth > 0 ? sheet.SheetWidth / sheet.TileWidth : 1;
var row = tile.PrimaryTileDefinition.FrameIndex / cols;
var col = tile.PrimaryTileDefinition.FrameIndex % cols;
var bgX = -col * sheet.TileWidth;
var bgY = -row * sheet.TileHeight;
var imgUrl = Model.GetCdnUrl(sheet.CdnPath);
<div style="width: @(sheet.TileWidth)px; height: @(sheet.TileHeight)px;
background: url('@imgUrl') @(bgX)px @(bgY)px no-repeat;
background-size: @(sheet.SheetWidth)px @(sheet.SheetHeight)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>
<!-- 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>
@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"
};
}
}