335 lines
18 KiB
Plaintext
335 lines
18 KiB
Plaintext
@page "/admin/dungeonbuilder/palettes/edit"
|
|
@model DungeonBuilder.PaletteEditModel
|
|
@{
|
|
ViewData["Title"] = Model.Palette.Id == 0 ? "New Dungeon Palette" : $"Edit: {Model.Palette.Name}";
|
|
}
|
|
|
|
<div class="mb-4">
|
|
<a href="/admin/dungeonbuilder/palettes" class="text-blue-400 hover:text-blue-300 text-sm">← Back to Palettes</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="Palette.Id" />
|
|
<input type="hidden" asp-for="Palette.FloorTemplateIdsJson" id="floorIds" />
|
|
<input type="hidden" asp-for="Palette.WallTemplateIdsJson" id="wallIds" />
|
|
<input type="hidden" asp-for="Palette.DoorTemplateIdsJson" id="doorIds" />
|
|
<input type="hidden" asp-for="Palette.DecorationIdsJson" id="decorIds" />
|
|
<input type="hidden" asp-for="Palette.ContainerIdsJson" id="containerIds" />
|
|
<input type="hidden" asp-for="Palette.TrapIdsJson" id="trapIds" />
|
|
<input type="hidden" asp-for="Palette.RoomTemplateIdsJson" id="roomIds" />
|
|
<input type="hidden" asp-for="Palette.AllowedBucketIdsJson" id="bucketIds" />
|
|
|
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
<!-- Left: Basic Settings -->
|
|
<div class="space-y-4">
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">Basic Settings</h3>
|
|
<div class="space-y-3">
|
|
<div>
|
|
<label class="text-xs text-gray-400">Name *</label>
|
|
<input type="text" asp-for="Palette.Name" class="input w-full text-sm" required placeholder="Stone Dungeon" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Description</label>
|
|
<textarea asp-for="Palette.Description" rows="2" class="input w-full text-sm" placeholder="Classic stone dungeon theme..."></textarea>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div>
|
|
<label class="text-xs text-gray-400">Biome</label>
|
|
<input type="text" asp-for="Palette.Biome" class="input w-full text-sm" placeholder="dungeon" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Tags</label>
|
|
<input type="text" asp-for="Palette.Tags" class="input w-full text-sm" placeholder="stone,dark" />
|
|
</div>
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<input type="checkbox" asp-for="Palette.IsEnabled" class="rounded" />
|
|
<label class="text-sm text-gray-300">Enabled</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">Bucket Filters</h3>
|
|
<p class="text-xs text-gray-500 mb-2">Limit generation to these buckets.</p>
|
|
<input type="text" id="bucketFilter" class="input w-full text-sm mb-2" placeholder="Type to filter buckets..." oninput="filterBuckets()" />
|
|
<div class="max-h-48 overflow-auto border border-gray-700 rounded p-2 space-y-1" id="bucketList">
|
|
@foreach (var b in Model.Buckets)
|
|
{
|
|
<label class="flex items-center gap-2 text-sm text-gray-300 bucket-item" data-name="@b.Name.ToLower()">
|
|
<input type="checkbox" class="rounded bucket-check" value="@b.Id"
|
|
@(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.Buckets.Any())
|
|
{
|
|
<div class="text-xs text-gray-500">No buckets defined yet.</div>
|
|
}
|
|
</div>
|
|
<div class="flex items-center gap-2 mt-3">
|
|
<input type="checkbox" asp-for="Palette.EnforceBiomeBuckets" class="rounded" />
|
|
<label class="text-sm text-gray-300">Enforce biome bucket</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">Room Generation</h3>
|
|
<div class="space-y-3">
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div>
|
|
<label class="text-xs text-gray-400">Min Rooms</label>
|
|
<input type="number" asp-for="Palette.MinRooms" class="input w-full text-sm" min="1" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Max Rooms</label>
|
|
<input type="number" asp-for="Palette.MaxRooms" class="input w-full text-sm" min="1" />
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div>
|
|
<label class="text-xs text-gray-400">Min Room W</label>
|
|
<input type="number" asp-for="Palette.MinRoomWidth" class="input w-full text-sm" min="3" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Max Room W</label>
|
|
<input type="number" asp-for="Palette.MaxRoomWidth" class="input w-full text-sm" min="3" />
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div>
|
|
<label class="text-xs text-gray-400">Min Room H</label>
|
|
<input type="number" asp-for="Palette.MinRoomHeight" class="input w-full text-sm" min="3" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Max Room H</label>
|
|
<input type="number" asp-for="Palette.MaxRoomHeight" class="input w-full text-sm" min="3" />
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-2">
|
|
<div>
|
|
<label class="text-xs text-gray-400">Min Corridor W</label>
|
|
<input type="number" asp-for="Palette.MinCorridorWidth" class="input w-full text-sm" min="1" />
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Max Corridor W</label>
|
|
<input type="number" asp-for="Palette.MaxCorridorWidth" class="input w-full text-sm" min="1" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">Density Settings</h3>
|
|
<div class="space-y-3">
|
|
<div>
|
|
<label class="text-xs text-gray-400">Decoration Density (0-100)</label>
|
|
<input type="range" asp-for="Palette.DecorationDensity" min="0" max="100" class="w-full" />
|
|
<div class="text-xs text-gray-500 text-right">@Model.Palette.DecorationDensity%</div>
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Container Density (0-100)</label>
|
|
<input type="range" asp-for="Palette.ContainerDensity" min="0" max="100" class="w-full" />
|
|
<div class="text-xs text-gray-500 text-right">@Model.Palette.ContainerDensity%</div>
|
|
</div>
|
|
<div>
|
|
<label class="text-xs text-gray-400">Trap Density (0-100)</label>
|
|
<input type="range" asp-for="Palette.TrapDensity" min="0" max="100" class="w-full" />
|
|
<div class="text-xs text-gray-500 text-right">@Model.Palette.TrapDensity%</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Center: Tile Templates -->
|
|
<div class="space-y-4">
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">🧱 Floor Templates</h3>
|
|
<p class="text-xs text-gray-500 mb-3">Select tile templates to use for floors</p>
|
|
<div class="space-y-2 max-h-[200px] overflow-auto" id="floorList">
|
|
@foreach (var tile in Model.FloorTiles)
|
|
{
|
|
<label class="flex items-center gap-2 p-2 bg-gray-800 rounded hover:bg-gray-700 cursor-pointer">
|
|
<input type="checkbox" class="rounded floor-check" value="@tile.Id"
|
|
@(Model.SelectedFloorIds.Contains(tile.Id) ? "checked" : "") />
|
|
<span class="text-sm text-gray-300">@tile.Name</span>
|
|
<span class="text-xs text-gray-500 ml-auto">W:@tile.Weight</span>
|
|
</label>
|
|
}
|
|
@if (!Model.FloorTiles.Any())
|
|
{
|
|
<div class="text-xs text-gray-500 p-2">No floor templates. Create some first!</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">🧱 Wall Templates</h3>
|
|
<p class="text-xs text-gray-500 mb-3">Select tile templates to use for walls</p>
|
|
<div class="space-y-2 max-h-[200px] overflow-auto" id="wallList">
|
|
@foreach (var tile in Model.WallTiles)
|
|
{
|
|
<label class="flex items-center gap-2 p-2 bg-gray-800 rounded hover:bg-gray-700 cursor-pointer">
|
|
<input type="checkbox" class="rounded wall-check" value="@tile.Id"
|
|
@(Model.SelectedWallIds.Contains(tile.Id) ? "checked" : "") />
|
|
<span class="text-sm text-gray-300">@tile.Name</span>
|
|
<span class="text-xs text-gray-500 ml-auto">W:@tile.Weight</span>
|
|
</label>
|
|
}
|
|
@if (!Model.WallTiles.Any())
|
|
{
|
|
<div class="text-xs text-gray-500 p-2">No wall templates. Create some first!</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">🚪 Door Templates</h3>
|
|
<p class="text-xs text-gray-500 mb-3">Select tile templates to use for doors</p>
|
|
<div class="space-y-2 max-h-[150px] overflow-auto" id="doorList">
|
|
@foreach (var tile in Model.DoorTiles)
|
|
{
|
|
<label class="flex items-center gap-2 p-2 bg-gray-800 rounded hover:bg-gray-700 cursor-pointer">
|
|
<input type="checkbox" class="rounded door-check" value="@tile.Id"
|
|
@(Model.SelectedDoorIds.Contains(tile.Id) ? "checked" : "") />
|
|
<span class="text-sm text-gray-300">@tile.Name</span>
|
|
</label>
|
|
}
|
|
@if (!Model.DoorTiles.Any())
|
|
{
|
|
<div class="text-xs text-gray-500 p-2">No door templates.</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">🗺️ Room Templates</h3>
|
|
<p class="text-xs text-gray-500 mb-3">Pre-built rooms to include</p>
|
|
<div class="space-y-2 max-h-[150px] overflow-auto" id="roomList">
|
|
@foreach (var room in Model.Rooms)
|
|
{
|
|
<label class="flex items-center gap-2 p-2 bg-gray-800 rounded hover:bg-gray-700 cursor-pointer">
|
|
<input type="checkbox" class="rounded room-check" value="@room.Id"
|
|
@(Model.SelectedRoomIds.Contains(room.Id) ? "checked" : "") />
|
|
<span class="text-sm text-gray-300">@room.Name</span>
|
|
<span class="text-xs text-gray-500 ml-auto">@room.Type</span>
|
|
</label>
|
|
}
|
|
@if (!Model.Rooms.Any())
|
|
{
|
|
<div class="text-xs text-gray-500 p-2">No room templates.</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Right: Object Templates -->
|
|
<div class="space-y-4">
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">🪨 Decorations</h3>
|
|
<p class="text-xs text-gray-500 mb-3">Objects placed as decoration</p>
|
|
<div class="space-y-2 max-h-[200px] overflow-auto" id="decorList">
|
|
@foreach (var obj in Model.Decorations)
|
|
{
|
|
<label class="flex items-center gap-2 p-2 bg-gray-800 rounded hover:bg-gray-700 cursor-pointer">
|
|
<input type="checkbox" class="rounded decor-check" value="@obj.Id"
|
|
@(Model.SelectedDecorationIds.Contains(obj.Id) ? "checked" : "") />
|
|
<span class="text-sm text-gray-300">@obj.Name</span>
|
|
</label>
|
|
}
|
|
@if (!Model.Decorations.Any())
|
|
{
|
|
<div class="text-xs text-gray-500 p-2">No decoration objects.</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">📦 Containers</h3>
|
|
<p class="text-xs text-gray-500 mb-3">Chests, barrels, crates</p>
|
|
<div class="space-y-2 max-h-[200px] overflow-auto" id="containerList">
|
|
@foreach (var obj in Model.Containers)
|
|
{
|
|
<label class="flex items-center gap-2 p-2 bg-gray-800 rounded hover:bg-gray-700 cursor-pointer">
|
|
<input type="checkbox" class="rounded container-check" value="@obj.Id"
|
|
@(Model.SelectedContainerIds.Contains(obj.Id) ? "checked" : "") />
|
|
<span class="text-sm text-gray-300">@obj.Name</span>
|
|
</label>
|
|
}
|
|
@if (!Model.Containers.Any())
|
|
{
|
|
<div class="text-xs text-gray-500 p-2">No container objects.</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card p-4">
|
|
<h3 class="font-semibold text-white mb-3">⚠️ Traps</h3>
|
|
<p class="text-xs text-gray-500 mb-3">Hazards and traps</p>
|
|
<div class="space-y-2 max-h-[200px] overflow-auto" id="trapList">
|
|
@foreach (var obj in Model.Traps)
|
|
{
|
|
<label class="flex items-center gap-2 p-2 bg-gray-800 rounded hover:bg-gray-700 cursor-pointer">
|
|
<input type="checkbox" class="rounded trap-check" value="@obj.Id"
|
|
@(Model.SelectedTrapIds.Contains(obj.Id) ? "checked" : "") />
|
|
<span class="text-sm text-gray-300">@obj.Name</span>
|
|
</label>
|
|
}
|
|
@if (!Model.Traps.Any())
|
|
{
|
|
<div class="text-xs text-gray-500 p-2">No trap objects.</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex justify-end gap-4 mt-6">
|
|
<a href="/admin/dungeonbuilder/palettes" class="btn btn-ghost">Cancel</a>
|
|
<button type="submit" class="btn btn-primary">
|
|
@(Model.Palette.Id == 0 ? "Create Palette" : "Save Changes")
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
<script>
|
|
function collectIds(selector) {
|
|
return Array.from(document.querySelectorAll(selector + ':checked')).map(cb => parseInt(cb.value));
|
|
}
|
|
|
|
function saveSelections() {
|
|
document.getElementById('floorIds').value = JSON.stringify(collectIds('.floor-check'));
|
|
document.getElementById('wallIds').value = JSON.stringify(collectIds('.wall-check'));
|
|
document.getElementById('doorIds').value = JSON.stringify(collectIds('.door-check'));
|
|
document.getElementById('decorIds').value = JSON.stringify(collectIds('.decor-check'));
|
|
document.getElementById('containerIds').value = JSON.stringify(collectIds('.container-check'));
|
|
document.getElementById('trapIds').value = JSON.stringify(collectIds('.trap-check'));
|
|
document.getElementById('roomIds').value = JSON.stringify(collectIds('.room-check'));
|
|
document.getElementById('bucketIds').value = JSON.stringify(collectIds('.bucket-check'));
|
|
}
|
|
|
|
document.querySelector('form').onsubmit = () => saveSelections();
|
|
|
|
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>
|