175 lines
7.8 KiB
Plaintext
175 lines
7.8 KiB
Plaintext
@page "/admin/tilemaps/tiles/edit"
|
|
@model TileMaps.TileEditModel
|
|
@using DataServer.Data.Entities
|
|
@{
|
|
ViewData["Title"] = Model.Tile.Id == 0 ? "New Tile Definition" : $"Edit Tile Definition: {Model.Tile.Name ?? $"Frame {Model.Tile.FrameIndex}"}";
|
|
|
|
var sheet = Model.Sheet;
|
|
var frameIndex = Model.Tile.FrameIndex;
|
|
var cols = sheet.Columns;
|
|
var col = cols > 0 ? frameIndex % cols : 0;
|
|
var row = cols > 0 ? frameIndex / cols : 0;
|
|
|
|
var imageUrl = sheet.CdnPath;
|
|
if (!string.IsNullOrEmpty(imageUrl))
|
|
{
|
|
if (!imageUrl.StartsWith("http"))
|
|
{
|
|
var baseUrl = Model.CdnBaseUrl.TrimEnd('/');
|
|
if (!baseUrl.EndsWith("/downloads"))
|
|
{
|
|
baseUrl += "/downloads";
|
|
}
|
|
imageUrl = $"{baseUrl}/{imageUrl.TrimStart('/')}";
|
|
}
|
|
}
|
|
}
|
|
|
|
<div class="mb-4">
|
|
<a href="/admin/tilemaps/edit?id=@sheet.Id" class="text-blue-400 hover:text-blue-300 text-sm">← Back to TileMap Sheet</a>
|
|
</div>
|
|
|
|
<h1 class="text-2xl font-bold text-white mb-6">@ViewData["Title"]</h1>
|
|
|
|
@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>
|
|
}
|
|
|
|
<form method="post">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" asp-for="Tile.Id" />
|
|
<input type="hidden" asp-for="Tile.TileMapSheetId" />
|
|
<input type="hidden" asp-for="Tile.FrameIndex" />
|
|
|
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
<div class="card p-4 space-y-3">
|
|
<h3 class="font-semibold text-white">Tile Preview</h3>
|
|
<div class="bg-gray-900 rounded p-4 flex items-center justify-center">
|
|
<div style="width:@(sheet.TileWidth)px;height:@(sheet.TileHeight)px;background:url('@imageUrl') @(-col * sheet.TileWidth)px @(-row * sheet.TileHeight)px no-repeat;background-size:@(sheet.SheetWidth)px @(sheet.SheetHeight)px;image-rendering:pixelated;"></div>
|
|
</div>
|
|
<div class="text-xs text-gray-500">
|
|
Sheet: <span class="text-gray-300">@sheet.Name</span><br />
|
|
Frame: <span class="text-gray-300">@frameIndex</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4 space-y-3">
|
|
<h3 class="font-semibold text-white">Tile Properties</h3>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Name</label>
|
|
<input type="text" asp-for="Tile.Name" class="input w-full text-sm" placeholder="Stone Floor Clean" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Type</label>
|
|
<select asp-for="Tile.Type" class="input w-full text-sm">
|
|
@foreach (var t in Enum.GetValues<TileType>())
|
|
{
|
|
<option value="@t">@t</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Tags</label>
|
|
<input type="text" asp-for="Tile.Tags" class="input w-full text-sm" placeholder="stone,clean" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Biome</label>
|
|
<input type="text" asp-for="Tile.Biome" class="input w-full text-sm" placeholder="dungeon" />
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div class="flex items-center gap-2">
|
|
<input type="checkbox" asp-for="Tile.IsWalkable" class="rounded" />
|
|
<label class="text-sm text-gray-300">Walkable</label>
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<input type="checkbox" asp-for="Tile.BlocksProjectiles" class="rounded" />
|
|
<label class="text-sm text-gray-300">Blocks Projectiles</label>
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<input type="checkbox" asp-for="Tile.BlocksLineOfSight" class="rounded" />
|
|
<label class="text-sm text-gray-300">Blocks LOS</label>
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<input type="checkbox" asp-for="Tile.IsInteractable" class="rounded" />
|
|
<label class="text-sm text-gray-300">Interactable</label>
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div>
|
|
<label class="text-xs text-gray-400">Render Layer</label>
|
|
<input type="number" asp-for="Tile.RenderLayer" class="input w-full text-sm" min="0" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Z Index</label>
|
|
<input type="number" asp-for="Tile.ZIndex" class="input w-full text-sm" min="0" />
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div class="flex items-center gap-2">
|
|
<input type="checkbox" asp-for="Tile.IsAnimated" class="rounded" />
|
|
<label class="text-sm text-gray-300">Animated</label>
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<input type="checkbox" asp-for="Tile.IsEnabled" class="rounded" />
|
|
<label class="text-sm text-gray-300">Enabled</label>
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div>
|
|
<label class="text-xs text-gray-400">Anim Frames</label>
|
|
<input type="number" asp-for="Tile.AnimationFrameCount" class="input w-full text-sm" min="1" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Anim FPS</label>
|
|
<input type="number" asp-for="Tile.AnimationFps" class="input w-full text-sm" min="1" step="0.5" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4 space-y-3">
|
|
<h3 class="font-semibold text-white">Buckets</h3>
|
|
<p class="text-xs text-gray-500">Assign this tile to one or more buckets.</p>
|
|
<input type="text" id="bucketFilter" class="input w-full text-sm" placeholder="Type to filter buckets..." oninput="filterBuckets()" />
|
|
<div id="bucketList" class="max-h-80 overflow-auto border border-gray-700 rounded p-2 space-y-1">
|
|
@foreach (var b in Model.AllBuckets)
|
|
{
|
|
<label class="flex items-center gap-2 text-sm text-gray-300 bucket-item" data-name="@b.Name.ToLower()">
|
|
<input type="checkbox" name="bucketIds" value="@b.Id" class="rounded"
|
|
@(Model.SelectedBucketIds.Contains(b.Id) ? "checked" : "") />
|
|
<span>@b.Name</span>
|
|
@if (!string.IsNullOrWhiteSpace(b.BucketType))
|
|
{
|
|
<span class="text-xs text-gray-500 ml-auto">@b.BucketType</span>
|
|
}
|
|
</label>
|
|
}
|
|
@if (!Model.AllBuckets.Any())
|
|
{
|
|
<div class="text-xs text-gray-500">No buckets defined yet.</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex justify-end gap-4 mt-6">
|
|
<a href="/admin/tilemaps/edit?id=@sheet.Id" class="btn btn-ghost">Cancel</a>
|
|
<button type="submit" class="btn btn-primary">
|
|
@(Model.Tile.Id == 0 ? "Create Tile" : "Save Changes")
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
@section Scripts {
|
|
<script>
|
|
function filterBuckets() {
|
|
const q = document.getElementById('bucketFilter').value.toLowerCase();
|
|
document.querySelectorAll('.bucket-item').forEach(el => {
|
|
el.style.display = el.dataset.name.includes(q) ? '' : 'none';
|
|
});
|
|
}
|
|
</script>
|
|
}
|