Upgrade NPC admin editor selectors and add dialog tree admin UI

This commit is contained in:
dingo
2026-02-14 01:31:05 -05:00
parent 0e71d64baa
commit 4ba5a1040b
8 changed files with 1157 additions and 29 deletions
@@ -0,0 +1,301 @@
@page "/admin/npcs/dialogtrees/edit"
@model Npcs.DialogTreeEditModel
@using DataServer.Data.Enums
@{
ViewData["Title"] = Model.IsNew ? "Create Dialog Tree" : $"Edit Dialog Tree: {Model.Tree.Name}";
}
<div class="space-y-6">
<div class="flex items-center gap-4">
<a href="/admin/npcs/dialogtrees" class="p-2 hover:bg-gray-800 rounded-lg">
<svg class="w-6 h-6 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
</svg>
</a>
<div>
<h1 class="text-3xl font-bold text-white">@(Model.IsNew ? "Create Dialog Tree" : "Edit Dialog Tree")</h1>
<p class="text-gray-400 mt-1">@(Model.IsNew ? "Create a conversation flow for NPCs" : $"ID: {Model.Tree.Id}")</p>
</div>
</div>
@if (!string.IsNullOrEmpty(Model.Message))
{
<div class="p-4 rounded-lg @(Model.IsError ? "bg-red-900/50 border border-red-700 text-red-200" : "bg-green-900/50 border border-green-700 text-green-200")">
@Model.Message
</div>
}
<form method="post" class="card p-6 space-y-4">
@Html.AntiForgeryToken()
<input type="hidden" name="Tree.Id" value="@Model.Tree.Id" />
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="md:col-span-2">
<label class="label">Name *</label>
<input type="text" name="Tree.Name" value="@Model.Tree.Name" class="input" maxlength="64" required />
</div>
<div class="flex items-center pt-6">
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" name="Tree.IsEnabled" value="true" checked="@Model.Tree.IsEnabled" class="w-4 h-4 rounded border-gray-600 bg-gray-800 text-indigo-600" />
<span class="text-gray-300">Enabled</span>
</label>
</div>
<div class="md:col-span-3">
<label class="label">Description</label>
<textarea name="Tree.Description" class="input" rows="2" maxlength="256">@Model.Tree.Description</textarea>
</div>
</div>
<div class="flex items-center gap-3">
<button type="submit" class="btn btn-primary">@(Model.IsNew ? "Create Dialog Tree" : "Save Dialog Tree")</button>
<a href="/admin/npcs/dialogtrees" class="btn btn-secondary">Back</a>
</div>
</form>
@if (!Model.IsNew)
{
<div class="card overflow-hidden">
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
<h2 class="text-lg font-semibold text-white">Nodes (@Model.Nodes.Count)</h2>
<button class="btn btn-primary btn-sm" type="button" onclick="showAddNodeModal()">+ Add Node</button>
</div>
<table class="w-full">
<thead class="bg-gray-900/50">
<tr>
<th class="table-header w-16">ID</th>
<th class="table-header">Node Key</th>
<th class="table-header">Text</th>
<th class="table-header w-20">Root</th>
<th class="table-header w-20">End</th>
<th class="table-header w-24">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
@foreach (var n in Model.Nodes)
{
<tr class="hover:bg-gray-700/30 @(Model.SelectedNodeId == n.Id ? "bg-indigo-900/20" : "")">
<td class="table-cell font-mono text-gray-500">@n.Id</td>
<td class="table-cell text-white">@n.NodeKey</td>
<td class="table-cell text-gray-300">@n.Text</td>
<td class="table-cell text-gray-300">@(n.IsRoot ? "Yes" : "No")</td>
<td class="table-cell text-gray-300">@(n.IsTerminal ? "Yes" : "No")</td>
<td class="table-cell">
<div class="flex items-center gap-2">
<a href="/admin/npcs/dialogtrees/edit?id=@Model.Tree.Id&nodeId=@n.Id" class="btn btn-secondary btn-sm">Options</a>
<form method="post" asp-page-handler="DeleteNode" onsubmit="return confirm('Delete this node and its options?');">
@Html.AntiForgeryToken()
<input type="hidden" name="treeId" value="@Model.Tree.Id" />
<input type="hidden" name="nodeId" value="@n.Id" />
<button class="btn btn-danger btn-sm" type="submit">Delete</button>
</form>
</div>
</td>
</tr>
}
@if (!Model.Nodes.Any())
{
<tr>
<td colspan="6" class="table-cell text-center text-gray-500 py-8">No nodes yet.</td>
</tr>
}
</tbody>
</table>
</div>
@if (Model.SelectedNodeId.HasValue)
{
<div class="card overflow-hidden">
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
<h2 class="text-lg font-semibold text-white">Options for Node @Model.SelectedNodeId (@Model.Options.Count)</h2>
<button class="btn btn-primary btn-sm" type="button" onclick="showAddOptionModal()">+ Add Option</button>
</div>
<table class="w-full">
<thead class="bg-gray-900/50">
<tr>
<th class="table-header w-16">ID</th>
<th class="table-header">Player Text</th>
<th class="table-header w-24">Next Node</th>
<th class="table-header w-28">Condition</th>
<th class="table-header w-20">Sort</th>
<th class="table-header w-24">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
@foreach (var o in Model.Options)
{
<tr class="hover:bg-gray-700/30">
<td class="table-cell font-mono text-gray-500">@o.Id</td>
<td class="table-cell text-white">@o.PlayerText</td>
<td class="table-cell text-gray-300">@o.NextNodeId</td>
<td class="table-cell text-gray-300">@o.ConditionType</td>
<td class="table-cell text-gray-300">@o.SortOrder</td>
<td class="table-cell">
<form method="post" asp-page-handler="DeleteOption" onsubmit="return confirm('Delete this option?');">
@Html.AntiForgeryToken()
<input type="hidden" name="treeId" value="@Model.Tree.Id" />
<input type="hidden" name="nodeId" value="@Model.SelectedNodeId.Value" />
<input type="hidden" name="optionId" value="@o.Id" />
<button class="btn btn-danger btn-sm" type="submit">Delete</button>
</form>
</td>
</tr>
}
@if (!Model.Options.Any())
{
<tr>
<td colspan="6" class="table-cell text-center text-gray-500 py-8">No options for this node.</td>
</tr>
}
</tbody>
</table>
</div>
}
<div id="addNodeModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50">
<div class="bg-gray-800 rounded-xl p-6 max-w-3xl w-full mx-4 border border-gray-700">
<h3 class="text-lg font-semibold text-white mb-4">Add Dialog Node</h3>
<form method="post" asp-page-handler="AddNode" class="space-y-4">
@Html.AntiForgeryToken()
<input type="hidden" name="treeId" value="@Model.Tree.Id" />
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="label">Node Key *</label>
<input type="text" name="nodeKey" class="input" required maxlength="128" />
</div>
<div class="flex items-center gap-6 pt-6">
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" name="isRoot" value="true" class="w-4 h-4 rounded border-gray-600 bg-gray-800 text-indigo-600" />
<span class="text-gray-300">Root Node</span>
</label>
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" name="isTerminal" value="true" class="w-4 h-4 rounded border-gray-600 bg-gray-800 text-indigo-600" />
<span class="text-gray-300">Terminal</span>
</label>
</div>
<div class="md:col-span-2">
<label class="label">NPC Text *</label>
<textarea name="text" class="input" rows="3" required maxlength="2048"></textarea>
</div>
<div>
<label class="label">Reward Type</label>
<input type="text" name="rewardType" class="input" maxlength="64" />
</div>
<div>
<label class="label">Reward Item</label>
<select name="rewardItemDefinitionId" class="input">
<option value="">None</option>
@foreach (var i in Model.ItemDefinitions)
{
<option value="@i.Id">@i.Name</option>
}
</select>
</div>
<div>
<label class="label">Reward Item Qty</label>
<input type="number" name="rewardItemQuantity" class="input" min="1" value="1" />
</div>
<div>
<label class="label">Reward Gold</label>
<input type="number" name="rewardGold" class="input" min="0" value="0" />
</div>
<div>
<label class="label">Reward XP</label>
<input type="number" name="rewardXp" class="input" min="0" value="0" />
</div>
<div>
<label class="label">Reward Quest Key</label>
<input type="text" name="rewardQuestKey" class="input" maxlength="64" />
</div>
</div>
<div class="flex justify-end gap-3 pt-2">
<button type="button" class="btn btn-secondary" onclick="closeAddNodeModal()">Cancel</button>
<button type="submit" class="btn btn-primary">Add Node</button>
</div>
</form>
</div>
</div>
<div id="addOptionModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50">
<div class="bg-gray-800 rounded-xl p-6 max-w-2xl w-full mx-4 border border-gray-700">
<h3 class="text-lg font-semibold text-white mb-4">Add Dialog Option</h3>
<form method="post" asp-page-handler="AddOption" class="space-y-4">
@Html.AntiForgeryToken()
<input type="hidden" name="treeId" value="@Model.Tree.Id" />
<input type="hidden" name="nodeId" value="@Model.SelectedNodeId" />
<div>
<label class="label">Player Text *</label>
<input type="text" name="playerText" class="input" required maxlength="256" />
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="label">Next Node</label>
<select name="nextNodeId" class="input">
<option value="">None (end)</option>
@foreach (var n in Model.Nodes)
{
<option value="@n.Id">@n.NodeKey (@n.Id)</option>
}
</select>
</div>
<div>
<label class="label">Sort Order</label>
<input type="number" name="sortOrder" class="input" value="0" />
</div>
<div>
<label class="label">Condition Type</label>
<select name="conditionType" class="input">
@foreach (var c in Enum.GetValues<NpcDialogConditionType>())
{
<option value="@c">@c</option>
}
</select>
</div>
<div>
<label class="label">Condition Value</label>
<input type="text" name="conditionValue" class="input" maxlength="64" />
</div>
<div>
<label class="label">Condition Quantity</label>
<input type="number" name="conditionQuantity" class="input" value="1" min="1" />
</div>
<div class="flex items-center pt-6">
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" name="consumeConditionItem" value="true" class="w-4 h-4 rounded border-gray-600 bg-gray-800 text-indigo-600" />
<span class="text-gray-300">Consume Condition Item</span>
</label>
</div>
</div>
<div class="flex justify-end gap-3 pt-2">
<button type="button" class="btn btn-secondary" onclick="closeAddOptionModal()">Cancel</button>
<button type="submit" class="btn btn-primary">Add Option</button>
</div>
</form>
</div>
</div>
}
</div>
@section Scripts {
<script>
function showAddNodeModal() {
document.getElementById('addNodeModal').classList.remove('hidden');
document.getElementById('addNodeModal').classList.add('flex');
}
function closeAddNodeModal() {
document.getElementById('addNodeModal').classList.add('hidden');
document.getElementById('addNodeModal').classList.remove('flex');
}
function showAddOptionModal() {
document.getElementById('addOptionModal').classList.remove('hidden');
document.getElementById('addOptionModal').classList.add('flex');
}
function closeAddOptionModal() {
document.getElementById('addOptionModal').classList.add('hidden');
document.getElementById('addOptionModal').classList.remove('flex');
}
document.addEventListener('keydown', e => {
if (e.key === 'Escape') {
closeAddNodeModal();
closeAddOptionModal();
}
});
</script>
}
@@ -0,0 +1,236 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using DataServer.Data;
using DataServer.Data.Entities;
using DataServer.Data.Enums;
namespace GameServices.Admin.Pages.Npcs;
public class DialogTreeEditModel : AdminPageModel
{
private readonly GameDbContext _db;
public DialogTreeEditModel(GameDbContext db)
{
_db = db;
}
[BindProperty]
public DungeonNpcDialogTree Tree { get; set; } = new();
public List<DungeonNpcDialogNode> Nodes { get; set; } = new();
public List<DungeonNpcDialogOption> Options { get; set; } = new();
public List<DungeonItemDefinition> ItemDefinitions { get; set; } = new();
[FromQuery(Name = "nodeId")]
public int? SelectedNodeId { get; set; }
public bool IsNew => Tree.Id == 0;
public string? Message { get; set; }
public bool IsError { get; set; }
public async Task OnGetAsync(int? id, int? nodeId)
{
await LoadLookupsAsync();
if (id.HasValue)
{
var tree = await _db.DungeonNpcDialogTrees.FindAsync(id.Value);
if (tree != null)
{
Tree = tree;
await LoadTreeDataAsync(tree.Id, nodeId);
return;
}
}
Tree = new DungeonNpcDialogTree
{
Name = "",
Description = "",
IsEnabled = true
};
}
public async Task<IActionResult> OnPostAsync()
{
await LoadLookupsAsync();
Tree.Name = (Tree.Name ?? "").Trim();
Tree.Description ??= "";
Tree.IsEnabled = Request.Form.ContainsKey("Tree.IsEnabled");
if (string.IsNullOrWhiteSpace(Tree.Name))
{
IsError = true;
Message = "Name is required.";
return Page();
}
try
{
if (Tree.Id == 0)
{
Tree.CreatedAt = DateTime.UtcNow;
Tree.UpdatedAt = DateTime.UtcNow;
_db.DungeonNpcDialogTrees.Add(Tree);
await _db.SaveChangesAsync();
return RedirectToPage("/Npcs/DialogTreeEdit", new { id = Tree.Id });
}
var existing = await _db.DungeonNpcDialogTrees.FindAsync(Tree.Id);
if (existing == null)
{
IsError = true;
Message = "Dialog tree not found.";
return Page();
}
existing.Name = Tree.Name;
existing.Description = Tree.Description;
existing.IsEnabled = Tree.IsEnabled;
existing.UpdatedAt = DateTime.UtcNow;
await _db.SaveChangesAsync();
Tree = existing;
Message = "Dialog tree saved.";
await LoadTreeDataAsync(existing.Id, SelectedNodeId);
}
catch (Exception ex)
{
IsError = true;
Message = $"Error: {ex.Message}";
if (Tree.Id > 0) await LoadTreeDataAsync(Tree.Id, SelectedNodeId);
}
return Page();
}
public async Task<IActionResult> OnPostAddNodeAsync(
int treeId,
string nodeKey,
string text,
bool isRoot,
bool isTerminal,
string? rewardType,
int? rewardItemDefinitionId,
int rewardItemQuantity,
long rewardGold,
long rewardXp,
string? rewardQuestKey)
{
if (isRoot)
{
var roots = await _db.DungeonNpcDialogNodes
.Where(n => n.DialogTreeId == treeId && n.IsRoot)
.ToListAsync();
foreach (var r in roots) r.IsRoot = false;
}
var node = new DungeonNpcDialogNode
{
DialogTreeId = treeId,
NodeKey = (nodeKey ?? "").Trim(),
Text = (text ?? "").Trim(),
IsRoot = isRoot,
IsTerminal = isTerminal,
RewardType = string.IsNullOrWhiteSpace(rewardType) ? null : rewardType.Trim(),
RewardItemDefinitionId = rewardItemDefinitionId,
RewardItemQuantity = Math.Max(1, rewardItemQuantity),
RewardGold = Math.Max(0, rewardGold),
RewardXp = Math.Max(0, rewardXp),
RewardQuestKey = string.IsNullOrWhiteSpace(rewardQuestKey) ? null : rewardQuestKey.Trim()
};
_db.DungeonNpcDialogNodes.Add(node);
await _db.SaveChangesAsync();
return RedirectToPage("/Npcs/DialogTreeEdit", new { id = treeId, nodeId = node.Id });
}
public async Task<IActionResult> OnPostDeleteNodeAsync(int treeId, int nodeId)
{
var node = await _db.DungeonNpcDialogNodes.FindAsync(nodeId);
if (node != null && node.DialogTreeId == treeId)
{
_db.DungeonNpcDialogNodes.Remove(node);
await _db.SaveChangesAsync();
}
return RedirectToPage("/Npcs/DialogTreeEdit", new { id = treeId });
}
public async Task<IActionResult> OnPostAddOptionAsync(
int treeId,
int nodeId,
string playerText,
int? nextNodeId,
NpcDialogConditionType conditionType,
string? conditionValue,
int conditionQuantity,
bool consumeConditionItem,
int sortOrder)
{
var node = await _db.DungeonNpcDialogNodes.FirstOrDefaultAsync(n => n.Id == nodeId && n.DialogTreeId == treeId);
if (node == null)
{
return RedirectToPage("/Npcs/DialogTreeEdit", new { id = treeId });
}
var option = new DungeonNpcDialogOption
{
NodeId = nodeId,
PlayerText = (playerText ?? "").Trim(),
NextNodeId = nextNodeId,
ConditionType = conditionType,
ConditionValue = string.IsNullOrWhiteSpace(conditionValue) ? null : conditionValue.Trim(),
ConditionQuantity = Math.Max(1, conditionQuantity),
ConsumeConditionItem = consumeConditionItem,
SortOrder = sortOrder
};
_db.DungeonNpcDialogOptions.Add(option);
await _db.SaveChangesAsync();
return RedirectToPage("/Npcs/DialogTreeEdit", new { id = treeId, nodeId });
}
public async Task<IActionResult> OnPostDeleteOptionAsync(int treeId, int nodeId, int optionId)
{
var option = await _db.DungeonNpcDialogOptions.FindAsync(optionId);
if (option != null && option.NodeId == nodeId)
{
_db.DungeonNpcDialogOptions.Remove(option);
await _db.SaveChangesAsync();
}
return RedirectToPage("/Npcs/DialogTreeEdit", new { id = treeId, nodeId });
}
private async Task LoadLookupsAsync()
{
ItemDefinitions = await _db.DungeonItemDefinitions
.Where(i => i.IsEnabled)
.OrderBy(i => i.Name)
.ToListAsync();
}
private async Task LoadTreeDataAsync(int treeId, int? nodeId)
{
Nodes = await _db.DungeonNpcDialogNodes
.Where(n => n.DialogTreeId == treeId)
.OrderByDescending(n => n.IsRoot)
.ThenBy(n => n.Id)
.ToListAsync();
SelectedNodeId = nodeId ?? Nodes.FirstOrDefault()?.Id;
if (SelectedNodeId.HasValue)
{
Options = await _db.DungeonNpcDialogOptions
.Where(o => o.NodeId == SelectedNodeId.Value)
.OrderBy(o => o.SortOrder)
.ThenBy(o => o.Id)
.ToListAsync();
}
else
{
Options = new List<DungeonNpcDialogOption>();
}
}
}
@@ -0,0 +1,70 @@
@page "/admin/npcs/dialogtrees"
@model Npcs.DialogTreesModel
@{
ViewData["Title"] = "Dialog Trees";
}
<div class="space-y-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-white">Dialog Trees</h1>
<p class="text-gray-400 mt-1">Manage NPC conversation trees, nodes, and options</p>
</div>
<a href="/admin/npcs/dialogtrees/edit" class="btn btn-primary">Create Dialog Tree</a>
</div>
<div class="card p-4">
<form method="get" class="flex items-end gap-4">
<div class="flex-1">
<label class="label">Search</label>
<input type="text" name="search" value="@Model.Search" class="input" placeholder="Search by name/description..." />
</div>
<button class="btn btn-secondary" type="submit">Filter</button>
<a class="btn btn-secondary" href="/admin/npcs/dialogtrees">Clear</a>
</form>
</div>
<div class="card overflow-hidden">
<table class="w-full">
<thead class="bg-gray-900/50">
<tr>
<th class="table-header w-16">ID</th>
<th class="table-header">Name</th>
<th class="table-header w-20">Nodes</th>
<th class="table-header w-20">Enabled</th>
<th class="table-header w-24">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-700">
@foreach (var t in Model.Trees)
{
<tr class="hover:bg-gray-700/30">
<td class="table-cell font-mono text-gray-500">@t.Id</td>
<td class="table-cell">
<div class="text-white font-medium">@t.Name</div>
<div class="text-xs text-gray-500">@t.Description</div>
</td>
<td class="table-cell text-gray-300">@Model.NodeCountByTreeId.GetValueOrDefault(t.Id)</td>
<td class="table-cell text-gray-300">@(t.IsEnabled ? "Yes" : "No")</td>
<td class="table-cell">
<div class="flex items-center gap-2">
<a href="/admin/npcs/dialogtrees/edit?id=@t.Id" class="btn btn-secondary btn-sm">Edit</a>
<form method="post" asp-page-handler="Delete" class="inline" onsubmit="return confirm('Delete this dialog tree?');">
@Html.AntiForgeryToken()
<input type="hidden" name="id" value="@t.Id" />
<button class="btn btn-danger btn-sm" type="submit">Delete</button>
</form>
</div>
</td>
</tr>
}
@if (!Model.Trees.Any())
{
<tr>
<td colspan="5" class="table-cell text-center text-gray-500 py-10">No dialog trees found.</td>
</tr>
}
</tbody>
</table>
</div>
</div>
@@ -0,0 +1,54 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using DataServer.Data;
using DataServer.Data.Entities;
namespace GameServices.Admin.Pages.Npcs;
public class DialogTreesModel : AdminPageModel
{
private readonly GameDbContext _db;
public DialogTreesModel(GameDbContext db)
{
_db = db;
}
[FromQuery(Name = "search")]
public string? Search { get; set; }
public List<DungeonNpcDialogTree> Trees { get; set; } = new();
public Dictionary<int, int> NodeCountByTreeId { get; set; } = new();
public async Task OnGetAsync()
{
var query = _db.DungeonNpcDialogTrees.AsQueryable();
if (!string.IsNullOrWhiteSpace(Search))
{
query = query.Where(t => t.Name.Contains(Search) || t.Description.Contains(Search));
}
Trees = await query
.OrderBy(t => t.Id)
.ToListAsync();
var treeIds = Trees.Select(t => t.Id).ToList();
NodeCountByTreeId = await _db.DungeonNpcDialogNodes
.Where(n => treeIds.Contains(n.DialogTreeId))
.GroupBy(n => n.DialogTreeId)
.Select(g => new { TreeId = g.Key, Count = g.Count() })
.ToDictionaryAsync(x => x.TreeId, x => x.Count);
}
public async Task<IActionResult> OnPostDeleteAsync(int id)
{
var tree = await _db.DungeonNpcDialogTrees.FindAsync(id);
if (tree != null)
{
_db.DungeonNpcDialogTrees.Remove(tree);
await _db.SaveChangesAsync();
}
return RedirectToPage();
}
}
+287 -21
View File
@@ -1,8 +1,12 @@
@page "/admin/npcs/edit"
@model Npcs.EditModel
@using System.Text.Json
@using DataServer.Data.Enums
@{
ViewData["Title"] = Model.IsNew ? "Create NPC" : $"Edit: {Model.Npc.Name}";
var selectedAbilitiesJson = JsonSerializer.Serialize(Model.SelectedAbilityIds);
var spriteSheetOptions = JsonSerializer.Serialize(Model.AllSpriteSheets.Select(s => new { id = s.Id, name = s.Name, cdnPath = s.CdnPath }));
var resistanceOptions = string.Join("", Model.ResistanceTypes.Select(rt => $"<option value=\"{rt.Key}\">{rt.DisplayName}</option>"));
}
<div class="space-y-6 max-w-6xl">
@@ -142,21 +146,150 @@
</div>
<div class="card">
<div class="p-4 border-b border-gray-700">
<h2 class="text-lg font-semibold text-white">Visual & Linked Systems</h2>
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
<h2 class="text-lg font-semibold text-white">Damage Resistances</h2>
</div>
<div class="p-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div>
<label class="label">Tint Color</label>
<div class="flex gap-2">
<input type="color" value="@Model.Npc.TintColor" class="w-10 h-10 rounded border border-gray-700 bg-gray-800 cursor-pointer" oninput="document.getElementById('tintColor').value=this.value" />
<input id="tintColor" type="text" name="Npc.TintColor" value="@Model.Npc.TintColor" class="input" maxlength="16" />
<div class="p-6">
<div id="resistancesList" class="space-y-2 mb-4">
@{
Dictionary<string, float> resistances = new();
try
{
resistances = JsonSerializer.Deserialize<Dictionary<string, float>>(Model.Npc.ResistancesJson ?? "{}") ?? new();
}
catch { }
}
@foreach (var resist in resistances)
{
var bgColor = resist.Value < 0 ? "bg-red-900/30 border-red-700" : resist.Value > 0 ? "bg-green-900/30 border-green-700" : "bg-gray-800 border-gray-700";
<div class="@bgColor border rounded-lg p-3 flex items-center gap-4 resistance-row">
<select name="resist_name[]" class="input w-40">
@foreach (var rt in Model.ResistanceTypes)
{
<option value="@rt.Key" selected="@(resist.Key == rt.Key)">@rt.DisplayName</option>
}
</select>
<div class="flex items-center gap-2 flex-1">
<input type="range" name="resist_value[]" value="@resist.Value" min="-1" max="1" step="0.05" class="flex-1" oninput="this.nextElementSibling.value = Math.round(this.value * 100)" />
<div class="flex items-center gap-1">
<input type="number" value="@((resist.Value * 100).ToString("0"))" min="-100" max="100" step="5" class="input w-20 text-center text-sm" oninput="this.parentElement.previousElementSibling.value = this.value / 100" />
<span class="text-gray-400">%</span>
</div>
</div>
<button type="button" onclick="this.closest('.resistance-row').remove()" class="p-2 text-red-400 hover:text-red-300">Remove</button>
</div>
}
</div>
<div class="flex items-center gap-4 pt-4 border-t border-gray-700">
<select id="newResistType" class="input w-48">
<option value="">Select type...</option>
@foreach (var rt in Model.ResistanceTypes)
{
<option value="@rt.Key">@rt.DisplayName</option>
}
</select>
<input type="number" id="newResistValue" class="input w-24" value="50" min="-100" max="100" step="5" />
<span class="text-gray-400">%</span>
<button type="button" onclick="addResistance()" class="btn btn-secondary">Add</button>
</div>
</div>
</div>
<div class="card">
<div class="p-4 border-b border-gray-700">
<h2 class="text-lg font-semibold text-white">Abilities</h2>
</div>
<div class="p-6 space-y-4">
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="md:col-span-2">
<label class="label">Filter Abilities</label>
<input id="abilitySearch" type="text" class="input" placeholder="Type to filter abilities..." oninput="filterAbilities()" />
</div>
<div>
<label class="label">Ability List</label>
<select id="abilityPicker" class="input" size="8" style="height:auto;">
@foreach (var a in Model.AllAbilities)
{
<option value="@a.Id" data-search="@($"{a.Name} {a.Key} {a.AbilityType}".ToLowerInvariant())">@a.Name (@a.AbilityType)</option>
}
</select>
</div>
</div>
<button type="button" class="btn btn-secondary" onclick="addSelectedAbility()">Add Selected Ability</button>
<div>
<label class="label">Scale</label>
<input type="number" name="Npc.Scale" value="@Model.Npc.Scale" class="input" min="0.1" step="0.1" />
<label class="label">Selected Abilities</label>
<div id="selectedAbilities" class="space-y-2"></div>
</div>
</div>
</div>
<div class="card">
<div class="p-4 border-b border-gray-700">
<h2 class="text-lg font-semibold text-white">Sprite Config</h2>
</div>
<div class="p-6 space-y-4">
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<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">Default FPS</label>
<input type="number" name="sprite_fps" value="@Model.SpriteConfig.Fps" class="input" min="1" max="60" />
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="label">Filter Sprite Sheets</label>
<input id="spriteSheetSearch" type="text" class="input" placeholder="Type to filter sprite sheets..." oninput="filterSpriteSheets()" />
</div>
</div>
<div id="spriteRows" class="space-y-2">
@for (var i = 0; i < Model.SpriteRows.Count; i++)
{
var row = Model.SpriteRows[i];
<div class="grid grid-cols-1 md:grid-cols-12 gap-2 sprite-row">
<select name="sprite_key[]" class="input md:col-span-2">
@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="@(row.Key == key)">@key</option>
}
</select>
<select name="sprite_sheet_id[]" class="input md:col-span-5 sprite-sheet-select">
<option value="">Select sheet...</option>
@foreach (var s in Model.AllSpriteSheets)
{
<option value="@s.Id" selected="@(row.SheetId == s.Id)" data-search="@($"{s.Name} {s.CdnPath}".ToLowerInvariant())">@s.Name (@s.CdnPath)</option>
}
</select>
<input type="number" name="sprite_frames[]" value="@row.Frames" class="input md:col-span-2" min="1" placeholder="Frames" />
<label class="md:col-span-2 flex items-center gap-2 text-sm text-gray-300">
<input type="checkbox" name="sprite_loop[]" value="@i" checked="@row.Loop" class="rounded border-gray-600 bg-gray-800" />
Loop
</label>
<button type="button" class="btn btn-danger md:col-span-1" onclick="this.closest('.sprite-row').remove()">X</button>
</div>
}
</div>
<button type="button" class="btn btn-secondary" onclick="addSpriteRow()">Add Sprite Row</button>
</div>
</div>
<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">Linked Systems</h2>
<a href="/admin/npcs/dialogtrees" class="text-sm text-indigo-400 hover:underline">Manage Dialog Trees</a>
</div>
<div class="p-6 grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label class="label">Loot Table</label>
<select name="Npc.LootTableId" class="input">
@@ -177,7 +310,7 @@
}
</select>
</div>
<div class="lg:col-span-2">
<div>
<label class="label">Dialog Tree</label>
<select name="Npc.DialogTreeId" class="input">
<option value="">None</option>
@@ -187,17 +320,16 @@
}
</select>
</div>
<div class="lg:col-span-4">
<label class="label">Resistances JSON</label>
<textarea name="Npc.ResistancesJson" class="input font-mono text-xs" rows="3">@Model.Npc.ResistancesJson</textarea>
<div>
<label class="label">Tint Color</label>
<div class="flex gap-2">
<input type="color" value="@Model.Npc.TintColor" class="w-10 h-10 rounded border border-gray-700 bg-gray-800 cursor-pointer" oninput="document.getElementById('tintColor').value=this.value" />
<input id="tintColor" type="text" name="Npc.TintColor" value="@Model.Npc.TintColor" class="input" maxlength="16" />
</div>
</div>
<div class="lg:col-span-4">
<label class="label">Ability Definition IDs JSON</label>
<textarea name="Npc.AbilityDefinitionIdsJson" class="input font-mono text-xs" rows="3">@Model.Npc.AbilityDefinitionIdsJson</textarea>
</div>
<div class="lg:col-span-4">
<label class="label">Sprite Config JSON</label>
<textarea name="Npc.SpriteConfigJson" class="input font-mono text-xs" rows="5">@Model.Npc.SpriteConfigJson</textarea>
<div>
<label class="label">Scale</label>
<input type="number" name="Npc.Scale" value="@Model.Npc.Scale" class="input" min="0.1" step="0.1" />
</div>
</div>
</div>
@@ -208,3 +340,137 @@
</div>
</form>
</div>
@section Scripts {
<script>
const selectedAbilitiesSeed = @Html.Raw(selectedAbilitiesJson);
const spriteSheetCatalog = @Html.Raw(spriteSheetOptions);
const resistanceOptionsHtml = `@Html.Raw(resistanceOptions)`;
const abilityById = {
@foreach (var a in Model.AllAbilities)
{
@:@a.Id: "@a.Name (@a.AbilityType)",
}
};
function renderSelectedAbilities() {
const container = document.getElementById('selectedAbilities');
container.innerHTML = '';
selectedAbilitiesSeed.forEach(id => {
const row = document.createElement('div');
row.className = 'flex items-center justify-between bg-gray-800 border border-gray-700 rounded p-2';
const label = abilityById[id] || ('Ability #' + id);
row.innerHTML = `<span class="text-gray-200">${label}</span><div class="flex items-center gap-2"><input type="hidden" name="ability_ids[]" value="${id}"/><button type="button" class="btn btn-danger btn-sm" onclick="removeAbility(${id})">Remove</button></div>`;
container.appendChild(row);
});
}
function removeAbility(id) {
const idx = selectedAbilitiesSeed.indexOf(id);
if (idx >= 0) {
selectedAbilitiesSeed.splice(idx, 1);
renderSelectedAbilities();
}
}
function addSelectedAbility() {
const select = document.getElementById('abilityPicker');
const id = parseInt(select.value || '0', 10);
if (!id) return;
if (!selectedAbilitiesSeed.includes(id)) {
selectedAbilitiesSeed.push(id);
renderSelectedAbilities();
}
}
function filterAbilities() {
const term = (document.getElementById('abilitySearch').value || '').toLowerCase();
const select = document.getElementById('abilityPicker');
for (let i = 0; i < select.options.length; i++) {
const opt = select.options[i];
const text = (opt.dataset.search || opt.text || '').toLowerCase();
opt.style.display = term === '' || text.includes(term) ? '' : 'none';
}
}
function addResistance() {
const typeSelect = document.getElementById('newResistType');
const valueInput = document.getElementById('newResistValue');
const key = typeSelect.value;
if (!key) return;
const percent = parseInt(valueInput.value || '0', 10);
const value = percent / 100;
const row = document.createElement('div');
row.className = 'bg-gray-800 border border-gray-700 rounded-lg p-3 flex items-center gap-4 resistance-row';
row.innerHTML = `
<select name="resist_name[]" class="input w-40">${resistanceOptionsHtml.replace(`value="${key}"`, `value="${key}" selected`)}</select>
<div class="flex items-center gap-2 flex-1">
<input type="range" name="resist_value[]" value="${value}" min="-1" max="1" step="0.05" class="flex-1" oninput="this.nextElementSibling.value = Math.round(this.value * 100)" />
<div class="flex items-center gap-1">
<input type="number" value="${percent}" min="-100" max="100" step="5" class="input w-20 text-center text-sm" oninput="this.parentElement.previousElementSibling.value = this.value / 100" />
<span class="text-gray-400">%</span>
</div>
</div>
<button type="button" onclick="this.closest('.resistance-row').remove()" class="p-2 text-red-400 hover:text-red-300">Remove</button>
`;
document.getElementById('resistancesList').appendChild(row);
typeSelect.value = '';
valueInput.value = '50';
}
function filterSpriteSheets() {
const term = (document.getElementById('spriteSheetSearch').value || '').toLowerCase();
const selects = document.querySelectorAll('.sprite-sheet-select');
selects.forEach(select => {
for (let i = 0; i < select.options.length; i++) {
const opt = select.options[i];
const text = (opt.dataset.search || opt.text || '').toLowerCase();
if (opt.value === '') {
opt.style.display = '';
} else {
opt.style.display = term === '' || text.includes(term) ? '' : 'none';
}
}
});
}
function addSpriteRow() {
const idx = document.querySelectorAll('#spriteRows .sprite-row').length;
const row = document.createElement('div');
row.className = 'grid grid-cols-1 md:grid-cols-12 gap-2 sprite-row';
const sheetOptions = spriteSheetCatalog
.map(s => `<option value="${s.id}" data-search="${(s.name + ' ' + s.cdnPath).toLowerCase()}">${s.name} (${s.cdnPath})</option>`)
.join('');
row.innerHTML = `
<select name="sprite_key[]" class="input md:col-span-2">
<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>
<select name="sprite_sheet_id[]" class="input md:col-span-5 sprite-sheet-select"><option value="">Select sheet...</option>${sheetOptions}</select>
<input type="number" name="sprite_frames[]" value="8" class="input md:col-span-2" min="1" placeholder="Frames" />
<label class="md:col-span-2 flex items-center gap-2 text-sm text-gray-300">
<input type="checkbox" name="sprite_loop[]" value="${idx}" checked class="rounded border-gray-600 bg-gray-800" />
Loop
</label>
<button type="button" class="btn btn-danger md:col-span-1" onclick="this.closest('.sprite-row').remove()">X</button>
`;
document.getElementById('spriteRows').appendChild(row);
filterSpriteSheets();
}
renderSelectedAbilities();
</script>
}
+196 -2
View File
@@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
using DataServer.Data;
using DataServer.Data.Entities;
using DataServer.Data.Enums;
using System.Text.Json;
namespace GameServices.Admin.Pages.Npcs;
@@ -21,11 +22,40 @@ public class EditModel : AdminPageModel
public List<DungeonLootTable> LootTables { get; set; } = new();
public List<DungeonNpcShop> Shops { get; set; } = new();
public List<DungeonNpcDialogTree> DialogTrees { get; set; } = new();
public List<DamageResistanceType> ResistanceTypes { get; set; } = new();
public List<MobAbilityDefinition> AllAbilities { get; set; } = new();
public List<MobSpriteSheet> AllSpriteSheets { get; set; } = new();
public List<int> SelectedAbilityIds { get; set; } = new();
public List<NpcSpriteRow> SpriteRows { get; set; } = new();
public NpcSpriteConfig SpriteConfig { get; set; } = new();
public bool IsNew => Npc.Id == 0;
public string? Message { get; set; }
public bool IsError { get; set; }
public class NpcSpriteRow
{
public string Key { get; set; } = "";
public int? SheetId { get; set; }
public int Frames { get; set; } = 8;
public bool Loop { get; set; } = true;
}
public class NpcSpriteConfig
{
public Dictionary<string, string> Sprites { get; set; } = new();
public Dictionary<string, SpriteAnimation> Animations { get; set; } = new();
public int FrameWidth { get; set; } = 64;
public int FrameHeight { get; set; } = 64;
public int Fps { get; set; } = 8;
public class SpriteAnimation
{
public int Frames { get; set; } = 8;
public bool Loop { get; set; } = true;
}
}
public async Task OnGetAsync(int? id)
{
await LoadSelectionsAsync();
@@ -36,6 +66,7 @@ public class EditModel : AdminPageModel
if (npc != null)
{
Npc = npc;
ParseNpcJsonFields();
return;
}
}
@@ -68,6 +99,7 @@ public class EditModel : AdminPageModel
WanderRadiusPx = 96f,
WanderIntervalSeconds = 2.5f
};
ParseNpcJsonFields();
}
public async Task<IActionResult> OnPostAsync()
@@ -83,14 +115,16 @@ public class EditModel : AdminPageModel
Npc.Name = (Npc.Name ?? "").Trim();
Npc.Key = (Npc.Key ?? "").Trim();
Npc.Description ??= "";
Npc.ResistancesJson ??= "{}";
Npc.AbilityDefinitionIdsJson ??= "[]";
Npc.TintColor = string.IsNullOrWhiteSpace(Npc.TintColor) ? "#ffffff" : Npc.TintColor.Trim();
ParseAndSetResistancesFromForm();
ParseAndSetAbilityIdsFromForm();
ParseAndSetSpriteConfigFromForm();
if (string.IsNullOrWhiteSpace(Npc.Name))
{
IsError = true;
Message = "Name is required.";
ParseNpcJsonFields();
return Page();
}
@@ -117,6 +151,7 @@ public class EditModel : AdminPageModel
{
IsError = true;
Message = "NPC not found.";
ParseNpcJsonFields();
return Page();
}
@@ -153,12 +188,14 @@ public class EditModel : AdminPageModel
await _db.SaveChangesAsync();
Npc = existing;
ParseNpcJsonFields();
Message = "Changes saved successfully.";
}
catch (Exception ex)
{
IsError = true;
Message = $"Error: {ex.Message}";
ParseNpcJsonFields();
}
return Page();
@@ -180,5 +217,162 @@ public class EditModel : AdminPageModel
.Where(d => d.IsEnabled)
.OrderBy(d => d.Name)
.ToListAsync();
ResistanceTypes = await _db.DamageResistanceTypes
.Where(r => r.IsEnabled)
.OrderBy(r => r.SortOrder)
.ToListAsync();
AllAbilities = await _db.MobAbilityDefinitions
.Where(a => a.IsEnabled)
.OrderBy(a => a.Name)
.ToListAsync();
AllSpriteSheets = await _db.MobSpriteSheets
.Where(s => s.IsEnabled)
.OrderBy(s => s.Name)
.ToListAsync();
}
private void ParseNpcJsonFields()
{
try
{
var resistanceMap = JsonSerializer.Deserialize<Dictionary<string, float>>(Npc.ResistancesJson ?? "{}") ?? new();
Npc.ResistancesJson = JsonSerializer.Serialize(resistanceMap);
}
catch
{
Npc.ResistancesJson = "{}";
}
try
{
SelectedAbilityIds = JsonSerializer.Deserialize<List<int>>(Npc.AbilityDefinitionIdsJson ?? "[]") ?? new();
}
catch
{
SelectedAbilityIds = new List<int>();
Npc.AbilityDefinitionIdsJson = "[]";
}
try
{
SpriteConfig = string.IsNullOrWhiteSpace(Npc.SpriteConfigJson)
? new NpcSpriteConfig()
: (JsonSerializer.Deserialize<NpcSpriteConfig>(Npc.SpriteConfigJson!, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
}) ?? new NpcSpriteConfig());
}
catch
{
SpriteConfig = new NpcSpriteConfig();
}
SpriteRows = new List<NpcSpriteRow>();
foreach (var kv in SpriteConfig.Sprites)
{
var frames = 8;
var loop = true;
if (SpriteConfig.Animations.TryGetValue(kv.Key, out var anim))
{
frames = anim.Frames;
loop = anim.Loop;
}
var matchingSheet = AllSpriteSheets.FirstOrDefault(s =>
string.Equals(s.CdnPath, kv.Value, StringComparison.OrdinalIgnoreCase));
SpriteRows.Add(new NpcSpriteRow
{
Key = kv.Key,
SheetId = matchingSheet?.Id,
Frames = frames,
Loop = loop
});
}
}
private void ParseAndSetResistancesFromForm()
{
var map = new Dictionary<string, float>(StringComparer.OrdinalIgnoreCase);
var keys = Request.Form["resist_name[]"].ToArray();
var vals = Request.Form["resist_value[]"].ToArray();
for (var i = 0; i < keys.Length && i < vals.Length; i++)
{
var key = (keys[i] ?? "").Trim().ToLowerInvariant();
if (string.IsNullOrWhiteSpace(key)) continue;
if (!float.TryParse(vals[i], out var val)) continue;
map[key] = val;
}
Npc.ResistancesJson = JsonSerializer.Serialize(map);
}
private void ParseAndSetAbilityIdsFromForm()
{
var list = new List<int>();
foreach (var raw in Request.Form["ability_ids[]"])
{
if (int.TryParse(raw, out var id) && id > 0 && !list.Contains(id))
{
list.Add(id);
}
}
SelectedAbilityIds = list;
Npc.AbilityDefinitionIdsJson = JsonSerializer.Serialize(list);
}
private void ParseAndSetSpriteConfigFromForm()
{
var spriteKeys = Request.Form["sprite_key[]"].ToArray();
var spriteSheetIds = Request.Form["sprite_sheet_id[]"].ToArray();
var spriteFrames = Request.Form["sprite_frames[]"].ToArray();
var spriteLoops = Request.Form["sprite_loop[]"].ToArray();
var config = new NpcSpriteConfig();
if (int.TryParse(Request.Form["sprite_frameWidth"], out var fw)) config.FrameWidth = fw;
if (int.TryParse(Request.Form["sprite_frameHeight"], out var fh)) config.FrameHeight = fh;
if (int.TryParse(Request.Form["sprite_fps"], out var fps)) config.Fps = fps;
for (var i = 0; i < spriteKeys.Length && i < spriteSheetIds.Length; i++)
{
var key = (spriteKeys[i] ?? "").Trim();
if (string.IsNullOrWhiteSpace(key)) continue;
if (!int.TryParse(spriteSheetIds[i], out var sheetId)) continue;
var sheet = AllSpriteSheets.FirstOrDefault(s => s.Id == sheetId);
if (sheet == null) continue;
var frames = 8;
if (i < spriteFrames.Length && int.TryParse(spriteFrames[i], out var rowFrames))
{
frames = Math.Max(1, rowFrames);
}
var loop = spriteLoops.Contains(i.ToString());
config.Sprites[key] = sheet.CdnPath;
config.Animations[key] = new NpcSpriteConfig.SpriteAnimation
{
Frames = frames,
Loop = loop
};
}
if (config.Sprites.Count == 0)
{
SpriteConfig = new NpcSpriteConfig();
SpriteRows = new List<NpcSpriteRow>();
Npc.SpriteConfigJson = null;
return;
}
SpriteConfig = config;
Npc.SpriteConfigJson = JsonSerializer.Serialize(config, new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});
// rebuild display rows for round-trip on validation failure
ParseNpcJsonFields();
}
}
+9 -6
View File
@@ -10,12 +10,15 @@
<h1 class="text-3xl font-bold text-white">NPCs</h1>
<p class="text-gray-400 mt-1">Manage NPC definitions, stats, behavior, and interactions</p>
</div>
<a href="/admin/npcs/edit" class="btn btn-primary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
</svg>
Create NPC
</a>
<div class="flex items-center gap-2">
<a href="/admin/npcs/dialogtrees" class="btn btn-secondary">Dialog Trees</a>
<a href="/admin/npcs/edit" class="btn btn-primary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
</svg>
Create NPC
</a>
</div>
</div>
<div class="card p-4">
@@ -117,6 +117,10 @@
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5V4H2v16h5m10 0v-2a4 4 0 00-4-4H11a4 4 0 00-4 4v2m10 0H7m8-10a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
<span>NPCs</span>
</a>
<a href="/admin/npcs/dialogtrees" class="sidebar-link @(ViewContext.RouteData.Values["page"]?.ToString()?.StartsWith("/Npcs/Dialog") == true ? "active" : "")" data-tooltip="Dialog Trees">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-4l-4 4v-4z"/></svg>
<span>Dialog Trees</span>
</a>
<a href="/admin/spritesheets" class="sidebar-link @(ViewContext.RouteData.Values["page"]?.ToString()?.StartsWith("/SpriteSheets") == true ? "active" : "")" data-tooltip="SpriteSheets">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /> </svg>
<span>Sprite Sheets</span>