Tile changes
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
@{
|
||||
ViewData["Title"] = Model.Sheet.Id == 0 ? "New TileMap Sheet" : $"Edit: {Model.Sheet.Name}";
|
||||
var tileTypes = Enum.GetValues<TileType>();
|
||||
var socketTypes = Enum.GetValues<SocketType>();
|
||||
// Build image URL - handle both with and without /downloads/ path
|
||||
var imageUrl = Model.Sheet.CdnPath;
|
||||
if (!string.IsNullOrEmpty(imageUrl))
|
||||
@@ -131,7 +132,7 @@
|
||||
<div class="card p-4 md:p-6 mt-4 md:mt-6">
|
||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4">
|
||||
<h2 class="text-lg md:text-xl font-semibold text-white">Tile Definitions</h2>
|
||||
<div class="flex gap-2">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<form method="post" asp-page-handler="AutoGenerate" class="flex gap-2">
|
||||
<input type="hidden" name="sheetId" value="@Model.Sheet.Id" />
|
||||
<select name="defaultType" class="input text-sm py-1">
|
||||
@@ -140,6 +141,12 @@
|
||||
</select>
|
||||
<button type="submit" class="btn btn-secondary text-sm py-1">Auto-Generate</button>
|
||||
</form>
|
||||
|
||||
<!-- Socket bulk actions -->
|
||||
<form method="post" asp-page-handler="AutoConfigureSockets" class="inline">
|
||||
<input type="hidden" name="sheetId" value="@Model.Sheet.Id" />
|
||||
<button type="submit" class="btn btn-secondary text-sm py-1" title="Set sockets based on tile type">Auto Sockets</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -197,14 +204,14 @@
|
||||
<div class="mt-6">
|
||||
<h3 class="text-base md:text-lg font-semibold text-white mb-3">Defined Tiles (@Model.TileDefinitions.Count)</h3>
|
||||
<div class="overflow-x-auto -mx-4 md:mx-0">
|
||||
<table class="w-full text-xs md:text-sm min-w-[600px]">
|
||||
<table class="w-full text-xs md:text-sm min-w-[700px]">
|
||||
<thead>
|
||||
<tr class="text-left text-gray-400 border-b border-gray-700">
|
||||
<th class="p-2">#</th>
|
||||
<th class="p-2">Preview</th>
|
||||
<th class="p-2">Name</th>
|
||||
<th class="p-2">Type</th>
|
||||
<th class="p-2">Tags</th>
|
||||
<th class="p-2">Sockets</th>
|
||||
<th class="p-2">Props</th>
|
||||
<th class="p-2">Actions</th>
|
||||
</tr>
|
||||
@@ -226,11 +233,16 @@
|
||||
<td class="p-2">
|
||||
<span class="px-1.5 py-0.5 text-xs rounded" style="background-color: @GetTileTypeColor(tile.Type);">@tile.Type</span>
|
||||
</td>
|
||||
<td class="p-2 text-gray-400 text-xs max-w-[80px] truncate">@(tile.Tags ?? "-")</td>
|
||||
<td class="p-2 text-xs">
|
||||
@if (tile.IsWalkable) { <span class="text-green-400">W</span> }
|
||||
@if (tile.BlocksProjectiles) { <span class="text-red-400">P</span> }
|
||||
@if (tile.BlocksLineOfSight) { <span class="text-yellow-400">L</span> }
|
||||
<span class="@GetSocketBadgeClass(tile.SocketN)" title="North">N</span>
|
||||
<span class="@GetSocketBadgeClass(tile.SocketE)" title="East">E</span>
|
||||
<span class="@GetSocketBadgeClass(tile.SocketS)" title="South">S</span>
|
||||
<span class="@GetSocketBadgeClass(tile.SocketW)" title="West">W</span>
|
||||
</td>
|
||||
<td class="p-2 text-xs">
|
||||
@if (tile.IsWalkable) { <span class="text-green-400" title="Walkable">W</span> }
|
||||
@if (tile.BlocksProjectiles) { <span class="text-red-400" title="Blocks Projectiles">P</span> }
|
||||
@if (tile.BlocksLineOfSight) { <span class="text-yellow-400" title="Blocks LOS">L</span> }
|
||||
</td>
|
||||
<td class="p-2">
|
||||
<button onclick="openTileEditor(@tile.FrameIndex, @tile.Id)" class="text-blue-400 hover:text-blue-300 mr-1">Edit</button>
|
||||
@@ -256,7 +268,7 @@
|
||||
|
||||
<!-- Tile Editor Modal -->
|
||||
<div id="tileEditorModal" class="fixed inset-0 bg-black/50 z-50 hidden items-center justify-center p-4">
|
||||
<div class="bg-gray-900 rounded-xl shadow-xl p-4 md:p-6 w-full max-w-md border border-gray-700 max-h-[90vh] overflow-y-auto">
|
||||
<div class="bg-gray-900 rounded-xl shadow-xl p-4 md:p-6 w-full max-w-lg border border-gray-700 max-h-[90vh] overflow-y-auto">
|
||||
<h3 class="text-lg font-semibold text-white mb-4">Edit Tile <span id="modalFrameIndex"></span></h3>
|
||||
|
||||
<form method="post" asp-page-handler="SaveTile">
|
||||
@@ -275,14 +287,25 @@
|
||||
<input type="text" name="name" id="editName" class="input w-full text-sm" placeholder="Stone Floor A" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Type</label>
|
||||
<select name="type" id="editType" class="input w-full text-sm">
|
||||
@foreach (var t in tileTypes)
|
||||
{
|
||||
<option value="@((int)t)">@t</option>
|
||||
}
|
||||
</select>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Type</label>
|
||||
<select name="type" id="editType" class="input w-full text-sm" onchange="onTypeChange()">
|
||||
@foreach (var t in tileTypes)
|
||||
{
|
||||
<option value="@((int)t)">@t</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Render Layer</label>
|
||||
<select name="renderLayer" id="editRenderLayer" class="input w-full text-sm">
|
||||
<option value="0">0 - Ground</option>
|
||||
<option value="1">1 - Floor Decor</option>
|
||||
<option value="2">2 - Walls</option>
|
||||
<option value="3">3 - Ceiling</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -290,14 +313,69 @@
|
||||
<input type="text" name="tags" id="editTags" class="input w-full text-sm" placeholder="stone, cracked" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-300 mb-1">Render Layer</label>
|
||||
<select name="renderLayer" id="editRenderLayer" class="input w-full text-sm">
|
||||
<option value="0">0 - Ground</option>
|
||||
<option value="1">1 - Floor Decor</option>
|
||||
<option value="2">2 - Walls</option>
|
||||
<option value="3">3 - Ceiling</option>
|
||||
</select>
|
||||
<!-- Socket Configuration -->
|
||||
<div class="border border-gray-700 rounded-lg p-3">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<label class="text-sm font-medium text-gray-300">Sockets</label>
|
||||
<div class="flex gap-1">
|
||||
<button type="button" onclick="setAllSockets(1)" class="text-xs px-2 py-0.5 bg-green-900/50 text-green-400 rounded hover:bg-green-900">All Open</button>
|
||||
<button type="button" onclick="setAllSockets(0)" class="text-xs px-2 py-0.5 bg-red-900/50 text-red-400 rounded hover:bg-red-900">All Closed</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-2 text-center">
|
||||
<!-- North -->
|
||||
<div></div>
|
||||
<div>
|
||||
<label class="text-xs text-gray-400 block">North</label>
|
||||
<select name="socketN" id="editSocketN" class="input w-full text-xs py-1" onchange="updateSocketCustom('N')">
|
||||
<option value="0">Closed</option>
|
||||
<option value="1">Open</option>
|
||||
<option value="2">Custom</option>
|
||||
</select>
|
||||
<input type="text" name="socketNCustom" id="editSocketNCustom" class="input w-full text-xs py-1 mt-1 hidden" placeholder="Custom type" />
|
||||
</div>
|
||||
<div></div>
|
||||
|
||||
<!-- West / Center / East -->
|
||||
<div>
|
||||
<label class="text-xs text-gray-400 block">West</label>
|
||||
<select name="socketW" id="editSocketW" class="input w-full text-xs py-1" onchange="updateSocketCustom('W')">
|
||||
<option value="0">Closed</option>
|
||||
<option value="1">Open</option>
|
||||
<option value="2">Custom</option>
|
||||
</select>
|
||||
<input type="text" name="socketWCustom" id="editSocketWCustom" class="input w-full text-xs py-1 mt-1 hidden" placeholder="Custom type" />
|
||||
</div>
|
||||
<div class="flex items-center justify-center">
|
||||
<div class="w-8 h-8 bg-gray-700 rounded flex items-center justify-center text-gray-500">
|
||||
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><rect x="2" y="2" width="16" height="16" rx="2"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-xs text-gray-400 block">East</label>
|
||||
<select name="socketE" id="editSocketE" class="input w-full text-xs py-1" onchange="updateSocketCustom('E')">
|
||||
<option value="0">Closed</option>
|
||||
<option value="1">Open</option>
|
||||
<option value="2">Custom</option>
|
||||
</select>
|
||||
<input type="text" name="socketECustom" id="editSocketECustom" class="input w-full text-xs py-1 mt-1 hidden" placeholder="Custom type" />
|
||||
</div>
|
||||
|
||||
<!-- South -->
|
||||
<div></div>
|
||||
<div>
|
||||
<label class="text-xs text-gray-400 block">South</label>
|
||||
<select name="socketS" id="editSocketS" class="input w-full text-xs py-1" onchange="updateSocketCustom('S')">
|
||||
<option value="0">Closed</option>
|
||||
<option value="1">Open</option>
|
||||
<option value="2">Custom</option>
|
||||
</select>
|
||||
<input type="text" name="socketSCustom" id="editSocketSCustom" class="input w-full text-xs py-1 mt-1 hidden" placeholder="Custom type" />
|
||||
</div>
|
||||
<div></div>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 mt-2">Open↔Open, Closed↔Closed. Custom must match exactly.</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-2 text-sm">
|
||||
@@ -353,7 +431,11 @@
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
const tileDefinitions = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(Model.TileDefinitions.ToDictionary(t => t.FrameIndex, t => new { t.Id, t.FrameIndex, t.Name, t.Type, t.Tags, t.IsWalkable, t.BlocksProjectiles, t.BlocksLineOfSight, t.RenderLayer })));
|
||||
const tileDefinitions = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(Model.TileDefinitions.ToDictionary(t => t.FrameIndex, t => new {
|
||||
t.Id, t.FrameIndex, t.Name, t.Type, t.Tags, t.IsWalkable, t.BlocksProjectiles, t.BlocksLineOfSight, t.RenderLayer,
|
||||
SocketN = (int)t.SocketN, SocketE = (int)t.SocketE, SocketS = (int)t.SocketS, SocketW = (int)t.SocketW,
|
||||
t.SocketNCustom, t.SocketECustom, t.SocketSCustom, t.SocketWCustom
|
||||
})));
|
||||
const sheetWidth = @Model.Sheet.SheetWidth;
|
||||
const sheetHeight = @Model.Sheet.SheetHeight;
|
||||
const tileWidth = @Model.Sheet.TileWidth;
|
||||
@@ -387,6 +469,15 @@
|
||||
document.getElementById('editWalkable').checked = existing.IsWalkable;
|
||||
document.getElementById('editBlocksProj').checked = existing.BlocksProjectiles;
|
||||
document.getElementById('editBlocksLOS').checked = existing.BlocksLineOfSight;
|
||||
// Sockets
|
||||
document.getElementById('editSocketN').value = existing.SocketN;
|
||||
document.getElementById('editSocketE').value = existing.SocketE;
|
||||
document.getElementById('editSocketS').value = existing.SocketS;
|
||||
document.getElementById('editSocketW').value = existing.SocketW;
|
||||
document.getElementById('editSocketNCustom').value = existing.SocketNCustom || '';
|
||||
document.getElementById('editSocketECustom').value = existing.SocketECustom || '';
|
||||
document.getElementById('editSocketSCustom').value = existing.SocketSCustom || '';
|
||||
document.getElementById('editSocketWCustom').value = existing.SocketWCustom || '';
|
||||
} else {
|
||||
document.getElementById('editName').value = '';
|
||||
document.getElementById('editType').value = '0';
|
||||
@@ -395,8 +486,20 @@
|
||||
document.getElementById('editWalkable').checked = true;
|
||||
document.getElementById('editBlocksProj').checked = false;
|
||||
document.getElementById('editBlocksLOS').checked = false;
|
||||
// Default sockets for new tile
|
||||
document.getElementById('editSocketN').value = '1'; // Open
|
||||
document.getElementById('editSocketE').value = '1';
|
||||
document.getElementById('editSocketS').value = '1';
|
||||
document.getElementById('editSocketW').value = '1';
|
||||
document.getElementById('editSocketNCustom').value = '';
|
||||
document.getElementById('editSocketECustom').value = '';
|
||||
document.getElementById('editSocketSCustom').value = '';
|
||||
document.getElementById('editSocketWCustom').value = '';
|
||||
}
|
||||
|
||||
// Update custom field visibility
|
||||
['N', 'E', 'S', 'W'].forEach(updateSocketCustom);
|
||||
|
||||
document.getElementById('tileEditorModal').classList.remove('hidden');
|
||||
document.getElementById('tileEditorModal').classList.add('flex');
|
||||
}
|
||||
@@ -406,6 +509,33 @@
|
||||
document.getElementById('tileEditorModal').classList.remove('flex');
|
||||
}
|
||||
|
||||
function updateSocketCustom(dir) {
|
||||
const select = document.getElementById('editSocket' + dir);
|
||||
const custom = document.getElementById('editSocket' + dir + 'Custom');
|
||||
custom.classList.toggle('hidden', select.value !== '2');
|
||||
}
|
||||
|
||||
function setAllSockets(value) {
|
||||
['N', 'E', 'S', 'W'].forEach(dir => {
|
||||
document.getElementById('editSocket' + dir).value = value;
|
||||
updateSocketCustom(dir);
|
||||
});
|
||||
}
|
||||
|
||||
function onTypeChange() {
|
||||
const type = parseInt(document.getElementById('editType').value);
|
||||
// Auto-set sockets based on type
|
||||
if (type === 0 || type === 30) { // Floor, FloorDecor
|
||||
setAllSockets(1); // Open
|
||||
document.getElementById('editWalkable').checked = true;
|
||||
} else if (type === 1 || type === 31) { // Wall, WallDecor
|
||||
setAllSockets(0); // Closed
|
||||
document.getElementById('editWalkable').checked = false;
|
||||
document.getElementById('editBlocksProj').checked = true;
|
||||
document.getElementById('editBlocksLOS').checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
function showCdnBrowser() {
|
||||
document.getElementById('cdnBrowserModal').classList.remove('hidden');
|
||||
document.getElementById('cdnBrowserModal').classList.add('flex');
|
||||
@@ -490,4 +620,15 @@
|
||||
_ => "transparent"
|
||||
};
|
||||
}
|
||||
|
||||
string GetSocketBadgeClass(SocketType socket)
|
||||
{
|
||||
return socket switch
|
||||
{
|
||||
SocketType.Open => "text-green-400",
|
||||
SocketType.Closed => "text-red-400",
|
||||
SocketType.Custom => "text-yellow-400",
|
||||
_ => "text-gray-400"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user