Admin tools for mob sprites
This commit is contained in:
@@ -490,6 +490,131 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Animations Section -->
|
||||
@if (!Model.IsNew)
|
||||
{
|
||||
<div class="card">
|
||||
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
||||
<h2 class="text-lg font-semibold text-white">Animations (@Model.MobAnimations.Count)</h2>
|
||||
<div class="flex gap-2">
|
||||
<a href="/admin/spritesheets" class="btn btn-sm btn-secondary" target="_blank">Manage Sheets</a>
|
||||
<button type="button" onclick="showAddAnimationModal()" class="btn btn-sm btn-primary">+ Add Animation</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4">
|
||||
@if (Model.MobAnimations.Count > 0)
|
||||
{
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="border-b border-gray-700">
|
||||
<th class="py-2 text-left text-gray-400">Key</th>
|
||||
<th class="py-2 text-left text-gray-400">Sheet</th>
|
||||
<th class="py-2 text-left text-gray-400">Frames</th>
|
||||
<th class="py-2 text-left text-gray-400">FPS</th>
|
||||
<th class="py-2 text-left text-gray-400">Options</th>
|
||||
<th class="py-2 text-left text-gray-400">Override Key</th>
|
||||
<th class="py-2 text-left text-gray-400">Status</th>
|
||||
<th class="py-2 text-right text-gray-400">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-700/50">
|
||||
@foreach (var assignment in Model.MobAnimations)
|
||||
{
|
||||
var anim = assignment.AnimationDefinition;
|
||||
var sheet = anim?.SpriteSheet;
|
||||
<tr class="hover:bg-gray-800/50">
|
||||
<td class="py-3 text-white font-mono">@anim?.Key</td>
|
||||
<td class="py-3 text-gray-300 text-xs">@sheet?.Name</td>
|
||||
<td class="py-3 text-gray-300 font-mono text-xs">@anim?.FrameSequence</td>
|
||||
<td class="py-3 text-gray-300">@anim?.Fps</td>
|
||||
<td class="py-3 text-gray-400 text-xs">
|
||||
@if (anim?.Loop == true) { <span class="mr-1">Loop</span> }
|
||||
@if (anim?.FlipX == true) { <span class="mr-1">FlipX</span> }
|
||||
@if (anim?.FlipY == true) { <span>FlipY</span> }
|
||||
</td>
|
||||
<td class="py-3 text-gray-300 font-mono text-xs">@(assignment.OverrideKey ?? "-")</td>
|
||||
<td class="py-3">
|
||||
@if (assignment.IsEnabled)
|
||||
{
|
||||
<span class="text-green-400 text-xs">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="text-gray-500 text-xs">Disabled</span>
|
||||
}
|
||||
</td>
|
||||
<td class="py-3 text-right">
|
||||
<div class="flex justify-end gap-1">
|
||||
<form method="post" asp-page-handler="ToggleAnimation" class="inline">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="assignmentId" value="@assignment.Id" />
|
||||
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
||||
<button type="submit" class="p-1.5 hover:bg-gray-700 rounded text-gray-400" title="Toggle">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
|
||||
</button>
|
||||
</form>
|
||||
<form method="post" asp-page-handler="RemoveAnimation" class="inline" onsubmit="return confirm('Remove this animation?')">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="assignmentId" value="@assignment.Id" />
|
||||
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
||||
<button type="submit" class="p-1.5 hover:bg-gray-700 rounded text-red-400" title="Remove">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="text-gray-400 text-center py-4">No animations assigned. <a href="/admin/spritesheets" class="text-indigo-400 hover:underline">Create sprite sheets</a> first, then add animations here.</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Animation Modal -->
|
||||
<div id="addAnimationModal" class="fixed inset-0 bg-black/50 z-50 hidden items-center justify-center">
|
||||
<div class="bg-gray-900 rounded-xl shadow-xl p-6 w-full max-w-md mx-4 border border-gray-700">
|
||||
<h3 class="text-lg font-semibold text-white mb-4">Add Animation</h3>
|
||||
<form method="post" asp-page-handler="AddAnimation">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="mobId" value="@Model.Mob.Id" />
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="label">Animation</label>
|
||||
<select name="animationId" class="input" required>
|
||||
<option value="">Select an animation...</option>
|
||||
@foreach (var anim in Model.AllAnimations)
|
||||
{
|
||||
<option value="@anim.Id">[@(anim.SpriteSheet?.Name ?? "?")] @anim.Key - @anim.FrameSequence (@anim.Fps fps)</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Override Key (optional)</label>
|
||||
<input type="text" name="overrideKey" class="input" placeholder="e.g., walk_down" />
|
||||
<p class="text-xs text-gray-500 mt-1">Use if you want to map this animation to a different key for this mob</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Priority</label>
|
||||
<input type="number" name="priority" value="0" class="input" />
|
||||
<p class="text-xs text-gray-500 mt-1">Higher priority used when multiple match</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-3 pt-4">
|
||||
<button type="button" onclick="closeAddAnimationModal()" class="btn btn-secondary">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Assign</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Loot Tables Section -->
|
||||
@if (!Model.IsNew)
|
||||
{
|
||||
@@ -613,10 +738,19 @@
|
||||
document.getElementById('addAbilityModal').classList.add('hidden');
|
||||
document.getElementById('addAbilityModal').classList.remove('flex');
|
||||
}
|
||||
function showAddAnimationModal() {
|
||||
document.getElementById('addAnimationModal').classList.remove('hidden');
|
||||
document.getElementById('addAnimationModal').classList.add('flex');
|
||||
}
|
||||
function closeAddAnimationModal() {
|
||||
document.getElementById('addAnimationModal').classList.add('hidden');
|
||||
document.getElementById('addAnimationModal').classList.remove('flex');
|
||||
}
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key === 'Escape') {
|
||||
closeAddLootModal();
|
||||
closeAddAbilityModal();
|
||||
closeAddAnimationModal();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user