Additional tools for Admin portal, and huge NameSpace Revamp
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
@page "/admin/mobs/edit"
|
||||
@model Mobs.EditModel
|
||||
@using Server.Data.Enums
|
||||
@using DataServer.Data.Enums
|
||||
@{
|
||||
ViewData["Title"] = Model.IsNew ? "Create Mob" : $"Edit: {Model.Mob.Name}";
|
||||
}
|
||||
@@ -243,9 +243,9 @@
|
||||
<!-- Visual -->
|
||||
<div class="card">
|
||||
<div class="p-4 border-b border-gray-700">
|
||||
<h2 class="text-lg font-semibold text-white">Visual</h2>
|
||||
<h2 class="text-lg font-semibold text-white">Visual Settings</h2>
|
||||
</div>
|
||||
<div class="p-6 grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div class="p-6 grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||
<div>
|
||||
<label class="label">Tint Color</label>
|
||||
<div class="flex gap-2">
|
||||
@@ -257,15 +257,71 @@
|
||||
<label class="label">Scale</label>
|
||||
<input type="number" name="Mob.Scale" value="@Model.Mob.Scale" class="input" min="0.1" step="0.1" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Frame Width</label>
|
||||
<input type="number" name="sprite_frameWidth" value="@Model.SpriteConfig.FrameWidth" class="input" min="8" step="8" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Frame Height</label>
|
||||
<input type="number" name="sprite_frameHeight" value="@Model.SpriteConfig.FrameHeight" class="input" min="8" step="8" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">FPS</label>
|
||||
<input type="number" name="sprite_fps" value="@Model.SpriteConfig.Fps" class="input" min="1" max="60" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label">Animation Speed</label>
|
||||
<input type="number" name="Mob.AnimationSpeed" value="@Model.Mob.AnimationSpeed" class="input" min="1" />
|
||||
</div>
|
||||
<div class="md:col-span-3">
|
||||
<label class="label">Sprite Config JSON</label>
|
||||
<textarea name="Mob.SpriteConfigJson" class="input font-mono text-sm" rows="4" placeholder='{"sprites":{"idle_front":"path.png"},"frameWidth":64,"frameHeight":64}'>@Model.Mob.SpriteConfigJson</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sprite Sheets -->
|
||||
<div class="card">
|
||||
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold text-white">Sprite Sheets</h2>
|
||||
<p class="text-sm text-gray-400">Configure sprite sheets for different directions and states</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div id="spritesList" class="space-y-2 mb-4">
|
||||
@foreach (var sprite in Model.SpriteConfig.Sprites)
|
||||
{
|
||||
<div class="bg-gray-800 border border-gray-700 rounded-lg p-3 flex items-center gap-3 sprite-row">
|
||||
<select name="sprite_key[]" class="input w-36">
|
||||
@foreach (var key in new[] { "idle_front", "idle_back", "idle_left", "idle_right", "run_front", "run_back", "run_left", "run_right", "attack_front", "attack_back", "death" })
|
||||
{
|
||||
<option value="@key" selected="@(sprite.Key == key)">@key</option>
|
||||
}
|
||||
</select>
|
||||
<input type="text" name="sprite_path[]" value="@sprite.Value" class="input flex-1" placeholder="textures/mobs/skeleton_idle_front.png" />
|
||||
<input type="number" name="sprite_frames[]" value="@Model.SpriteConfig.GetFrameCount(sprite.Key)" class="input w-20" min="1" placeholder="Frames" title="Frame count" />
|
||||
<label class="flex items-center gap-1 text-sm text-gray-400">
|
||||
<input type="checkbox" name="sprite_loop[]" value="@sprite.Key" checked="@Model.SpriteConfig.IsLooping(sprite.Key)" class="rounded border-gray-600 bg-gray-800" />
|
||||
Loop
|
||||
</label>
|
||||
<button type="button" onclick="this.closest('.sprite-row').remove()" class="p-2 text-red-400 hover:text-red-300">
|
||||
<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="M6 18L18 6M6 6l12 12"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (!Model.SpriteConfig.Sprites.Any())
|
||||
{
|
||||
<p class="text-gray-500 text-sm mb-4">No sprites configured. Add sprite sheets below.</p>
|
||||
}
|
||||
|
||||
<button type="button" onclick="addSprite()" class="btn btn-secondary">
|
||||
<svg class="w-4 h-4 mr-1 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
||||
</svg>
|
||||
Add Sprite Sheet
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Save -->
|
||||
@@ -460,5 +516,37 @@
|
||||
customInput.classList.add('hidden');
|
||||
valueInput.value = '50';
|
||||
}
|
||||
|
||||
function addSprite() {
|
||||
const html = `
|
||||
<div class="bg-gray-800 border border-gray-700 rounded-lg p-3 flex items-center gap-3 sprite-row">
|
||||
<select name="sprite_key[]" class="input w-36">
|
||||
<option value="idle_front">idle_front</option>
|
||||
<option value="idle_back">idle_back</option>
|
||||
<option value="idle_left">idle_left</option>
|
||||
<option value="idle_right">idle_right</option>
|
||||
<option value="run_front">run_front</option>
|
||||
<option value="run_back">run_back</option>
|
||||
<option value="run_left">run_left</option>
|
||||
<option value="run_right">run_right</option>
|
||||
<option value="attack_front">attack_front</option>
|
||||
<option value="attack_back">attack_back</option>
|
||||
<option value="death">death</option>
|
||||
</select>
|
||||
<input type="text" name="sprite_path[]" value="" class="input flex-1" placeholder="textures/mobs/skeleton_idle_front.png" />
|
||||
<input type="number" name="sprite_frames[]" value="8" class="input w-20" min="1" placeholder="Frames" title="Frame count" />
|
||||
<label class="flex items-center gap-1 text-sm text-gray-400">
|
||||
<input type="checkbox" name="sprite_loop[]" value="new" checked class="rounded border-gray-600 bg-gray-800" />
|
||||
Loop
|
||||
</label>
|
||||
<button type="button" onclick="this.closest('.sprite-row').remove()" class="p-2 text-red-400 hover:text-red-300">
|
||||
<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="M6 18L18 6M6 6l12 12"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('spritesList').insertAdjacentHTML('beforeend', html);
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user